refactor(core/state): add GetStateAndCommittedState #31585#2316
refactor(core/state): add GetStateAndCommittedState #31585#2316gzliudan wants to merge 1 commit intoXinFinOrg:dev-upgradefrom
Conversation
expose a combined state getter and use it in sstore gas accounting. keep tracer test doubles compatible with the vm interface change.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR introduces a combined storage getter (GetStateAndCommittedState) to reduce duplicated state lookups, and updates SSTORE gas accounting to use the combined getter while keeping tracer-related test doubles compatible with the VM interface change.
Changes:
- Add
GetStateAndCommittedStatetocore/vm.StateDBand implement it incore/state.StateDB(and hooked wrapper). - Refactor SSTORE gas accounting paths to use the combined getter instead of separate
GetState/GetCommittedStatecalls. - Add/adjust tests to validate the combined getter behavior and confirm SSTORE gas uses it; add an interpreter cancellation test/benchmark.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| eth/tracers/logger/logger_test.go | Updates dummy StateDB to satisfy the new VM interface method. |
| core/vm/operations_acl.go | Refactors EIP-2200/2929 SSTORE gas accounting to use the combined getter. |
| core/vm/interpreter_test.go | Adds loop-interrupt test and a benchmark for interpreter/SSTORE gas path. |
| core/vm/interface.go | Replaces GetCommittedState in the VM StateDB interface with GetStateAndCommittedState. |
| core/vm/gas_table_test.go | Adds a test ensuring EIP-2200 SSTORE gas uses the combined getter. |
| core/vm/gas_table.go | Refactors legacy and EIP-2200 SSTORE gas accounting to use the combined getter. |
| core/state/statedb_test.go | Adds unit test covering StateDB.GetStateAndCommittedState semantics. |
| core/state/statedb_hooked.go | Updates hooked StateDB wrapper to forward the combined getter. |
| core/state/statedb.go | Implements GetStateAndCommittedState on StateDB. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Proposed changes
expose a combined state getter and use it in sstore gas accounting.
keep tracer test doubles compatible with the vm interface change.
Ref: ethereum#31585
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which parts of the codebase does this PR touch?
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that