ccipocr3

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 21 Imported by: 0

README

CCIP OCR3 Provider gRPC Implementation

This package implements the gRPC-based adapter for the CCIPProvider interface, following the pattern established by the median provider implementation.

Overview

The CCIPProvider interface requires three main components:

  1. ChainAccessor - For all direct chain access operations
  2. ContractTransmitter - For OCR3 contract transmission (reuses existing OCR3 implementation)
  3. Codec - For encoding/decoding various types of CCIP data

Files

  • ccip_provider.go - Main CCIPProvider client/server implementation
  • chainaccessor.go - ChainAccessor gRPC client/server
  • codec.go - Codec interfaces gRPC client/server implementations
  • helpers.go - Helper functions and type conversions
  • chainaccessor.proto - Protocol buffer definitions for ChainAccessor
  • codec.proto - Protocol buffer definitions for Codec interfaces

Architecture

The implementation follows the established gRPC adapter pattern:

  1. Client Side: Wraps gRPC clients to implement Go interfaces
  2. Server Side: Wraps Go interface implementations to serve gRPC requests
  3. Protocol Buffers: Define the wire format for all method calls
  4. Type Conversion: Convert between Go types and protobuf types

Components

ChainAccessor

Implements the complete ChainAccessor interface with methods for:

  • AllAccessors: Common functionality (GetContractAddress, GetAllConfigsLegacy, etc.)
  • DestinationAccessor: Destination chain operations (CommitReports, ExecutedMessages, etc.)
  • SourceAccessor: Source chain operations (MsgsBetweenSeqNums, TokenPriceUSD, etc.)
Codec

Implements all codec interfaces:

  • ChainSpecificAddressCodec: Address encoding/decoding
  • CommitPluginCodec: Commit plugin report encoding/decoding (reuses existing)
  • ExecutePluginCodec: Execute plugin report encoding/decoding
  • TokenDataEncoder: Token data encoding (USDC/CCTP)
  • SourceChainExtraDataCodec: Source chain extra data decoding
ContractTransmitter

Reuses the existing OCR3 ContractTransmitter gRPC implementation from pkg/loop/internal/relayer/pluginprovider/ocr3/.

Usage

// Server side - register all services
func RegisterProviderServices(s *grpc.Server, provider types.CCIPProvider) {
    ccipocr3.RegisterProviderServices(s, provider)
}

// Client side - create provider client
func ConnToProvider(conn grpc.ClientConnInterface, broker net.Broker, brokerCfg net.BrokerConfig) types.CCIPProvider {
    be := &net.BrokerExt{Broker: broker, BrokerConfig: brokerCfg}
    return ccipocr3.NewProviderClient(be, conn)
}

Development Notes

  • Type conversions between Go and protobuf types are handled in helper functions
  • Complex types like maps and nested structures require careful conversion
  • Error handling follows gRPC best practices
  • The implementation is designed to be compatible with the existing LOOP infrastructure

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewChainAccessorServer

func NewChainAccessorServer(impl ccipocr3.ChainAccessor) *chainAccessorServer

func NewChainSpecificAddressCodecServer

func NewChainSpecificAddressCodecServer(impl ccipocr3.ChainSpecificAddressCodec) *chainSpecificAddressCodecServer

func NewCommitPluginCodecClient

func NewCommitPluginCodecClient(broker *net.BrokerExt, cc grpc.ClientConnInterface) ccipocr3.CommitPluginCodec

func NewExecutePluginCodecClient

func NewExecutePluginCodecClient(broker *net.BrokerExt, cc grpc.ClientConnInterface) ccipocr3.ExecutePluginCodec

func NewTokenDataEncoderClient

func NewTokenDataEncoderClient(broker *net.BrokerExt, cc grpc.ClientConnInterface) ccipocr3.TokenDataEncoder

func RegisterProviderServices

func RegisterProviderServices(s *grpc.Server, provider types.CCIPProvider)

Types

type CCIPProviderClient

type CCIPProviderClient struct {
	*goplugin.ServiceClient
	// contains filtered or unexported fields
}

func (*CCIPProviderClient) ChainAccessor

func (p *CCIPProviderClient) ChainAccessor() ccipocr3.ChainAccessor

func (*CCIPProviderClient) Codec

func (p *CCIPProviderClient) Codec() ccipocr3.Codec

func (*CCIPProviderClient) ContractTransmitter

func (p *CCIPProviderClient) ContractTransmitter() ocr3types.ContractTransmitter[[]byte]

func (*CCIPProviderClient) GetSyncRequests added in v0.9.5

func (p *CCIPProviderClient) GetSyncRequests() map[string][]byte

type CCIPProviderServer

type CCIPProviderServer struct{}

Server implementation

func (CCIPProviderServer) ConnToProvider

func (s CCIPProviderServer) ConnToProvider(conn grpc.ClientConnInterface, broker net.Broker, brokerCfg net.BrokerConfig) types.CCIPProvider

type ChainAccessorClient added in v0.9.5

type ChainAccessorClient struct {
	*net.BrokerExt
	// contains filtered or unexported fields
}

func NewChainAccessorClient

func NewChainAccessorClient(broker *net.BrokerExt, cc grpc.ClientConnInterface) *ChainAccessorClient

func (*ChainAccessorClient) CommitReportsGTETimestamp added in v0.9.5

func (c *ChainAccessorClient) CommitReportsGTETimestamp(
	ctx context.Context,
	ts time.Time,
	confidence primitives.ConfidenceLevel,
	limit int,
) ([]ccipocr3.CommitPluginReportWithMeta, error)

DestinationAccessor methods

func (*ChainAccessorClient) ExecutedMessages added in v0.9.5

func (*ChainAccessorClient) GetAllConfigsLegacy added in v0.9.5

func (c *ChainAccessorClient) GetAllConfigsLegacy(
	ctx context.Context,
	destChainSelector ccipocr3.ChainSelector,
	sourceChainSelectors []ccipocr3.ChainSelector,
) (ccipocr3.ChainConfigSnapshot, map[ccipocr3.ChainSelector]ccipocr3.SourceChainConfig, error)

func (*ChainAccessorClient) GetChainFeeComponents added in v0.9.5

func (c *ChainAccessorClient) GetChainFeeComponents(ctx context.Context) (ccipocr3.ChainFeeComponents, error)

func (*ChainAccessorClient) GetChainFeePriceUpdate added in v0.9.5

func (*ChainAccessorClient) GetContractAddress added in v0.9.5

func (c *ChainAccessorClient) GetContractAddress(contractName string) ([]byte, error)

AllAccessors methods

func (*ChainAccessorClient) GetExpectedNextSequenceNumber added in v0.9.5

func (c *ChainAccessorClient) GetExpectedNextSequenceNumber(ctx context.Context, dest ccipocr3.ChainSelector) (ccipocr3.SeqNum, error)

func (*ChainAccessorClient) GetFeeQuoterDestChainConfig added in v0.9.5

func (c *ChainAccessorClient) GetFeeQuoterDestChainConfig(ctx context.Context, dest ccipocr3.ChainSelector) (ccipocr3.FeeQuoterDestChainConfig, error)

func (*ChainAccessorClient) GetFeeQuoterTokenUpdates added in v0.9.5

func (*ChainAccessorClient) GetFeedPricesUSD added in v0.9.5

PriceReader methods

func (*ChainAccessorClient) GetLatestPriceSeqNr added in v0.9.5

func (c *ChainAccessorClient) GetLatestPriceSeqNr(ctx context.Context) (ccipocr3.SeqNum, error)

func (*ChainAccessorClient) GetSyncRequests added in v0.9.5

func (c *ChainAccessorClient) GetSyncRequests() map[string]ccipocr3.UnknownAddress

func (*ChainAccessorClient) GetTokenPriceUSD added in v0.9.5

func (*ChainAccessorClient) LatestMessageTo added in v0.9.5

func (c *ChainAccessorClient) LatestMessageTo(ctx context.Context, dest ccipocr3.ChainSelector) (ccipocr3.SeqNum, error)

func (*ChainAccessorClient) MessagesByTokenID added in v0.9.5

USDCMessageReader methods

func (*ChainAccessorClient) MsgsBetweenSeqNums added in v0.9.5

func (c *ChainAccessorClient) MsgsBetweenSeqNums(ctx context.Context, dest ccipocr3.ChainSelector, seqNumRange ccipocr3.SeqNumRange) ([]ccipocr3.Message, error)

SourceAccessor methods

func (*ChainAccessorClient) NextSeqNum added in v0.9.5

func (*ChainAccessorClient) Nonces added in v0.9.5

func (*ChainAccessorClient) Sync added in v0.9.5

func (c *ChainAccessorClient) Sync(ctx context.Context, contractName string, contractAddress ccipocr3.UnknownAddress) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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