Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/loop/ccip_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ func TestCCIPChainAccessorSyncPersistence(t *testing.T) {
ExternalJobID: uuid.New(),
ContractReaderConfig: []byte("asdf"),
ChainWriterConfig: []byte("asdf"),
OffRampAddress: "0x1234123412341234123412341234123412341234",
OffRampAddress: []byte("0x1234123412341234123412341234123412341234"),
PluginType: 0,
TransmitterAddress: "0x4321432143214321432143214321432143214321",
})
require.NoError(t, err)
require.NotNil(t, ccipProvider)
Expand Down
30 changes: 20 additions & 10 deletions pkg/loop/internal/pb/relayer.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion pkg/loop/internal/pb/relayer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ message CCIPProviderArgs {
bytes externalJobID = 1; // [32]byte
bytes contractReaderConfig = 2;
bytes chainWriterConfig = 3;
string OffRampAddress = 4;
bytes offRampAddress = 4;
// pluginType is actually a uint8 but uint32 is the smallest supported by protobuf
uint32 pluginType = 5;
map<string, bytes> synced_addresses = 6; // map[contract_name]contract_address
string transmitterAddress = 7;
Comment on lines +63 to +67
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you had mentioned bytes offRampAddress is easier to manage if it's passed in as bytes, does the same apply for transmitterAddress?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping transmitter as a string is ok since we don't have to decode it. It's just used to serve as a string out of the transmitter here

}

// NewContractWriterRequest has request parameters for [github.com/smartcontractkit/chainlink-common/pkg/loop.Relayer.NewContractWriter].
Expand Down
7 changes: 5 additions & 2 deletions pkg/loop/internal/relayer/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/loop/internal/relayer/pluginprovider/ocr2"
looptypes "github.com/smartcontractkit/chainlink-common/pkg/loop/internal/types"
"github.com/smartcontractkit/chainlink-common/pkg/types"
ccipocr3types "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"
"github.com/smartcontractkit/chainlink-common/pkg/types/core"
)

Expand Down Expand Up @@ -298,8 +299,9 @@ func (r *relayerClient) NewCCIPProvider(ctx context.Context, cargs types.CCIPPro
ContractReaderConfig: cargs.ContractReaderConfig,
ChainWriterConfig: cargs.ChainWriterConfig,
OffRampAddress: cargs.OffRampAddress,
PluginType: cargs.PluginType,
PluginType: uint32(cargs.PluginType),
SyncedAddresses: persistedSyncs,
TransmitterAddress: string(cargs.TransmitterAddress),
},
})
if err != nil {
Expand Down Expand Up @@ -731,7 +733,8 @@ func (r *relayerServer) NewCCIPProvider(ctx context.Context, request *pb.NewCCIP
ContractReaderConfig: rargs.ContractReaderConfig,
ChainWriterConfig: rargs.ChainWriterConfig,
OffRampAddress: rargs.OffRampAddress,
PluginType: rargs.PluginType,
PluginType: ccipocr3types.PluginType(rargs.PluginType),
TransmitterAddress: ccipocr3types.UnknownEncodedAddress(rargs.TransmitterAddress),
}

provider, err := r.impl.NewCCIPProvider(ctx, ccipProviderArgs)
Expand Down
15 changes: 10 additions & 5 deletions pkg/loop/internal/relayer/test/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/services"
"github.com/smartcontractkit/chainlink-common/pkg/services/servicetest"
"github.com/smartcontractkit/chainlink-common/pkg/types"
"github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"
"github.com/smartcontractkit/chainlink-common/pkg/types/core"
)

Expand Down Expand Up @@ -74,8 +75,9 @@ type staticRelayerConfig struct {
pluginArgs types.PluginArgs
contractReaderConfig []byte
chainWriterConfig []byte
offRampAddress string
pluginType uint32
offRampAddress ccipocr3.UnknownAddress
pluginType ccipocr3.PluginType
transmitterAddress ccipocr3.UnknownEncodedAddress
medianProvider testtypes.MedianProviderTester
agnosticProvider testtypes.PluginProviderTester
mercuryProvider mercurytest.MercuryProviderTester
Expand All @@ -101,8 +103,9 @@ func newStaticRelayerConfig(lggr logger.Logger, staticChecks bool) staticRelayer
pluginArgs: PluginArgs,
contractReaderConfig: []byte("test"),
chainWriterConfig: []byte("chainwriterconfig"),
offRampAddress: "fakeAddress",
offRampAddress: []byte("fakeAddress"),
pluginType: 0,
transmitterAddress: "fakeAddress",
medianProvider: mediantest.MedianProvider(lggr),
mercuryProvider: mercurytest.MercuryProvider(lggr),
executionProvider: cciptest.ExecutionProvider(lggr),
Expand Down Expand Up @@ -320,6 +323,7 @@ func (s staticRelayer) NewCCIPProvider(ctx context.Context, r types.CCIPProvider
ChainWriterConfig: s.chainWriterConfig,
OffRampAddress: s.offRampAddress,
PluginType: s.pluginType,
TransmitterAddress: s.transmitterAddress,
}
if s.StaticChecks && !equalCCIPProviderArgs(r, ccipProviderArgs) {
return nil, fmt.Errorf("expected relay args:\n\t%v\nbut got:\n\t%v", s.relayArgs, r)
Expand Down Expand Up @@ -477,8 +481,9 @@ func equalCCIPProviderArgs(a, b types.CCIPProviderArgs) bool {
return a.ExternalJobID == b.ExternalJobID &&
slices.Equal(a.ContractReaderConfig, b.ContractReaderConfig) &&
slices.Equal(a.ChainWriterConfig, b.ChainWriterConfig) &&
a.OffRampAddress == b.OffRampAddress &&
a.PluginType == b.PluginType
slices.Equal(a.OffRampAddress, b.OffRampAddress) &&
a.PluginType == b.PluginType &&
a.TransmitterAddress == b.TransmitterAddress
}

func newRelayArgsWithProviderType(_type types.OCR2PluginType) types.RelayArgs {
Expand Down
30 changes: 30 additions & 0 deletions pkg/types/ccipocr3/generic_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,3 +373,33 @@ func (ca ContractAddresses) Append(contract string, chain ChainSelector, address
resp[contract][chain] = address
return resp
}

// PluginType represents the type of CCIP plugin.
// It mirrors the OCRPluginType in Internal.sol.
type PluginType uint8

const (
PluginTypeCCIPCommit PluginType = 0
PluginTypeCCIPExec PluginType = 1
)

func (pt PluginType) String() string {
switch pt {
case PluginTypeCCIPCommit:
return "CCIPCommit"
case PluginTypeCCIPExec:
return "CCIPExec"
default:
return "Unknown"
}
}

// ExtraDataDecoded contains a generic representation of chain specific message parameters. A
// map from string to any is used to account for different parameters required for sending messages
// to different destinations.
type ExtraDataDecoded struct {
// ExtraArgsDecoded contain message specific extra args.
ExtraArgsDecoded map[string]any
// DestExecDataDecoded contain token transfer specific extra args.
DestExecDataDecoded []map[string]any
}
10 changes: 7 additions & 3 deletions pkg/types/provider_ccip.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ type CCIPProvider interface {
// CCIPProviderArgs are the args required to create a CCIP Provider through a Relayer.
// The are common to all relayer implementations.
type CCIPProviderArgs struct {
ExternalJobID uuid.UUID
ExternalJobID uuid.UUID
OffRampAddress ccipocr3.UnknownAddress
PluginType ccipocr3.PluginType
TransmitterAddress ccipocr3.UnknownEncodedAddress

// These CR/CW configs are only used by accessors that still rely on ChainReader
// and ChainWriter, like SolanaAccessor.
ContractReaderConfig []byte
ChainWriterConfig []byte
OffRampAddress string
PluginType uint32
}
Loading