Documentation
¶
Index ¶
- Variables
- func CrossSafeUpdate(logger log.Logger, chainID eth.ChainID, d CrossSafeDeps, ...) error
- func CrossUnsafeUpdate(logger log.Logger, chainID eth.ChainID, d CrossUnsafeDeps, ...) error
- func GenerateMermaidDiagram(g *graph) string
- func HazardCycleChecks(d CycleCheckDeps, inTimestamp uint64, hazards *HazardSet) error
- func HazardSafeFrontierChecks(d SafeFrontierCheckDeps, inL1Source eth.BlockID, hazards *HazardSet) error
- func HazardUnsafeFrontierChecks(d UnsafeFrontierCheckDeps, hazards *HazardSet) error
- type CrossSafeDeps
- type CrossSafeWorker
- type CrossUnsafeDeps
- type CrossUnsafeWorker
- type CycleCheckDeps
- type HazardDeps
- type HazardSet
- func CrossSafeHazards(d SafeStartDeps, linker depset.LinkChecker, logger log.Logger, ...) (*HazardSet, error)
- func CrossUnsafeHazards(d UnsafeStartDeps, linker depset.LinkChecker, logger log.Logger, ...) (*HazardSet, error)
- func NewHazardSet(deps HazardDeps, linker depset.LinkChecker, logger log.Logger, ...) (*HazardSet, error)
- func NewHazardSetFromEntries(entries map[eth.ChainID]types.BlockSeal) *HazardSet
- type SafeFrontierCheckDeps
- type SafeHazardDeps
- type SafeStartDeps
- type UnsafeFrontierCheckDeps
- type UnsafeHazardDeps
- type UnsafeStartDeps
Constants ¶
This section is empty.
Variables ¶
var ( ErrCycle = fmt.Errorf("%w: cycle detected", types.ErrConflict) ErrExecMsgHasInvalidIndex = fmt.Errorf("%w: executing message has invalid log index", types.ErrConflict) ErrExecMsgUnknownChain = fmt.Errorf("%w: executing message references unknown chain", types.ErrConflict) )
These error must be considered as ErrConflict to trigger a reorg.
Functions ¶
func CrossSafeUpdate ¶
func CrossSafeUpdate(logger log.Logger, chainID eth.ChainID, d CrossSafeDeps, linker depset.LinkChecker) error
func CrossUnsafeUpdate ¶
func CrossUnsafeUpdate(logger log.Logger, chainID eth.ChainID, d CrossUnsafeDeps, linker depset.LinkChecker) error
func GenerateMermaidDiagram ¶
func GenerateMermaidDiagram(g *graph) string
GenerateMermaidDiagram creates a Mermaid flowchart diagram from the graph data for debugging.
func HazardCycleChecks ¶
func HazardCycleChecks(d CycleCheckDeps, inTimestamp uint64, hazards *HazardSet) error
HazardCycleChecks checks for cyclical dependencies between logs at the given timestamp. Here the timestamp invariant alone does not ensure ordering of messages.
We perform this check in 3 steps:
- Gather all logs across all hazard blocks at the given timestamp.
- Build the logs into a directed graph of dependencies between logs.
- Check the graph for cycles.
The edges of the graph are determined by:
- For all logs except the first in a block, there is an edge from the previous log.
- For all executing messages, there is an edge from the initiating message.
The edges between sequential logs ensure the graph is well-connected and free of any disjoint subgraphs that would make cycle checking more difficult.
The cycle check is performed by executing Kahn's topological sort algorithm which succeeds if and only if a graph is acyclic.
Returns nil if no cycles are found or ErrCycle if a cycle is detected.
func HazardSafeFrontierChecks ¶
func HazardSafeFrontierChecks(d SafeFrontierCheckDeps, inL1Source eth.BlockID, hazards *HazardSet) error
HazardSafeFrontierChecks verifies all the hazard blocks are either:
- already cross-safe.
- the first (if not first: local blocks to verify before proceeding) local-safe block, after the cross-safe block.
func HazardUnsafeFrontierChecks ¶
func HazardUnsafeFrontierChecks(d UnsafeFrontierCheckDeps, hazards *HazardSet) error
HazardUnsafeFrontierChecks verifies all the hazard blocks are either:
- already cross-unsafe.
- the first (if not first: local blocks to verify before proceeding) local-unsafe block, after the cross-unsafe block.
Types ¶
type CrossSafeDeps ¶
type CrossSafeDeps interface { reads.Acquirer CrossSafe(chainID eth.ChainID) (pair types.DerivedBlockSealPair, err error) SafeFrontierCheckDeps SafeStartDeps CandidateCrossSafe(chain eth.ChainID) (candidate types.DerivedBlockRefPair, err error) NextSource(chain eth.ChainID, source eth.BlockID) (after eth.BlockRef, err error) PreviousCrossDerived(chain eth.ChainID, derived eth.BlockID) (prevDerived types.BlockSeal, err error) OpenBlock(chainID eth.ChainID, blockNum uint64) (ref eth.BlockRef, logCount uint32, execMsgs map[uint32]*types.ExecutingMessage, err error) UpdateCrossSafe(chain eth.ChainID, l1View eth.BlockRef, lastCrossDerived eth.BlockRef) error // InvalidateLocalSafe is called when a local block cannot be upgraded to cross-safe, and has to be dropped. // This is called relative to what was determined based on the l1Scope. // It is called with the candidate, the block that will be invalidated. // The replacement of this candidate will effectively be "derived from" // the scope that the candidate block was invalidated at. InvalidateLocalSafe(chainID eth.ChainID, candidate types.DerivedBlockRefPair) error }
type CrossSafeWorker ¶ added in v1.11.0
type CrossSafeWorker struct {
// contains filtered or unexported fields
}
func NewCrossSafeWorker ¶
func NewCrossSafeWorker(logger log.Logger, chainID eth.ChainID, d CrossSafeDeps, linker depset.LinkChecker) *CrossSafeWorker
type CrossUnsafeDeps ¶
type CrossUnsafeDeps interface { reads.Acquirer CrossUnsafe(chainID eth.ChainID) (types.BlockSeal, error) UnsafeStartDeps UnsafeFrontierCheckDeps OpenBlock(chainID eth.ChainID, blockNum uint64) (block eth.BlockRef, logCount uint32, execMsgs map[uint32]*types.ExecutingMessage, err error) UpdateCrossUnsafe(chain eth.ChainID, crossUnsafe types.BlockSeal) error }
type CrossUnsafeWorker ¶ added in v1.11.0
type CrossUnsafeWorker struct {
// contains filtered or unexported fields
}
func NewCrossUnsafeWorker ¶
func NewCrossUnsafeWorker(logger log.Logger, chainID eth.ChainID, d CrossUnsafeDeps, linker depset.LinkChecker) *CrossUnsafeWorker
type CycleCheckDeps ¶
type CycleCheckDeps interface { // OpenBlock returns log data for the requested block, to be used for cycle checking. OpenBlock(chainID eth.ChainID, blockNum uint64) (block eth.BlockRef, logCount uint32, execMsgs map[uint32]*types.ExecutingMessage, err error) }
CycleCheckDeps is an interface for checking cyclical dependencies between logs.
type HazardDeps ¶ added in v1.12.0
type HazardDeps interface { Contains(chain eth.ChainID, query types.ContainsQuery) (types.BlockSeal, error) IsCrossValidBlock(chainID eth.ChainID, block eth.BlockID) error OpenBlock(chainID eth.ChainID, blockNum uint64) (ref eth.BlockRef, logCount uint32, execMsgs map[uint32]*types.ExecutingMessage, err error) }
type HazardSet ¶ added in v1.12.0
type HazardSet struct {
// contains filtered or unexported fields
}
HazardSet tracks blocks that must be checked before a candidate can be promoted
func CrossSafeHazards ¶
func CrossSafeHazards(d SafeStartDeps, linker depset.LinkChecker, logger log.Logger, chainID eth.ChainID, inL1Source eth.BlockID, candidate types.BlockSeal) (*HazardSet, error)
CrossSafeHazards checks if the given messages all exist and pass invariants. It returns a hazard-set: if any intra-block messaging happened, these hazard blocks have to be verified.
func CrossUnsafeHazards ¶
func CrossUnsafeHazards(d UnsafeStartDeps, linker depset.LinkChecker, logger log.Logger, chainID eth.ChainID, candidate types.BlockSeal) (*HazardSet, error)
CrossUnsafeHazards checks if the given messages all exist and pass invariants. It returns a hazard-set: if any intra-block messaging happened, these hazard blocks have to be verified.
func NewHazardSet ¶ added in v1.12.0
func NewHazardSet(deps HazardDeps, linker depset.LinkChecker, logger log.Logger, chainID eth.ChainID, block types.BlockSeal) (*HazardSet, error)
NewHazardSet creates a new HazardSet with the given dependencies and initial block
func NewHazardSetFromEntries ¶ added in v1.12.0
type SafeFrontierCheckDeps ¶
type SafeHazardDeps ¶ added in v1.12.0
type SafeHazardDeps struct { SafeStartDeps // contains filtered or unexported fields }
func (*SafeHazardDeps) IsCrossValidBlock ¶ added in v1.12.0
type SafeStartDeps ¶
type SafeStartDeps interface { Contains(chain eth.ChainID, query types.ContainsQuery) (includedIn types.BlockSeal, err error) CrossDerivedToSource(chainID eth.ChainID, derived eth.BlockID) (source types.BlockSeal, err error) OpenBlock(chainID eth.ChainID, blockNum uint64) (ref eth.BlockRef, logCount uint32, execMsgs map[uint32]*types.ExecutingMessage, err error) }
type UnsafeFrontierCheckDeps ¶
type UnsafeHazardDeps ¶ added in v1.12.0
type UnsafeHazardDeps struct {
UnsafeStartDeps
}
UnsafeHazardDeps adapts UnsafeStartDeps to HazardDeps
func (*UnsafeHazardDeps) IsCrossValidBlock ¶ added in v1.12.0
VerifyBlock implements HazardDeps by checking cross-unsafe status
type UnsafeStartDeps ¶
type UnsafeStartDeps interface { Contains(chain eth.ChainID, query types.ContainsQuery) (includedIn types.BlockSeal, err error) IsCrossUnsafe(chainID eth.ChainID, block eth.BlockID) error OpenBlock(chainID eth.ChainID, blockNum uint64) (ref eth.BlockRef, logCount uint32, execMsgs map[uint32]*types.ExecutingMessage, err error) }