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 @@ -2380,6 +2380,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
Comment thread
maoueh marked this conversation as resolved.

Comment thread
maoueh marked this conversation as resolved.
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 @@ -3009,3 +3010,21 @@ func TestDisablePendingBlock(t *testing.T) {
}, 2*time.Second, 100*time.Millisecond, "pending block, receipts and state should not be nil when DisablePendingBlock is false")
})
}

// 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")
}
Loading