PR: Part 3

This commit is contained in:
David Zhou 2025-05-13 15:57:18 -04:00
parent a1e2e8f291
commit ec1caf10ed
2 changed files with 13 additions and 4 deletions

View file

@ -2,6 +2,7 @@ package firehose_test
import ( import (
"fmt" "fmt"
"github.com/ethereum/go-ethereum/eth/tracers"
"math/big" "math/big"
"path/filepath" "path/filepath"
"strings" "strings"
@ -49,7 +50,11 @@ func TestFirehosePrestate(t *testing.T) {
for _, model := range tracingModels { for _, model := range tracingModels {
t.Run(fmt.Sprintf("%s/%s/%s", model, name, concurrencyLabel), func(t *testing.T) { t.Run(fmt.Sprintf("%s/%s/%s", model, name, concurrencyLabel), func(t *testing.T) {
tracer, tracingHooks, onClose := newFirehoseTestTracer(t, model, concurrent) config := &tracers.FirehoseConfig{
ConcurrentBlockFlushing: concurrent,
}
tracer, tracingHooks, onClose := newFirehoseTestTracer(t, model, config)
defer onClose() defer onClose()
runPrestateBlock(t, filepath.Join(folder, "prestate.json"), tracingHooks) runPrestateBlock(t, filepath.Join(folder, "prestate.json"), tracingHooks)
@ -202,7 +207,11 @@ func testBlockTracesCorrectly(t *testing.T, genesisSpec *core.Genesis, engine co
for _, model := range tracingModels { for _, model := range tracingModels {
t.Run(fmt.Sprintf("%s/%s", model, concurrencyLabel), func(t *testing.T) { t.Run(fmt.Sprintf("%s/%s", model, concurrencyLabel), func(t *testing.T) {
tracer, tracingHooks, onClose := newFirehoseTestTracer(t, model, concurrent) config := &tracers.FirehoseConfig{
ConcurrentBlockFlushing: concurrent,
}
tracer, tracingHooks, onClose := newFirehoseTestTracer(t, model, config)
defer onClose() defer onClose()
chain, err := core.NewBlockChain(rawdb.NewMemoryDatabase(), nil, genesisSpec, nil, engine, vm.Config{Tracer: tracingHooks}, nil) chain, err := core.NewBlockChain(rawdb.NewMemoryDatabase(), nil, genesisSpec, nil, engine, vm.Config{Tracer: tracingHooks}, nil)

View file

@ -29,7 +29,7 @@ type firehoseInitLine struct {
type firehoseBlockLines []firehoseBlockLine type firehoseBlockLines []firehoseBlockLine
func newFirehoseTestTracer(t *testing.T, model tracingModel, concurrentBlockFlushing bool) (*tracers.Firehose, *tracing.Hooks, func()) { func newFirehoseTestTracer(t *testing.T, model tracingModel, config *tracers.FirehoseConfig) (*tracers.Firehose, *tracing.Hooks, func()) {
t.Helper() t.Helper()
tracer, err := tracers.NewFirehoseFromRawJSON([]byte(fmt.Sprintf(`{ tracer, err := tracers.NewFirehoseFromRawJSON([]byte(fmt.Sprintf(`{
@ -39,7 +39,7 @@ func newFirehoseTestTracer(t *testing.T, model tracingModel, concurrentBlockFlus
"ignoreGenesisBlock": true, "ignoreGenesisBlock": true,
"forcedBackwardCompatibility": %t "forcedBackwardCompatibility": %t
} }
}`, concurrentBlockFlushing, model == tracingModelFirehose2_3))) }`, config.ConcurrentBlockFlushing, model == tracingModelFirehose2_3)))
require.NoError(t, err) require.NoError(t, err)
hooks := tracers.NewTracingHooksFromFirehose(tracer) hooks := tracers.NewTracingHooksFromFirehose(tracer)