Documentation
¶
Index ¶
- type BlockNum
- type Config
- type Event
- type GEREventType
- type GlobalExitRootInfo
- type L1InfoTreeQuerier
- type L2EVMGERReader
- type L2GERSync
- func (s *L2GERSync) GetFirstGERAfterL1InfoTreeIndex(ctx context.Context, atOrAfterL1InfoTreeIndex uint32) (GlobalExitRootInfo, error)
- func (s *L2GERSync) GetInjectedGERsForRange(ctx context.Context, fromBlock, toBlock uint64) (map[common.Hash]GlobalExitRootInfo, error)
- func (s *L2GERSync) GetLastProcessedBlock(ctx context.Context) (uint64, error)
- func (s *L2GERSync) Start(ctx context.Context)
- type SyncMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 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 ¶
func New( ctx context.Context, cfg Config, rdL2 sync.ReorgDetector, l2Client aggkittypes.BaseEthereumClienter, l1InfoTreeSync L1InfoTreeQuerier, l1Client aggkittypes.BaseEthereumClienter, ) (*L2GERSync, error)
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 ¶
GetLastProcessedBlock returns the last processed block number