fix(runtime): fix record_contract_call using RuntimeContractIdentifier#15430
Conversation
record_contract_call using RuntimeContractIdentifier
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #15430 +/- ##
==========================================
- Coverage 69.11% 69.10% -0.02%
==========================================
Files 935 936 +1
Lines 210213 210309 +96
Branches 210213 210309 +96
==========================================
+ Hits 145283 145328 +45
- Misses 58944 58979 +35
- Partials 5986 6002 +16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ntifier - Move record_contract_call from TrieUpdate method to standalone function in function_call.rs that dispatches based on RuntimeContractIdentifier - Remove GlobalEthWallet variant and old_hash() — no longer needed since record_contract_call now uses the resolved contract identifier directly - Remove LegacyEthWallet::magic_bytes_hash() as it has no remaining callers - Change Global variant to carry GlobalContractIdentifier for trie key construction in record_contract_call - Add AccountId to AccountLocal variant for the same reason - Convert AccountLocal and Global to named-field struct variants - Drop Copy from RuntimeContractIdentifier (GlobalContractIdentifier contains AccountId) Co-Authored-By: Claude Opus 4.6 <[email protected]>
214b581 to
6b6af53
Compare
There was a problem hiding this comment.
Pull request overview
Fixes contract-access recording during function calls so stateless validation / contract distribution records the effective executed contract (including ETH implicit/global-contract cases) by keying off RuntimeContractIdentifier rather than the on-chain AccountContract representation.
Changes:
- Move and reimplement
record_contract_callas a runtime-local helper that dispatches onRuntimeContractIdentifierand records the correct trie key + code hash. - Simplify
RuntimeContractIdentifier(removeGlobalEthWallet/stored_hash, switch to named-field variants carryingAccountId/GlobalContractIdentifier, dropCopy). - Extend the existing test-loop regression by adding a chunk-only validator and clearing its compiled-contract cache to verify contract propagation via witness distribution.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
runtime/runtime/src/function_call.rs |
Replace TrieUpdate::record_contract_call usage with a new helper based on RuntimeContractIdentifier and correct trie key selection. |
runtime/runtime/src/contract_code.rs |
Update RuntimeContractIdentifier variants to carry enough context (account/global identifier) and remove legacy hash plumbing. |
runtime/runtime/src/ext.rs |
Adjust contract code lookup to match the updated RuntimeContractIdentifier variants. |
core/store/src/trie/update.rs |
Remove the old TrieUpdate::record_contract_call method now handled in runtime. |
runtime/near-wallet-contract/src/lib.rs |
Remove LegacyEthWallet::magic_bytes_hash() (no remaining callers). |
test-loop-tests/src/utils/node.rs |
Add a test-feature-only helper to clear a node’s compiled-contract cache. |
test-loop-tests/src/tests/mod.rs |
Gate eth_implicit_global_contract test module behind test_features. |
test-loop-tests/src/tests/eth_implicit_global_contract.rs |
Add a chunk-only validator and clear its cache to validate global contract distribution behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…orage Co-Authored-By: Claude Opus 4.6 <[email protected]>
Reverts #15415 (fix: properly include accessed contracts for eth implicit account) and replaces it with #15430 which uses RuntimeContractIdentifier for correct dispatch. Co-Authored-By: Claude Opus 4.6 <[email protected]>
record_contract_callwas using AccountContract (the on-chain stored value) to determine which contract code hash to record for distribution to validators. This is incorrect for the old ETH wallet accounts: the stored hash is the magic bytes hash, not the actual contract code hash, and for accounts using global contracts the wrong trie key was used. This is a better alternative to #15415.Stacked on #15429.