Meter EVM gas for asset‐ID conversion and enforce storage_growth in X-Tokens precompiles#348
Merged
Merged
Conversation
… for improved consistency
…ng parameters across multiple lines
There was a problem hiding this comment.
Pull Request Overview
This PR implements gas metering and enforces a minimum storage growth cost for two precompile modules.
- Assets-Factory: meters a 36-byte DB read in
convert_asset_id_to_address. - X-Tokens: replaces zero storage growth in
try_dispatchcalls withSYSTEM_ACCOUNT_SIZE.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| precompiles/assets-factory/src/lib.rs | Add _handle.record_db_read::<Runtime>(36)?; to meter asset ID lookup. |
| precompiles/xtokens/src/lib.rs | Update try_dispatch calls to use SYSTEM_ACCOUNT_SIZE instead of 0. |
Comments suppressed due to low confidence (1)
precompiles/assets-factory/src/lib.rs:78
- Add unit tests to verify that the 36-byte DB read is charged correctly and that error paths propagate as expected.
_handle.record_db_read::<Runtime>(36)?;
sfffaaa
approved these changes
May 22, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR resolves two high-severity audit findings:
Assets-Factory:
• Add _handle.record_db_read::(36)?; to convert_asset_id_to_address
• Ensures the 36-byte lookup is properly charged gas
X-Tokens:
• Import pallet_balances::SYSTEM_ACCOUNT_SIZE
• Replace every try_dispatch(..., 0) with try_dispatch(..., SYSTEM_ACCOUNT_SIZE)?
audit findings 3 & 4.