You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Review Summary — fix(precompiles): Cap B20 Token Supply
Overall
The change is clean and well-tested. The constant definition, update_supply_cap guard, factory default, and test coverage are all solid. One potential gap worth discussing:
Findings
Mintable::mint does not enforce B20_MAX_SUPPLY_CAP directly (medium severity)
The PR summary states "enforce that max in mint even if a stored/configured cap is higher," but Mintable::mint (crates/common/precompiles/src/common/ops/mintable.rs:22-31) only checks against the storedcap value:
let cap = self.accounting().supply_cap()?;// ...if new_supply > cap { ...}
The defense relies on two invariants:
The factory always initializes tokens with DEFAULT_SUPPLY_CAP = B20_MAX_SUPPLY_CAP
Configurable::update_supply_cap now rejects new_cap > B20_MAX_SUPPLY_CAP
This is sufficient if no tokens exist on-chain with the old U256::MAX default. However, if any tokens were already created before this change, their stored supply cap remains U256::MAX, and mint would still allow minting above 2^128 - 1 for those tokens.
If pre-existing tokens are a concern, consider clamping in the mint path:
let cap = self.accounting().supply_cap()?.min(B20_MAX_SUPPLY_CAP);
If no tokens have been deployed yet (i.e., this lands before any factory usage), the current approach is safe. Either way, the PR description should be updated to accurately reflect the enforcement model — the cap is enforced at write boundaries (factory init + updateSupplyCap), not at mint time.
No other issues found. The constant definition via U256::from_limbs is correct and verified by the test. The update_supply_cap validation ordering (checking new_cap > B20_MAX_SUPPLY_CAP alongside new_cap < supply) is correct.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tests