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) GetLastGER(ctx context.Context) (GlobalExitRootInfo, error)
- func (s *L2GERSync) GetLastProcessedBlock(ctx context.Context) (uint64, error)
- func (s *L2GERSync) GetRemoveGEREvents(ctx context.Context, globalExitRoot *common.Hash, limit uint32) ([]*RemoveGEREvent, error)
- func (s *L2GERSync) Start(ctx context.Context)
- func (s *L2GERSync) SyncMode() SyncMode
- type RemoveGEREvent
- 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 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"`
// Timestamp of the L2 block where the GER was injected. Nullable: rows written before this
// column existed have it NULL, and GetFirstGERAfterL1InfoTreeIndex backfills it lazily from
// the L2 RPC (see L2GERSync.GetFirstGERAfterL1InfoTreeIndex) rather than eagerly migrating
// every historical row. Always NULL for chains synced in Legacy mode: BlockNum there is the
// polling head rather than the real injection block, so no accurate timestamp can be derived
// (see evm_downloader_legacy.go).
Timestamp *uint64 `meddler:"block_timestamp"`
Removed bool `meddler:"-"`
}
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)
}
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 If the block range is too large, it automatically splits the request into smaller chunks.
func (*L2EVMGERReader) GetRemovedGERsForRange ¶ added in v0.8.0
func (e *L2EVMGERReader) GetRemovedGERsForRange(ctx context.Context, fromBlock, toBlock uint64) ([]*agglayertypes.RemovedGER, error)
GetRemovedGERsForRange returns the removed GlobalExitRoots for the given block range If the block range is too large, it automatically splits the request into smaller chunks.
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. If the resolved row predates timestamp persistence (nullable column, see l2gersync0006.sql), its timestamp is resolved from the L2 RPC and backfilled into the row before returning, so callers (e.g. bridgeservice.InjectedL1InfoLeafHandler) get it transparently on the very first request that hits a legacy row, without knowing about the gap themselves.
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) GetLastGER ¶
func (s *L2GERSync) GetLastGER(ctx context.Context) (GlobalExitRootInfo, error)
GetLastGER returns the most recently injected global exit root (the one with the highest L1 info tree index), or db.ErrNotFound if none has been injected yet. This is diagnostic-only — e.g. bridgeservice.InjectedL1InfoLeafHandler uses it to report how far injection has actually progressed when the requested leaf index hasn't been reached yet — so, unlike GetFirstGERAfterL1InfoTreeIndex, it does not backfill a missing timestamp from the L2 RPC: an extra RPC round trip isn't worth paying on an error path just to fill in an optional field.
func (*L2GERSync) GetLastProcessedBlock ¶
GetLastProcessedBlock returns the last processed block number
func (*L2GERSync) GetRemoveGEREvents ¶ added in v0.8.0
func (s *L2GERSync) GetRemoveGEREvents( ctx context.Context, globalExitRoot *common.Hash, limit uint32, ) ([]*RemoveGEREvent, error)
GetRemoveGEREvents retrieves remove GER events from the database with optional filters
func (*L2GERSync) SyncMode ¶
SyncMode returns the sync mode (Legacy or SovereignChain) resolved for the deployed L2 GER manager contract when this syncer was created (see resolveSyncMode). This is not user configuration: it's auto-detected by probing the contract, and reported here purely as operational information (e.g. for the bridge service's public config endpoint).
type RemoveGEREvent ¶ added in v0.8.0
type RemoveGEREvent struct {
GlobalExitRoot ethcommon.Hash `meddler:"global_exit_root,hash"`
BlockNum uint64 `meddler:"block_num"`
BlockPos uint64 `meddler:"block_pos"`
CreatedAt uint64 `meddler:"created_at"`
}
RemoveGEREvent represents a remove GER event stored in the database