Fix uid_lookup gas consumption#2825
Conversation
🚨🚨🚨 HOTFIX DETECTED 🚨🚨🚨It looks like you are trying to merge a hotfix PR into If you are trying to merge a hotfix PR, please complete the following essential steps:
If you do not complete these steps, your hotfix may be inadvertently removed in the future when branches are promoted to |
🛡️ AI Review — Skeptic (security review)VERDICT: VULNERABLE LOW scrutiny: established contributor with write permission; hotfix branch No Findings
ConclusionThe diff appears legitimate, but it changes runtime behavior and storage without a corresponding 🔍 AI Review — Auditor (domain review)VERDICT: 👍 Gittensor: LIKELY by recent subtensor-heavy contribution pattern; author has write permission and substantial prior repo activity. PR body is substantive and matches the implementation. Static audit found the hotfix narrowly scoped: it adds and backfills per-subnet EVM association counts, maintains the count on insert/remove/clear paths, uses that count to cap UID lookup gas precharging, exposes the count through the precompile, and adds focused tests for migration, cleanup, and precompile cost behavior. Spec version is bumped to FindingsNo findings. ConclusionApproved. The count map is initialized by migration, updated on the relevant association lifecycle paths, and the precompile now meters only the bounded actual-read count while preserving the caller's lookup semantics up to that bound. |
|
🔄 AI review updated — Skeptic: SAFE Auditor: 👍 |
1 similar comment
|
🔄 AI review updated — Skeptic: SAFE Auditor: 👍 |
| pub type AssociatedEvmAddress<T: Config> = | ||
| StorageDoubleMap<_, Twox64Concat, NetUid, Twox64Concat, u16, (H160, u64), OptionQuery>; |
There was a problem hiding this comment.
[CRITICAL] Runtime storage change lacks spec_version bump
This PR adds runtime storage and migration/precompile behavior, but the diff does not bump runtime/src/lib.rs spec_version (it remains 425). Runtime-affecting changes must advance spec_version; otherwise nodes with an old native runtime at the same spec can treat old native code as equivalent to the upgraded Wasm, risking divergent execution or silently missing this hotfix. Add the runtime version bump in this PR before merging to main.
|
🔄 AI review updated — Skeptic: VULNERABLE |
Summary
AssociatedEvmAddressCountstorage and maintain it on association insert/remove/clear paths.AssociatedEvmAddressentries during runtime upgrade.min(limit, associated_count)to prechargeuidLookupiteration and bound the lookup to the charged read count.associatedEvmAddressCount(uint16)on the UID lookup precompile for smart contracts.associate_evm_keyweight.