From 2b3381c32e1ee70ad0d0fab9eb09996e4950bb6c Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Thu, 25 Apr 2024 16:58:28 +0700 Subject: [PATCH 1/2] save --- turbo/stages/mock/mock_sentry.go | 1 + 1 file changed, 1 insertion(+) diff --git a/turbo/stages/mock/mock_sentry.go b/turbo/stages/mock/mock_sentry.go index 343ef978207..8576493c460 100644 --- a/turbo/stages/mock/mock_sentry.go +++ b/turbo/stages/mock/mock_sentry.go @@ -251,6 +251,7 @@ func MockWithEverything(tb testing.TB, gspec *types.Genesis, key *ecdsa.PrivateK var err error cfg := ethconfig.Defaults + cfg.Sync.LoopBlockLimit = 1 cfg.StateStream = true cfg.BatchSize = 1 * datasize.MB cfg.Sync.BodyDownloadTimeoutSeconds = 10 From 052bbaa503d7b40f62f0c851e1f4f0545a9fd8c7 Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Thu, 25 Apr 2024 17:55:01 +0700 Subject: [PATCH 2/2] save --- turbo/stages/mock/mock_sentry.go | 33 +++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/turbo/stages/mock/mock_sentry.go b/turbo/stages/mock/mock_sentry.go index 8576493c460..b7f6e75db89 100644 --- a/turbo/stages/mock/mock_sentry.go +++ b/turbo/stages/mock/mock_sentry.go @@ -698,8 +698,10 @@ func (ms *MockSentry) insertPoWBlocks(chain *core.ChainPack) error { initialCycle := MockInsertAsInitialCycle hook := stages2.NewHook(ms.Ctx, ms.DB, ms.Notifications, ms.Sync, ms.BlockReader, ms.ChainConfig, ms.Log, nil) - if err = stages2.StageLoopIteration(ms.Ctx, ms.DB, wrap.TxContainer{}, ms.Sync, initialCycle, true, ms.Log, ms.BlockReader, hook); err != nil { - return err + for i := 0; i < len(chain.Blocks); i++ { + if err = stages2.StageLoopIteration(ms.Ctx, ms.DB, wrap.TxContainer{}, ms.Sync, initialCycle, true, ms.Log, ms.BlockReader, hook); err != nil { + return err + } } if ms.TxPool != nil { ms.ReceiveWg.Wait() // Wait for TxPool notification @@ -727,19 +729,20 @@ func (ms *MockSentry) insertPoSBlocks(chain *core.ChainPack) error { tipHash := chain.TopBlock.Hash() - status, _, lvh, err := wr.UpdateForkChoice(ctx, tipHash, tipHash, tipHash) - - if err != nil { - return err - } - if err := ms.DB.UpdateNosync(ms.Ctx, func(tx kv.RwTx) error { - rawdb.WriteHeadBlockHash(tx, lvh) - return nil - }); err != nil { - return err - } - if status != execution.ExecutionStatus_Success { - return fmt.Errorf("insertion failed for block %d, code: %s", chain.Blocks[chain.Length()-1].NumberU64(), status.String()) + for i := 0; i < len(chain.Blocks); i++ { + status, _, lvh, err := wr.UpdateForkChoice(ctx, tipHash, tipHash, tipHash) + if err != nil { + return err + } + if err := ms.DB.UpdateNosync(ms.Ctx, func(tx kv.RwTx) error { + rawdb.WriteHeadBlockHash(tx, lvh) + return nil + }); err != nil { + return err + } + if status != execution.ExecutionStatus_Success { + return fmt.Errorf("insertion failed for block %d, code: %s", chain.Blocks[chain.Length()-1].NumberU64(), status.String()) + } } return nil