mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 17:44:29 +00:00
All stages - finish fast if current progress > target (#1773)
This commit is contained in:
parent
aacc457ea8
commit
df8c5e3095
@ -14,6 +14,11 @@ func FinishForward(s *StageState, db ethdb.Database, notifier ChainEventNotifier
|
||||
if executionAt, err = s.ExecutionAt(db); err != nil {
|
||||
return err
|
||||
}
|
||||
if executionAt <= s.BlockNumber {
|
||||
s.Done()
|
||||
return nil
|
||||
}
|
||||
|
||||
logPrefix := s.state.LogPrefix()
|
||||
log.Info(fmt.Sprintf("[%s] Update current block for the RPC API", logPrefix), "to", executionAt)
|
||||
|
||||
|
@ -55,7 +55,7 @@ func SpawnAccountHistoryIndex(s *StageState, db ethdb.Database, cfg HistoryCfg,
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: getting last executed block: %w", logPrefix, err)
|
||||
}
|
||||
if executionAt == s.BlockNumber {
|
||||
if executionAt <= s.BlockNumber {
|
||||
s.Done()
|
||||
return nil
|
||||
}
|
||||
@ -102,7 +102,7 @@ func SpawnStorageHistoryIndex(s *StageState, db ethdb.Database, cfg HistoryCfg,
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: logs index: getting last executed block: %w", logPrefix, err)
|
||||
}
|
||||
if executionAt == s.BlockNumber {
|
||||
if executionAt <= s.BlockNumber {
|
||||
s.Done()
|
||||
return nil
|
||||
}
|
||||
|
@ -42,6 +42,11 @@ func SpawnTxPool(s *StageState, db ethdb.Database, cfg TxPoolCfg, quitCh <-chan
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if to == s.BlockNumber {
|
||||
s.Done()
|
||||
return nil
|
||||
}
|
||||
|
||||
logPrefix := s.state.LogPrefix()
|
||||
if to < s.BlockNumber {
|
||||
return fmt.Errorf("%s: to (%d) < from (%d)", logPrefix, to, s.BlockNumber)
|
||||
|
@ -12,7 +12,6 @@ import (
|
||||
"github.com/ledgerwatch/turbo-geth/core/vm"
|
||||
"github.com/ledgerwatch/turbo-geth/eth/stagedsync/stages"
|
||||
"github.com/ledgerwatch/turbo-geth/ethdb"
|
||||
"github.com/ledgerwatch/turbo-geth/log"
|
||||
"github.com/ledgerwatch/turbo-geth/params"
|
||||
"github.com/ledgerwatch/turbo-geth/turbo/stages/bodydownload"
|
||||
)
|
||||
@ -344,28 +343,10 @@ func DefaultStages() StageBuilders {
|
||||
ID: stages.Finish,
|
||||
Description: "Final: update current block for the RPC API",
|
||||
ExecFunc: func(s *StageState, _ Unwinder) error {
|
||||
var executionAt uint64
|
||||
var err error
|
||||
if executionAt, err = s.ExecutionAt(world.DB); err != nil {
|
||||
return err
|
||||
}
|
||||
logPrefix := s.state.LogPrefix()
|
||||
log.Info(fmt.Sprintf("[%s] Update current block for the RPC API", logPrefix), "to", executionAt)
|
||||
|
||||
err = NotifyNewHeaders(s.BlockNumber+1, executionAt, world.notifier, world.DB)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.DoneAndUpdate(world.DB, executionAt)
|
||||
return FinishForward(s, world.DB, world.notifier)
|
||||
},
|
||||
UnwindFunc: func(u *UnwindState, s *StageState) error {
|
||||
var executionAt uint64
|
||||
var err error
|
||||
if executionAt, err = s.ExecutionAt(world.DB); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.DoneAndUpdate(world.DB, executionAt)
|
||||
return UnwindFinish(u, s, world.DB)
|
||||
},
|
||||
}
|
||||
},
|
||||
|
@ -174,6 +174,7 @@ func (s *State) Run(db ethdb.GetterPutter, tx ethdb.GetterPutter) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
_, stage := s.CurrentStage()
|
||||
if hook, ok := s.beforeStageRun[string(stage.ID)]; ok {
|
||||
if err := hook(); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user