ccipocr3

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: MIT Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BigInt

type BigInt struct {
	*big.Int
}

func NewBigInt

func NewBigInt(i *big.Int) BigInt

func NewBigIntFromInt64

func NewBigIntFromInt64(i int64) BigInt

func (BigInt) IsEmpty

func (b BigInt) IsEmpty() bool

func (BigInt) MarshalJSON

func (b BigInt) MarshalJSON() ([]byte, error)

func (*BigInt) UnmarshalJSON

func (b *BigInt) UnmarshalJSON(p []byte) error

type Bytes

type Bytes []byte

func NewBytesFromString

func NewBytesFromString(s string) (Bytes, error)

func (Bytes) MarshalJSON

func (b Bytes) MarshalJSON() ([]byte, error)

func (Bytes) String

func (b Bytes) String() string

func (*Bytes) UnmarshalJSON

func (b *Bytes) UnmarshalJSON(data []byte) error

type Bytes32

type Bytes32 [32]byte

func NewBytes32FromString

func NewBytes32FromString(s string) (Bytes32, error)

func (Bytes32) IsEmpty

func (b Bytes32) IsEmpty() bool

func (Bytes32) MarshalJSON

func (b Bytes32) MarshalJSON() ([]byte, error)

func (Bytes32) String

func (b Bytes32) String() string

func (*Bytes32) UnmarshalJSON

func (b *Bytes32) UnmarshalJSON(data []byte) error

type ChainSelector

type ChainSelector uint64

func (ChainSelector) String

func (c ChainSelector) String() string

type CommitPluginCodec

type CommitPluginCodec interface {
	Encode(context.Context, CommitPluginReport) ([]byte, error)
	Decode(context.Context, []byte) (CommitPluginReport, error)
}

type CommitPluginReport

type CommitPluginReport struct {
	MerkleRoots  []MerkleRootChain `json:"merkleRoots"`
	PriceUpdates PriceUpdates      `json:"priceUpdates"`

	// RMNSignatures are the ECDSA signatures from the RMN signing nodes on the RMNReport structure.
	// For more details see the contract here: https://github.com/smartcontractkit/chainlink/blob/7ba0f37134a618375542079ff1805fe2224d7916/contracts/src/v0.8/ccip/interfaces/IRMNV2.sol#L8-L12
	RMNSignatures []RMNECDSASignature `json:"rmnSignatures"`

	// RMNRawVs is a 256-bit bitmap. A bit is set if the v value of the signature is 28,
	// and unset if the v value is 27.
	// Note that this implies that the maximum number of RMN signatures is 256.
	RMNRawVs BigInt `json:"rmnRawVs"`
}

CommitPluginReport contains the necessary information to commit CCIP messages from potentially many source chains, to a single destination chain.

It must consist of either:

  1. a non-empty MerkleRoots array, or
  2. a non-empty PriceUpdates array

If neither of the above is provided the report is considered empty and should not be transmitted on-chain.

In the event the MerkleRoots array is non-empty, it may also contain RMNSignatures, if RMN is configured for some lanes involved in the commitment. A report with RMN signatures but without merkle roots is invalid.

func (CommitPluginReport) IsEmpty

func (r CommitPluginReport) IsEmpty() bool

IsEmpty returns true if the CommitPluginReport is empty

type ExecutePluginCodec

type ExecutePluginCodec interface {
	Encode(context.Context, ExecutePluginReport) ([]byte, error)
	Decode(context.Context, []byte) (ExecutePluginReport, error)
}

type ExecutePluginReport

type ExecutePluginReport struct {
	ChainReports []ExecutePluginReportSingleChain `json:"chainReports"`
}

type ExecutePluginReportSingleChain

type ExecutePluginReportSingleChain struct {
	SourceChainSelector ChainSelector `json:"sourceChainSelector"`
	Messages            []Message     `json:"messages"`
	OffchainTokenData   [][][]byte    `json:"offchainTokenData"`
	Proofs              []Bytes32     `json:"proofs"`
	ProofFlagBits       BigInt        `json:"proofFlagBits"`
}

type GasPriceChain

type GasPriceChain struct {
	GasPrice BigInt        `json:"gasPrice"`
	ChainSel ChainSelector `json:"chainSel"`
}

func NewGasPriceChain

func NewGasPriceChain(gasPrice *big.Int, chainSel ChainSelector) GasPriceChain

type MerkleRootChain

type MerkleRootChain struct {
	ChainSel      ChainSelector `json:"chain"`
	OnRampAddress Bytes         `json:"onRampAddress"`
	SeqNumsRange  SeqNumRange   `json:"seqNumsRange"`
	MerkleRoot    Bytes32       `json:"merkleRoot"`
}

MerkleRootChain Mirroring https://github.com/smartcontractkit/chainlink/blob/cd5c78959575f593b27fd83d8766086d0c678487/contracts/src/v0.8/ccip/libraries/Internal.sol#L356-L362

func NewMerkleRootChain

func NewMerkleRootChain(
	chainSel ChainSelector,
	onRampAddress Bytes,
	seqNumsRange SeqNumRange,
	merkleRoot Bytes32,
) MerkleRootChain

func (MerkleRootChain) Equals added in v0.3.0

func (m MerkleRootChain) Equals(other MerkleRootChain) bool

type Message

type Message struct {
	// Header is the family-agnostic header for OnRamp and OffRamp messages.
	// This is always set on all CCIP messages.
	Header RampMessageHeader `json:"header"`
	// Sender address on the source chain.
	// i.e if the source chain is EVM, this is an abi-encoded EVM address.
	Sender Bytes `json:"sender"`
	// Data is the arbitrary data payload supplied by the message sender.
	Data Bytes `json:"data"`
	// Receiver is the receiver address on the destination chain.
	// This is encoded in the destination chain family specific encoding.
	// i.e if the destination is EVM, this is abi.encode(receiver).
	Receiver Bytes `json:"receiver"`
	// ExtraArgs is destination-chain specific extra args, such as the gasLimit for EVM chains.
	ExtraArgs Bytes `json:"extraArgs"`
	// FeeToken is the fee token address.
	// i.e if the source chain is EVM, len(FeeToken) == 20 (i.e, is not abi-encoded).
	FeeToken Bytes `json:"feeToken"`
	// FeeTokenAmount is the amount of fee tokens paid.
	FeeTokenAmount BigInt `json:"feeTokenAmount"`
	// FeeValueJuels is the fee amount in Juels
	FeeValueJuels BigInt `json:"feeValueJuels"`
	// TokenAmounts is the array of tokens and amounts to transfer.
	TokenAmounts []RampTokenAmount `json:"tokenAmounts"`
}

Message is the generic Any2Any message type for CCIP messages. It represents, in particular, a message emitted by a CCIP onramp. The message is expected to be consumed by a CCIP offramp after translating it into the appropriate format for the destination chain.

func (Message) String

func (c Message) String() string

type MessageHasher

type MessageHasher interface {
	Hash(context.Context, Message) (Bytes32, error)
}

type PriceUpdates

type PriceUpdates struct {
	TokenPriceUpdates []TokenPrice    `json:"tokenPriceUpdates"`
	GasPriceUpdates   []GasPriceChain `json:"gasPriceUpdates"`
}

type RMNCrypto added in v0.2.2

type RMNCrypto interface {
	// VerifyReportSignatures verifies each provided signature against the provided report and the signer addresses.
	// If any signature is invalid (no matching signer address is found), an error is returned immediately.
	VerifyReportSignatures(
		ctx context.Context,
		sigs []RMNECDSASignature,
		report RMNReport,
		signerAddresses []Bytes,
	) error
}

RMNCrypto provides a chain-agnostic interface for verifying RMN signatures. For example, on EVM, RMN reports are abi-encoded prior to being signed. On Solana, they would be borsh encoded instead, etc.

type RMNECDSASignature added in v0.2.2

type RMNECDSASignature struct {
	R Bytes32 `json:"r"`
	S Bytes32 `json:"s"`
}

RMNECDSASignature represents the signature provided by RMN on the RMNReport structure. The V value of the signature is included in the top-level commit report as part of a bitmap.

type RMNLaneUpdate added in v0.2.2

type RMNLaneUpdate struct {
	SourceChainSelector ChainSelector
	OnRampAddress       Bytes // (for EVM should be abi-encoded)
	MinSeqNr            SeqNum
	MaxSeqNr            SeqNum
	MerkleRoot          Bytes32
}

RMNLaneUpdate represents an interval that has been observed by an RMN node. It is part of the payload that is signed and transmitted onchain.

type RMNReport added in v0.2.2

type RMNReport struct {
	ReportVersion               string // e.g. "RMN_V1_6_ANY2EVM_REPORT".
	DestChainID                 BigInt // If applies, a chain specific id, e.g. evm chain id otherwise empty.
	DestChainSelector           ChainSelector
	RmnRemoteContractAddress    Bytes
	OfframpAddress              Bytes
	RmnHomeContractConfigDigest Bytes32
	LaneUpdates                 []RMNLaneUpdate
}

RMNReport is the payload that is signed by the RMN nodes, transmitted and verified onchain.

type RampMessageHeader

type RampMessageHeader struct {
	// MessageID is a unique identifier for the message, it should be unique across all chains.
	// It is generated on the chain that the CCIP send is requested (i.e. the source chain of a message).
	MessageID Bytes32 `json:"messageId"`
	// SourceChainSelector is the chain selector of the chain that the message originated from.
	SourceChainSelector ChainSelector `json:"sourceChainSelector,string"`
	// DestChainSelector is the chain selector of the chain that the message is destined for.
	DestChainSelector ChainSelector `json:"destChainSelector,string"`
	// SequenceNumber is an auto-incrementing sequence number for the message.
	// Not unique across lanes.
	SequenceNumber SeqNum `json:"seqNum,string"`
	// Nonce is the nonce for this lane for this sender, not unique across senders/lanes
	Nonce uint64 `json:"nonce"`

	// MsgHash is the hash of all the message fields.
	// NOTE: The field is expected to be empty, and will be populated by the plugin using the MsgHasher interface.
	MsgHash Bytes32 `json:"msgHash"` // populated

	// OnRamp is the address of the onramp that sent the message.
	// NOTE: This is populated by the ccip reader. Not emitted explicitly onchain.
	OnRamp Bytes `json:"onRamp"`
}

RampMessageHeader is the family-agnostic header for OnRamp and OffRamp messages. The MessageID is not expected to match MsgHash, since it may originate from a different ramp family.

type RampTokenAmount

type RampTokenAmount struct {
	// SourcePoolAddress is the source pool address, encoded according to source family native encoding scheme.
	// This value is trusted as it was obtained through the onRamp. It can be relied upon by the destination
	// pool to validate the source pool.
	SourcePoolAddress Bytes `json:"sourcePoolAddress"`

	// DestTokenAddress is the address of the destination token, abi encoded in the case of EVM chains.
	// This value is UNTRUSTED as any pool owner can return whatever value they want.
	DestTokenAddress Bytes `json:"destTokenAddress"`

	// ExtraData is optional pool data to be transferred to the destination chain. Be default this is capped at
	// CCIP_LOCK_OR_BURN_V1_RET_BYTES bytes. If more data is required, the TokenTransferFeeConfig.destBytesOverhead
	// has to be set for the specific token.
	ExtraData Bytes `json:"extraData"`

	// Amount is the amount of tokens to be transferred.
	Amount BigInt `json:"amount"`

	// DestExecData is destination chain specific execution data encoded in bytes.
	// For an EVM destination, it consists of the amount of gas available for the releaseOrMint
	// and transfer calls made by the offRamp.
	// NOTE: this must be decoded before providing it as an execution input to the destination chain
	// or hashing it. See Internal._hash(Any2EVMRampMessage) for more details as an example.
	DestExecData Bytes `json:"destExecData"`
}

RampTokenAmount represents the family-agnostic token amounts used for both OnRamp & OffRamp messages.

type SeqNum

type SeqNum uint64

func (SeqNum) String

func (s SeqNum) String() string

type SeqNumRange

type SeqNumRange [2]SeqNum

SeqNumRange defines an inclusive range of sequence numbers.

func NewSeqNumRange

func NewSeqNumRange(start, end SeqNum) SeqNumRange

func (SeqNumRange) Contains

func (s SeqNumRange) Contains(seq SeqNum) bool

Contains returns true if the range contains the given sequence number.

func (SeqNumRange) End

func (s SeqNumRange) End() SeqNum

func (*SeqNumRange) Limit added in v0.3.0

func (s *SeqNumRange) Limit(n uint64) SeqNumRange

Limit returns a range limited up to n elements by truncating the end if necessary. Example: [1 -> 10].Limit(5) => [1 -> 5]

func (SeqNumRange) Overlaps

func (s SeqNumRange) Overlaps(other SeqNumRange) bool

Overlaps returns true if the two ranges overlap.

func (*SeqNumRange) SetEnd

func (s *SeqNumRange) SetEnd(v SeqNum)

func (*SeqNumRange) SetStart

func (s *SeqNumRange) SetStart(v SeqNum)

func (SeqNumRange) Start

func (s SeqNumRange) Start() SeqNum

func (SeqNumRange) String

func (s SeqNumRange) String() string

type TokenDataEncoder added in v0.3.0

type TokenDataEncoder interface {
	EncodeUSDC(ctx context.Context, message Bytes, attestation Bytes) (Bytes, error)
}

TokenDataEncoder is a generic interface for encoding offchain token data for different chain families. Right now it supports only USDC/CCTP, but every new token that requires offchain data processsing should be added to that interface and implemented in the downstream repositories (e.g. chainlink-ccip, chainlink).

type TokenPrice

type TokenPrice struct {
	TokenID types.Account `json:"tokenID"`
	Price   BigInt        `json:"price"`
}

func NewTokenPrice

func NewTokenPrice(tokenID types.Account, price *big.Int) TokenPrice

Jump to

Keyboard shortcuts

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