Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(template_lib): builtin template addresses #881

Merged
merged 6 commits into from
Jan 8, 2024

Conversation

mrnaveira
Copy link
Collaborator

Description

  • template_lib exports an enum BuiltinTemplate that enumerates all the builtin templates and allows to retrieve the addresses via a new BuiltinTemplateInvoke engine operation
  • The engine implements the EngineOp::BuiltinTemplateInvoke by accessing the appropriate constants in the template_builtin crate

Motivation and Context

Template developers will want to perform cross-template calls with builtin templates (e.g. accounts). For convenience we want to expose the corresponding template addresses in the template_lib crate.

There are two main ways of doing this:

  1. Export the template addresses directly as constants
  2. Create a new engine call for getting the template address

This PR follows (2) for template WASM size optimisation reasons, as (1) would require to include the full address (32 bytes for each one of the builtin templates, and we may have more of them in the future) in every template WASM.

How Has This Been Tested?

New engine unit test for builtin template addresses

What process can a PR reviewer use to test or verify this change?

Use the new BuiltinTemplate enum in a template

Breaking Changes

  • None
  • Requires data directory to be deleted
  • Other - Please specify

Copy link

github-actions bot commented Jan 5, 2024

Test Results (CI)

194 tests  +1   194 ✅ +1   1h 36m 28s ⏱️ + 18m 53s
 52 suites ±0     0 💤 ±0 
  2 files   ±0     0 ❌ ±0 

Results for commit 52990bd. ± Comparison against base commit 6d30028.

♻️ This comment has been updated with latest results.

Copy link
Member

@sdbondi sdbondi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, could we also provide a method to fetch the currently executing template address in templates?

@sdbondi sdbondi enabled auto-merge January 8, 2024 09:10
@sdbondi sdbondi added this pull request to the merge queue Jan 8, 2024
Merged via the queue into tari-project:development with commit 7e47cce Jan 8, 2024
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants