Documentation ¶
Index ¶
- Variables
- func GetStageData(db kv.Getter, stage SyncStage) ([]byte, error)
- func GetStageProgress(db kv.Getter, stage SyncStage) (uint64, error)
- func GetStagePruneProgress(db kv.Getter, stage SyncStage) (uint64, error)
- func PrintTables(db kv.RoDB, tx kv.RwTx) []interface{}
- func SaveStageData(db kv.Putter, stage SyncStage, data []byte) error
- func SaveStageProgress(db kv.Putter, stage SyncStage, progress uint64) error
- func SaveStagePruneProgress(db kv.Putter, stage SyncStage, progress uint64) error
- func UpdateMetrics(tx kv.Tx) error
- type ExecFunc
- type PruneFunc
- type PruneOrder
- type PruneState
- type Stage
- type StageState
- func (s *StageState) ExecutionAt(db kv.Getter) (uint64, error)
- func (s *StageState) IntermediateHashesAt(db kv.Getter) (uint64, error)
- func (s *StageState) LogPrefix() string
- func (s *StageState) Update(db kv.Putter, newBlockNum uint64) error
- func (s *StageState) UpdatePrune(db kv.Putter, blockNum uint64) error
- type Sync
- func (s *Sync) DisableAllStages() []SyncStage
- func (s *Sync) DisableStages(ids ...SyncStage)
- func (s *Sync) EnableStages(ids ...SyncStage)
- func (s *Sync) IsAfter(stage1, stage2 SyncStage) bool
- func (s *Sync) IsBefore(stage1, stage2 SyncStage) bool
- func (s *Sync) IsDone() bool
- func (s *Sync) Len() int
- func (s *Sync) LogPrefix() string
- func (s *Sync) MockExecFunc(id SyncStage, f ExecFunc)
- func (s *Sync) NewUnwindState(id SyncStage, unwindPoint, currentProgress uint64) *UnwindState
- func (s *Sync) NextStage()
- func (s *Sync) PrevUnwindPoint() *uint64
- func (s *Sync) PrintTimings() []interface{}
- func (s *Sync) PruneStageState(id SyncStage, forwardProgress uint64, tx kv.Tx, db kv.RwDB) (*PruneState, error)
- func (s *Sync) Run(db kv.RwDB, tx kv.RwTx, firstCycle bool, quiet bool) error
- func (s *Sync) RunPrune(db kv.RwDB, tx kv.RwTx, firstCycle bool) error
- func (s *Sync) RunUnwind(db kv.RwDB, tx kv.RwTx) error
- func (s *Sync) SetCurrentStage(id SyncStage) error
- func (s *Sync) StageState(stage SyncStage, tx kv.Tx, db kv.RoDB) (*StageState, error)
- func (s *Sync) UnwindTo(unwindPoint uint64, badBlock libcommon.Hash)
- type SyncStage
- type Timing
- type UnwindFunc
- type UnwindOrder
- type UnwindState
- type Unwinder
Constants ¶
This section is empty.
Variables ¶
var AllStages = []SyncStage{ Snapshots, Headers, BlockHashes, Bodies, Senders, Execution, Translation, HashState, IntermediateHashes, AccountHistoryIndex, StorageHistoryIndex, LogIndex, CallTraces, TxLookup, Finish, }
var Metrics = map[SyncStage]*metrics.Counter{}
Functions ¶
func GetStageProgress ¶
GetStageProgress retrieves saved progress of given sync stage from the database
func GetStagePruneProgress ¶
GetStagePruneProgress retrieves saved progress of given sync stage from the database
func SaveStageProgress ¶
func SaveStagePruneProgress ¶
func UpdateMetrics ¶
UpdateMetrics - need update metrics manually because current "metrics" package doesn't support labels need to fix it in future
Types ¶
type ExecFunc ¶
type ExecFunc func(firstCycle bool, badBlockUnwind bool, s *StageState, unwinder Unwinder, tx kv.RwTx, quiet bool) error
ExecFunc is the execution function for the stage to move forward. * state - is the current state of the stage and contains stage data. * unwinder - if the stage needs to cause unwinding, `unwinder` methods can be used.
type PruneFunc ¶
type PruneFunc func(firstCycle bool, p *PruneState, tx kv.RwTx) error
PruneFunc is the execution function for the stage to prune old data. * state - is the current state of the stage and contains stage data.
type PruneOrder ¶
type PruneOrder []SyncStage
type PruneState ¶
type PruneState struct { ID SyncStage ForwardProgress uint64 // progress of stage forward move PruneProgress uint64 // progress of stage prune move. after sync cycle it become equal to ForwardProgress by Done() method // contains filtered or unexported fields }
func (*PruneState) LogPrefix ¶
func (s *PruneState) LogPrefix() string
type Stage ¶
type Stage struct { // Description is a string that is shown in the logs. Description string // DisabledDescription shows in the log with a message if the stage is disabled. Here, you can show which command line flags should be provided to enable the page. DisabledDescription string // Forward is called when the stage is executed. The main logic of the stage should be here. Should always end with `s.Done()` to allow going to the next stage. MUST NOT be nil! Forward ExecFunc // Unwind is called when the stage should be unwound. The unwind logic should be there. MUST NOT be nil! Unwind UnwindFunc Prune PruneFunc // ID of the sync stage. Should not be empty and should be unique. It is recommended to prefix it with reverse domain to avoid clashes (`com.example.my-stage`). ID SyncStage // Disabled defines if the stage is disabled. It sets up when the stage is build by its `StageBuilder`. Disabled bool }
Stage is a single sync stage in staged sync.
type StageState ¶
type StageState struct { ID SyncStage BlockNumber uint64 // BlockNumber is the current block number of the stage at the beginning of the state execution. // contains filtered or unexported fields }
StageState is the state of the stage.
func (*StageState) ExecutionAt ¶
func (s *StageState) ExecutionAt(db kv.Getter) (uint64, error)
ExecutionAt gets the current state of the "Execution" stage, which block is currently executed.
func (*StageState) IntermediateHashesAt ¶
func (s *StageState) IntermediateHashesAt(db kv.Getter) (uint64, error)
IntermediateHashesAt gets the current state of the "IntermediateHashes" stage. A block is fully validated after the IntermediateHashes stage is passed successfully.
func (*StageState) LogPrefix ¶
func (s *StageState) LogPrefix() string
func (*StageState) Update ¶
func (s *StageState) Update(db kv.Putter, newBlockNum uint64) error
Update updates the stage state (current block number) in the database. Can be called multiple times during stage execution.
func (*StageState) UpdatePrune ¶
func (s *StageState) UpdatePrune(db kv.Putter, blockNum uint64) error
type Sync ¶
type Sync struct {
// contains filtered or unexported fields
}
func New ¶
func New(stagesList []*Stage, unwindOrder UnwindOrder, pruneOrder PruneOrder) *Sync
func (*Sync) DisableAllStages ¶
DisableAllStages - including their unwinds
func (*Sync) DisableStages ¶
func (*Sync) EnableStages ¶
func (*Sync) MockExecFunc ¶
func (*Sync) NewUnwindState ¶
func (s *Sync) NewUnwindState(id SyncStage, unwindPoint, currentProgress uint64) *UnwindState
func (*Sync) PrevUnwindPoint ¶
func (*Sync) PrintTimings ¶
func (s *Sync) PrintTimings() []interface{}
func (*Sync) PruneStageState ¶
func (*Sync) SetCurrentStage ¶
func (*Sync) StageState ¶
type SyncStage ¶
type SyncStage string
SyncStage represents the stages of syncronisation in the Mode.StagedSync mode It is used to persist the information about the stage state into the database. It should not be empty and should be unique.
var ( Snapshots SyncStage = "Snapshots" // Snapshots Headers SyncStage = "Headers" // Headers are downloaded, their Proof-Of-Work validity and chaining is verified CumulativeIndex SyncStage = "CumulativeIndex" // Calculate how much gas has been used up to each block. BlockHashes SyncStage = "BlockHashes" // Headers Number are written, fills blockHash => number bucket Bodies SyncStage = "Bodies" // Block bodies are downloaded, TxHash and UncleHash are getting verified Senders SyncStage = "Senders" // "From" recovered from signatures, bodies re-written Execution SyncStage = "Execution" // Executing each block w/o buildinf a trie Translation SyncStage = "Translation" // Translation each marked for translation contract (from EVM to TEVM) VerkleTrie SyncStage = "VerkleTrie" IntermediateHashes SyncStage = "IntermediateHashes" // Generate intermediate hashes, calculate the state root hash HashState SyncStage = "HashState" // Apply Keccak256 to all the keys in the state AccountHistoryIndex SyncStage = "AccountHistoryIndex" // Generating history index for accounts StorageHistoryIndex SyncStage = "StorageHistoryIndex" // Generating history index for storage LogIndex SyncStage = "LogIndex" // Generating logs index (from receipts) CallTraces SyncStage = "CallTraces" // Generating call traces index TxLookup SyncStage = "TxLookup" // Generating transactions lookup index Finish SyncStage = "Finish" // Nominal stage after all other stages MiningCreateBlock SyncStage = "MiningCreateBlock" MiningExecution SyncStage = "MiningExecution" MiningFinish SyncStage = "MiningFinish" // Beacon chain stages BeaconHistoryReconstruction SyncStage = "BeaconHistoryReconstruction" // BeaconHistoryReconstruction reconstruct missing history. BeaconBlocks SyncStage = "BeaconBlocks" // BeaconBlocks are downloaded, no verification BeaconState SyncStage = "BeaconState" // Beacon blocks are sent to the state transition function BeaconIndexes SyncStage = "BeaconIndexes" // Fills up Beacon indexes // ZK stages L1Syncer SyncStage = "L1Syncer" L1VerificationsBatchNo SyncStage = "L1VerificationsBatchNo" Batches SyncStage = "Batches" HighestHashableL2BlockNo SyncStage = "HighestHashableL2BlockNo" VerificationsStateRootCheck SyncStage = "VerificationStateRootCheck" ForkId SyncStage = "ForkId" )
type UnwindFunc ¶
type UnwindFunc func(firstCycle bool, u *UnwindState, s *StageState, tx kv.RwTx) error
UnwindFunc is the unwinding logic of the stage. * unwindState - contains information about the unwind itself. * stageState - represents the state of this stage at the beginning of unwind.
type UnwindOrder ¶
type UnwindOrder []SyncStage
UnwindOrder represents the order in which the stages needs to be unwound. The unwind order is important and not always just stages going backwards. Let's say, there is tx pool can be unwound only after execution. It's ok to remove some stage from here to disable only unwind of stage
type UnwindState ¶
type UnwindState struct { ID SyncStage // UnwindPoint is the block to unwind to. UnwindPoint uint64 CurrentBlockNumber uint64 // If unwind is caused by a bad block, this hash is not empty BadBlock libcommon.Hash // contains filtered or unexported fields }
UnwindState contains the information about unwind.
func (*UnwindState) Done ¶
func (u *UnwindState) Done(db kv.Putter) error
Done updates the DB state of the stage.
func (*UnwindState) LogPrefix ¶
func (u *UnwindState) LogPrefix() string