diff --git a/eth/backend.go b/eth/backend.go index ec29d91a01c..1741a2760a6 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -158,6 +158,7 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere return nil, err } + var currentBlock *types.Block // Check if we have an already initialized chain and fall back to // that if so. Otherwise we need to generate a new genesis spec. if err := chainKv.View(context.Background(), func(tx kv.Tx) error { @@ -168,6 +169,7 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere if h != (common.Hash{}) { config.Genesis = nil // fallback to db content } + currentBlock = rawdb.ReadCurrentBlock(tx) return nil }); err != nil { panic(err) @@ -434,6 +436,24 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere } } + if currentBlock == nil { + currentBlock = genesis + } + // We start the transaction pool on startup, for a couple of reasons: + // 1) Hive tests requires us to do so and starting it from eth_sendRawTransaction is not viable as we have not enough data + // to initialize it properly. + // 2) we cannot propose for block 1 regardless. + go func() { + time.Sleep(10 * time.Millisecond) + baseFee := uint64(0) + if currentBlock.BaseFee() != nil { + baseFee = currentBlock.BaseFee().Uint64() + } + backend.notifications.Accumulator.StartChange(currentBlock.NumberU64(), currentBlock.Hash(), nil, false) + backend.notifications.Accumulator.SendAndReset(ctx, backend.notifications.StateChangesConsumer, baseFee, currentBlock.GasLimit()) + + }() + if !config.DeprecatedTxPool.Disable { backend.txPool2Fetch.ConnectCore() backend.txPool2Fetch.ConnectSentries() diff --git a/turbo/stages/stageloop.go b/turbo/stages/stageloop.go index 7fdd36ca352..a93342e2dd2 100644 --- a/turbo/stages/stageloop.go +++ b/turbo/stages/stageloop.go @@ -126,7 +126,6 @@ func StageLoopStep( } }() // avoid crash because Erigon's core does many things - var prevHeadBlockHash common.Hash var origin, finishProgressBefore uint64 if err := db.View(ctx, func(tx kv.Tx) error { origin, err = stages.GetStageProgress(tx, stages.Headers) @@ -137,7 +136,6 @@ func StageLoopStep( if err != nil { return err } - prevHeadBlockHash = rawdb.ReadHeadBlockHash(tx) return nil }); err != nil { return headBlockHash, err @@ -207,7 +205,7 @@ func StageLoopStep( } if notifications != nil && notifications.Accumulator != nil { header := rawdb.ReadCurrentHeader(rotx) - if header != nil && headBlockHash != prevHeadBlockHash { + if header != nil { pendingBaseFee := misc.CalcBaseFee(notifications.Accumulator.ChainConfig(), header) if header.Number.Uint64() == 0 {