l1infotreesync

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBlockNotProcessed = errors.New("given block(s) have not been processed yet")
	ErrNotFound          = errors.New("not found")
	ErrNoBlock0          = errors.New("blockNum must be greater than 0")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	DBPath             string         `mapstructure:"DBPath"`
	GlobalExitRootAddr common.Address `mapstructure:"GlobalExitRootAddr"`
	RollupManagerAddr  common.Address `mapstructure:"RollupManagerAddr"`
	SyncBlockChunkSize uint64         `mapstructure:"SyncBlockChunkSize"`
	// 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 */
	URLRPCL1                   string         `mapstructure:"URLRPCL1"`
	WaitForNewBlocksPeriod     types.Duration `mapstructure:"WaitForNewBlocksPeriod"`
	InitialBlock               uint64         `mapstructure:"InitialBlock"`
	RetryAfterErrorPeriod      types.Duration `mapstructure:"RetryAfterErrorPeriod"`
	MaxRetryAttemptsAfterError int            `mapstructure:"MaxRetryAttemptsAfterError"`
}

type EthClienter

type EthClienter interface {
	ethereum.LogFilterer
	ethereum.BlockNumberReader
	ethereum.ChainReader
	bind.ContractBackend
}

type Event

type Event struct {
	UpdateL1InfoTree  *UpdateL1InfoTree
	VerifyBatches     *VerifyBatches
	InitL1InfoRootMap *InitL1InfoRootMap
}

type InitL1InfoRootMap

type InitL1InfoRootMap struct {
	LeafCount         uint32
	CurrentL1InfoRoot ethCommon.Hash
}

type L1InfoTreeLeaf

type L1InfoTreeLeaf struct {
	BlockNumber       uint64         `meddler:"block_num"`
	BlockPosition     uint64         `meddler:"block_pos"`
	L1InfoTreeIndex   uint32         `meddler:"position"`
	PreviousBlockHash ethCommon.Hash `meddler:"previous_block_hash,hash"`
	Timestamp         uint64         `meddler:"timestamp"`
	MainnetExitRoot   ethCommon.Hash `meddler:"mainnet_exit_root,hash"`
	RollupExitRoot    ethCommon.Hash `meddler:"rollup_exit_root,hash"`
	GlobalExitRoot    ethCommon.Hash `meddler:"global_exit_root,hash"`
	Hash              ethCommon.Hash `meddler:"hash,hash"`
}

L1InfoTreeLeaf representation of a leaf of the L1 Info tree

type L1InfoTreeSync

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

func New

func New(
	ctx context.Context,
	dbPath string,
	globalExitRoot, rollupManager common.Address,
	syncBlockChunkSize uint64,
	blockFinalityType etherman.BlockNumberFinality,
	rd sync.ReorgDetector,
	l1Client EthClienter,
	waitForNewBlocksPeriod time.Duration,
	initialBlock uint64,
	retryAfterErrorPeriod time.Duration,
	maxRetryAttemptsAfterError int,
) (*L1InfoTreeSync, error)

New creates a L1 Info tree syncer that syncs the L1 info tree and the rollup exit tree

func (*L1InfoTreeSync) GetInfoByIndex

func (s *L1InfoTreeSync) GetInfoByIndex(ctx context.Context, index uint32) (*L1InfoTreeLeaf, error)

GetInfoByIndex returns the value of a leaf (not the hash) of the L1 info tree

func (*L1InfoTreeSync) GetL1InfoTreeMerkleProof

func (s *L1InfoTreeSync) GetL1InfoTreeMerkleProof(ctx context.Context, index uint32) (types.Proof, types.Root, error)

GetL1InfoTreeMerkleProof creates a merkle proof for the L1 Info tree

func (*L1InfoTreeSync) GetL1InfoTreeRootByIndex

func (s *L1InfoTreeSync) GetL1InfoTreeRootByIndex(ctx context.Context, index uint32) (types.Root, error)

GetL1InfoTreeRootByIndex returns the root of the L1 info tree at the moment the leaf with the given index was added

func (*L1InfoTreeSync) GetLastL1InfoTreeRoot

func (s *L1InfoTreeSync) GetLastL1InfoTreeRoot(ctx context.Context) (types.Root, error)

GetLastL1InfoTreeRoot return the last root and index processed from the L1 Info tree

func (*L1InfoTreeSync) GetLastProcessedBlock

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

GetLastProcessedBlock return the last processed block

func (*L1InfoTreeSync) GetLastRollupExitRoot

func (s *L1InfoTreeSync) GetLastRollupExitRoot(ctx context.Context) (types.Root, error)

GetLastRollupExitRoot return the last rollup exit root processed

func (*L1InfoTreeSync) GetLatestInfoUntilBlock

func (s *L1InfoTreeSync) GetLatestInfoUntilBlock(ctx context.Context, blockNum uint64) (*L1InfoTreeLeaf, error)

GetLatestInfoUntilBlock returns the most recent L1InfoTreeLeaf that occurred before or at blockNum. If the blockNum has not been processed yet the error ErrBlockNotProcessed will be returned

func (*L1InfoTreeSync) GetLocalExitRoot

func (s *L1InfoTreeSync) GetLocalExitRoot(
	ctx context.Context, networkID uint32, rollupExitRoot common.Hash,
) (common.Hash, error)

func (*L1InfoTreeSync) GetRollupExitTreeMerkleProof

func (s *L1InfoTreeSync) GetRollupExitTreeMerkleProof(
	ctx context.Context,
	networkID uint32,
	root common.Hash,
) (types.Proof, error)

GetRollupExitTreeMerkleProof creates a merkle proof for the rollup exit tree

func (*L1InfoTreeSync) Start

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

Start starts the synchronization process

type UpdateL1InfoTree

type UpdateL1InfoTree struct {
	BlockPosition   uint64
	MainnetExitRoot ethCommon.Hash
	RollupExitRoot  ethCommon.Hash
	ParentHash      ethCommon.Hash
	Timestamp       uint64
}

UpdateL1InfoTree representation of the UpdateL1InfoTree event

type VerifyBatches

type VerifyBatches struct {
	BlockPosition uint64
	RollupID      uint32
	NumBatch      uint64
	StateRoot     ethCommon.Hash
	ExitRoot      ethCommon.Hash
	Aggregator    ethCommon.Address
}

VerifyBatches representation of the VerifyBatches and VerifyBatchesTrustedAggregator events

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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