types

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

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

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

Documentation

Index

Constants

View Source
const (
	EstimatedSizeBridgeExit = 230
	EstimatedSizeClaim      = 8000
)
View Source
const NilStr = "nil"

Variables

This section is empty.

Functions

This section is empty.

Types

type AggchainProof added in v0.3.0

type AggchainProof struct {
	LastProvenBlock uint64            `json:"last_proven_block"`
	EndBlock        uint64            `json:"end_block"`
	CustomChainData []byte            `json:"custom_chain_data,omitempty"`
	LocalExitRoot   common.Hash       `json:"local_exit_root"`
	AggchainParams  common.Hash       `json:"aggchain_params"`
	Context         map[string][]byte `json:"context,omitempty"`
	SP1StarkProof   *SP1StarkProof    `json:"sp1_stark_proof,omitempty"`
}

func (*AggchainProof) String added in v0.3.0

func (a *AggchainProof) String() string

type AggsenderFlow added in v0.3.0

type AggsenderFlow interface {
	// GetCertificateBuildParams returns the parameters to build a certificate
	GetCertificateBuildParams(ctx context.Context) (*CertificateBuildParams, error)
	// BuildCertificate builds a certificate based on the buildParams
	BuildCertificate(ctx context.Context,
		buildParams *CertificateBuildParams) (*agglayertypes.Certificate, error)
}

AggsenderFlow is an interface that defines the methods to manage the flow of the AggSender based on the different prover types

type AggsenderInfo

type AggsenderInfo struct {
	AggsenderStatus          AggsenderStatus `json:"aggsender_status"`
	Version                  zkevm.FullVersion
	EpochNotifierDescription string `json:"epoch_notifier_description"`
	NetworkID                uint32 `json:"network_id"`
}

type AggsenderMode added in v0.3.0

type AggsenderMode string
const (
	PessimisticProofMode AggsenderMode = "PessimisticProof"
	AggchainProofMode    AggsenderMode = "AggchainProof"
)

type AggsenderStatus

type AggsenderStatus struct {
	Running   bool                `json:"running"`
	StartTime time.Time           `json:"start_time"`
	Status    AggsenderStatusType `json:"status"`
	LastError string              `json:"last_error"`
}

func (*AggsenderStatus) SetLastError

func (a *AggsenderStatus) SetLastError(err error)

func (*AggsenderStatus) Start

func (a *AggsenderStatus) Start(startTime time.Time)

type AggsenderStatusType

type AggsenderStatusType string
const (
	StatusNone                 AggsenderStatusType = "none"
	StatusCheckingInitialStage AggsenderStatusType = "checking_initial_stage"
	StatusCertificateStage     AggsenderStatusType = "certificate_stage"
)

type BlockNotifier

type BlockNotifier interface {
	// NotifyEpochStarted notifies the epoch has started.
	Subscribe(id string) <-chan EventNewBlock
	GetCurrentBlockNumber() uint64
	String() string
}

BlockNotifier is the interface that wraps the basic methods to notify a new block.

type CertificateBuildParams

type CertificateBuildParams struct {
	FromBlock                      uint64
	ToBlock                        uint64
	Bridges                        []bridgesync.Bridge
	Claims                         []bridgesync.Claim
	CreatedAt                      uint32
	RetryCount                     int
	LastSentCertificate            *CertificateInfo
	L1InfoTreeRootFromWhichToProve common.Hash
	L1InfoTreeLeafCount            uint32
	AggchainProof                  *AggchainProof
}

CertificateBuildParams is a struct that holds the parameters to build a certificate

func (*CertificateBuildParams) EstimatedSize

func (c *CertificateBuildParams) EstimatedSize() uint

EstimatedSize returns the estimated size of the certificate

func (*CertificateBuildParams) IsEmpty

func (c *CertificateBuildParams) IsEmpty() bool

IsEmpty returns true if the certificate is empty

func (*CertificateBuildParams) MaxDepositCount

func (c *CertificateBuildParams) MaxDepositCount() uint32

MaxDepoitCount returns the maximum deposit count in the certificate

func (*CertificateBuildParams) NumberOfBlocks

func (c *CertificateBuildParams) NumberOfBlocks() int

NumberOfBlocks returns the number of blocks in the certificate

func (*CertificateBuildParams) NumberOfBridges

func (c *CertificateBuildParams) NumberOfBridges() int

NumberOfBridges returns the number of bridges in the certificate

func (*CertificateBuildParams) NumberOfClaims

func (c *CertificateBuildParams) NumberOfClaims() int

NumberOfClaims returns the number of claims in the certificate

func (*CertificateBuildParams) Range

func (c *CertificateBuildParams) Range(fromBlock, toBlock uint64) (*CertificateBuildParams, error)

Range create a new CertificateBuildParams with the given range

func (*CertificateBuildParams) String

func (c *CertificateBuildParams) String() string

type CertificateInfo

type CertificateInfo struct {
	Height        uint64      `meddler:"height"`
	RetryCount    int         `meddler:"retry_count"`
	CertificateID common.Hash `meddler:"certificate_id,hash"`
	// PreviousLocalExitRoot if it's nil means no reported
	PreviousLocalExitRoot   *common.Hash                    `meddler:"previous_local_exit_root,hash"`
	NewLocalExitRoot        common.Hash                     `meddler:"new_local_exit_root,hash"`
	FromBlock               uint64                          `meddler:"from_block"`
	ToBlock                 uint64                          `meddler:"to_block"`
	Status                  agglayertypes.CertificateStatus `meddler:"status"`
	CreatedAt               uint32                          `meddler:"created_at"`
	UpdatedAt               uint32                          `meddler:"updated_at"`
	SignedCertificate       string                          `meddler:"signed_certificate"`
	AggchainProof           *AggchainProof                  `meddler:"aggchain_proof,aggchainproof"`
	FinalizedL1InfoTreeRoot *common.Hash                    `meddler:"finalized_l1_info_tree_root,hash"`
	L1InfoTreeLeafCount     uint32                          `meddler:"l1_info_tree_leaf_count"`
}

func (*CertificateInfo) ElapsedTimeSinceCreation

func (c *CertificateInfo) ElapsedTimeSinceCreation() time.Duration

ElapsedTimeSinceCreation returns the time elapsed since the certificate was created

func (*CertificateInfo) ID

func (c *CertificateInfo) ID() string

ID returns a string with the unique identifier of the cerificate (height+certificateID)

func (*CertificateInfo) IsClosed

func (c *CertificateInfo) IsClosed() bool

IsClosed returns true if the certificate is closed (settled or inError)

func (*CertificateInfo) StatusString added in v0.0.2

func (c *CertificateInfo) StatusString() string

StatusString returns the string representation of the status

func (*CertificateInfo) String

func (c *CertificateInfo) String() string

type CertificateMetadata

type CertificateMetadata struct {
	// ToBlock contains the pre v1 value stored in the metadata certificate field
	// is not stored in the hash post v1
	ToBlock uint64

	// FromBlock is the block number from which the certificate contains data
	FromBlock uint64

	// Offset is the number of blocks from the FromBlock that the certificate contains
	Offset uint32

	// CreatedAt is the timestamp when the certificate was created
	CreatedAt uint32

	// Version is the version of the metadata
	Version uint8
}

func NewCertificateMetadata

func NewCertificateMetadata(fromBlock uint64, offset uint32, createdAt uint32) *CertificateMetadata

NewCertificateMetadataFromHash returns a new CertificateMetadata from the given hash

func NewCertificateMetadataFromHash

func NewCertificateMetadataFromHash(hash common.Hash) *CertificateMetadata

NewCertificateMetadataFromHash returns a new CertificateMetadata from the given hash

func (*CertificateMetadata) ToHash

func (c *CertificateMetadata) ToHash() common.Hash

ToHash returns the hash of the metadata

type ChainGERReader added in v0.3.0

type ChainGERReader interface {
	GetInjectedGERsForRange(
		ctx context.Context,
		fromBlock, toBlock uint64) (map[common.Hash]chaingerreader.InjectedGER, error)
}

ChainGERReader is an interface defining functions that an ChainGERReader should implement

type EpochEvent

type EpochEvent struct {
	Epoch uint64
	// ExtraInfo if a detailed information about the epoch that depends on implementation
	ExtraInfo fmt.Stringer
}

EpochEvent is the event that notifies the neear end epoch

func (EpochEvent) String

func (e EpochEvent) String() string

type EpochNotifier

type EpochNotifier interface {
	// NotifyEpochStarted notifies the epoch is close to end.
	Subscribe(id string) <-chan EpochEvent
	// Start starts the notifier synchronously
	Start(ctx context.Context)
	// GetEpochStatus returns the current status of the epoch
	GetEpochStatus() EpochStatus
	String() string
}

type EpochStatus added in v0.0.2

type EpochStatus struct {
	Epoch        uint64
	PercentEpoch float64
}

type EthClient

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

EthClient is an interface defining functions that an EthClient should implement

type EventNewBlock

type EventNewBlock struct {
	BlockNumber       uint64
	BlockFinalityType etherman.BlockNumberFinality
	BlockRate         time.Duration
}

type GenericSubscriber

type GenericSubscriber[T any] interface {
	Subscribe(subscriberName string) <-chan T
	Publish(data T)
}

type L1InfoTreeDataQuerier added in v0.3.0

type L1InfoTreeDataQuerier interface {
	// GetLatestFinalizedL1InfoRoot returns the latest processed l1 info tree root
	// based on the latest finalized l1 block
	GetLatestFinalizedL1InfoRoot(ctx context.Context) (*treetypes.Root, *l1infotreesync.L1InfoTreeLeaf, error)

	// GetFinalizedL1InfoTreeData returns the L1 Info tree data for the last finalized processed block
	// l1InfoTreeData is:
	// - merkle proof of given l1 info tree leaf
	// - the leaf data of the highest index leaf on that block and root
	// - the root of the l1 info tree on that block
	GetFinalizedL1InfoTreeData(ctx context.Context,
	) (treetypes.Proof, *l1infotreesync.L1InfoTreeLeaf, *treetypes.Root, error)

	// GetProofForGER returns the L1 Info tree leaf and the merkle proof for the given GER
	GetProofForGER(ctx context.Context, ger, rootFromWhichToProve common.Hash) (
		*l1infotreesync.L1InfoTreeLeaf, treetypes.Proof, error)

	// CheckIfClaimsArePartOfFinalizedL1InfoTree checks if the claims are part of the finalized L1 Info tree
	CheckIfClaimsArePartOfFinalizedL1InfoTree(
		finalizedL1InfoTreeRoot *treetypes.Root, claims []bridgesync.Claim) error
}

L1InfoTreeDataQuerier is an interface defining functions that an L1InfoTreeDataQuerier should implement It is used to query data from the L1 Info tree

type L1InfoTreeSyncer

type L1InfoTreeSyncer interface {
	GetInfoByGlobalExitRoot(globalExitRoot common.Hash) (*l1infotreesync.L1InfoTreeLeaf, error)
	GetL1InfoTreeMerkleProofFromIndexToRoot(
		ctx context.Context, index uint32, root common.Hash,
	) (treetypes.Proof, error)
	GetL1InfoTreeRootByIndex(ctx context.Context, index uint32) (treetypes.Root, error)
	GetProcessedBlockUntil(ctx context.Context, blockNumber uint64) (uint64, common.Hash, error)
	GetInfoByIndex(ctx context.Context, index uint32) (*l1infotreesync.L1InfoTreeLeaf, error)
	GetLatestInfoUntilBlock(ctx context.Context, blockNum uint64) (*l1infotreesync.L1InfoTreeLeaf, error)
}

L1InfoTreeSyncer is an interface defining functions that an L1InfoTreeSyncer should implement

type L2BridgeSyncer

type L2BridgeSyncer interface {
	GetBlockByLER(ctx context.Context, ler common.Hash) (uint64, error)
	GetExitRootByIndex(ctx context.Context, index uint32) (treetypes.Root, error)
	GetBridgesPublished(ctx context.Context, fromBlock, toBlock uint64) ([]bridgesync.Bridge, error)
	GetClaims(ctx context.Context, fromBlock, toBlock uint64) ([]bridgesync.Claim, error)
	OriginNetwork() uint32
	BlockFinality() etherman.BlockNumberFinality
	GetLastProcessedBlock(ctx context.Context) (uint64, error)
}

L2BridgeSyncer is an interface defining functions that an L2BridgeSyncer should implement

type Logger

type Logger interface {
	Fatalf(format string, args ...interface{})
	Info(args ...interface{})
	Infof(format string, args ...interface{})
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Warn(args ...interface{})
	Warnf(format string, args ...interface{})
	Debug(args ...interface{})
	Debugf(format string, args ...interface{})
}

Logger is an interface that defines the methods to log messages

type SP1StarkProof added in v0.3.0

type SP1StarkProof struct {
	// SP1 Version
	Version string `json:"version,omitempty"`
	// SP1 stark proof.
	Proof []byte `json:"proof,omitempty"`
	// SP1 stark proof verification key.
	Vkey []byte `json:"vkey,omitempty"`
}

func (*SP1StarkProof) String added in v0.3.0

func (s *SP1StarkProof) String() string

Jump to

Keyboard shortcuts

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