Skip to content

Stable TMPL_ byte sizes#717

Draft
iglosiggio wants to merge 3 commits into
mainfrom
iglosiggio/stable-tmpl-byte-size
Draft

Stable TMPL_ byte sizes#717
iglosiggio wants to merge 3 commits into
mainfrom
iglosiggio/stable-tmpl-byte-size

Conversation

@iglosiggio
Copy link
Copy Markdown
Member

Proposed Changes

This PR modifies the way we generate bytecode so a statically-known amount of bytes is used whenever possible. For uint64 values this makes our constants bigger (unless -O2 is chosen).

  • Add a num_bytes property to the TemplateVar definition in both the MIR an TEAL layers
  • Add a _TemplateInt marker class that allows the encoding layer to distinguish regular constants from template variable constants
  • Update the compiled code

TO-DO

  • Check that these changes work properly with cblock offsets when debugging
  • Implement the _TemplateInt change in a cleaner way

Outside scope

  • Fix typechecking issues when substituting template variables (AK-1224)

@engineering-ci
Copy link
Copy Markdown

engineering-ci Bot commented May 4, 2026

⚠️ No changelog fragment detected

@engineering-ci
Copy link
Copy Markdown

engineering-ci Bot commented May 4, 2026

Name Status O0 bytes O1 bytes O2 bytes O0 ops O1 ops O2 ops
arc_56 🔺 +9 +9 - - - -
debug 🔺 +9 +9 - - - -
logic_signature/pre_approved_sale 🔺 +18 +18 - - - -
template_variables 🔺 +18 +18 - - - -
Total 🔺 +54 +54 - - - -

@engineering-ci
Copy link
Copy Markdown

engineering-ci Bot commented May 4, 2026

Checking stubs for changes and corresponding version bump in origin/iglosiggio/stable-tmpl-byte-size

Last puyapy release: v5.8.1
This branch stubs version: 3.5.0
Last released stubs version: 3.5.0
Main stubs version: 3.5.0

✅ Stub files unchanged
✅ Stub check passed!

@engineering-ci
Copy link
Copy Markdown

engineering-ci Bot commented May 4, 2026

Coverage

Tests Skipped Failures Errors Time
1693 3 💤 0 ❌ 0 🔥 11m 45s ⏱️

value >>= 7
result = b""
while value:
for i in range(0, 9):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be 10 bytes? If each byte can carry 7 bits then 7 * 9 is 63 bits, one short of 64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants