feat(core): state journal wrapper #30441 #33978#2295
feat(core): state journal wrapper #30441 #33978#2295gzliudan wants to merge 1 commit intoXinFinOrg:dev-upgradefrom
Conversation
|
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 extends the core tracing/state interfaces to support richer live-tracing signals (nonce-change reasons, blockhash reads, and code-hash access) and adds a journaling wrapper to automatically emit reverse state-change events on EVM reverts.
Changes:
- Added
core/tracing.WrapWithJournalto journal state-change hooks and emit revert (“reverse”) events on call-frame failure. - Introduced
OnBlockHashReadhook and emitted it from theBLOCKHASHopcode path. - Extended nonce handling with
NonceChangeReasonand updatedSetNoncesignatures/call sites accordingly.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/state_test_util.go | Updates test pre-state nonce initialization to the new SetNonce signature. |
| internal/ethapi/override/override.go | Updates state override nonce setting to pass a nonce-change reason. |
| eth/tracers/live/noop.go | Wires up the new OnBlockHashRead hook in the live noop tracer. |
| core/vm/runtime/runtime_test.go | Updates runtime benchmark setup to the new SetNonce signature. |
| core/vm/interface.go | Extends VM StateDB interface SetNonce to include NonceChangeReason. |
| core/vm/instructions.go | Emits OnBlockHashRead when executing BLOCKHASH. |
| core/vm/evm.go | Tags contract-creation nonce changes with explicit nonce-change reasons. |
| core/txpool/legacypool/legacypool_test.go | Updates txpool tests for new SetNonce signature. |
| core/tracing/journal.go | Adds journaling wrapper implementation to replay reverse state changes on reverts. |
| core/tracing/journal_test.go | Adds unit tests validating journaling wrapper behavior and hook coverage. |
| core/tracing/hooks.go | Adds OnBlockHashRead, NonceChangeReason, OnNonceChangeV2, and GetCodeHash to tracing interfaces. |
| core/tracing/gen_balance_change_reason_stringer.go | Updates generated stringer for new BalanceChangeRevert enum value. |
| core/tracing/CHANGELOG.md | Documents new hooks/types and the journaling wrapper. |
| core/state/statedb.go | Updates StateDB.SetNonce signature to accept NonceChangeReason. |
| core/state/statedb_utils.go | Updates nonce increment helper to pass a nonce-change reason. |
| core/state/statedb_test.go | Updates state tests for the new SetNonce signature. |
| core/state/statedb_hooked.go | Propagates nonce-change reasons into tracing hooks (preferring V2 when present). |
| core/state/statedb_hooked_test.go | Updates hooked statedb tests to pass a nonce-change reason. |
| core/state/statedb_fuzz_test.go | Updates fuzz test actions to use the new SetNonce signature. |
| core/state_transition.go | Tags transaction/authorization nonce changes with explicit reasons. |
| core/state_processor.go | Tags nonce increments during tx processing and system processing with reasons. |
| core/state_processor_test.go | Updates tests for new SetNonce signature in processor tests. |
| core/genesis.go | Tags genesis nonce initialization with NonceChangeGenesis. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3cfa267 to
a24f238
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // invoked by the go-ethereum core at various points in the state transition. | ||
| // | ||
| // To create a tracer that can be invoked with Geth, you need to register it using | ||
| // [github.com/ethereum/go-ethereum/eth/tracers.LiveDirectory.Register]. |
There was a problem hiding this comment.
Package-level docs link to github.com/ethereum/go-ethereum/eth/tracers.LiveDirectory.Register, but in this repo the package is github.com/XinFinOrg/XDPoSChain/eth/tracers (see eth/tracers/live.go). This makes the godoc link incorrect/broken; please update the reference to the correct module path (or use a relative reference) to keep docs accurate for this fork.
| // [github.com/ethereum/go-ethereum/eth/tracers.LiveDirectory.Register]. | |
| // [github.com/XinFinOrg/XDPoSChain/eth/tracers.LiveDirectory.Register]. |
core/tracing/journal_test.go
Outdated
| } | ||
|
|
||
| func (t *testTracer) OnStorageChange(addr common.Address, slot common.Hash, prev common.Hash, new common.Hash) { | ||
| t.t.Logf("OnStorageCodeChange(%v, %v, %v -> %v)", addr, slot, prev, new) |
There was a problem hiding this comment.
Log message says OnStorageCodeChange, but the hook is OnStorageChange. This looks like a copy/paste typo and can make test output confusing; consider renaming it to match the hook name.
| t.t.Logf("OnStorageCodeChange(%v, %v, %v -> %v)", addr, slot, prev, new) | |
| t.t.Logf("OnStorageChange(%v, %v, %v -> %v)", addr, slot, prev, new) |
add some more changes for live tracing API: - Hook OnSystemCallStartV2 was introduced with VMContext as parameter. - Hook OnBlockHashRead was introduced. - GetCodeHash was added to the state interface - The new WrapWithJournal construction helps with tracking EVM reverts in the tracer.
Proposed changes
add some more changes for live tracing API:
Ref:
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