Skip to content

Commit

Permalink
Merge branch 'develop' into CCIP-4508
Browse files Browse the repository at this point in the history
  • Loading branch information
kylesmartin committed Jan 21, 2025
2 parents 549466b + f367549 commit b774023
Show file tree
Hide file tree
Showing 14 changed files with 366 additions and 32 deletions.
17 changes: 17 additions & 0 deletions .github/integration-in-memory-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,21 @@ runner-test-matrix:
- PR Integration CCIP Tests
test_cmd: cd integration-tests/ && go test smoke/ccip/ccip_token_transfer_test.go -timeout 16m -test.parallel=1 -count=1 -json

- id: smoke/ccip/ccip_cs_update_rmn_config_test.go:*
path: integration-tests/smoke/ccip/ccip_cs_update_rmn_config_test.go
test_env_type: in-memory
runs_on: ubuntu-latest
triggers:
- PR Integration CCIP Tests
test_cmd: cd integration-tests/ && go test smoke/ccip/ccip_cs_update_rmn_config_test.go -timeout 20m -test.parallel=1 -count=1 -json

- id: smoke/ccip/ccip_cs_rmn_curse_uncurse_test.go:*
path: integration-tests/smoke/ccip/ccip_cs_rmn_curse_uncurse_test.go
test_env_type: in-memory
runs_on: ubuntu-latest
triggers:
- PR Integration CCIP Tests
test_cmd: cd integration-tests/ && go test smoke/ccip/ccip_cs_rmn_curse_uncurse_test.go -timeout 10m -test.parallel=1 -count=1 -json


# END: CCIP tests
26 changes: 25 additions & 1 deletion core/config/mercury_config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"fmt"
"time"

commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config"
Expand All @@ -17,8 +18,31 @@ type MercuryTLS interface {
CertFile() string
}

type MercuryTransmitterProtocol string

const (
MercuryTransmitterProtocolWSRPC MercuryTransmitterProtocol = "wsrpc"
MercuryTransmitterProtocolGRPC MercuryTransmitterProtocol = "grpc"
)

func (m MercuryTransmitterProtocol) String() string {
return string(m)
}

func (m *MercuryTransmitterProtocol) UnmarshalText(text []byte) error {
switch string(text) {
case "wsrpc":
*m = MercuryTransmitterProtocolWSRPC
case "grpc":
*m = MercuryTransmitterProtocolGRPC
default:
return fmt.Errorf("unknown mercury transmitter protocol: %s", text)
}
return nil
}

type MercuryTransmitter interface {
Protocol() string
Protocol() MercuryTransmitterProtocol
TransmitQueueMaxSize() uint32
TransmitTimeout() commonconfig.Duration
TransmitConcurrency() uint32
Expand Down
2 changes: 1 addition & 1 deletion core/config/toml/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ func (m *MercuryTLS) ValidateConfig() (err error) {
}

type MercuryTransmitter struct {
Protocol *string
Protocol *config.MercuryTransmitterProtocol
TransmitQueueMaxSize *uint32
TransmitTimeout *commonconfig.Duration
TransmitConcurrency *uint32
Expand Down
2 changes: 1 addition & 1 deletion core/services/chainlink/config_mercury.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type mercuryTransmitterConfig struct {
c toml.MercuryTransmitter
}

func (m *mercuryTransmitterConfig) Protocol() string {
func (m *mercuryTransmitterConfig) Protocol() config.MercuryTransmitterProtocol {
return *m.c.Protocol
}

Expand Down
17 changes: 8 additions & 9 deletions core/services/chainlink/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
ocrcommontypes "github.com/smartcontractkit/libocr/commontypes"

commonassets "github.com/smartcontractkit/chainlink-common/pkg/assets"
"github.com/smartcontractkit/chainlink-common/pkg/config"
commoncfg "github.com/smartcontractkit/chainlink-common/pkg/config"
"github.com/smartcontractkit/chainlink-common/pkg/utils/hex"
coscfg "github.com/smartcontractkit/chainlink-cosmos/pkg/cosmos/config"
Expand All @@ -32,7 +31,7 @@ import (
evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/types"
ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big"
legacy "github.com/smartcontractkit/chainlink/v2/core/config"
"github.com/smartcontractkit/chainlink/v2/core/config"
"github.com/smartcontractkit/chainlink/v2/core/config/toml"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink/cfgtest"
Expand Down Expand Up @@ -327,7 +326,7 @@ func TestConfig_Marshal(t *testing.T) {
Backup: toml.DatabaseBackup{
Dir: ptr("test/backup/dir"),
Frequency: &hour,
Mode: &legacy.DatabaseBackupModeFull,
Mode: &config.DatabaseBackupModeFull,
OnVersionUpgrade: ptr(true),
},
}
Expand Down Expand Up @@ -846,7 +845,7 @@ func TestConfig_Marshal(t *testing.T) {
CertFile: ptr("/path/to/cert.pem"),
},
Transmitter: toml.MercuryTransmitter{
Protocol: ptr("grpc"),
Protocol: ptr(config.MercuryTransmitterProtocolGRPC),
TransmitQueueMaxSize: ptr(uint32(123)),
TransmitTimeout: commoncfg.MustNewDuration(234 * time.Second),
TransmitConcurrency: ptr(uint32(456)),
Expand Down Expand Up @@ -1378,7 +1377,7 @@ TransmitConcurrency = 456

var got Config

require.NoError(t, config.DecodeTOML(strings.NewReader(s), &got))
require.NoError(t, commoncfg.DecodeTOML(strings.NewReader(s), &got))
ts, err := got.TOMLString()

require.NoError(t, err)
Expand All @@ -1389,7 +1388,7 @@ TransmitConcurrency = 456

func TestConfig_full(t *testing.T) {
var got Config
require.NoError(t, config.DecodeTOML(strings.NewReader(fullTOML), &got))
require.NoError(t, commoncfg.DecodeTOML(strings.NewReader(fullTOML), &got))
// Except for some EVM node fields.
for c := range got.EVM {
addr, err := types.NewEIP55Address("0x2a3e23c6f242F5345320814aC8a1b4E58707D292")
Expand Down Expand Up @@ -1565,7 +1564,7 @@ func TestConfig_Validate(t *testing.T) {
} {
t.Run(tt.name, func(t *testing.T) {
var c Config
require.NoError(t, config.DecodeTOML(strings.NewReader(tt.toml), &c))
require.NoError(t, commoncfg.DecodeTOML(strings.NewReader(tt.toml), &c))
c.setDefaults()
assertValidationError(t, &c, tt.exp)
})
Expand Down Expand Up @@ -1770,7 +1769,7 @@ AllowSimplePasswords = true`,
} {
t.Run(tt.name, func(t *testing.T) {
var s Secrets
require.NoError(t, config.DecodeTOML(strings.NewReader(tt.toml), &s))
require.NoError(t, commoncfg.DecodeTOML(strings.NewReader(tt.toml), &s))
assertValidationError(t, &s, tt.exp)
})
}
Expand Down Expand Up @@ -1830,7 +1829,7 @@ func TestConfig_SetFrom(t *testing.T) {
var c Config
for _, fs := range tt.from {
var f Config
require.NoError(t, config.DecodeTOML(strings.NewReader(fs), &f))
require.NoError(t, commoncfg.DecodeTOML(strings.NewReader(fs), &f))
require.NoError(t, c.SetFrom(&f))
}
ts, err := c.TOMLString()
Expand Down
3 changes: 2 additions & 1 deletion core/services/llo/mercurytransmitter/transmitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"
ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types"

"github.com/smartcontractkit/chainlink/v2/core/config"
"github.com/smartcontractkit/chainlink/v2/core/services/llo/grpc"

commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config"
Expand Down Expand Up @@ -102,7 +103,7 @@ type Transmitter interface {
var _ Transmitter = (*transmitter)(nil)

type Config interface {
Protocol() string
Protocol() config.MercuryTransmitterProtocol
TransmitQueueMaxSize() uint32
TransmitTimeout() commonconfig.Duration
TransmitConcurrency() uint32
Expand Down
5 changes: 3 additions & 2 deletions core/services/llo/mercurytransmitter/transmitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/smartcontractkit/chainlink-data-streams/rpc"

commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config"
"github.com/smartcontractkit/chainlink/v2/core/config"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest"
"github.com/smartcontractkit/chainlink/v2/core/logger"
Expand All @@ -25,8 +26,8 @@ import (

type mockCfg struct{}

func (m mockCfg) Protocol() string {
return ""
func (m mockCfg) Protocol() config.MercuryTransmitterProtocol {
return config.MercuryTransmitterProtocolGRPC
}

func (m mockCfg) TransmitQueueMaxSize() uint32 {
Expand Down
3 changes: 2 additions & 1 deletion core/services/ocr2/plugins/llo/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (

commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config"
evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types"
"github.com/smartcontractkit/chainlink/v2/core/config"

"github.com/smartcontractkit/chainlink/v2/core/bridges"
"github.com/smartcontractkit/chainlink/v2/core/internal/cltest"
Expand Down Expand Up @@ -199,7 +200,7 @@ func setupNode(
dbName string,
backend evmtypes.Backend,
csaKey csakey.KeyV2,
transmissionMode string,
transmissionMode config.MercuryTransmitterProtocol,
) (app chainlink.Application, peerID string, clientPubKey credentials.StaticSizedPublicKey, ocr2kb ocr2key.KeyBundle, observedLogs *observer.ObservedLogs) {
k := big.NewInt(int64(port)) // keys unique to port
p2pKey := p2pkey.MustNewV2XXXTestingOnly(k)
Expand Down
20 changes: 15 additions & 5 deletions core/services/ocr2/plugins/llo/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils"
ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big"
"github.com/smartcontractkit/chainlink/v2/core/config"

"github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/link_token_interface"
Expand Down Expand Up @@ -383,7 +384,7 @@ func TestIntegration_LLO_evm_premium_legacy(t *testing.T) {
}

// Setup oracle nodes
oracles, nodes := setupNodes(t, nNodes, backend, clientCSAKeys, streams, "wsrpc")
oracles, nodes := setupNodes(t, nNodes, backend, clientCSAKeys, streams, config.MercuryTransmitterProtocolWSRPC)

chainID := testutils.SimulatedChainID
relayType := "evm"
Expand Down Expand Up @@ -477,6 +478,7 @@ channelDefinitionsContractFromBlock = %d`, serverURL, serverPubKey, donID, confi
seen[opts.FeedID] = make(map[credentials.StaticSizedPublicKey]struct{}, nNodes)
}
for req := range reqs {
assert.Equal(t, uint32(llotypes.ReportFormatEVMPremiumLegacy), req.req.ReportFormat)
v := make(map[string]interface{})
err := mercury.PayloadTypes.UnpackIntoMap(v, req.req.Payload)
require.NoError(t, err)
Expand Down Expand Up @@ -599,7 +601,7 @@ func TestIntegration_LLO_evm_abi_encode_unpacked(t *testing.T) {
}

// Setup oracle nodes
oracles, nodes := setupNodes(t, nNodes, backend, clientCSAKeys, streams, "grpc")
oracles, nodes := setupNodes(t, nNodes, backend, clientCSAKeys, streams, config.MercuryTransmitterProtocolGRPC)

chainID := testutils.SimulatedChainID
relayType := "evm"
Expand Down Expand Up @@ -938,6 +940,7 @@ dp -> deribit_funding_interval_hours_parse -> deribit_funding_interval_hours_dec
}

for req := range reqs {
assert.Equal(t, uint32(llotypes.ReportFormatEVMABIEncodeUnpacked), req.ReportFormat)
v := make(map[string]interface{})
err := mercury.PayloadTypes.UnpackIntoMap(v, req.Payload)
require.NoError(t, err)
Expand Down Expand Up @@ -1078,7 +1081,7 @@ func TestIntegration_LLO_blue_green_lifecycle(t *testing.T) {
}

// Setup oracle nodes
oracles, nodes := setupNodes(t, nNodes, backend, clientCSAKeys, streams, "grpc")
oracles, nodes := setupNodes(t, nNodes, backend, clientCSAKeys, streams, config.MercuryTransmitterProtocolGRPC)

chainID := testutils.SimulatedChainID
relayType := "evm"
Expand Down Expand Up @@ -1129,6 +1132,7 @@ channelDefinitionsContractFromBlock = %d`, serverURL, serverPubKey, donID, confi
// NOTE: Wait until blue produces a report

for req := range reqs {
assert.Equal(t, uint32(llotypes.ReportFormatJSON), req.ReportFormat)
_, _, r, _, err := (datastreamsllo.JSONReportCodec{}).UnpackDecode(req.Payload)
require.NoError(t, err)

Expand All @@ -1150,6 +1154,7 @@ channelDefinitionsContractFromBlock = %d`, serverURL, serverPubKey, donID, confi
// NOTE: Wait until green produces the first "specimen" report

for req := range reqs {
assert.Equal(t, uint32(llotypes.ReportFormatJSON), req.ReportFormat)
_, _, r, _, err := (datastreamsllo.JSONReportCodec{}).UnpackDecode(req.Payload)
require.NoError(t, err)

Expand All @@ -1171,6 +1176,7 @@ channelDefinitionsContractFromBlock = %d`, serverURL, serverPubKey, donID, confi
// NOTE: Wait for first non-specimen report for the newly promoted (green) instance

for req := range reqs {
assert.Equal(t, uint32(llotypes.ReportFormatJSON), req.ReportFormat)
_, _, r, _, err := (datastreamsllo.JSONReportCodec{}).UnpackDecode(req.Payload)
require.NoError(t, err)

Expand Down Expand Up @@ -1240,6 +1246,7 @@ channelDefinitionsContractFromBlock = %d`, serverURL, serverPubKey, donID, confi
if i == 5 {
break
}
assert.Equal(t, uint32(llotypes.ReportFormatJSON), req.ReportFormat)
_, _, r, _, err := (datastreamsllo.JSONReportCodec{}).UnpackDecode(req.Payload)
require.NoError(t, err)

Expand All @@ -1257,6 +1264,7 @@ channelDefinitionsContractFromBlock = %d`, serverURL, serverPubKey, donID, confi
// NOTE: Wait until blue produces the first "specimen" report

for req := range reqs {
assert.Equal(t, uint32(llotypes.ReportFormatJSON), req.ReportFormat)
_, _, r, _, err := (datastreamsllo.JSONReportCodec{}).UnpackDecode(req.Payload)
require.NoError(t, err)

Expand All @@ -1277,6 +1285,7 @@ channelDefinitionsContractFromBlock = %d`, serverURL, serverPubKey, donID, confi
// NOTE: Wait for first non-specimen report for the newly promoted (blue) instance

for req := range reqs {
assert.Equal(t, uint32(llotypes.ReportFormatJSON), req.ReportFormat)
_, _, r, _, err := (datastreamsllo.JSONReportCodec{}).UnpackDecode(req.Payload)
require.NoError(t, err)

Expand Down Expand Up @@ -1317,6 +1326,7 @@ channelDefinitionsContractFromBlock = %d`, serverURL, serverPubKey, donID, confi
// NOTE: Wait until the first report for the new channel definition is produced

for req := range reqs {
assert.Equal(t, uint32(llotypes.ReportFormatJSON), req.ReportFormat)
_, _, r, _, err := (datastreamsllo.JSONReportCodec{}).UnpackDecode(req.Payload)
require.NoError(t, err)

Expand Down Expand Up @@ -1344,10 +1354,10 @@ channelDefinitionsContractFromBlock = %d`, serverURL, serverPubKey, donID, confi
})
}

func setupNodes(t *testing.T, nNodes int, backend evmtypes.Backend, clientCSAKeys []csakey.KeyV2, streams []Stream, transmissionMode string) (oracles []confighelper.OracleIdentityExtra, nodes []Node) {
func setupNodes(t *testing.T, nNodes int, backend evmtypes.Backend, clientCSAKeys []csakey.KeyV2, streams []Stream, transmitterProtocol config.MercuryTransmitterProtocol) (oracles []confighelper.OracleIdentityExtra, nodes []Node) {
ports := freeport.GetN(t, nNodes)
for i := 0; i < nNodes; i++ {
app, peerID, transmitter, kb, observedLogs := setupNode(t, ports[i], fmt.Sprintf("oracle_streams_%d", i), backend, clientCSAKeys[i], transmissionMode)
app, peerID, transmitter, kb, observedLogs := setupNode(t, ports[i], fmt.Sprintf("oracle_streams_%d", i), backend, clientCSAKeys[i], transmitterProtocol)

nodes = append(nodes, Node{
app, transmitter, kb, observedLogs,
Expand Down
5 changes: 3 additions & 2 deletions core/services/relay/evm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
txm "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr"
evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types"
"github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm"
"github.com/smartcontractkit/chainlink/v2/core/config"
coreconfig "github.com/smartcontractkit/chainlink/v2/core/config"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore"
"github.com/smartcontractkit/chainlink/v2/core/services/llo"
Expand Down Expand Up @@ -744,14 +745,14 @@ func (r *Relayer) NewLLOProvider(ctx context.Context, rargs commontypes.RelayArg
for _, server := range lloCfg.GetServers() {
var client grpc.Client
switch r.mercuryCfg.Transmitter().Protocol() {
case "grpc":
case config.MercuryTransmitterProtocolGRPC:
client = grpc.NewClient(grpc.ClientOpts{
Logger: r.lggr,
ClientPrivKey: privKey.PrivateKey(),
ServerPubKey: ed25519.PublicKey(server.PubKey),
ServerURL: server.URL,
})
case "wsrpc":
case config.MercuryTransmitterProtocolWSRPC:
wsrpcClient, checkoutErr := r.mercuryPool.Checkout(ctx, privKey, server.PubKey, server.URL)
if checkoutErr != nil {
return nil, checkoutErr
Expand Down
7 changes: 4 additions & 3 deletions core/services/relay/evm/mercury/transmitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/capabilities/triggers"
commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils"
"github.com/smartcontractkit/chainlink/v2/core/config"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest"
"github.com/smartcontractkit/chainlink/v2/core/logger"
Expand All @@ -28,12 +29,12 @@ import (

type mockCfg struct{}

func (m mockCfg) Protocol() string {
return ""
func (m mockCfg) Protocol() config.MercuryTransmitterProtocol {
return config.MercuryTransmitterProtocolGRPC
}

func (m mockCfg) TransmitQueueMaxSize() uint32 {
return 10_000
return 100_000
}

func (m mockCfg) TransmitTimeout() commonconfig.Duration {
Expand Down
Loading

0 comments on commit b774023

Please sign in to comment.