ccipocr3

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: MIT Imports: 19 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 NewChainAccessorClient

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

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]

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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