Skip to content

feat: per page ops calibration#19

Merged
cusma merged 20 commits intomainfrom
feat/per-page-ops
Dec 22, 2025
Merged

feat: per page ops calibration#19
cusma merged 20 commits intomainfrom
feat/per-page-ops

Conversation

@cusma
Copy link
Copy Markdown
Collaborator

@cusma cusma commented Dec 22, 2025

This PR adds opcodes budget calibration to ensure sufficient per-page budget

@cusma cusma requested a review from Copilot December 22, 2025 16:39
@cusma cusma self-assigned this Dec 22, 2025
@cusma cusma added enhancement New feature or request test labels Dec 22, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds per-page opcodes budget calibration to ensure sufficient computational budget for operations that scale with metadata page count. The changes introduce budget allocation calls for hash computation operations and add a test suite to validate budget sufficiency across all possible page counts.

  • Adds ensure_budget calls to _compute_header_hash and _compute_page_hash methods with calibrated budget values
  • Introduces pages_min_fee helper function to calculate appropriate transaction fees based on page count
  • Adds parametrized test covering all page counts from 0 to MAX_PAGES (31)

Reviewed changes

Copilot reviewed 7 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/test_per_page_op_budget_calibration.py New test file that validates budget calibration across all possible page counts (0-31)
tests/helpers/utils.py Adds pages_min_fee function for calculating fees based on page count; updates add_extra_resources with default count parameter
tests/helpers/factories.py Adds create_metadata_with_page_count factory function to generate metadata with specific page counts for testing
tests/conftest.py Updates fixture to use pages_min_fee function for consistent fee calculation
smart_contracts/asa_metadata_registry/constants.py Renames APP_CALL_OP_CODE_BUDGET to APP_CALL_OP_BUDGET and adds HEADER_HASH_OP_BUDGET and PAGE_HASH_OP_BUDGET constants; renames ARC89_REPLACE_METADATA_FIXED_SIZE to ARC89_REPLACE_METADATA_SLICE_FIXED_SIZE for clarity
smart_contracts/asa_metadata_registry/contract.py Adds ensure_budget calls with calibrated budgets to hash computation methods; reorders comment and code for clarity
smart_contracts/artifacts/asa_metadata_registry/AsaMetadataRegistry.approval.teal Updated TEAL bytecode reflecting the source code changes with budget allocation logic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/helpers/factories.py Outdated
Comment thread tests/helpers/factories.py
Comment thread tests/helpers/utils.py Outdated
Comment thread tests/helpers/utils.py Outdated
Comment thread tests/conftest.py Outdated
cusma and others added 7 commits December 22, 2025 17:48
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@cusma cusma merged commit 3aa160b into main Dec 22, 2025
1 check passed
@cusma cusma deleted the feat/per-page-ops branch December 22, 2025 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants