Skip to content

fix(token): take Uint<128> burn amounts in ZOwnableNativeShieldedToken - #1247

Open
rhmatzeka wants to merge 1 commit into
OpenZeppelin:mainfrom
rhmatzeka:fix/zownable-native-burn-uint128-1171
Open

rhmatzeka wants to merge 1 commit into
OpenZeppelin:mainfrom
rhmatzeka:fix/zownable-native-burn-uint128-1171

Conversation

@rhmatzeka

@rhmatzeka rhmatzeka commented Nov 15, 2026 •

Copy link
Copy Markdown

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Fixes #1171

ZOwnableNativeShieldedToken.burn narrowed the amount to Uint<64>, while the NativeShieldedToken._burn it wraps takes Uint<128>. The preset, the example and the mock now take Uint<128>, the same change #1033 made for NativeShieldedTokenIssuer.

Not visible in the diff:

  • mint stays at Uint<64>, since mintShieldedToken caps it there.
  • The happy path above Uint<64> is skipped, like in fix(multisig): take Uint<128> issuer burn amounts #1033. compact-runtime still encodes coin values in 8 bytes (Runtime rejects shielded coin values above Uint<64> LFDT-Minokawa/compact#811), so a coin that large can't be built off-chain yet. The skipped block covers a partial and a full burn and can be turned on once that's fixed.
  • The old rejects a burn amount above Uint<64> test now checks that such an amount reaches the module's coin value check (NativeShieldedToken: insufficient coin value). On main the same call fails with the Uint<0..18446744073709551616> range error.
  • The compatibility test's expected ABI for burn.amount is now UINT_128.
  • burn grows from 48,448 to 48,464 rows and stays at k=16. Both numbers were measured with key generation on compiler 0.36.0, against main and this branch.

Checked locally: yarn compile:token, the token unit suite (1224 passed, 12 skipped) and yarn lint. The archive/ ShieldedToken.burn still takes Uint<64>, but it's archived, so I left it alone.

PR Checklist

  • I have read the Contributing Guide
  • I have added tests that prove my fix is effective or that my feature works. See GUIDELINES.md#testing for more information.
  • I have added documentation for new methods or changes to existing method behavior. See GUIDELINES.md#documentation for more information.
  • I have added a CHANGELOG entry under ## Unreleased, or asked a maintainer to add the skip-changelog label because nothing user-facing changed. See CONTRIBUTING.md.
  • CI Workflows Are Passing

Summary by CodeRabbit

  • Bug Fixes
    • Token burning now supports amounts up to 128 bits, allowing burns larger than the previous 64-bit limit.
    • Burn amounts exceeding a coin’s value continue to be rejected.

NativeShieldedToken._burn takes a Uint<128> amount, but the preset's
burn narrowed it to Uint<64>, and the example and mock copied that
signature. A coin above Uint<64> could only be destroyed 2^64 - 1 at
a time. Widen all three to Uint<128>, as OpenZeppelin#1033 did for
NativeShieldedTokenIssuer.

Fixes OpenZeppelin#1171
@rhmatzeka
rhmatzeka requested review from a team as code owners November 15, 2026 14:53
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The burn circuit now accepts a Uint<128> amount instead of Uint<64>. The example and test mock use the updated signature. Circuit metadata, compatibility expectations, and unit tests are also updated.

Changes: Burn amount width

Layer / File(s) Summary
Update burn circuit signatures
contracts/src/token/presets/ZOwnableNativeShieldedToken.compact, contracts/src/token/examples/ZOwnableNativeShieldedTokenExample.compact, contracts/src/token/presets/test/mocks/MockZOwnableNativeShieldedToken.compact, contracts/src/token/presets/test/ZOwnableNativeShieldedToken.compatibility.test.ts, CHANGELOG.md
The preset, example, and mock burn circuits now accept Uint<128>. The compatibility expectation and documented row count are updated. The changelog records the signature and row-count changes.
Update burn amount tests
contracts/src/token/presets/test/ZOwnableNativeShieldedToken.unit.test.ts
The test for burning U64_BOUND from a MAX_U64 coin now expects an insufficient coin value error. Tests for partial and full burns of a 2^80 coin are added but skipped.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: 0xisk, andrew-fleming

Merge Risk: Minimal · up to 3dcbe

The burn circuit now accepts 128-bit amounts, matching the wrapped module. No concrete merge-blocking risk was identified. Burning coins above 64 bits still depends on a runtime fix that is tracked separately.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the burn amount in ZOwnableNativeShieldedToken widens from Uint<64> to Uint<128>. The raw summary and PR objectives both describe this change to the preset, example, a…
Linked Issues check Passed [#1171] Requirement: widen ZOwnableNativeShieldedToken.burn from Uint<64> to Uint<128>, matching the wrapped NativeShieldedToken._burn, and cover the preset, example, and mock. The summary sho…
Out of Scope Changes check Passed Every changed file ties to #1171. The preset, example, and mock change the burn signature. The compatibility test updates the expected ABI for burn.amount. The unit test covers the new behavior an…
Full details: Title check

Explanation

The title names the main change: the burn amount in ZOwnableNativeShieldedToken widens from Uint<64> to Uint<128>. The raw summary and PR objectives both describe this change to the preset, example, and mock. The fix(token) prefix is a conventional-commit style scope that matches the changed token module.

Full details: Linked Issues check

Explanation

[#1171] Requirement: widen ZOwnableNativeShieldedToken.burn from Uint&lt;64&gt; to Uint&lt;128&gt;, matching the wrapped NativeShieldedToken._burn, and cover the preset, example, and mock. The summary shows burn in presets/ZOwnableNativeShieldedToken.compact, examples/ZOwnableNativeShieldedTokenExample.compact, and presets/test/mocks/MockZOwnableNativeShieldedToken.compact now takes amount: Uint&lt;128&gt; and forwards it to the same underlying burn circuit. Requirement: skip the above-Uint&lt;64&gt; happy-path test until the runtime limit is fixed. The unit test file adds two skipped tests for a coin valued at 2^80 (partial and full burn). Requirement: the oversized-burn case must reach the module's own check. The unit test now expects NativeShieldedToken: insufficient coin value for U64_BOUND. The compatibility test expects UINT_128 for burn.amount. All requirements are coding requirements and the summary shows each one implemented. Evidence is the PR summary and the PR description; no source file was read directly.

Full details: Out of Scope Changes check

Explanation

Every changed file ties to #1171. The preset, example, and mock change the burn signature. The compatibility test updates the expected ABI for burn.amount. The unit test covers the new behavior and the skipped happy-path cases. The CHANGELOG entry documents the fix. The row-count change (48,448 to 48,464, k=16) follows from the signature change. The archive/ ShieldedToken.burn is unchanged, which keeps it out of scope. No unrelated change appears in the summary.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f85f1a2 and 3dcbe3f.

Files selected for processing: 6

  • CHANGELOG.md
  • contracts/src/token/examples/ZOwnableNativeShieldedTokenExample.compact
  • contracts/src/token/presets/ZOwnableNativeShieldedToken.compact
  • contracts/src/token/presets/test/ZOwnableNativeShieldedToken.compatibility.test.ts
  • contracts/src/token/presets/test/ZOwnableNativeShieldedToken.unit.test.ts
  • contracts/src/token/presets/test/mocks/MockZOwnableNativeShieldedToken.compact

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

This branch has not been deployed

No deployments
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.

[Bug]: ZOwnableNativeShieldedToken.burn narrows the amount to Uint<64>

1 participant