Skip to content

Commit 853372a

Browse files
authored
Updated CCIP provider args and types (#1561)
1 parent a30db46 commit 853372a

File tree

7 files changed

+77
-22
lines changed

7 files changed

+77
-22
lines changed

pkg/loop/ccip_provider_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ func TestCCIPChainAccessorSyncPersistence(t *testing.T) {
5656
ExternalJobID: uuid.New(),
5757
ContractReaderConfig: []byte("asdf"),
5858
ChainWriterConfig: []byte("asdf"),
59-
OffRampAddress: "0x1234123412341234123412341234123412341234",
59+
OffRampAddress: []byte("0x1234123412341234123412341234123412341234"),
6060
PluginType: 0,
61+
TransmitterAddress: "0x4321432143214321432143214321432143214321",
6162
})
6263
require.NoError(t, err)
6364
require.NotNil(t, ccipProvider)

pkg/loop/internal/pb/relayer.pb.go

Lines changed: 20 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/loop/internal/pb/relayer.proto

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ message CCIPProviderArgs {
6060
bytes externalJobID = 1; // [32]byte
6161
bytes contractReaderConfig = 2;
6262
bytes chainWriterConfig = 3;
63-
string OffRampAddress = 4;
63+
bytes offRampAddress = 4;
64+
// pluginType is actually a uint8 but uint32 is the smallest supported by protobuf
6465
uint32 pluginType = 5;
6566
map<string, bytes> synced_addresses = 6; // map[contract_name]contract_address
67+
string transmitterAddress = 7;
6668
}
6769

6870
// NewContractWriterRequest has request parameters for [github.com/smartcontractkit/chainlink-common/pkg/loop.Relayer.NewContractWriter].

pkg/loop/internal/relayer/relayer.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/smartcontractkit/chainlink-common/pkg/loop/internal/relayer/pluginprovider/ocr2"
3232
looptypes "github.com/smartcontractkit/chainlink-common/pkg/loop/internal/types"
3333
"github.com/smartcontractkit/chainlink-common/pkg/types"
34+
ccipocr3types "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"
3435
"github.com/smartcontractkit/chainlink-common/pkg/types/core"
3536
)
3637

@@ -298,8 +299,9 @@ func (r *relayerClient) NewCCIPProvider(ctx context.Context, cargs types.CCIPPro
298299
ContractReaderConfig: cargs.ContractReaderConfig,
299300
ChainWriterConfig: cargs.ChainWriterConfig,
300301
OffRampAddress: cargs.OffRampAddress,
301-
PluginType: cargs.PluginType,
302+
PluginType: uint32(cargs.PluginType),
302303
SyncedAddresses: persistedSyncs,
304+
TransmitterAddress: string(cargs.TransmitterAddress),
303305
},
304306
})
305307
if err != nil {
@@ -731,7 +733,8 @@ func (r *relayerServer) NewCCIPProvider(ctx context.Context, request *pb.NewCCIP
731733
ContractReaderConfig: rargs.ContractReaderConfig,
732734
ChainWriterConfig: rargs.ChainWriterConfig,
733735
OffRampAddress: rargs.OffRampAddress,
734-
PluginType: rargs.PluginType,
736+
PluginType: ccipocr3types.PluginType(rargs.PluginType),
737+
TransmitterAddress: ccipocr3types.UnknownEncodedAddress(rargs.TransmitterAddress),
735738
}
736739

737740
provider, err := r.impl.NewCCIPProvider(ctx, ccipProviderArgs)

pkg/loop/internal/relayer/test/relayer.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/smartcontractkit/chainlink-common/pkg/services"
3232
"github.com/smartcontractkit/chainlink-common/pkg/services/servicetest"
3333
"github.com/smartcontractkit/chainlink-common/pkg/types"
34+
"github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"
3435
"github.com/smartcontractkit/chainlink-common/pkg/types/core"
3536
)
3637

@@ -74,8 +75,9 @@ type staticRelayerConfig struct {
7475
pluginArgs types.PluginArgs
7576
contractReaderConfig []byte
7677
chainWriterConfig []byte
77-
offRampAddress string
78-
pluginType uint32
78+
offRampAddress ccipocr3.UnknownAddress
79+
pluginType ccipocr3.PluginType
80+
transmitterAddress ccipocr3.UnknownEncodedAddress
7981
medianProvider testtypes.MedianProviderTester
8082
agnosticProvider testtypes.PluginProviderTester
8183
mercuryProvider mercurytest.MercuryProviderTester
@@ -101,8 +103,9 @@ func newStaticRelayerConfig(lggr logger.Logger, staticChecks bool) staticRelayer
101103
pluginArgs: PluginArgs,
102104
contractReaderConfig: []byte("test"),
103105
chainWriterConfig: []byte("chainwriterconfig"),
104-
offRampAddress: "fakeAddress",
106+
offRampAddress: []byte("fakeAddress"),
105107
pluginType: 0,
108+
transmitterAddress: "fakeAddress",
106109
medianProvider: mediantest.MedianProvider(lggr),
107110
mercuryProvider: mercurytest.MercuryProvider(lggr),
108111
executionProvider: cciptest.ExecutionProvider(lggr),
@@ -320,6 +323,7 @@ func (s staticRelayer) NewCCIPProvider(ctx context.Context, r types.CCIPProvider
320323
ChainWriterConfig: s.chainWriterConfig,
321324
OffRampAddress: s.offRampAddress,
322325
PluginType: s.pluginType,
326+
TransmitterAddress: s.transmitterAddress,
323327
}
324328
if s.StaticChecks && !equalCCIPProviderArgs(r, ccipProviderArgs) {
325329
return nil, fmt.Errorf("expected relay args:\n\t%v\nbut got:\n\t%v", s.relayArgs, r)
@@ -477,8 +481,9 @@ func equalCCIPProviderArgs(a, b types.CCIPProviderArgs) bool {
477481
return a.ExternalJobID == b.ExternalJobID &&
478482
slices.Equal(a.ContractReaderConfig, b.ContractReaderConfig) &&
479483
slices.Equal(a.ChainWriterConfig, b.ChainWriterConfig) &&
480-
a.OffRampAddress == b.OffRampAddress &&
481-
a.PluginType == b.PluginType
484+
slices.Equal(a.OffRampAddress, b.OffRampAddress) &&
485+
a.PluginType == b.PluginType &&
486+
a.TransmitterAddress == b.TransmitterAddress
482487
}
483488

484489
func newRelayArgsWithProviderType(_type types.OCR2PluginType) types.RelayArgs {

pkg/types/ccipocr3/generic_types.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,3 +373,33 @@ func (ca ContractAddresses) Append(contract string, chain ChainSelector, address
373373
resp[contract][chain] = address
374374
return resp
375375
}
376+
377+
// PluginType represents the type of CCIP plugin.
378+
// It mirrors the OCRPluginType in Internal.sol.
379+
type PluginType uint8
380+
381+
const (
382+
PluginTypeCCIPCommit PluginType = 0
383+
PluginTypeCCIPExec PluginType = 1
384+
)
385+
386+
func (pt PluginType) String() string {
387+
switch pt {
388+
case PluginTypeCCIPCommit:
389+
return "CCIPCommit"
390+
case PluginTypeCCIPExec:
391+
return "CCIPExec"
392+
default:
393+
return "Unknown"
394+
}
395+
}
396+
397+
// ExtraDataDecoded contains a generic representation of chain specific message parameters. A
398+
// map from string to any is used to account for different parameters required for sending messages
399+
// to different destinations.
400+
type ExtraDataDecoded struct {
401+
// ExtraArgsDecoded contain message specific extra args.
402+
ExtraArgsDecoded map[string]any
403+
// DestExecDataDecoded contain token transfer specific extra args.
404+
DestExecDataDecoded []map[string]any
405+
}

pkg/types/provider_ccip.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,13 @@ type CCIPProvider interface {
5959
// CCIPProviderArgs are the args required to create a CCIP Provider through a Relayer.
6060
// The are common to all relayer implementations.
6161
type CCIPProviderArgs struct {
62-
ExternalJobID uuid.UUID
62+
ExternalJobID uuid.UUID
63+
OffRampAddress ccipocr3.UnknownAddress
64+
PluginType ccipocr3.PluginType
65+
TransmitterAddress ccipocr3.UnknownEncodedAddress
66+
67+
// These CR/CW configs are only used by accessors that still rely on ChainReader
68+
// and ChainWriter, like SolanaAccessor.
6369
ContractReaderConfig []byte
6470
ChainWriterConfig []byte
65-
OffRampAddress string
66-
PluginType uint32
6771
}

0 commit comments

Comments
 (0)