From 64486d0a826068aecc62c845a5512f1d466112ac Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Mon, 26 Jun 2023 12:54:08 +0530 Subject: [PATCH] fix : runtime testcases --- core/txpool/txpool.go | 1 + eth/backend.go | 20 ++++++++++---------- miner/worker.go | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/core/txpool/txpool.go b/core/txpool/txpool.go index 869c47a443..c5b9d3c992 100644 --- a/core/txpool/txpool.go +++ b/core/txpool/txpool.go @@ -420,6 +420,7 @@ func (pool *TxPool) loop() { // Handle stats reporting ticks case <-report.C: + pool.mu.RLock() pending, queued := pool.stats() pool.mu.RUnlock() stales := int(pool.priced.stales.Load()) diff --git a/eth/backend.go b/eth/backend.go index 36de38edea..5a4c78046b 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -189,8 +189,6 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { gpoParams.Default = config.Miner.GasPrice } - ethereum.APIBackend.gpo = gasprice.NewOracle(ethereum.APIBackend, gpoParams) - // Override the chain config with provided settings. var overrides core.ChainOverrides if config.OverrideShanghai != nil { @@ -258,6 +256,8 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { ethereum.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, ethereum.engine, vmConfig, ethereum.shouldPreserve, &config.TxLookupLimit, checker) } + ethereum.APIBackend.gpo = gasprice.NewOracle(ethereum.APIBackend, gpoParams) + if err != nil { return nil, err } @@ -530,17 +530,17 @@ func (s *Ethereum) StartMining(threads int) error { cli.Authorize(eb, wallet.SignData) } - } - if bor, ok := s.engine.(*bor.Bor); ok { - wallet, err := s.accountManager.Find(accounts.Account{Address: eb}) - if wallet == nil || err != nil { - log.Error("Etherbase account unavailable locally", "err", err) + if bor, ok := s.engine.(*bor.Bor); ok { + wallet, err := s.accountManager.Find(accounts.Account{Address: eb}) + if wallet == nil || err != nil { + log.Error("Etherbase account unavailable locally", "err", err) - return fmt.Errorf("signer missing: %v", err) + return fmt.Errorf("signer missing: %v", err) + } + + bor.Authorize(eb, wallet.SignData) } - - bor.Authorize(eb, wallet.SignData) } // If mining is started, we can disable the transaction rejection mechanism diff --git a/miner/worker.go b/miner/worker.go index c45f6033cd..f19f0d8cdc 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1678,7 +1678,7 @@ func (w *worker) commitWork(ctx context.Context, interrupt *atomic.Int32, noempt }() if !noempty && w.interruptCommitFlag { - block := w.chain.GetBlockByHash(w.chain.CurrentBlock().TxHash) + block := w.chain.GetBlockByHash(w.chain.CurrentBlock().Hash()) interruptCtx, stopFn = getInterruptTimer(ctx, work, block) // nolint : staticcheck interruptCtx = vm.PutCache(interruptCtx, w.interruptedTxCache)