diff --git a/eth/stagedsync/exec3_serial.go b/eth/stagedsync/exec3_serial.go index ffc29987570..398f6b1f8ff 100644 --- a/eth/stagedsync/exec3_serial.go +++ b/eth/stagedsync/exec3_serial.go @@ -4,10 +4,11 @@ import ( "context" "errors" "fmt" - chaos_monkey "github.com/erigontech/erigon/tests/chaos-monkey" "sync/atomic" "time" + chaos_monkey "github.com/erigontech/erigon/tests/chaos-monkey" + "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/log/v3" @@ -104,7 +105,7 @@ func (se *serialExecutor) execute(ctx context.Context, tasks []*state.TxTask) (c return false, err } se.logger.Warn(fmt.Sprintf("[%s] Execution failed", se.execStage.LogPrefix()), - "block", txTask.BlockNum, "txNum", txTask.TxNum, "hash", txTask.Header.Hash().String(), "err", err) + "block", txTask.BlockNum, "txNum", txTask.TxNum, "hash", txTask.Header.Hash().String(), "err", err, "inMem", se.inMemExec) if se.cfg.hd != nil && se.cfg.hd.POSSync() && errors.Is(err, consensus.ErrInvalidBlock) { se.cfg.hd.ReportBadHeaderPoS(txTask.Header.Hash(), txTask.Header.ParentHash) } diff --git a/eth/stagedsync/stage_txlookup.go b/eth/stagedsync/stage_txlookup.go index c6e57e0bf93..42884727d78 100644 --- a/eth/stagedsync/stage_txlookup.go +++ b/eth/stagedsync/stage_txlookup.go @@ -23,7 +23,9 @@ import ( "math/big" "time" + "github.com/erigontech/erigon-lib/kv/rawdbv3" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon/eth/stagedsync/stages" "github.com/erigontech/erigon-lib/chain" libcommon "github.com/erigontech/erigon-lib/common" @@ -242,6 +244,21 @@ func PruneTxLookup(s *PruneState, tx kv.RwTx, cfg TxLookupCfg, ctx context.Conte defer tx.Rollback() } blockFrom := s.PruneProgress + if blockFrom == 0 { + firstNonGenesisHeader, err := rawdbv3.SecondKey(tx, kv.Headers) + if err != nil { + return err + } + if firstNonGenesisHeader != nil { + blockFrom = binary.BigEndian.Uint64(firstNonGenesisHeader) + } else { + execProgress, err := stageProgress(tx, nil, stages.Senders) + if err != nil { + return err + } + blockFrom = execProgress + } + } var blockTo uint64 var pruneBor bool @@ -269,7 +286,7 @@ func PruneTxLookup(s *PruneState, tx kv.RwTx, cfg TxLookupCfg, ctx context.Conte for ; pruneBlockNum < blockTo; pruneBlockNum++ { select { case <-logEvery.C: - logger.Info(fmt.Sprintf("[%s] pruning tx lookup periodic progress", logPrefix), "blockNum", pruneBlockNum) + logger.Info(fmt.Sprintf("[%s] progress", logPrefix), "blockNum", pruneBlockNum) default: }