Skip to content

refactor(account-keychain): use enumerable maps for scopes#3410

Closed
legion2002 wants to merge 3 commits intomainfrom
tanishk/tip-1011-rest-exact-enumerable-map
Closed

refactor(account-keychain): use enumerable maps for scopes#3410
legion2002 wants to merge 3 commits intomainfrom
tanishk/tip-1011-rest-exact-enumerable-map

Conversation

@legion2002
Copy link
Copy Markdown
Contributor

@legion2002 legion2002 commented Apr 1, 2026

What This PR Does

This PR now contains only the enumerable-map refactor that remained after the TIP-1011 stack merged.

  • adds EnumerableMap<K, V> to the precompile storage types, backed by a Set<K> for authoritative key membership and a Mapping<K, V> for values
  • exports EnumerableMap from crates/precompiles/src/storage/types/mod.rs
  • changes AccountKeychain scope storage so KeyScope.targets becomes EnumerableMap<Address, TargetScope> and TargetScope.selectors becomes EnumerableMap<FixedBytes<4>, SelectorScope>
  • updates the AccountKeychain read and mutation paths to use the enumerable-map API instead of parallel Set + Mapping structures when enumerating, inserting, removing, and clearing target and selector scopes
  • preserves the existing TIP-1011 behavior: is_scoped still distinguishes unrestricted vs scoped deny-all, and empty child sets still mean "no further restriction"

This does not change the external TIP-1011 interface or validation model. It only changes how scoped target/selector state is stored and maintained internally.

Verification

  • cargo fmt --all --check
  • cargo test -p tempo-precompiles --lib

@legion2002 legion2002 force-pushed the tanishk/tip-1011-rest-exact branch from 3a6c0bb to f2e4a1f Compare April 1, 2026 13:07
Base automatically changed from tanishk/tip-1011-rest-exact to tanishk/tip-1011-precompiles-exact April 1, 2026 13:11
Base automatically changed from tanishk/tip-1011-precompiles-exact to tanishk/tip-1011-primitives-exact April 1, 2026 13:12
Comment thread crates/precompiles/src/storage/types/enumerable_map.rs Outdated
Base automatically changed from tanishk/tip-1011-primitives-exact to main April 1, 2026 23:19
@legion2002 legion2002 requested a review from onbjerg as a code owner April 1, 2026 23:19
@legion2002 legion2002 force-pushed the tanishk/tip-1011-rest-exact-enumerable-map branch from a404ce5 to 039285a Compare April 2, 2026 11:53
Co-authored-by: 0xrusowsky <90208954+0xrusowsky@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

📊 Tempo Precompiles Coverage

📦 Download full HTML report

@legion2002 legion2002 added the cyclops Trigger Cyclops PR audit label Apr 2, 2026
Copy link
Copy Markdown

@tempoxyz-bot tempoxyz-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👁️ Cyclops Review — No actionable findings.

Nine independent audit passes (3 workers × 3 iterations) confirmed that the Set + MappingEnumerableMap refactor is storage-layout compatible, preserves all TIP-1011 invariants, and remains unreachable on the current T1C production hardfork.

Reviewer Callouts
  • Future EnumerableMap reuse with nested values: EnumerableMap::load()/store() intentionally return Fatal (enumerable_map.rs:L201-L210). Current code only uses handler-style access (keys(), contains(), remove(), clear(), set_with()). Re-check if whole-value at()/set() is ever used with nested struct values.
  • Keychain atomicity under T1C: AccountKeychain performs multi-step scope writes without a storage.checkpoint() guard. Pre-existing pattern, not introduced here, but worth revisiting if keychain mutators grow.
  • T3 activation re-review: All TIP-1011 call-scope entrypoints remain T3-gated. Run upgrade-compatibility tests when T3 activates on non-dev networks.

@legion2002
Copy link
Copy Markdown
Contributor Author

we've chosen not to do this, because it does not have perf improvements over the enumerable set approach we have right now. We might reopen later, just to add an enumerable map impl to the PR

@legion2002 legion2002 closed this Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cyclops Trigger Cyclops PR audit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants