Skip to content

feat(core): extends tracing.Hooks with OnSystemCallStartV2 #30786#2073

Merged
AnilChinchawale merged 1 commit intoXinFinOrg:dev-upgradefrom
gzliudan:OnSystemCallStartV2
Feb 28, 2026
Merged

feat(core): extends tracing.Hooks with OnSystemCallStartV2 #30786#2073
AnilChinchawale merged 1 commit intoXinFinOrg:dev-upgradefrom
gzliudan:OnSystemCallStartV2

Conversation

@gzliudan
Copy link
Copy Markdown
Collaborator

Proposed changes

This PR extends the Hooks interface with a new method, OnSystemCallStartV2, which takes VMContext as its parameter.

Motivation

By including VMContext as a parameter, the OnSystemCallStartV2 hook achieves parity with the OnTxStart hook in terms of provided insights. This alignment simplifies the inner tracer logic, enabling consistent handling of state changes and internal calls within the same framework.

Ref: ethereum#30786

Types of changes

What types of changes does your code introduce to XDC network?
Put an in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)
  • Regular KTLO or any of the maintaince work. e.g code style
  • CICD Improvement

Impacted Components

Which part of the codebase this PR will touch base on,

Put an in the boxes that apply

  • Consensus
  • Account
  • Network
  • Geth
  • Smart Contract
  • External components
  • Not sure (Please specify below)

Checklist

Put an in the boxes once you have confirmed below actions (or provide reasons on not doing so) that

  • This PR has sufficient test coverage (unit/integration test) OR I have provided reason in the PR description for not having test coverage
  • Provide an end-to-end test plan in the PR description on how to manually test it on the devnet/testnet.
  • Tested the backwards compatibility.
  • Tested with XDC nodes running this version co-exist with those running the previous version.
  • Relevant documentation has been updated as part of this PR
  • N/A

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 18, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the tracing infrastructure to provide richer context for system call tracing by adding a new OnSystemCallStartV2 hook that receives VMContext as a parameter. Additionally, it refactors several function signatures to eliminate redundant parameters by deriving configuration and state from the EVM instance.

Changes:

  • Added OnSystemCallStartV2 hook to the tracing.Hooks interface that provides VMContext for system calls
  • Refactored ApplyTransaction and ApplyTransactionWithEVM to derive ChainConfig from the EVM instance instead of passing it separately
  • Refactored ProcessParentBlockHash to access StateDB through evm.StateDB instead of passing it as a separate parameter

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
core/tracing/hooks.go Added new OnSystemCallStartV2 hook type and field to Hooks struct
core/state_processor.go Implemented onSystemCallStart helper with backward compatibility, refactored function signatures to reduce parameter duplication
core/state_processor_test.go Updated test calls to match new function signatures
core/chain_makers.go Updated ApplyTransaction and ProcessParentBlockHash calls
miner/worker.go Updated ProcessParentBlockHash and ApplyTransaction calls
eth/tracers/api.go Updated ProcessParentBlockHash and ApplyTransactionWithEVM calls
eth/state_accessor.go Updated ProcessParentBlockHash call
internal/ethapi/simulate.go Changed sanitizeCall parameter from concrete *state.StateDB to interface vm.StateDB
consensus/tests/engine_v1_tests/helper.go Updated ApplyTransaction call
consensus/tests/engine_v2_tests/helper.go Updated ApplyTransaction call

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/tracing/hooks.go
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/state_processor.go
Comment on lines 705 to 707
if tracer := evm.Config.Tracer; tracer != nil {
if tracer.OnSystemCallStart != nil {
tracer.OnSystemCallStart()
}
onSystemCallStart(tracer, evm.GetVMContext())
if tracer.OnSystemCallEnd != nil {
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OnSystemCallStartV2 receives evm.GetVMContext() before evm.SetTxContext(NewEVMTxContext(msg)) is applied. Since GetVMContext() includes GasPrice from evm.TxContext, the V2 hook can observe the previous tx gas price instead of the system-call context (0), and it will be inconsistent with the subsequent EVM call tracing. Consider setting the tx context first (or constructing a VMContext with the intended gas price) before invoking the start hook.

Copilot uses AI. Check for mistakes.
Comment thread core/state_processor.go
Comment on lines +737 to +742
func onSystemCallStart(tracer *tracing.Hooks, ctx *tracing.VMContext) {
if tracer.OnSystemCallStartV2 != nil {
tracer.OnSystemCallStartV2(ctx)
} else if tracer.OnSystemCallStart != nil {
tracer.OnSystemCallStart()
}
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New behavior (OnSystemCallStartV2 preference + fallback to OnSystemCallStart) isn’t covered by tests. Since this affects tracer callbacks, please extend the existing state processor tests (there are already tests for ProcessParentBlockHash) to assert: (1) V2 is invoked with a non-nil VMContext when set, and (2) legacy OnSystemCallStart is still invoked when V2 is nil.

Copilot uses AI. Check for mistakes.
@AnilChinchawale AnilChinchawale merged commit 240b318 into XinFinOrg:dev-upgrade Feb 28, 2026
17 checks passed
@gzliudan gzliudan deleted the OnSystemCallStartV2 branch February 28, 2026 13:16
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.

6 participants