mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
DEV: Config
This commit is contained in:
parent
1edc65acdc
commit
0dac0bcbe3
4 changed files with 18 additions and 18 deletions
|
|
@ -109,7 +109,7 @@ func NewTracingHooksFromFirehose(tracer *Firehose) *tracing.Hooks {
|
||||||
|
|
||||||
type FirehoseConfig struct {
|
type FirehoseConfig struct {
|
||||||
ApplyBackwardCompatibility *bool `json:"applyBackwardCompatibility"`
|
ApplyBackwardCompatibility *bool `json:"applyBackwardCompatibility"`
|
||||||
ConcurrentBlockFlushing bool `json:"concurrentBlockFlushing"`
|
ConcurrentBlockFlushing int `json:"concurrentBlockFlushing"`
|
||||||
|
|
||||||
// Only used for testing, only possible through JSON configuration
|
// Only used for testing, only possible through JSON configuration
|
||||||
private *privateFirehoseConfig
|
private *privateFirehoseConfig
|
||||||
|
|
@ -161,7 +161,7 @@ type Firehose struct {
|
||||||
// here. If not set in the config, then we inspect `OnBlockchainInit` the chain config to determine
|
// here. If not set in the config, then we inspect `OnBlockchainInit` the chain config to determine
|
||||||
// if it's a network for which we must reproduce the legacy bugs.
|
// if it's a network for which we must reproduce the legacy bugs.
|
||||||
applyBackwardCompatibility *bool
|
applyBackwardCompatibility *bool
|
||||||
concurrentBlockFlushing bool
|
concurrentBlockFlushing int
|
||||||
|
|
||||||
// Block state
|
// Block state
|
||||||
block *pbeth.Block
|
block *pbeth.Block
|
||||||
|
|
@ -264,13 +264,13 @@ func NewFirehose(config *FirehoseConfig) *Firehose {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.ConcurrentBlockFlushing {
|
if config.ConcurrentBlockFlushing > 0 {
|
||||||
log.Info("Firehose concurrent block flushing enabled, starting block " +
|
log.Info("Firehose concurrent block flushing enabled, starting", config.ConcurrentBlockFlushing,
|
||||||
"print worker goroutine")
|
"block print worker goroutine")
|
||||||
const numWorkers = 10 // TODO: This becomes a parameter
|
|
||||||
firehose.blockPrintQueue = make(chan *blockPrintJob, 100) // TODO: Optimal buffer size tbd
|
firehose.blockPrintQueue = make(chan *blockPrintJob, 100) // TODO: Optimal buffer size tbd
|
||||||
firehose.blockOutputQueue = make(chan *blockOutput, 100)
|
firehose.blockOutputQueue = make(chan *blockOutput, 100)
|
||||||
for i := 0; i < numWorkers; i++ {
|
for i := 0; i < config.ConcurrentBlockFlushing; i++ {
|
||||||
firehose.blockFlushDone.Add(1)
|
firehose.blockFlushDone.Add(1)
|
||||||
go firehose.blockPrintWorker()
|
go firehose.blockPrintWorker()
|
||||||
}
|
}
|
||||||
|
|
@ -545,7 +545,7 @@ func (f *Firehose) OnBlockEnd(err error) {
|
||||||
f.ensureInBlockAndNotInTrx()
|
f.ensureInBlockAndNotInTrx()
|
||||||
|
|
||||||
// Flush block to firehose and optionally use goroutine
|
// Flush block to firehose and optionally use goroutine
|
||||||
if f.concurrentBlockFlushing {
|
if f.concurrentBlockFlushing > 0 {
|
||||||
f.startBlockCond.L.Lock()
|
f.startBlockCond.L.Lock()
|
||||||
if !f.startBlockInitialized {
|
if !f.startBlockInitialized {
|
||||||
f.startBlockNum = f.block.Number
|
f.startBlockNum = f.block.Number
|
||||||
|
|
@ -681,7 +681,7 @@ func (f *Firehose) reorderCallOrdinals(call *pbeth.Call, ordinalBase uint64) (or
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Firehose) OnClose() {
|
func (f *Firehose) OnClose() {
|
||||||
if f.concurrentBlockFlushing {
|
if f.concurrentBlockFlushing > 0 {
|
||||||
log.Info("Firehose closing, flushing queued blocks to standard output")
|
log.Info("Firehose closing, flushing queued blocks to standard output")
|
||||||
f.CloseBlockPrintQueue()
|
f.CloseBlockPrintQueue()
|
||||||
}
|
}
|
||||||
|
|
@ -1946,7 +1946,7 @@ func (f *Firehose) printBlockToFirehose(block *pbeth.Block, finalityStatus *Fina
|
||||||
|
|
||||||
buf.WriteString("\n")
|
buf.WriteString("\n")
|
||||||
|
|
||||||
if f.concurrentBlockFlushing {
|
if f.concurrentBlockFlushing > 0 {
|
||||||
f.blockOutputQueue <- &blockOutput{
|
f.blockOutputQueue <- &blockOutput{
|
||||||
blockNum: block.Number,
|
blockNum: block.Number,
|
||||||
data: buf.Bytes(),
|
data: buf.Bytes(),
|
||||||
|
|
@ -2904,7 +2904,7 @@ func (f *Firehose) blockPrintWorker() {
|
||||||
// It blocks until all concurrent block flushing operations are completed, ensuring a clean
|
// It blocks until all concurrent block flushing operations are completed, ensuring a clean
|
||||||
// shutdown of the printing pipeline.
|
// shutdown of the printing pipeline.
|
||||||
func (f *Firehose) CloseBlockPrintQueue() {
|
func (f *Firehose) CloseBlockPrintQueue() {
|
||||||
if f.concurrentBlockFlushing {
|
if f.concurrentBlockFlushing > 0 {
|
||||||
f.closeChannels.Do(func() {
|
f.closeChannels.Do(func() {
|
||||||
close(f.blockPrintQueue)
|
close(f.blockPrintQueue)
|
||||||
f.blockFlushDone.Wait()
|
f.blockFlushDone.Wait()
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import (
|
||||||
func TestFirehose_BlockPrintsToFirehose_SingleBlock(t *testing.T) {
|
func TestFirehose_BlockPrintsToFirehose_SingleBlock(t *testing.T) {
|
||||||
|
|
||||||
f := NewFirehose(&FirehoseConfig{
|
f := NewFirehose(&FirehoseConfig{
|
||||||
ConcurrentBlockFlushing: true,
|
ConcurrentBlockFlushing: 1,
|
||||||
ApplyBackwardCompatibility: ptr(false),
|
ApplyBackwardCompatibility: ptr(false),
|
||||||
private: &privateFirehoseConfig{
|
private: &privateFirehoseConfig{
|
||||||
FlushToTestBuffer: true,
|
FlushToTestBuffer: true,
|
||||||
|
|
@ -58,7 +58,7 @@ func TestFirehose_BlocksPrintToFirehose_MultipleBlocksInOrder(t *testing.T) {
|
||||||
const baseBlockNum = 0
|
const baseBlockNum = 0
|
||||||
|
|
||||||
f := NewFirehose(&FirehoseConfig{
|
f := NewFirehose(&FirehoseConfig{
|
||||||
ConcurrentBlockFlushing: true,
|
ConcurrentBlockFlushing: 1,
|
||||||
ApplyBackwardCompatibility: ptr(false),
|
ApplyBackwardCompatibility: ptr(false),
|
||||||
private: &privateFirehoseConfig{
|
private: &privateFirehoseConfig{
|
||||||
FlushToTestBuffer: true,
|
FlushToTestBuffer: true,
|
||||||
|
|
|
||||||
|
|
@ -40,11 +40,11 @@ func TestFirehosePrestate(t *testing.T) {
|
||||||
"./testdata/TestFirehosePrestate/extra_account_creations",
|
"./testdata/TestFirehosePrestate/extra_account_creations",
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, concurrent := range []bool{true, false} {
|
for _, concurrent := range []int{0, 1} {
|
||||||
for _, folder := range testFolders {
|
for _, folder := range testFolders {
|
||||||
name := filepath.Base(folder)
|
name := filepath.Base(folder)
|
||||||
concurrencyLabel := "sequential"
|
concurrencyLabel := "sequential"
|
||||||
if concurrent {
|
if concurrent == 1 {
|
||||||
concurrencyLabel = "concurrent"
|
concurrencyLabel = "concurrent"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -199,9 +199,9 @@ func TestFirehose_SystemCalls(t *testing.T) {
|
||||||
func testBlockTracesCorrectly(t *testing.T, genesisSpec *core.Genesis, engine consensus.Engine, blocks []*types.Block, goldenDir string) {
|
func testBlockTracesCorrectly(t *testing.T, genesisSpec *core.Genesis, engine consensus.Engine, blocks []*types.Block, goldenDir string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
for _, concurrent := range []bool{true, false} {
|
for _, concurrent := range []int{0, 1} {
|
||||||
concurrencyLabel := "sequential"
|
concurrencyLabel := "sequential"
|
||||||
if concurrent {
|
if concurrent == 1 {
|
||||||
concurrencyLabel = "concurrent"
|
concurrencyLabel = "concurrent"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ func newFirehoseTestTracer(t *testing.T, model tracingModel, config *tracers.Fir
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
tracer, err := tracers.NewFirehoseFromRawJSON([]byte(fmt.Sprintf(`{
|
tracer, err := tracers.NewFirehoseFromRawJSON([]byte(fmt.Sprintf(`{
|
||||||
"concurrentBlockFlushing": %t,
|
"concurrentBlockFlushing": %d,
|
||||||
"_private": {
|
"_private": {
|
||||||
"flushToTestBuffer": true,
|
"flushToTestBuffer": true,
|
||||||
"ignoreGenesisBlock": true,
|
"ignoreGenesisBlock": true,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue