implement IERC20Metadata for pallet-assets-precompiles#10971
implement IERC20Metadata for pallet-assets-precompiles#109710xRVE merged 9 commits intoparitytech:masterfrom
IERC20Metadata for pallet-assets-precompiles#10971Conversation
There was a problem hiding this comment.
need to be renamed to 10971.prdoc
Co-authored-by: 0xRVE <robertvaneerdewijk@gmail.com>
…--pallet pallet_assets'
40722eb to
f536ea0
Compare
|
https://github.com/paritytech/polkadot-sdk/actions/runs/21674695442/job/62491853047?pr=10971 |
Weights are already on this branch no? |
CI complains with this |
| assert_eq!(Reserves::<T, I>::get(id)[0], reserve); | ||
| } | ||
|
|
||
| get_name { |
There was a problem hiding this comment.
these are identical we should probably only have one and just call it for both methods in the precompile
@0xRVE can you do that in a follow up, so we can merge this
ba0839d
…a benchmark (#11037) ## Summary Consolidates the three identical `get_name`, `get_symbol`, and `get_decimals` benchmarks into a single `get_metadata` benchmark. This addresses the follow-up from #10971 where it was noted that these benchmarks perform the same operation (`Pallet::get_metadata()`). ## Changes ### Benchmarks - **`substrate/frame/assets/src/benchmarking.rs`** - Replaced `get_name`, `get_symbol`, `get_decimals` with single `get_metadata` benchmark - Updated verification to check all three metadata fields (name, symbol, decimals) ### Weight Functions - **`substrate/frame/assets/src/weights.rs`** - Replaced `get_name()`, `get_symbol()`, `get_decimals()` with single `get_metadata()` in `WeightInfo` trait - Updated implementations for `SubstrateWeight<T>` and `()` ### Precompile - **`substrate/frame/assets/precompiles/src/lib.rs`** - Updated `name()`, `symbol()`, and `decimals()` methods to all charge `get_metadata()` weight ### Cumulus Runtimes Updated weight implementations in: - `asset-hub-rococo`: `pallet_assets_foreign.rs`, `pallet_assets_local.rs`, `pallet_assets_pool.rs` - `asset-hub-westend`: `pallet_assets_foreign.rs`, `pallet_assets_local.rs`, `pallet_assets_pool.rs` ## Rationale All three original benchmarks were measuring the exact same operation - a single metadata storage read. Consolidating them: 1. Reduces code duplication 2. Simplifies the `WeightInfo` trait 3. Accurately reflects that `name()`, `symbol()`, and `decimals()` have identical costs Closes follow-up from #10971 (comment) --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Summary
Implements the missing ERC20 metadata functions (
name,symbol,decimals) for the pallet-assets precompile to provide full ERC20 compatibility. These functions were missing from the original implementation and are essential for proper EVM wallet and tooling integration.Changes
Solidity Interface
substrate/primitives/ethereum-standards/src/IERC20.solname() external view returns (string memory)symbol() external view returns (string memory)decimals() external view returns (uint8)Precompile Implementation
substrate/frame/assets/precompiles/src/lib.rsname()- reads metadata from pallet-assets storage and returns UTF-8 stringsymbol()- reads metadata from pallet-assets storage and returns UTF-8 stringdecimals()- reads metadata from pallet-assets storage and returns uint8 valueBenchmarks
substrate/frame/assets/src/benchmarking.rsget_namebenchmark - measures metadata read for name fieldget_symbolbenchmark - measures metadata read for symbol fieldget_decimalsbenchmark - measures metadata read for decimals fieldWeight Functions
substrate/frame/assets/src/weights.rsget_name() -> Weightto WeightInfo traitget_symbol() -> Weightto WeightInfo traitget_decimals() -> Weightto WeightInfo traitSubstrateWeight<T>and()(fallback)Assets::Metadata(~12-12.5ms, 2615 bytes proof size)Closes #8658