l1infotreesync

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 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")
	ErrNoBlock0          = errors.New("blockNum must be greater than 0")
)
View Source
var (
	ErrNotFound = errors.New("l1infotreesync: not found")
)

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 CreationFlags added in v0.0.19

type CreationFlags uint64
const (

	// CreationFlags defitinion
	FlagNone                     CreationFlags = 0
	FlagAllowWrongContractsAddrs CreationFlags = 1 << iota // Allow to set wrong contracts addresses
)

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 common.Hash
}

func (*InitL1InfoRootMap) String added in v0.0.19

func (i *InitL1InfoRootMap) String() string

type L1InfoTreeInitial added in v0.0.19

type L1InfoTreeInitial struct {
	BlockNumber uint64      `meddler:"block_num"`
	LeafCount   uint32      `meddler:"leaf_count"`
	L1InfoRoot  common.Hash `meddler:"l1_info_root,hash"`
}

L1InfoTreeInitial representation of the initial info of the L1 Info tree for this rollup

func (*L1InfoTreeInitial) String added in v0.0.19

func (l *L1InfoTreeInitial) String() string

type L1InfoTreeLeaf

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

L1InfoTreeLeaf representation of a leaf of the L1 Info tree

func (*L1InfoTreeLeaf) String added in v0.0.19

func (l *L1InfoTreeLeaf) String() string

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,
	flags CreationFlags,
) (*L1InfoTreeSync, error)

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

func (*L1InfoTreeSync) GetFirstInfo

func (s *L1InfoTreeSync) GetFirstInfo() (*L1InfoTreeLeaf, error)

func (*L1InfoTreeSync) GetFirstInfoAfterBlock

func (s *L1InfoTreeSync) GetFirstInfoAfterBlock(blockNum uint64) (*L1InfoTreeLeaf, error)

func (*L1InfoTreeSync) GetFirstL1InfoWithRollupExitRoot

func (s *L1InfoTreeSync) GetFirstL1InfoWithRollupExitRoot(rollupExitRoot common.Hash) (*L1InfoTreeLeaf, error)

func (*L1InfoTreeSync) GetFirstVerifiedBatches

func (s *L1InfoTreeSync) GetFirstVerifiedBatches(rollupID uint32) (*VerifyBatches, error)

func (*L1InfoTreeSync) GetFirstVerifiedBatchesAfterBlock

func (s *L1InfoTreeSync) GetFirstVerifiedBatchesAfterBlock(rollupID uint32, blockNum uint64) (*VerifyBatches, error)

func (*L1InfoTreeSync) GetInfoByGlobalExitRoot

func (s *L1InfoTreeSync) GetInfoByGlobalExitRoot(ger common.Hash) (*L1InfoTreeLeaf, error)

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) GetInitL1InfoRootMap added in v0.0.19

func (s *L1InfoTreeSync) GetInitL1InfoRootMap(ctx context.Context) (*L1InfoTreeInitial, error)

GetInitL1InfoRootMap returns the initial L1 info root map, nil if no root map has been set

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) GetL1InfoTreeMerkleProofFromIndexToRoot

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

GetL1InfoTreeMerkleProofFromIndexToRoot 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) GetLastInfo

func (s *L1InfoTreeSync) GetLastInfo() (*L1InfoTreeLeaf, error)

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) GetLastVerifiedBatches

func (s *L1InfoTreeSync) GetLastVerifiedBatches(rollupID uint32) (*VerifyBatches, error)

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 It can returns next errors: - ErrBlockNotProcessed, - ErrNotFound

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 common.Hash
	RollupExitRoot  common.Hash
	ParentHash      common.Hash
	Timestamp       uint64
}

UpdateL1InfoTree representation of the UpdateL1InfoTree event

type VerifyBatches

type VerifyBatches struct {
	BlockNumber   uint64         `meddler:"block_num"`
	BlockPosition uint64         `meddler:"block_pos"`
	RollupID      uint32         `meddler:"rollup_id"`
	NumBatch      uint64         `meddler:"batch_num"`
	StateRoot     common.Hash    `meddler:"state_root,hash"`
	ExitRoot      common.Hash    `meddler:"exit_root,hash"`
	Aggregator    common.Address `meddler:"aggregator,address"`

	// Not provided by downloader
	RollupExitRoot common.Hash `meddler:"rollup_exit_root,hash"`
}

VerifyBatches representation of the VerifyBatches and VerifyBatchesTrustedAggregator events

func (*VerifyBatches) String added in v0.0.19

func (v *VerifyBatches) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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