Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2372,6 +2372,12 @@ func (w *worker) clearPending(number uint64) {
// vmConfig returns the VM config.
func (w *worker) vmConfig() vm.Config {
cfg := *w.chain.GetVMConfig()
// The miner copies its vm.Config from the chain instance, which may include
// a vm.Config.Tracer intended only for live tracing, not for mining. Clear
// the tracer here to prevent the miner from tracing block production and
// conflicting with live tracing.
cfg.Tracer = nil
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

This change alters miner EVM behavior when the chain VM config has a tracer set, but there’s no regression test to ensure the worker always strips the tracer from its vm.Config. Please add a unit test in miner/worker_test.go that sets a non-nil tracer on backend.chain.GetVMConfig(), calls w.vmConfig(), and asserts the returned config has Tracer == nil (and ideally that the chain’s VM config tracer remains unchanged).

Copilot uses AI. Check for mistakes.

Comment on lines 2374 to +2380
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

Consider adding a unit test to lock in this behavior: when the underlying chain VM config has a non-nil Tracer (e.g., from the VMTrace/live tracing flag), worker.vmConfig() should return a config with Tracer cleared. This prevents regressions where mining accidentally reuses the live tracer again.

Copilot uses AI. Check for mistakes.
return cfg
}

Expand Down
19 changes: 19 additions & 0 deletions miner/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"github.com/ethereum/go-ethereum/core/blockstm"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/tracing"
"github.com/ethereum/go-ethereum/core/txpool"
"github.com/ethereum/go-ethereum/core/txpool/legacypool"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -2967,3 +2968,21 @@ func TestDelayFlagOffByOne(t *testing.T) {
require.True(t, buggyDelayFlag(), "bug: last tx skipped, DAG hint incorrectly embedded")
require.False(t, fixedDelayFlag(), "fix: last tx detected, DAG hint suppressed")
}

// TestVMConfigTracerStripped verifies that vmConfig() always returns a vm.Config
// with Tracer == nil, even when the chain's VMConfig has a non-nil tracer set
// (e.g. during live tracing). The chain's own VMConfig must remain unchanged.
func TestVMConfigTracerStripped(t *testing.T) {
engine := clique.New(cliqueChainConfig.Clique, rawdb.NewMemoryDatabase())
defer engine.Close()

w, b, cleanup := newTestWorker(t, DefaultTestConfig(), cliqueChainConfig, engine, rawdb.NewMemoryDatabase(), false, 0)
defer cleanup()

sentinel := &tracing.Hooks{}
b.chain.GetVMConfig().Tracer = sentinel

got := w.vmConfig()
require.Nil(t, got.Tracer, "vmConfig() must strip the tracer so the miner does not conflict with live tracing")
require.Same(t, sentinel, b.chain.GetVMConfig().Tracer, "chain VMConfig tracer must remain unchanged after vmConfig() call")
}