Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
715c921
Add VM trace support for StateSyncTx tracing
milando12 Feb 6, 2026
7b13a88
generate mocks
milando12 Feb 6, 2026
12e21b6
Remove debug trace logs from StateSyncTx processing
milando12 Feb 12, 2026
276a404
Propagate VM config through HeaderChain for tracer access
milando12 Feb 12, 2026
2b43baf
Pass tracingStateDB to Finalize in state processor
milando12 Feb 12, 2026
afa51c2
Add vm.Config parameter to failingGenesisContract's CommitState method
milando12 Feb 23, 2026
ee7c122
Refactor StateSyncTx tracing logic to instantiate only if tracing is …
milando12 Feb 23, 2026
f1e065e
Remove unused comment in StateSyncTx tracing initialization logic
milando12 Feb 23, 2026
9e48c5e
trigger PR update
milando12 Feb 24, 2026
8ddbaad
trigger PR update
milando12 Feb 24, 2026
9ef5449
params: version bump to v2.7.0-beta
pratikspatil024 Mar 13, 2026
c557c52
added giugliano block for amoy (#2141)
pratikspatil024 Mar 16, 2026
9dbbecf
params: version bump to v2.7.0-beta2
pratikspatil024 Mar 16, 2026
2b949e9
witness: disable filestore by default (#2144)
pratikspatil024 Mar 19, 2026
7d6a68d
eth/filters, rpc: add --rpc.rangelimit flag and fix filter config pas…
lucca30 Mar 19, 2026
155fe5e
gomemlimit fix: additional changes for configs / fix gomemlimit
marcello33 Mar 16, 2026
e6bfe34
update the config to initial state
pratikspatil024 Mar 19, 2026
21922c7
core/vm: add kzg precompile back for madhugiri forks (#2140)
manav2401 Mar 19, 2026
c2f2cee
params: version bump to v2.7.0-beta3
pratikspatil024 Mar 19, 2026
16c1ab4
Merge tag 'v2.7.0-beta3' into md/feat-tracer-original
milando12 Mar 26, 2026
cc1cc0d
Remove deprecated VM tracing flags from server CLI
milando12 Mar 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions builder/files/genesis-amoy.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"dandeliBlock": 31890000,
"lisovoBlock": 33634700,
"lisovoProBlock": 34062000,
"giuglianoBlock": 35573500,
"skipValidatorByteCheck": [26160367, 26161087, 26171567, 26173743, 26175647],
"stateSyncConfirmationDelay": {
"0": 128
Expand Down
5 changes: 5 additions & 0 deletions cmd/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (

"github.com/ethereum/go-ethereum/internal/cli"
"github.com/ethereum/go-ethereum/params"

// Force-load the tracer engines to trigger registration
_ "github.com/ethereum/go-ethereum/eth/tracers/js"
_ "github.com/ethereum/go-ethereum/eth/tracers/live"
_ "github.com/ethereum/go-ethereum/eth/tracers/native"
)

func main() {
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ var (
utils.RPCGlobalEVMTimeoutFlag,
utils.RPCGlobalTxFeeCapFlag,
utils.RPCGlobalLogQueryLimit,
utils.RPCGlobalRangeLimitFlag,
utils.AllowUnprotectedTxs,
utils.BatchRequestLimit,
utils.BatchResponseMaxSize,
Expand Down
13 changes: 12 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,12 @@ var (
Value: ethconfig.Defaults.LogQueryLimit,
Category: flags.APICategory,
}
RPCGlobalRangeLimitFlag = &cli.Uint64Flag{
Name: "rpc.rangelimit",
Usage: "Maximum block range allowed for eth_getLogs and bor_getLogs (0 = no limit)",
Value: ethconfig.Defaults.RPCBlockRangeLimit,
Category: flags.APICategory,
}
RPCTxSyncDefaultTimeoutFlag = &cli.DurationFlag{
Name: "rpc.txsync.defaulttimeout",
Usage: "Default timeout for eth_sendRawTransactionSync (e.g. 2s, 500ms)",
Expand Down Expand Up @@ -1878,6 +1884,10 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
}
if ctx.IsSet(RPCGlobalLogQueryLimit.Name) {
cfg.LogQueryLimit = ctx.Int(RPCGlobalLogQueryLimit.Name)
cfg.RPCLogQueryLimit = ctx.Int(RPCGlobalLogQueryLimit.Name)
}
if ctx.IsSet(RPCGlobalRangeLimitFlag.Name) {
cfg.RPCBlockRangeLimit = ctx.Uint64(RPCGlobalRangeLimitFlag.Name)
}
if ctx.IsSet(RPCTxSyncDefaultTimeoutFlag.Name) {
cfg.TxSyncDefaultTimeout = ctx.Duration(RPCTxSyncDefaultTimeoutFlag.Name)
Expand Down Expand Up @@ -2230,7 +2240,8 @@ func RegisterGraphQLService(stack *node.Node, backend ethapi.Backend, filterSyst
func RegisterFilterAPI(stack *node.Node, backend ethapi.Backend, ethcfg *ethconfig.Config) *filters.FilterSystem {
filterSystem := filters.NewFilterSystem(backend, filters.Config{
LogCacheSize: ethcfg.FilterLogCacheSize,
LogQueryLimit: ethcfg.LogQueryLimit,
LogQueryLimit: ethcfg.RPCLogQueryLimit,
RangeLimit: ethcfg.RPCBlockRangeLimit,
})

filterAPI := filters.NewFilterAPI(filterSystem, ethcfg.BorLogs)
Expand Down
62 changes: 52 additions & 10 deletions consensus/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1185,22 +1185,46 @@ func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header,
var (
stateSyncData []*types.StateSyncData
err error
vmCfg vm.Config
)

if bc, ok := chain.(*core.BlockChain); ok {
vmCfg = *bc.GetVMConfig()
} else if hc, ok := chain.(*core.HeaderChain); ok {
if cfg := hc.GetVMConfig(); cfg != nil {
vmCfg = *cfg
}
}

if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) {
start := time.Now()
cx := statefull.ChainContext{Chain: chain, Bor: c}

// Start tracing StateSyncTx (if present in the block body)
if hooks := vmCfg.Tracer; hooks != nil && hooks.OnTxStart != nil {
if c.config.IsMadhugiri(header.Number) && len(body.Transactions) > 0 {
lastTx := body.Transactions[len(body.Transactions)-1]
if lastTx.Type() == types.StateSyncTxType {
vmenv := vm.NewEVM(
core.NewEVMBlockContext(header, cx, &header.Coinbase),
wrappedState, c.chainConfig, vmCfg,
)
hooks.OnTxStart(vmenv.GetVMContext(), lastTx, statefull.SystemAddress)
}
}
}

// check and commit span
if !c.config.IsRio(header.Number) {
if err := c.checkAndCommitSpan(wrappedState, header, cx); err != nil {
if err := c.checkAndCommitSpan(wrappedState, header, cx, vmCfg); err != nil {
log.Error("Error while committing span", "error", err)
return nil
}
}

if c.HeimdallClient != nil {
// commit states
stateSyncData, err = c.CommitStates(wrappedState, header, cx)
stateSyncData, err = c.CommitStates(wrappedState, header, cx, vmCfg)
if err != nil {
log.Error("Error while committing states", "error", err)
return nil
Expand Down Expand Up @@ -1231,7 +1255,7 @@ func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header,
return receipts
}
if lastTx.Type() == types.StateSyncTxType {
receipts = insertStateSyncTransactionAndCalculateReceipt(lastTx, header, body, wrappedState, receipts)
receipts = insertStateSyncTransactionAndCalculateReceipt(lastTx, header, body, wrappedState, receipts, vmCfg)
}
}
} else {
Expand All @@ -1242,7 +1266,7 @@ func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header,
return receipts
}

func insertStateSyncTransactionAndCalculateReceipt(stateSyncTx *types.Transaction, header *types.Header, body *types.Body, state vm.StateDB, receipts []*types.Receipt) []*types.Receipt {
func insertStateSyncTransactionAndCalculateReceipt(stateSyncTx *types.Transaction, header *types.Header, body *types.Body, state vm.StateDB, receipts []*types.Receipt, vmConfig vm.Config) []*types.Receipt {
allLogs := state.Logs()
sort.SliceStable(allLogs, func(i, j int) bool {
return allLogs[i].Index < allLogs[j].Index
Expand Down Expand Up @@ -1275,6 +1299,12 @@ func insertStateSyncTransactionAndCalculateReceipt(stateSyncTx *types.Transactio
}

stateSyncReceipt.Bloom = types.CreateBloom(stateSyncReceipt)

// End tracing for StateSyncTx
if hooks := vmConfig.Tracer; hooks != nil && hooks.OnTxEnd != nil {
hooks.OnTxEnd(stateSyncReceipt, nil)
}

receipts = append(receipts, stateSyncReceipt)

return receipts
Expand Down Expand Up @@ -1331,23 +1361,32 @@ func (c *Bor) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *typ
var (
stateSyncData []*types.StateSyncData
err error
vmCfg vm.Config
)

if bc, ok := chain.(*core.BlockChain); ok {
vmCfg = *bc.GetVMConfig()
} else if hc, ok := chain.(*core.HeaderChain); ok {
if cfg := hc.GetVMConfig(); cfg != nil {
vmCfg = *cfg
}
}

if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) {
borStart := time.Now()
cx := statefull.ChainContext{Chain: chain, Bor: c}

// check and commit span
if !c.config.IsRio(header.Number) {
if err = c.checkAndCommitSpan(state, header, cx); err != nil {
if err = c.checkAndCommitSpan(state, header, cx, vmCfg); err != nil {
log.Error("Error while committing span", "error", err)
return nil, nil, 0, err
}
}

if c.HeimdallClient != nil {
// commit states
stateSyncData, err = c.CommitStates(state, header, cx)
stateSyncData, err = c.CommitStates(state, header, cx, vmCfg)
if err != nil {
log.Error("Error while committing states", "error", err)
return nil, nil, 0, err
Expand All @@ -1374,7 +1413,7 @@ func (c *Bor) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *typ
StateSyncData: stateSyncData,
})
body.Transactions = append(body.Transactions, stateSyncTx)
receipts = insertStateSyncTransactionAndCalculateReceipt(stateSyncTx, header, body, state, receipts)
receipts = insertStateSyncTransactionAndCalculateReceipt(stateSyncTx, header, body, state, receipts, vmCfg)
} else {
// set state sync
bc := chain.(core.BorStateSyncer)
Expand Down Expand Up @@ -1576,6 +1615,7 @@ func (c *Bor) checkAndCommitSpan(
state vm.StateDB,
header *types.Header,
chain core.ChainContext,
vmCfg vm.Config,
) error {
var ctx = context.Background()
headerNumber := header.Number.Uint64()
Expand All @@ -1592,7 +1632,7 @@ func (c *Bor) checkAndCommitSpan(
tempState.IntermediateRoot(false)

if c.needToCommitSpan(span, headerNumber) {
return c.FetchAndCommitSpan(ctx, span.Id+1, state, header, chain)
return c.FetchAndCommitSpan(ctx, span.Id+1, state, header, chain, vmCfg)
}

return nil
Expand Down Expand Up @@ -1631,6 +1671,7 @@ func (c *Bor) FetchAndCommitSpan(
state vm.StateDB,
header *types.Header,
chain core.ChainContext,
vmCfg vm.Config,
) error {
var (
minSpan borTypes.Span
Expand Down Expand Up @@ -1694,14 +1735,15 @@ func (c *Bor) FetchAndCommitSpan(
)
}

return c.spanner.CommitSpan(ctx, minSpan, validators, producers, state, header, chain)
return c.spanner.CommitSpan(ctx, minSpan, validators, producers, state, header, chain, vmCfg)
}

// CommitStates commit states
func (c *Bor) CommitStates(
state vm.StateDB,
header *types.Header,
chain statefull.ChainContext,
vmCfg vm.Config,
) ([]*types.StateSyncData, error) {
fetchStart := time.Now()
number := header.Number.Uint64()
Expand Down Expand Up @@ -1815,7 +1857,7 @@ func (c *Bor) CommitStates(
// we expect that this call MUST emit an event, otherwise we wouldn't make a receipt
// if the receiver address is not a contract then we'll skip the most of the execution and emitting an event as well
// https://github.com/0xPolygon/genesis-contracts/blob/master/contracts/StateReceiver.sol#L27
gasUsed, err = c.GenesisContractsClient.CommitState(eventRecord, state, header, chain)
gasUsed, err = c.GenesisContractsClient.CommitState(eventRecord, state, header, chain, vmCfg)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions consensus/bor/bor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
func (s *fakeSpanner) GetCurrentValidatorsByBlockNrOrHash(ctx context.Context, _ rpc.BlockNumberOrHash, _ uint64) ([]*valset.Validator, error) {
return s.vals, nil
}
func (s *fakeSpanner) CommitSpan(ctx context.Context, _ borTypes.Span, _ []stakeTypes.MinimalVal, _ []stakeTypes.MinimalVal, _ vm.StateDB, _ *types.Header, _ core.ChainContext) error {
func (s *fakeSpanner) CommitSpan(ctx context.Context, _ borTypes.Span, _ []stakeTypes.MinimalVal, _ []stakeTypes.MinimalVal, _ vm.StateDB, _ *types.Header, _ core.ChainContext, _ vm.Config) error {

Check warning on line 70 in consensus/bor/bor_test.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function has 8 parameters, which is greater than the 7 authorized.

See more on https://sonarcloud.io/project/issues?id=0xPolygon_bor&issues=AZ0qoSD_2BMkbzG0YwWy&open=AZ0qoSD_2BMkbzG0YwWy&pullRequest=2166
if s.shouldFailCommit {
return errors.New("span commit failed")
}
Expand All @@ -80,7 +80,7 @@
// failingGenesisContract simulates GenesisContract failures
type failingGenesisContract struct{}

func (f *failingGenesisContract) CommitState(event *clerk.EventRecordWithTime, state vm.StateDB, header *types.Header, chCtx statefull.ChainContext) (uint64, error) {
func (f *failingGenesisContract) CommitState(event *clerk.EventRecordWithTime, state vm.StateDB, header *types.Header, chCtx statefull.ChainContext, vmCfg vm.Config) (uint64, error) {
return 0, errors.New("commit state failed")
}

Expand Down
3 changes: 2 additions & 1 deletion consensus/bor/contract/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func (gc *GenesisContractsClient) CommitState(
state vm.StateDB,
header *types.Header,
chCtx statefull.ChainContext,
vmCfg vm.Config,
) (uint64, error) {
eventRecord := event.BuildEventRecord()

Expand All @@ -96,7 +97,7 @@ func (gc *GenesisContractsClient) CommitState(

log.Info("→ committing new state", "eventRecord", event.ID)

gasUsed, err := statefull.ApplyMessage(context.Background(), msg, state, header, gc.chainConfig, chCtx)
gasUsed, err := statefull.ApplyMessage(context.Background(), msg, state, header, gc.chainConfig, chCtx, vmCfg)

// Logging event log with time and individual gasUsed
log.Info("→ committed new state", "eventRecord", event.String(gasUsed))
Expand Down
2 changes: 1 addition & 1 deletion consensus/bor/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ import (

//go:generate mockgen -destination=./genesis_contract_mock.go -package=bor . GenesisContract
type GenesisContract interface {
CommitState(event *clerk.EventRecordWithTime, state vm.StateDB, header *types.Header, chCtx statefull.ChainContext) (uint64, error)
CommitState(event *clerk.EventRecordWithTime, state vm.StateDB, header *types.Header, chCtx statefull.ChainContext, vmCfg vm.Config) (uint64, error)
LastStateId(state *state.StateDB, number uint64, hash common.Hash) (*big.Int, error)
}
8 changes: 4 additions & 4 deletions consensus/bor/genesis_contract_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions consensus/bor/heimdall/span/spanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@

const method = "commitSpan"

func (c *ChainSpanner) CommitSpan(ctx context.Context, minimalSpan borTypes.Span, validators, producers []stakeTypes.MinimalVal, state vm.StateDB, header *types.Header, chainContext core.ChainContext) error {
func (c *ChainSpanner) CommitSpan(ctx context.Context, minimalSpan borTypes.Span, validators, producers []stakeTypes.MinimalVal, state vm.StateDB, header *types.Header, chainContext core.ChainContext, vmCfg vm.Config) error {

Check warning on line 294 in consensus/bor/heimdall/span/spanner.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function has 8 parameters, which is greater than the 7 authorized.

See more on https://sonarcloud.io/project/issues?id=0xPolygon_bor&issues=AZ0qoSAf2BMkbzG0YwWv&open=AZ0qoSAf2BMkbzG0YwWv&pullRequest=2166
// get validators bytes
validatorBytes, err := rlp.EncodeToBytes(validators)
if err != nil {
Expand Down Expand Up @@ -329,7 +329,7 @@
msg := statefull.GetSystemMessage(c.validatorContractAddress, data)

// apply message
_, err = statefull.ApplyMessage(ctx, msg, state, header, c.chainConfig, chainContext)
_, err = statefull.ApplyMessage(ctx, msg, state, header, c.chainConfig, chainContext, vmCfg)

return err
}
2 changes: 1 addition & 1 deletion consensus/bor/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ type Spanner interface {
GetCurrentSpan(ctx context.Context, headerHash common.Hash, state *state.StateDB) (*borTypes.Span, error)
GetCurrentValidatorsByHash(ctx context.Context, headerHash common.Hash, blockNumber uint64) ([]*valset.Validator, error)
GetCurrentValidatorsByBlockNrOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, blockNumber uint64) ([]*valset.Validator, error)
CommitSpan(ctx context.Context, minimalSpan borTypes.Span, validators, producers []stakeTypes.MinimalVal, state vm.StateDB, header *types.Header, chainContext core.ChainContext) error
CommitSpan(ctx context.Context, minimalSpan borTypes.Span, validators, producers []stakeTypes.MinimalVal, state vm.StateDB, header *types.Header, chainContext core.ChainContext, vmCfg vm.Config) error
}
8 changes: 4 additions & 4 deletions consensus/bor/span_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions consensus/bor/statefull/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/ethereum/go-ethereum/params"
)

var systemAddress = common.HexToAddress("0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE")
var SystemAddress = common.HexToAddress("0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE")

type ChainContext struct {
Chain consensus.ChainHeaderReader
Expand Down Expand Up @@ -70,7 +70,7 @@ func (m Callmsg) Data() []byte { return m.CallMsg.Data }
func GetSystemMessage(toAddress common.Address, data []byte) Callmsg {
return Callmsg{
ethereum.CallMsg{
From: systemAddress,
From: SystemAddress,
Gas: params.MaxTxGas, // should be more than enough for state-sync related syscalls
GasPrice: big.NewInt(0),
Value: big.NewInt(0),
Expand All @@ -88,6 +88,7 @@ func ApplyMessage(
header *types.Header,
chainConfig *params.ChainConfig,
chainContext core.ChainContext,
vmConfig vm.Config,
) (uint64, error) {
initialGas := msg.Gas()

Expand All @@ -96,7 +97,7 @@ func ApplyMessage(

// Create a new environment which holds all relevant information
// about the transaction and calling mechanisms.
vmenv := vm.NewEVM(blockContext, state, chainConfig, vm.Config{})
vmenv := vm.NewEVM(blockContext, state, chainConfig, vmConfig)

// nolint : contextcheck
// Apply the transaction to the current state (included in the env)
Expand Down
1 change: 1 addition & 0 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ func NewBlockChain(db ethdb.Database, genesis *Genesis, engine consensus.Engine,
if err != nil {
return nil, err
}
bc.hc.vmConfig = &bc.cfg.VmConfig
bc.flushInterval.Store(int64(cfg.TrieTimeLimit))
bc.forker = NewForkChoice(bc, cfg.ShouldPreserve, cfg.Checker)

Expand Down
Loading