l1infotreesync

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: Apache-2.0, MIT Imports: 28 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

func CalculateGER added in v0.7.0

func CalculateGER(mainnetExitRoot, rollupExitRoot common.Hash) common.Hash

CalculateGER calculates the Global Exit Root (GER) based on the mainnet and rollup exit roots

Types

type Config

type Config struct {
	DBPath                     string         `mapstructure:"DBPath"`
	GlobalExitRootAddr         common.Address `mapstructure:"GlobalExitRootAddr"`
	RollupManagerAddr          common.Address `mapstructure:"RollupManagerAddr"`
	SyncBlockChunkSize         uint64         `mapstructure:"SyncBlockChunkSize"`
	URLRPCL1                   string         `mapstructure:"URLRPCL1"`
	WaitForNewBlocksPeriod     types.Duration `mapstructure:"WaitForNewBlocksPeriod"`
	InitialBlock               uint64         `mapstructure:"InitialBlock"`
	RetryAfterErrorPeriod      types.Duration `mapstructure:"RetryAfterErrorPeriod"`
	MaxRetryAttemptsAfterError int            `mapstructure:"MaxRetryAttemptsAfterError"`
	// RequireStorageContentCompatibility is true it's mandatory that data stored in the database
	// is compatible with the running environment
	RequireStorageContentCompatibility bool `mapstructure:"RequireStorageContentCompatibility"`
}

type CreationFlags

type CreationFlags uint64
const (
	FlagNone                     CreationFlags = 1 << iota // Check for correct contracts addresses
	FlagAllowWrongContractsAddrs                           // Allow to set wrong contracts addresses
)

type Event

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

type InitL1InfoRootMap

type InitL1InfoRootMap struct {
	LeafCount         uint32
	CurrentL1InfoRoot common.Hash
}

func (*InitL1InfoRootMap) String

func (i *InitL1InfoRootMap) String() string

type L1InfoTreeInitial

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

func (l *L1InfoTreeInitial) String() string

type L1InfoTreeLeaf

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

L1InfoTreeLeaf representation of a leaf of the L1 Info tree

func (*L1InfoTreeLeaf) GetGlobalExitRoot added in v0.4.0

func (l *L1InfoTreeLeaf) GetGlobalExitRoot() common.Hash

GlobalExitRoot returns the GER

func (*L1InfoTreeLeaf) GetHash added in v0.4.0

func (l *L1InfoTreeLeaf) GetHash() common.Hash

Hash as expected by the tree

func (*L1InfoTreeLeaf) String

func (l *L1InfoTreeLeaf) String() string

type L1InfoTreeSync

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

func New

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

func NewReadOnly added in v0.7.0

func NewReadOnly(
	ctx context.Context,
	dbPath string,
) (*L1InfoTreeSync, error)

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) GetInfoByRoot added in v0.7.0

func (s *L1InfoTreeSync) GetInfoByRoot(root common.Hash) (*L1InfoTreeLeaf, error)

func (*L1InfoTreeSync) GetInitL1InfoRootMap

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) GetLatestL1InfoLeaf added in v0.7.0

func (s *L1InfoTreeSync) GetLatestL1InfoLeaf(ctx context.Context) (*L1InfoTreeLeaf, error)

GetLatestL1InfoLeaf returns the most recent L1InfoTreeLeaf that has been indexed It can return next errors: - ErrInconsistentState - ErrNotFound

func (*L1InfoTreeSync) GetLatestL1InfoLeafUntilBlock added in v0.7.0

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

GetLatestL1InfoLeafUntilBlock 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) GetProcessedBlockUntil added in v0.3.0

func (s *L1InfoTreeSync) GetProcessedBlockUntil(ctx context.Context, blockNum uint64) (uint64, common.Hash, error)

GetProcessedBlockUntil returns the last block processed before the given block number or the exact block num and hash associated to given block if it was processed

func (*L1InfoTreeSync) GetRPCServices added in v0.7.0

func (a *L1InfoTreeSync) GetRPCServices() []jRPC.Service

GetRPCServices returns the list of services that the RPC provider exposes

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) IsUpToDate added in v0.7.0

func (s *L1InfoTreeSync) IsUpToDate(ctx context.Context, l1Client aggkittypes.BaseEthereumClienter) (bool, error)

IsUpToDate checks if the L1InfoTreeSync is up to date with the finalized L1 blocks

func (*L1InfoTreeSync) Start

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

Start starts the synchronization process

type L1InfoTreeSyncRPC added in v0.7.0

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

L1InfoTreeSyncRPC is the RPC interface for the L1InfoTreeSync

func NewL1InfoTreeSyncRPC added in v0.7.0

func NewL1InfoTreeSyncRPC(
	logger aggkitcommon.Logger,
	l1InfoTreeSyncer L1InfoTreeSyncer,
) *L1InfoTreeSyncRPC

func (*L1InfoTreeSyncRPC) GetInfoByGlobalExitRoot added in v0.7.0

func (b *L1InfoTreeSyncRPC) GetInfoByGlobalExitRoot(inputGER *string) (interface{}, rpc.Error)

GetInfoByGlobalExitRoot returns a leaf for the given global exit root if param is `nil` it returns the last leaf latest:

curl -X POST http://localhost:5576/ -H "Content-Type: application/json" \
 -d '{"method":"l1infotreesync_getInfoByGlobalExitRoot", "params":[], "id":1}'

specific height:

curl -X POST http://localhost:5576/ -H "Content-Type: application/json" \ -d '{"method":"l1infotreesync_getInfoByGlobalExitRoot", "params":[$ger], "id":1}'

func (*L1InfoTreeSyncRPC) GetInfoByRoot added in v0.7.0

func (b *L1InfoTreeSyncRPC) GetInfoByRoot(inputRoot *string) (interface{}, rpc.Error)

GetInfoByRoot returns a leaf for the given root if param is `nil` it returns the last leaf latest:

curl -X POST http://localhost:5576/ -H "Content-Type: application/json" \
 -d '{"method":"l1infotreesync_getInfoByRoot", "params":[], "id":1}'

specific height:

curl -X POST http://localhost:5576/ -H "Content-Type: application/json" \ -d '{"method":"l1infotreesync_getInfoByRoot", "params":[$root], "id":1}'

func (*L1InfoTreeSyncRPC) Status added in v0.7.0

func (b *L1InfoTreeSyncRPC) Status() (interface{}, rpc.Error)

Status returns the status of the L1InfoTreeSync component curl -X POST http://localhost:5576/ "Content-Type: application/json" \ -d '{"method":"l1infotreesync_status", "params":[], "id":1}'

type L1InfoTreeSyncer added in v0.7.0

type L1InfoTreeSyncer interface {
	GetInfoByGlobalExitRoot(ger common.Hash) (*L1InfoTreeLeaf, error)
	GetLatestL1InfoLeaf(ctx context.Context) (*L1InfoTreeLeaf, error)
	GetInfoByRoot(ger common.Hash) (*L1InfoTreeLeaf, error)
}

type L1InfoTreeSyncerMock added in v0.7.0

type L1InfoTreeSyncerMock struct {
	mock.Mock
}

L1InfoTreeSyncerMock is an autogenerated mock type for the L1InfoTreeSyncer type

func NewL1InfoTreeSyncerMock added in v0.7.0

func NewL1InfoTreeSyncerMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *L1InfoTreeSyncerMock

NewL1InfoTreeSyncerMock creates a new instance of L1InfoTreeSyncerMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*L1InfoTreeSyncerMock) EXPECT added in v0.7.0

func (*L1InfoTreeSyncerMock) GetInfoByGlobalExitRoot added in v0.7.0

func (_m *L1InfoTreeSyncerMock) GetInfoByGlobalExitRoot(ger common.Hash) (*L1InfoTreeLeaf, error)

GetInfoByGlobalExitRoot provides a mock function with given fields: ger

func (*L1InfoTreeSyncerMock) GetInfoByRoot added in v0.7.0

func (_m *L1InfoTreeSyncerMock) GetInfoByRoot(ger common.Hash) (*L1InfoTreeLeaf, error)

GetInfoByRoot provides a mock function with given fields: ger

func (*L1InfoTreeSyncerMock) GetLatestL1InfoLeaf added in v0.7.0

func (_m *L1InfoTreeSyncerMock) GetLatestL1InfoLeaf(ctx context.Context) (*L1InfoTreeLeaf, error)

GetLatestL1InfoLeaf provides a mock function with given fields: ctx

type L1InfoTreeSyncerMock_Expecter added in v0.7.0

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

func (*L1InfoTreeSyncerMock_Expecter) GetInfoByGlobalExitRoot added in v0.7.0

func (_e *L1InfoTreeSyncerMock_Expecter) GetInfoByGlobalExitRoot(ger interface{}) *L1InfoTreeSyncerMock_GetInfoByGlobalExitRoot_Call

GetInfoByGlobalExitRoot is a helper method to define mock.On call

  • ger common.Hash

func (*L1InfoTreeSyncerMock_Expecter) GetInfoByRoot added in v0.7.0

func (_e *L1InfoTreeSyncerMock_Expecter) GetInfoByRoot(ger interface{}) *L1InfoTreeSyncerMock_GetInfoByRoot_Call

GetInfoByRoot is a helper method to define mock.On call

  • ger common.Hash

func (*L1InfoTreeSyncerMock_Expecter) GetLatestL1InfoLeaf added in v0.7.0

func (_e *L1InfoTreeSyncerMock_Expecter) GetLatestL1InfoLeaf(ctx interface{}) *L1InfoTreeSyncerMock_GetLatestL1InfoLeaf_Call

GetLatestL1InfoLeaf is a helper method to define mock.On call

  • ctx context.Context

type L1InfoTreeSyncerMock_GetInfoByGlobalExitRoot_Call added in v0.7.0

type L1InfoTreeSyncerMock_GetInfoByGlobalExitRoot_Call struct {
	*mock.Call
}

L1InfoTreeSyncerMock_GetInfoByGlobalExitRoot_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetInfoByGlobalExitRoot'

func (*L1InfoTreeSyncerMock_GetInfoByGlobalExitRoot_Call) Return added in v0.7.0

func (*L1InfoTreeSyncerMock_GetInfoByGlobalExitRoot_Call) Run added in v0.7.0

func (*L1InfoTreeSyncerMock_GetInfoByGlobalExitRoot_Call) RunAndReturn added in v0.7.0

type L1InfoTreeSyncerMock_GetInfoByRoot_Call added in v0.7.0

type L1InfoTreeSyncerMock_GetInfoByRoot_Call struct {
	*mock.Call
}

L1InfoTreeSyncerMock_GetInfoByRoot_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetInfoByRoot'

func (*L1InfoTreeSyncerMock_GetInfoByRoot_Call) Return added in v0.7.0

func (*L1InfoTreeSyncerMock_GetInfoByRoot_Call) Run added in v0.7.0

func (*L1InfoTreeSyncerMock_GetInfoByRoot_Call) RunAndReturn added in v0.7.0

type L1InfoTreeSyncerMock_GetLatestL1InfoLeaf_Call added in v0.7.0

type L1InfoTreeSyncerMock_GetLatestL1InfoLeaf_Call struct {
	*mock.Call
}

L1InfoTreeSyncerMock_GetLatestL1InfoLeaf_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLatestL1InfoLeaf'

func (*L1InfoTreeSyncerMock_GetLatestL1InfoLeaf_Call) Return added in v0.7.0

func (*L1InfoTreeSyncerMock_GetLatestL1InfoLeaf_Call) Run added in v0.7.0

func (*L1InfoTreeSyncerMock_GetLatestL1InfoLeaf_Call) RunAndReturn added in v0.7.0

type StatusInfo added in v0.7.0

type StatusInfo struct {
	Status string `json:"status"`
}

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 UpdateL1InfoTreeV2

type UpdateL1InfoTreeV2 struct {
	CurrentL1InfoRoot common.Hash
	LeafCount         uint32
	Blockhash         common.Hash
	MinTimestamp      uint64
}

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

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