feat: add tracing support for StateSyncTx#2062
feat: add tracing support for StateSyncTx#2062milando12 wants to merge 36 commits into0xPolygon:developfrom
Conversation
consensus/bor/bor.go
Outdated
| start := time.Now() | ||
| cx := statefull.ChainContext{Chain: chain, Bor: c} | ||
|
|
||
| // Start tracing StateSyncTx (if present in the block body) |
There was a problem hiding this comment.
I think we might have integration tests locally (we maintain our own Polygon Live Tracing branch for now).
I'll check if I could add that on top of your PR.
There was a problem hiding this comment.
That sounds great. Feel free to add them on top of this PR whenever you're ready.
- Introduced `vm.Config` to multiple functions for customizable VM tracing. - Added tracer configuration flags (`vmtrace` and `vmtrace.jsonconfig`) to streamline monitoring during blockchain synchronization. - Updated GenesisContract and spanner interfaces for trace integration. - Integrated tracing hooks for StateSyncTx events.
Remove the 4 [DEBUG] log lines that were added during development to diagnose StateSyncTx tracing issues.
When Finalize is called, the chain parameter can be a *core.HeaderChain (not just *core.BlockChain). Without this change, the tracer in vmCfg is nil during finalization, so StateSyncTx tracing hooks never fire. - Add vmConfig field and GetVMConfig() method to HeaderChain - Set hc.vmConfig in NewBlockChain after creating the HeaderChain - Add else-if branch in Finalize and FinalizeAndAssemble to extract VM config from HeaderChain
The Process function creates a tracingStateDB wrapper for tracing but was passing the unwrapped statedb to Finalize, causing the tracer to miss StateSyncTx state changes.
da6e677 to
2b43baf
Compare
Expand the `CommitState` method signature to include the `vm.Config` parameter, enabling proper VM tracing integration and configuration.
EVM struct has a comment saying never reuse
Add support for preconf and private transaction APIs - Introduce new flags and APIs for preconf and private transactions. - Add methods for transaction preconfirmation and private transaction handling in backends and API layers. - Update transaction submission logic to support preconf/private paths. - Include tests for all new functionalities and edge cases.
- Update method signatures to include `vm.Config`, enabling better VM tracing and configuration integration in testing and state processing logic.
…lper function - Consolidate duplicate code for retrieving `vm.Config` from `ChainHeaderReader`. - Simplify `Finalize` method by utilizing the new helper.
The state processor now passes the traced (hooked) StateDB to the consensus engine's Finalize method, so live tracers can observe balance changes from block reward distribution. This is the correct behavior — previously, Finalize received the raw StateDB, making block rewards invisible to live tracers like the supply tracer. Update TestSupplyRewards and TestSupplyEip1559Burn to include the expected ethash block reward (2 ETH) in their assertions, matching the new traced output.
|
@claude - review this PR. |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
It won't be able to review this PR is from a fork, and hence it doesn't have perms to fetch the branch. |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Can we ad integration tests that verify the trace output for a block containing a StateSyncTx? |
|
|
Closing this in favor of #2172. Some tests won't work in this PR as it's created from a fork. |


Description
Adding tracing support for
StateSyncTx.Changes
Checklist
Cross repository changes
Testing
Manual tests
Ran the Node with this code for few days - no problems showed up and I verified that
StateSyncTxtrace that we get is correct.