lastgersync

package
v0.2.0-beta7-bridge-tmp Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: Apache-2.0, MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockNum added in v0.5.1

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 string `` //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"`
	// 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"`
	// SyncMode denotes should the latest global exit root be determined
	// by querying the global exit root map (which is common way for FEP chains)
	// or the events emitted by sovereign chains (which is a common way for PP chains)
	SyncMode SyncMode `jsonschema:"enum=FEP, enum=PP" mapstructure:"SyncMode"`
}

type Event

type Event struct {
	GERInfo  *GlobalExitRootInfo
	GEREvent *GEREvent
}

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

type GEREvent added in v0.5.1

type GEREvent struct {
	BlockNum        uint64
	GlobalExitRoot  ethCommon.Hash
	L1InfoTreeIndex uint32
	IsRemove        bool
}

type GlobalExitRootInfo added in v0.5.1

type GlobalExitRootInfo struct {
	GlobalExitRoot  ethCommon.Hash `meddler:"global_exit_root,hash"`
	L1InfoTreeIndex uint32         `meddler:"l1_info_tree_index"`
}

type L1InfoTreeQuerier added in v0.5.1

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 LastGERSync

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

LastGERSync is responsible for managing GER synchronization.

func New

func New(
	ctx context.Context,
	dbPath string,
	rdL2 sync.ReorgDetector,
	l2Client aggkittypes.BaseEthereumClienter,
	l2GERManagerAddr common.Address,
	l1InfoTreeSync L1InfoTreeQuerier,
	retryAfterErrorPeriod time.Duration,
	maxRetryAttemptsAfterError int,
	blockFinality etherman.BlockNumberFinality,
	waitForNewBlocksPeriod time.Duration,
	downloadBufferSize int,
	requireStorageContentCompatibility bool,
	syncMode SyncMode,
) (*LastGERSync, error)

New initializes and returns a new instance of LastGERSync

func (*LastGERSync) GetFirstGERAfterL1InfoTreeIndex

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

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

func (*LastGERSync) GetLastProcessedBlock

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

GetLastProcessedBlock returns the last processed block number

func (*LastGERSync) Start

func (s *LastGERSync) Start(ctx context.Context) error

Start initiates the synchronization process.

type SyncMode added in v0.5.1

type SyncMode string
const (
	FEP SyncMode = "FEP"
	PP  SyncMode = "PP"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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