l2gersync

package
v0.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2025 License: Apache-2.0, MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockNum

type BlockNum struct {
	Num uint64 `meddler:"num"`
}

type Config

type Config struct {
	// DBPath path of the DB
	DBPath string `mapstructure:"DBPath"`
	// BlockFinality indicates the status of the blocks that will be queried in order to sync
	BlockFinality aggkittypes.BlockNumberFinality `` //nolint:lll
	/* 134-byte string literal not displayed */
	// InitialBlockNum is the first block that will be queried when starting the synchronization from scratch.
	// It should be a number equal or bellow the creation of the bridge contract
	InitialBlockNum uint64 `mapstructure:"InitialBlockNum"`
	// GlobalExitRootL2Addr is the address of the GER smart contract on L2
	GlobalExitRootL2Addr common.Address `mapstructure:"GlobalExitRootL2Addr"`
	// GlobalExitRootL1Addr is the address of the GER smart contract on L1
	GlobalExitRootL1Addr common.Address `mapstructure:"GlobalExitRootL1Addr"`
	// SyncBlockChunkSize is the maximum block range downloaded at once
	SyncBlockChunkSize uint64 `mapstructure:"SyncBlockChunkSize"`
	// RetryAfterErrorPeriod is the time that will be waited when an unexpected error happens before retry
	RetryAfterErrorPeriod types.Duration `mapstructure:"RetryAfterErrorPeriod"`
	// MaxRetryAttemptsAfterError is the maximum number of consecutive attempts that will happen before panicing.
	// Any number smaller than zero will be considered as unlimited retries
	MaxRetryAttemptsAfterError int `mapstructure:"MaxRetryAttemptsAfterError"`
	// WaitForNewBlocksPeriod time that will be waited when the synchronizer has reached the latest block
	WaitForNewBlocksPeriod types.Duration `mapstructure:"WaitForNewBlocksPeriod"`
	// DownloadBufferSize buffer size of events to be processed. When the buffer limit is reached,
	// downloading will stop until the processing catches up.
	DownloadBufferSize int `mapstructure:"DownloadBufferSize"`
	// RequireStorageContentCompatibility is true it's mandatory that data stored in the database
	// is compatible with the running environment
	RequireStorageContentCompatibility bool `mapstructure:"RequireStorageContentCompatibility"`
}

type Event

type Event struct {
	GERInfo   *GlobalExitRootInfo
	EventType GEREventType
}

Event is the combination of the events that are emitted by the L2 GER manager

type GEREventType

type GEREventType int

GEREventType represents the type of Global Exit Root event. It can be either an insertion or a removal of a Global Exit Root.

const (
	GEREventTypeInsert GEREventType = iota
	GEREventTypeRemove
)

type GlobalExitRootInfo

type GlobalExitRootInfo struct {
	GlobalExitRoot  ethcommon.Hash `meddler:"global_exit_root,hash"`
	L1InfoTreeIndex uint32         `meddler:"l1_info_tree_index"`
	BlockNum        uint64         `meddler:"block_num"`
	BlockPosition   *uint64        `meddler:"block_pos"`
}

type L1InfoTreeQuerier

type L1InfoTreeQuerier interface {
	GetLastL1InfoTreeRoot(ctx context.Context) (treetypes.Root, error)
	GetInfoByIndex(ctx context.Context, index uint32) (*l1infotreesync.L1InfoTreeLeaf, error)
	GetInfoByGlobalExitRoot(ger common.Hash) (*l1infotreesync.L1InfoTreeLeaf, error)
	IsUpToDate(ctx context.Context, l1Client aggkittypes.BaseEthereumClienter) (bool, error)
}

L1InfoTreeQuerier is abstraction for querying the L1InfoTree data

type L2EVMGERReader

type L2EVMGERReader struct {
	// contains filtered or unexported fields
}

L2EVMGERReader is a component used to read GlobalExitRootManager L2 contract

func NewL2EVMGERReader

func NewL2EVMGERReader(
	l2GERManagerAddr common.Address,
	l2Client aggkittypes.BaseEthereumClienter,
	l1InfoTreeSync L1InfoTreeQuerier,
) (*L2EVMGERReader, error)

NewL2EVMGERReader creates a new instance of L2 EVM global exit root reader

func (*L2EVMGERReader) GetInjectedGERsForRange

func (e *L2EVMGERReader) GetInjectedGERsForRange(ctx context.Context,
	fromBlock, toBlock uint64) (map[common.Hash]GlobalExitRootInfo, error)

GetInjectedGERsForRange returns the injected GlobalExitRoots for the given block range

type L2GERSync

type L2GERSync struct {
	// contains filtered or unexported fields
}

L2GERSync is responsible for managing GER synchronization.

func New

New initializes and returns a new instance of L2GERSync

func (*L2GERSync) GetFirstGERAfterL1InfoTreeIndex

func (s *L2GERSync) GetFirstGERAfterL1InfoTreeIndex(
	ctx context.Context, atOrAfterL1InfoTreeIndex uint32,
) (GlobalExitRootInfo, error)

GetFirstGERAfterL1InfoTreeIndex returns the first GER after a specified L1 info tree index

func (*L2GERSync) GetInjectedGERsForRange

func (s *L2GERSync) GetInjectedGERsForRange(ctx context.Context,
	fromBlock, toBlock uint64) (map[common.Hash]GlobalExitRootInfo, error)

GetInjectedGERsForRange retrieves all injected global exit roots within a specified block range. It returns a map where the keys are the global exit root hashes and the values are the corresponding GlobalExitRootInfo containing the L1 info tree index, global exit root and block number.

func (*L2GERSync) GetLastProcessedBlock

func (s *L2GERSync) GetLastProcessedBlock(ctx context.Context) (uint64, error)

GetLastProcessedBlock returns the last processed block number

func (*L2GERSync) Start

func (s *L2GERSync) Start(ctx context.Context)

Start initiates the synchronization process.

type SyncMode

type SyncMode string
const (
	Legacy         SyncMode = "Legacy"
	SovereignChain SyncMode = "SovereignChain"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL