Skip to content

Precompile deprecation and storage read precompile#1

Open
pablo-reef wants to merge 7 commits into
mainfrom
precompile-deprecation-and-storage-read-precompile
Open

Precompile deprecation and storage read precompile#1
pablo-reef wants to merge 7 commits into
mainfrom
precompile-deprecation-and-storage-read-precompile

Conversation

@pablo-reef

Copy link
Copy Markdown
Collaborator

Description

Add typed storage view precompiles to replace raw StorageQueryPrecompile access with compile-time safe, ABI-typed functions. This PR also introduces a deprecation registry to support structured precompile versioning.

New Precompiles

  • DeprecationRegistryPrecompile (0x810) — query deprecation info for any precompile function via getDeprecationInfo(address, bytes32)
  • DrandPrecompile (0x811) — getLastStoredRound, getOldestStoredRound, getPulse, getCurrentRandomness
  • TimestampPrecompile (0x812) — getNow

Extended Existing Precompiles

  • CrowdloanPrecompilegetNextCrowdloanId, getCurrentCrowdloanId
  • ProxyPrecompilegetLastCallResult
  • BalanceTransferPrecompilegetTotalIssuance, getFreeBalance
  • NeuronPrecompilegetUid, isHotkeyRegistered, getPrometheus, getBurnCost, getDifficulty

Deprecation Registry (pallet-admin-utils)

  • DeprecationInfo struct + DeprecationRegistryStorage (keyed by precompile INDEX + selector)
  • sudo_set_deprecation_info / sudo_remove_deprecation_info extrinsics
  • Staking V1 interface soft-deprecated with @deprecated natspec pointing to V2

Related Issue(s)

  • Precompile Versioning & Deprecation RFC

Type of Change

  • New feature (non-breaking change which adds functionality)

Breaking Change

No breaking changes. All existing precompile addresses and function selectors remain unchanged. StakingV1 at 0x801 continues to work identically — only Solidity interface annotations have changed.

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have run ./scripts/fix_rust.sh to ensure my code is formatted and linted correctly
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Additional Notes

Files changed: 21 (+593, -531 — the -531 is mostly from removing duplicated contract-tests TS bindings that were replaced)

Precompile Address Map (new entries)

Address Precompile Views
0x810 DeprecationRegistry getDeprecationInfo
0x811 Drand 4 views
0x812 Timestamp getNow

pablo-reef and others added 7 commits February 25, 2026 13:50
Implement the Precompile Versioning & Deprecation RFC (Phases 1-3):

Phase 1 — Deprecation Registry Precompile:
- Add DeprecationInfo struct and DeprecationRegistryStorage (StorageDoubleMap
  keyed by precompile INDEX + function selector) to pallet-admin-utils
- Add DeprecationRegistry variant to PrecompileEnum
- Add sudo_set_deprecation_info (call_index 86) and
  sudo_remove_deprecation_info (call_index 87) extrinsics
- Add DeprecationInfoSet and DeprecationInfoRemoved events
- Create DeprecationRegistryPrecompile at INDEX 2064 (0x810) with
  getDeprecationInfo(address, bytes32) view function
- Create deprecationRegistry.sol Solidity interface with DeprecationInfo struct
- Wire precompile in lib.rs (used_addresses 26 → 27)

Phase 2 — Staking V1 Soft-Deprecation:
- Rename IStaking → IStakingV1, ISTAKING_ADDRESS → ISTAKING_V1_ADDRESS
- Add @deprecated natspec to all V1 functions pointing to V2 at 0x805
- No Rust changes — V1 at 0x801 continues to work identically

Phase 3 — Metagraph Interface Completeness:
- Verified all 17 Rust functions have matching Solidity declarations
…PREFIXES pallets

New precompiles:
- DrandPrecompile (0x811): getLastStoredRound, getOldestStoredRound, getPulse, getCurrentRandomness
- TimestampPrecompile (0x812): getNow

Extended existing precompiles:
- CrowdloanPrecompile: getNextCrowdloanId, getCurrentCrowdloanId
- ProxyPrecompile: getLastCallResult
- BalanceTransferPrecompile: getTotalIssuance, getFreeBalance
- NeuronPrecompile: getUid, isHotkeyRegistered, getPrometheus, getBurnCost, getDifficulty

Wiring: added pallet-drand/pallet-timestamp deps, PrecompileEnum variants, used_addresses 27->29
…ile views

- Implemented explicit typed precompile views for all 10 authorized pallets (SubtensorModule, Swap, Balances, Proxy, Drand, Crowdloan, Scheduler, Sudo, Multisig, Timestamp).
- Auto-generated 144+ Solidity view interfaces (e.g. `ISubtensor`, `ISwap`) to map seamlessly with Substrate EVM bindings.
fixed precompile lints and removed warnings
replaced banned as_* calls with safe try_into
fixed freeze_struct hashes in admin-utils
fixed contract tests for subtensor, crowdloan, and drand
updated balanceTransfer and timestamp test assertions
@fine135 fine135 force-pushed the precompile-deprecation-and-storage-read-precompile branch from d363a2e to b1f269c Compare March 4, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants