ccip

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 7 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address string

type Addresses

type Addresses []Address

func MakeAddresses

func MakeAddresses(s []string) Addresses

func (Addresses) Strings

func (a Addresses) Strings() []string

type CommitOffchainConfig

type CommitOffchainConfig struct {
	GasPriceDeviationPPB   uint32
	GasPriceHeartBeat      time.Duration
	TokenPriceDeviationPPB uint32
	TokenPriceHeartBeat    time.Duration
	InflightCacheExpiry    time.Duration
	PriceReportingDisabled bool
}

type CommitStoreInterval

type CommitStoreInterval struct {
	Min uint64
	Max uint64
}

type CommitStoreReader

type CommitStoreReader interface {
	// ChangeConfig notifies the reader that the config has changed onchain
	ChangeConfig(ctx context.Context, onchainConfig []byte, offchainConfig []byte) (Address, error)
	DecodeCommitReport(ctx context.Context, report []byte) (CommitStoreReport, error)
	EncodeCommitReport(ctx context.Context, report CommitStoreReport) ([]byte, error)
	GasPriceEstimator(ctx context.Context) (GasPriceEstimatorCommit, error)
	// GetAcceptedCommitReportsGteTimestamp returns all the commit reports with timestamp greater than or equal to the provided.
	// Returned Commit Reports have to be sorted by Interval.Min/Interval.Max in ascending order.
	GetAcceptedCommitReportsGteTimestamp(ctx context.Context, ts time.Time, confirmations int) ([]CommitStoreReportWithTxMeta, error)
	// GetCommitReportMatchingSeqNum returns accepted commit report that satisfies Interval.Min <= seqNum <= Interval.Max. Returned slice should be empty or have exactly one element
	GetCommitReportMatchingSeqNum(ctx context.Context, seqNum uint64, confirmations int) ([]CommitStoreReportWithTxMeta, error)
	GetCommitStoreStaticConfig(ctx context.Context) (CommitStoreStaticConfig, error)
	GetExpectedNextSequenceNumber(ctx context.Context) (uint64, error)
	GetLatestPriceEpochAndRound(ctx context.Context) (uint64, error)
	IsBlessed(ctx context.Context, root [32]byte) (bool, error)
	// IsDestChainHealthy returns true if the destination chain is healthy.
	IsDestChainHealthy(ctx context.Context) (bool, error)
	IsDown(ctx context.Context) (bool, error)
	OffchainConfig(ctx context.Context) (CommitOffchainConfig, error)
	VerifyExecutionReport(ctx context.Context, report ExecReport) (bool, error)

	io.Closer
}

type CommitStoreReport

type CommitStoreReport struct {
	TokenPrices []TokenPrice
	GasPrices   []GasPrice
	Interval    CommitStoreInterval
	MerkleRoot  [32]byte
}

type CommitStoreReportWithTxMeta

type CommitStoreReportWithTxMeta struct {
	TxMeta
	CommitStoreReport
}

type CommitStoreStaticConfig

type CommitStoreStaticConfig struct {
	ChainSelector       uint64
	SourceChainSelector uint64
	OnRamp              Address
	ArmProxy            Address
}

type CommonGasPriceEstimator

type CommonGasPriceEstimator interface {
	// GetGasPrice fetches the current gas price.
	GetGasPrice(ctx context.Context) (*big.Int, error)
	// DenoteInUSD converts the gas price to be in units of USD. Input prices should not be nil.
	DenoteInUSD(p *big.Int, wrappedNativePrice *big.Int) (*big.Int, error)
	// TODO CCIP-1882: reconcile gas price estimator to remove unnecessary interface funcs
	// this can be a helper function implementation detail. not needed in the interface
	// Median finds the median gas price in slice. If gas price has multiple components, median of each individual component should be taken. Input prices should not contain nil.
	Median(gasPrices []*big.Int) (*big.Int, error)
}

CommonGasPriceEstimator is abstraction over multi-component gas prices. TODO CCIP-1882: reconcile gas price estimator to remove unnecessary interface funcs

type EVM2EVMMessage

type EVM2EVMMessage struct {
	SequenceNumber      uint64
	GasLimit            *big.Int
	Nonce               uint64
	MessageID           Hash
	SourceChainSelector uint64
	Sender              Address
	Receiver            Address
	Strict              bool
	FeeToken            Address
	FeeTokenAmount      *big.Int
	Data                []byte
	TokenAmounts        []TokenAmount
	SourceTokenData     [][]byte

	// Computed
	Hash Hash
}

EVM2EVMMessage is the interface for a message sent from the off-ramp to the on-ramp Plugin can operate against any lane version which has a message satisfying this interface.

type EVM2EVMMessageWithTxMeta

type EVM2EVMMessageWithTxMeta struct {
	TxMeta
	EVM2EVMMessage
}

type EVM2EVMOnRampCCIPSendRequestedWithMeta

type EVM2EVMOnRampCCIPSendRequestedWithMeta struct {
	EVM2EVMMessage
	BlockTimestamp time.Time
	Executed       bool
	Finalized      bool
	LogIndex       uint
	TxHash         string
}

EVM2EVMOnRampCCIPSendRequestedWithMeta helper struct to hold the send request and some metadata

type ExecOffchainConfig

type ExecOffchainConfig struct {
	// DestOptimisticConfirmations is how many confirmations to wait for the dest chain event before we consider it
	// confirmed (optimistically, need not be finalized).
	DestOptimisticConfirmations uint32
	// BatchGasLimit is the maximum sum of user callback gas we permit in one execution report.
	BatchGasLimit uint32
	// RelativeBoostPerWaitHour indicates how much to increase (artificially) the fee paid on the source chain per hour
	// of wait time, such that eventually the fee paid is greater than the execution cost, and we’ll execute it.
	// For example: if set to 0.5, that means the fee paid is increased by 50% every hour the message has been waiting.
	RelativeBoostPerWaitHour float64
	// InflightCacheExpiry indicates how long we keep a report in the plugin cache before we expire it.
	// The caching prevents us from issuing another report while one is already in flight.
	InflightCacheExpiry config.Duration
	// RootSnoozeTime is the interval at which we check roots for executable messages.
	RootSnoozeTime config.Duration
	// MessageVisibilityInterval is the interval at which we check for new messages.
	MessageVisibilityInterval config.Duration
	// BatchingStrategyID is the strategy to use for batching messages.
	BatchingStrategyID uint32
}

ExecOffchainConfig specifies configuration for nodes executing committed messages.

type ExecOnchainConfig

type ExecOnchainConfig struct {
	PermissionLessExecutionThresholdSeconds time.Duration
	Router                                  Address
	MaxDataBytes                            uint32
	MaxNumberOfTokensPerMsg                 uint16
	PriceRegistry                           Address
	MaxPoolReleaseOrMintGas                 uint32
	MaxTokenTransferGas                     uint32
}

func (ExecOnchainConfig) Validate

func (c ExecOnchainConfig) Validate() error

type ExecReport

type ExecReport struct {
	Messages          []EVM2EVMMessage
	OffchainTokenData [][][]byte
	Proofs            [][32]byte
	ProofFlagBits     *big.Int
}

type ExecutionStateChanged

type ExecutionStateChanged struct {
	SequenceNumber uint64
	Finalized      bool
}

type ExecutionStateChangedWithTxMeta

type ExecutionStateChangedWithTxMeta struct {
	TxMeta
	ExecutionStateChanged
}

type GasPrice

type GasPrice struct {
	DestChainSelector uint64
	Value             *big.Int
}

type GasPriceEstimator

type GasPriceEstimator interface {
	GasPriceEstimatorCommit
	GasPriceEstimatorExec
}

type GasPriceEstimatorCommit

type GasPriceEstimatorCommit interface {
	CommonGasPriceEstimator

	// TODO CCIP-1882: reconcile gas price estimator to remove unnecessary interface funcs
	// this can be a helper function implementation detail. not needed in the interface
	// Deviates checks if p1 gas price diffs from p2 by deviation options. Input prices should not be nil.
	Deviates(p1 *big.Int, p2 *big.Int) (bool, error)
}

type GasPriceEstimatorExec

type GasPriceEstimatorExec interface {
	CommonGasPriceEstimator

	// EstimateMsgCostUSD estimates the costs for msg execution, and converts to USD value scaled by 1e18 (e.g. 5$ = 5e18).
	EstimateMsgCostUSD(p *big.Int, wrappedNativePrice *big.Int, msg EVM2EVMOnRampCCIPSendRequestedWithMeta) (*big.Int, error)
}

GasPriceEstimatorExec provides gasPriceEstimatorCommon + features needed in exec plugin, e.g. message cost estimation.

type GasPriceUpdate

type GasPriceUpdate struct {
	GasPrice
	TimestampUnixSec *big.Int
}

GasPriceUpdate represents a gas price at the last it was quoted.

type GasPriceUpdateWithTxMeta

type GasPriceUpdateWithTxMeta struct {
	TxMeta
	GasPriceUpdate
}

GasPriceUpdateWithTxMeta represents a gas price update with transaction metadata.

type Hash

type Hash [32]byte

func (Hash) String

func (h Hash) String() string

type MessageExecutionState

type MessageExecutionState uint8

MessageExecutionState defines the execution states of CCIP messages.

const (
	ExecutionStateUntouched MessageExecutionState = iota
	ExecutionStateInProgress
	ExecutionStateSuccess
	ExecutionStateFailure
)

type OffRampReader

type OffRampReader interface {
	Address(ctx context.Context) (Address, error)
	// ChangeConfig notifies the reader that the config has changed onchain
	ChangeConfig(ctx context.Context, onchainConfig []byte, offchainConfig []byte) (Address, Address, error)
	CurrentRateLimiterState(ctx context.Context) (TokenBucketRateLimit, error)
	// DecodeExecutionReport will error if messages are not a compatible version.
	DecodeExecutionReport(ctx context.Context, report []byte) (ExecReport, error)
	// EncodeExecutionReport will error if messages are not a compatible version.
	EncodeExecutionReport(ctx context.Context, report ExecReport) ([]byte, error)
	// GasPriceEstimator returns the gas price estimator for the offramp.
	GasPriceEstimator(ctx context.Context) (GasPriceEstimatorExec, error)
	GetExecutionState(ctx context.Context, sequenceNumber uint64) (uint8, error)
	// GetExecutionStateChangesBetweenSeqNums returns all the execution state change events for the provided message sequence numbers (inclusive).
	GetExecutionStateChangesBetweenSeqNums(ctx context.Context, seqNumMin, seqNumMax uint64, confirmations int) ([]ExecutionStateChangedWithTxMeta, error)
	GetRouter(ctx context.Context) (Address, error)
	ListSenderNonces(ctx context.Context, senders []Address) (map[Address]uint64, error)
	GetSourceToDestTokensMapping(ctx context.Context) (map[Address]Address, error)
	GetStaticConfig(ctx context.Context) (OffRampStaticConfig, error)
	GetTokens(ctx context.Context) (OffRampTokens, error)
	OffchainConfig(ctx context.Context) (ExecOffchainConfig, error)
	OnchainConfig(ctx context.Context) (ExecOnchainConfig, error)

	io.Closer
}

OffRampReader all methods need to accept a context and return an error

type OffRampStaticConfig

type OffRampStaticConfig struct {
	CommitStore         Address
	ChainSelector       uint64
	SourceChainSelector uint64
	OnRamp              Address
	PrevOffRamp         Address
	ArmProxy            Address
}

type OffRampTokens

type OffRampTokens struct {
	DestinationTokens []Address
	SourceTokens      []Address
}

type OnRampDynamicConfig

type OnRampDynamicConfig struct {
	Router                            Address
	MaxNumberOfTokensPerMsg           uint16
	DestGasOverhead                   uint32
	DestGasPerPayloadByte             uint16
	DestDataAvailabilityOverheadGas   uint32
	DestGasPerDataAvailabilityByte    uint16
	DestDataAvailabilityMultiplierBps uint16
	PriceRegistry                     Address
	MaxDataBytes                      uint32
	MaxPerMsgGasLimit                 uint32
}

type OnRampReader

type OnRampReader interface {
	Address(ctx context.Context) (Address, error)
	GetDynamicConfig(ctx context.Context) (OnRampDynamicConfig, error)
	// GetSendRequestsBetweenSeqNums returns all the finalized message send requests in the provided sequence numbers range (inclusive).
	GetSendRequestsBetweenSeqNums(ctx context.Context, seqNumMin, seqNumMax uint64, finalized bool) ([]EVM2EVMMessageWithTxMeta, error)
	// IsSourceChainHealthy returns true if the source chain is healthy.
	IsSourceChainHealthy(ctx context.Context) (bool, error)
	// IsSourceCursed returns true if the source chain is cursed. OnRamp communicates with the underlying RMN
	// to verify if source chain was cursed or not.
	IsSourceCursed(ctx context.Context) (bool, error)
	// RouterAddress returns the router address that is configured on the onRamp
	RouterAddress(context.Context) (Address, error)
	// SourcePriceRegistryAddress returns the address of the current price registry configured on the onRamp.
	SourcePriceRegistryAddress(ctx context.Context) (Address, error)
	io.Closer
}

type PriceGetter

type PriceGetter interface {
	// FilterConfiguredTokens filters a list of token addresses
	// for only those that are configured to be able to get a price and those that aren't
	FilterConfiguredTokens(ctx context.Context, tokens []Address) (configured []Address, unconfigured []Address, err error)
	// TokenPricesUSD returns token prices in USD.
	// Note: The result might contain tokens that are not passed with the 'tokens' param.
	//       The opposite cannot happen, an error will be returned if a token price was not found.
	TokenPricesUSD(ctx context.Context, tokens []Address) (map[Address]*big.Int, error)
	io.Closer
}

type PriceRegistryFactory

type PriceRegistryFactory interface {
	NewPriceRegistryReader(ctx context.Context, addr Address) (PriceRegistryReader, error)
}

type PriceRegistryReader

type PriceRegistryReader interface {
	// GetTokenPriceUpdatesCreatedAfter returns all the token price updates that happened after the provided timestamp.
	// The returned updates are sorted by timestamp in ascending order.
	GetTokenPriceUpdatesCreatedAfter(ctx context.Context, ts time.Time, confirmations int) ([]TokenPriceUpdateWithTxMeta, error)

	// GetGasPriceUpdatesCreatedAfter returns all the gas price updates that happened after the provided timestamp.
	// The returned updates are sorted by timestamp in ascending order.
	GetGasPriceUpdatesCreatedAfter(ctx context.Context, chainSelector uint64, ts time.Time, confirmations int) ([]GasPriceUpdateWithTxMeta, error)

	// GetAllGasPriceUpdatesCreatedAfter returns all the gas price updates that happened after the provided timestamp for all chain selectors.
	// The returned updates are sorted by timestamp in ascending order.
	GetAllGasPriceUpdatesCreatedAfter(ctx context.Context, ts time.Time, confirmations int) ([]GasPriceUpdateWithTxMeta, error)

	// Address returns the address of the price registry.
	Address(ctx context.Context) (Address, error)

	GetFeeTokens(ctx context.Context) ([]Address, error)

	// GetTokenPrices returns the latest price and time of quote of the given tokens.
	GetTokenPrices(ctx context.Context, wantedTokens []Address) ([]TokenPriceUpdate, error)

	GetTokensDecimals(ctx context.Context, tokenAddresses []Address) ([]uint8, error)

	Close() error
}

type TokenAmount

type TokenAmount struct {
	Token  Address
	Amount *big.Int
}

type TokenBucketRateLimit

type TokenBucketRateLimit struct {
	Tokens      *big.Int
	LastUpdated uint32
	IsEnabled   bool
	Capacity    *big.Int
	Rate        *big.Int
}

type TokenDataReader

type TokenDataReader interface {
	// ReadTokenData returns the attestation bytes if ready, and throws an error if not ready.
	// It supports messages with a single token transfer, the returned []byte has the token data for the first token of the msg.
	ReadTokenData(ctx context.Context, msg EVM2EVMOnRampCCIPSendRequestedWithMeta, tokenIndex int) (tokenData []byte, err error)
	io.Closer
}

type TokenPoolBatchedReader

type TokenPoolBatchedReader interface {
	GetInboundTokenPoolRateLimits(ctx context.Context, tokenPoolReaders []Address) ([]TokenBucketRateLimit, error)
	io.Closer
}

type TokenPrice

type TokenPrice struct {
	Token Address
	Value *big.Int
}

type TokenPriceUpdate

type TokenPriceUpdate struct {
	TokenPrice
	TimestampUnixSec *big.Int
}

TokenPriceUpdate represents a token price at the last it was quoted.

type TokenPriceUpdateWithTxMeta

type TokenPriceUpdateWithTxMeta struct {
	TxMeta
	TokenPriceUpdate
}

type TxMeta

type TxMeta struct {
	BlockTimestampUnixMilli int64
	BlockNumber             uint64
	TxHash                  string
	LogIndex                uint64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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