agglayer

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NonSettledStatuses = []CertificateStatus{Pending, Candidate, Proven}
	ClosedStatuses     = []CertificateStatus{Settled, InError}
)
View Source
var (
	ErrAgglayerRateLimitExceeded = fmt.Errorf("agglayer rate limit exceeded")
)

Functions

This section is empty.

Types

type AggLayerClient

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

AggLayerClient is the client that will be used to interact with the AggLayer

func NewAggLayerClient

func NewAggLayerClient(url string) *AggLayerClient

NewAggLayerClient returns a client ready to be used

func (*AggLayerClient) GetCertificateHeader

func (c *AggLayerClient) GetCertificateHeader(certificateHash common.Hash) (*CertificateHeader, error)

GetCertificateHeader returns the certificate header associated to the hash

func (*AggLayerClient) GetEpochConfiguration

func (c *AggLayerClient) GetEpochConfiguration() (*ClockConfiguration, error)

GetEpochConfiguration returns the clock configuration of AggLayer

func (*AggLayerClient) GetLatestKnownCertificateHeader added in v0.5.0

func (c *AggLayerClient) GetLatestKnownCertificateHeader(networkID uint32) (*CertificateHeader, error)

GetLatestKnownCertificateHeader returns the last certificate header submitted by networkID

func (*AggLayerClient) SendCertificate

func (c *AggLayerClient) SendCertificate(certificate *SignedCertificate) (common.Hash, error)

SendCertificate sends a certificate to the AggLayer

func (*AggLayerClient) SendTx

func (c *AggLayerClient) SendTx(signedTx SignedTx) (common.Hash, error)

SendTx sends a signed transaction to the AggLayer

func (*AggLayerClient) WaitTxToBeMined

func (c *AggLayerClient) WaitTxToBeMined(hash common.Hash, ctx context.Context) error

WaitTxToBeMined waits for a transaction to be mined

type AggLayerClientGetEpochConfiguration

type AggLayerClientGetEpochConfiguration interface {
	GetEpochConfiguration() (*ClockConfiguration, error)
}

type AgglayerClientInterface

type AgglayerClientInterface interface {
	SendTx(signedTx SignedTx) (common.Hash, error)
	WaitTxToBeMined(hash common.Hash, ctx context.Context) error
	SendCertificate(certificate *SignedCertificate) (common.Hash, error)
	GetCertificateHeader(certificateHash common.Hash) (*CertificateHeader, error)
	GetLatestKnownCertificateHeader(networkID uint32) (*CertificateHeader, error)
	AggLayerClientGetEpochConfiguration
}

AgglayerClientInterface is the interface that defines the methods that the AggLayerClient will implement

type AgglayerClientMock

type AgglayerClientMock struct {
	mock.Mock
}

AgglayerClientMock is an autogenerated mock type for the AgglayerClientInterface type

func NewAgglayerClientMock

func NewAgglayerClientMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *AgglayerClientMock

NewAgglayerClientMock creates a new instance of AgglayerClientMock. 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 (*AgglayerClientMock) EXPECT

func (*AgglayerClientMock) GetCertificateHeader

func (_m *AgglayerClientMock) GetCertificateHeader(certificateHash common.Hash) (*CertificateHeader, error)

GetCertificateHeader provides a mock function with given fields: certificateHash

func (*AgglayerClientMock) GetEpochConfiguration

func (_m *AgglayerClientMock) GetEpochConfiguration() (*ClockConfiguration, error)

GetEpochConfiguration provides a mock function with given fields:

func (*AgglayerClientMock) GetLatestKnownCertificateHeader added in v0.5.0

func (_m *AgglayerClientMock) GetLatestKnownCertificateHeader(networkID uint32) (*CertificateHeader, error)

GetLatestKnownCertificateHeader provides a mock function with given fields: networkID

func (*AgglayerClientMock) SendCertificate

func (_m *AgglayerClientMock) SendCertificate(certificate *SignedCertificate) (common.Hash, error)

SendCertificate provides a mock function with given fields: certificate

func (*AgglayerClientMock) SendTx

func (_m *AgglayerClientMock) SendTx(signedTx SignedTx) (common.Hash, error)

SendTx provides a mock function with given fields: signedTx

func (*AgglayerClientMock) WaitTxToBeMined

func (_m *AgglayerClientMock) WaitTxToBeMined(hash common.Hash, ctx context.Context) error

WaitTxToBeMined provides a mock function with given fields: hash, ctx

type AgglayerClientMock_Expecter

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

func (*AgglayerClientMock_Expecter) GetCertificateHeader

func (_e *AgglayerClientMock_Expecter) GetCertificateHeader(certificateHash interface{}) *AgglayerClientMock_GetCertificateHeader_Call

GetCertificateHeader is a helper method to define mock.On call

  • certificateHash common.Hash

func (*AgglayerClientMock_Expecter) GetEpochConfiguration

GetEpochConfiguration is a helper method to define mock.On call

func (*AgglayerClientMock_Expecter) GetLatestKnownCertificateHeader added in v0.5.0

func (_e *AgglayerClientMock_Expecter) GetLatestKnownCertificateHeader(networkID interface{}) *AgglayerClientMock_GetLatestKnownCertificateHeader_Call

GetLatestKnownCertificateHeader is a helper method to define mock.On call

  • networkID uint32

func (*AgglayerClientMock_Expecter) SendCertificate

func (_e *AgglayerClientMock_Expecter) SendCertificate(certificate interface{}) *AgglayerClientMock_SendCertificate_Call

SendCertificate is a helper method to define mock.On call

  • certificate *SignedCertificate

func (*AgglayerClientMock_Expecter) SendTx

func (_e *AgglayerClientMock_Expecter) SendTx(signedTx interface{}) *AgglayerClientMock_SendTx_Call

SendTx is a helper method to define mock.On call

  • signedTx SignedTx

func (*AgglayerClientMock_Expecter) WaitTxToBeMined

func (_e *AgglayerClientMock_Expecter) WaitTxToBeMined(hash interface{}, ctx interface{}) *AgglayerClientMock_WaitTxToBeMined_Call

WaitTxToBeMined is a helper method to define mock.On call

  • hash common.Hash
  • ctx context.Context

type AgglayerClientMock_GetCertificateHeader_Call

type AgglayerClientMock_GetCertificateHeader_Call struct {
	*mock.Call
}

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

func (*AgglayerClientMock_GetCertificateHeader_Call) Return

func (*AgglayerClientMock_GetCertificateHeader_Call) Run

func (*AgglayerClientMock_GetCertificateHeader_Call) RunAndReturn

type AgglayerClientMock_GetEpochConfiguration_Call

type AgglayerClientMock_GetEpochConfiguration_Call struct {
	*mock.Call
}

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

func (*AgglayerClientMock_GetEpochConfiguration_Call) Return

func (*AgglayerClientMock_GetEpochConfiguration_Call) Run

func (*AgglayerClientMock_GetEpochConfiguration_Call) RunAndReturn

type AgglayerClientMock_GetLatestKnownCertificateHeader_Call added in v0.5.0

type AgglayerClientMock_GetLatestKnownCertificateHeader_Call struct {
	*mock.Call
}

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

func (*AgglayerClientMock_GetLatestKnownCertificateHeader_Call) Return added in v0.5.0

func (*AgglayerClientMock_GetLatestKnownCertificateHeader_Call) Run added in v0.5.0

func (*AgglayerClientMock_GetLatestKnownCertificateHeader_Call) RunAndReturn added in v0.5.0

type AgglayerClientMock_SendCertificate_Call

type AgglayerClientMock_SendCertificate_Call struct {
	*mock.Call
}

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

func (*AgglayerClientMock_SendCertificate_Call) Return

func (*AgglayerClientMock_SendCertificate_Call) Run

func (*AgglayerClientMock_SendCertificate_Call) RunAndReturn

type AgglayerClientMock_SendTx_Call

type AgglayerClientMock_SendTx_Call struct {
	*mock.Call
}

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

func (*AgglayerClientMock_SendTx_Call) Return

func (*AgglayerClientMock_SendTx_Call) Run

func (*AgglayerClientMock_SendTx_Call) RunAndReturn

type AgglayerClientMock_WaitTxToBeMined_Call

type AgglayerClientMock_WaitTxToBeMined_Call struct {
	*mock.Call
}

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

func (*AgglayerClientMock_WaitTxToBeMined_Call) Return

func (*AgglayerClientMock_WaitTxToBeMined_Call) Run

func (*AgglayerClientMock_WaitTxToBeMined_Call) RunAndReturn

type BridgeExit

type BridgeExit struct {
	LeafType           LeafType       `json:"leaf_type"`
	TokenInfo          *TokenInfo     `json:"token_info"`
	DestinationNetwork uint32         `json:"dest_network"`
	DestinationAddress common.Address `json:"dest_address"`
	Amount             *big.Int       `json:"amount"`
	IsMetadataHashed   bool           `json:"-"`
	Metadata           []byte         `json:"metadata"`
}

BridgeExit represents a token bridge exit

func (*BridgeExit) Hash

func (b *BridgeExit) Hash() common.Hash

Hash returns a hash that uniquely identifies the bridge exit

func (*BridgeExit) MarshalJSON

func (b *BridgeExit) MarshalJSON() ([]byte, error)

MarshalJSON is the implementation of the json.Marshaler interface

func (*BridgeExit) String

func (b *BridgeExit) String() string

type Certificate

type Certificate struct {
	NetworkID           uint32                `json:"network_id"`
	Height              uint64                `json:"height"`
	PrevLocalExitRoot   common.Hash           `json:"prev_local_exit_root"`
	NewLocalExitRoot    common.Hash           `json:"new_local_exit_root"`
	BridgeExits         []*BridgeExit         `json:"bridge_exits"`
	ImportedBridgeExits []*ImportedBridgeExit `json:"imported_bridge_exits"`
	Metadata            common.Hash           `json:"metadata"`
}

Certificate is the data structure that will be sent to the agglayer

func (*Certificate) Brief added in v0.5.0

func (c *Certificate) Brief() string

Brief returns a string with a brief cert

func (*Certificate) Hash

func (c *Certificate) Hash() common.Hash

Hash returns a hash that uniquely identifies the certificate

func (*Certificate) HashToSign

func (c *Certificate) HashToSign() common.Hash

HashToSign is the actual hash that needs to be signed by the aggsender as expected by the agglayer

type CertificateHeader

type CertificateHeader struct {
	NetworkID             uint32            `json:"network_id"`
	Height                uint64            `json:"height"`
	EpochNumber           *uint64           `json:"epoch_number"`
	CertificateIndex      *uint64           `json:"certificate_index"`
	CertificateID         common.Hash       `json:"certificate_id"`
	PreviousLocalExitRoot *common.Hash      `json:"prev_local_exit_root,omitempty"`
	NewLocalExitRoot      common.Hash       `json:"new_local_exit_root"`
	Status                CertificateStatus `json:"status"`
	Metadata              common.Hash       `json:"metadata"`
	Error                 error             `json:"-"`
}

CertificateHeader is the structure returned by the interop_getCertificateHeader RPC call

func (*CertificateHeader) ID added in v0.5.0

func (c *CertificateHeader) ID() string

ID returns a string with the ident of this cert (height/certID)

func (*CertificateHeader) String

func (c *CertificateHeader) String() string

func (*CertificateHeader) UnmarshalJSON

func (c *CertificateHeader) UnmarshalJSON(data []byte) error

type CertificateStatus

type CertificateStatus int
const (
	Pending CertificateStatus = iota
	Proven
	Candidate
	InError
	Settled
)

func (CertificateStatus) IsClosed added in v0.5.0

func (c CertificateStatus) IsClosed() bool

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

func (CertificateStatus) IsInError added in v0.5.0

func (c CertificateStatus) IsInError() bool

IsInError returns true if the certificate is in error

func (CertificateStatus) IsOpen added in v0.5.0

func (c CertificateStatus) IsOpen() bool

IsOpen returns true if the certificate is open (pending, candidate or proven)

func (CertificateStatus) IsSettled added in v0.5.0

func (c CertificateStatus) IsSettled() bool

IsSettled returns true if the certificate is settled

func (CertificateStatus) String

func (c CertificateStatus) String() string

String representation of the enum

func (*CertificateStatus) UnmarshalJSON

func (c *CertificateStatus) UnmarshalJSON(rawStatus []byte) error

UnmarshalJSON is the implementation of the json.Unmarshaler interface

type Claim

type Claim interface {
	Type() string
	Hash() common.Hash
	MarshalJSON() ([]byte, error)
	String() string
}

Claim is the interface that will be implemented by the different types of claims

type ClaimFromMainnnet

type ClaimFromMainnnet struct {
	ProofLeafMER     *MerkleProof    `json:"proof_leaf_mer"`
	ProofGERToL1Root *MerkleProof    `json:"proof_ger_l1root"`
	L1Leaf           *L1InfoTreeLeaf `json:"l1_leaf"`
}

ClaimFromMainnnet represents a claim originating from the mainnet

func (*ClaimFromMainnnet) Hash

func (c *ClaimFromMainnnet) Hash() common.Hash

Hash is the implementation of Claim interface

func (*ClaimFromMainnnet) MarshalJSON

func (c *ClaimFromMainnnet) MarshalJSON() ([]byte, error)

MarshalJSON is the implementation of Claim interface

func (*ClaimFromMainnnet) String

func (c *ClaimFromMainnnet) String() string

func (ClaimFromMainnnet) Type

func (c ClaimFromMainnnet) Type() string

Type is the implementation of Claim interface

type ClaimFromRollup

type ClaimFromRollup struct {
	ProofLeafLER     *MerkleProof    `json:"proof_leaf_ler"`
	ProofLERToRER    *MerkleProof    `json:"proof_ler_rer"`
	ProofGERToL1Root *MerkleProof    `json:"proof_ger_l1root"`
	L1Leaf           *L1InfoTreeLeaf `json:"l1_leaf"`
}

ClaimFromRollup represents a claim originating from a rollup

func (*ClaimFromRollup) Hash

func (c *ClaimFromRollup) Hash() common.Hash

Hash is the implementation of Claim interface

func (*ClaimFromRollup) MarshalJSON

func (c *ClaimFromRollup) MarshalJSON() ([]byte, error)

MarshalJSON is the implementation of Claim interface

func (*ClaimFromRollup) String

func (c *ClaimFromRollup) String() string

func (ClaimFromRollup) Type

func (c ClaimFromRollup) Type() string

Type is the implementation of Claim interface

type ClockConfiguration

type ClockConfiguration struct {
	EpochDuration uint64 `json:"epoch_duration"`
	GenesisBlock  uint64 `json:"genesis_block"`
}

ClockConfiguration represents the configuration of the epoch clock returned by the interop_GetEpochConfiguration RPC call

func (ClockConfiguration) String

func (c ClockConfiguration) String() string

type GenericError added in v0.5.0

type GenericError struct {
	Key   string
	Value string
}

func (*GenericError) Error added in v0.5.0

func (p *GenericError) Error() string

type GlobalIndex

type GlobalIndex struct {
	MainnetFlag bool   `json:"mainnet_flag"`
	RollupIndex uint32 `json:"rollup_index"`
	LeafIndex   uint32 `json:"leaf_index"`
}

GlobalIndex represents the global index of an imported bridge exit

func (*GlobalIndex) Hash

func (g *GlobalIndex) Hash() common.Hash

func (*GlobalIndex) String

func (g *GlobalIndex) String() string

String returns a string representation of the GlobalIndex struct

func (*GlobalIndex) UnmarshalFromMap

func (g *GlobalIndex) UnmarshalFromMap(data map[string]interface{}) error

type ImportedBridgeExit

type ImportedBridgeExit struct {
	BridgeExit  *BridgeExit  `json:"bridge_exit"`
	ClaimData   Claim        `json:"claim_data"`
	GlobalIndex *GlobalIndex `json:"global_index"`
}

ImportedBridgeExit represents a token bridge exit originating on another network but claimed on the current network.

func (*ImportedBridgeExit) Hash

func (c *ImportedBridgeExit) Hash() common.Hash

Hash returns a hash that uniquely identifies the imported bridge exit

func (*ImportedBridgeExit) String

func (c *ImportedBridgeExit) String() string

type L1InfoTreeLeaf

type L1InfoTreeLeaf struct {
	L1InfoTreeIndex uint32               `json:"l1_info_tree_index"`
	RollupExitRoot  common.Hash          `json:"rer"`
	MainnetExitRoot common.Hash          `json:"mer"`
	Inner           *L1InfoTreeLeafInner `json:"inner"`
}

L1InfoTreeLeaf represents the leaf of the L1 info tree

func (*L1InfoTreeLeaf) Hash

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

Hash returns the hash of the L1InfoTreeLeaf struct

func (*L1InfoTreeLeaf) String

func (l *L1InfoTreeLeaf) String() string

type L1InfoTreeLeafInner

type L1InfoTreeLeafInner struct {
	GlobalExitRoot common.Hash `json:"global_exit_root"`
	BlockHash      common.Hash `json:"block_hash"`
	Timestamp      uint64      `json:"timestamp"`
}

L1InfoTreeLeafInner represents the inner part of the L1 info tree leaf

func (*L1InfoTreeLeafInner) Hash

func (l *L1InfoTreeLeafInner) Hash() common.Hash

Hash returns the hash of the L1InfoTreeLeafInner struct

func (*L1InfoTreeLeafInner) String

func (l *L1InfoTreeLeafInner) String() string

type LeafType

type LeafType uint8
const (
	LeafTypeAsset LeafType = iota
	LeafTypeMessage
)

func (LeafType) String

func (l LeafType) String() string

func (LeafType) Uint8

func (l LeafType) Uint8() uint8

type MerkleProof

type MerkleProof struct {
	Root  common.Hash                      `json:"root"`
	Proof [types.DefaultHeight]common.Hash `json:"proof"`
}

MerkleProof represents an inclusion proof of a leaf in a Merkle tree

func (*MerkleProof) Hash

func (m *MerkleProof) Hash() common.Hash

Hash returns the hash of the Merkle proof struct

func (*MerkleProof) MarshalJSON

func (m *MerkleProof) MarshalJSON() ([]byte, error)

MarshalJSON is the implementation of the json.Marshaler interface

func (*MerkleProof) String

func (m *MerkleProof) String() string

type Signature

type Signature struct {
	R         common.Hash `json:"r"`
	S         common.Hash `json:"s"`
	OddParity bool        `json:"odd_y_parity"`
}

Signature is the data structure that will hold the signature of the given certificate

func (*Signature) String

func (s *Signature) String() string

type SignedCertificate

type SignedCertificate struct {
	*Certificate
	Signature *Signature `json:"signature"`
}

SignedCertificate is the struct that contains the certificate and the signature of the signer

func (*SignedCertificate) Brief added in v0.5.0

func (s *SignedCertificate) Brief() string

func (*SignedCertificate) CopyWithDefaulting

func (s *SignedCertificate) CopyWithDefaulting() *SignedCertificate

CopyWithDefaulting returns a shallow copy of the signed certificate

type SignedTx

type SignedTx struct {
	Tx        Tx             `json:"tx"`
	Signature types.ArgBytes `json:"signature"`
}

SignedTx is the struct that contains the signed batch transaction

func (*SignedTx) Signer

func (s *SignedTx) Signer() (common.Address, error)

Signer returns the address of the signer

type TokenInfo

type TokenInfo struct {
	OriginNetwork      uint32         `json:"origin_network"`
	OriginTokenAddress common.Address `json:"origin_token_address"`
}

TokenInfo encapsulates the information to uniquely identify a token on the origin network.

func (*TokenInfo) String

func (t *TokenInfo) String() string

String returns a string representation of the TokenInfo struct

type Tx

type Tx struct {
	RollupID          uint32
	LastVerifiedBatch types.ArgUint64 `json:"lastVerifiedBatch"`
	NewVerifiedBatch  types.ArgUint64 `json:"newVerifiedBatch"`
	ZKP               ZKP             `json:"ZKP"`
}

Tx is the struct that contains the verified batch transaction

func (*Tx) Hash

func (t *Tx) Hash() common.Hash

Hash returns a hash that uniquely identifies the tx

func (*Tx) Sign

func (t *Tx) Sign(privateKey *ecdsa.PrivateKey) (*SignedTx, error)

Sign returns a signed batch by the private key

type ZKP

type ZKP struct {
	NewStateRoot     common.Hash    `json:"newStateRoot"`
	NewLocalExitRoot common.Hash    `json:"newLocalExitRoot"`
	Proof            types.ArgBytes `json:"proof"`
}

ZKP is the struct that contains the zero-knowledge proof

Jump to

Keyboard shortcuts

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