Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed transaction on hive tests #4590

Merged
merged 8 commits into from
Jul 1, 2022
Merged
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
20 changes: 20 additions & 0 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 1 addition & 3 deletions turbo/stages/stageloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -137,7 +136,6 @@ func StageLoopStep(
if err != nil {
return err
}
prevHeadBlockHash = rawdb.ReadHeadBlockHash(tx)
return nil
}); err != nil {
return headBlockHash, err
Expand Down Expand Up @@ -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 {
Expand Down