Skip to content

Commit

Permalink
integration-tests/smoke/ccip: fix fSign reading (#16191)
Browse files Browse the repository at this point in the history
* integration-tests/smoke/ccip: fix fSign reading

Add TestCCIPReader_GetRMNRemoteConfig to test that
fSign reading is correctly done in the CCIP reader.

There was no coverage for this before.

* bump to main
  • Loading branch information
makramkd authored Feb 3, 2025
1 parent 0d051fe commit 26cd292
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 15 deletions.
2 changes: 1 addition & 1 deletion core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ require (
github.com/shirou/gopsutil/v3 v3.24.3 // indirect
github.com/smartcontractkit/ccip-owner-contracts v0.0.0-salt-fix // indirect
github.com/smartcontractkit/chain-selectors v1.0.37 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203130001-13e2609047e9 // indirect
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250128074412-9b02e505b268 // indirect
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20250130125138-3df261e09ddc // indirect
github.com/smartcontractkit/chainlink-feeds v0.1.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions core/scripts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1329,8 +1329,8 @@ github.com/smartcontractkit/chain-selectors v1.0.37 h1:EKVl8wayhOVfnlqfVmEyZ8rXO
github.com/smartcontractkit/chain-selectors v1.0.37/go.mod h1:xsKM0aN3YGcQKTPRPDDtPx2l4mlTN1Djmg0VVXV40b8=
github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU=
github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49 h1:Y9mC8DCJQUjU7IwGi0FVsH2Q8ujv9Na8DLq1StsGbso=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203130001-13e2609047e9 h1:+/KEPuWctPObgOoEEBCnli1/H3XnjMdCY3Tn+J32XRM=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203130001-13e2609047e9/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250128074412-9b02e505b268 h1:R1fQXQL1AKLfRqZHlbGO0NHN3uZKEkI3r2uBlctwt7k=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250128074412-9b02e505b268/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130202959-6f1f48342e36 h1:bS51NFGHVjkCy7yu9L2Ss4sBsCW6jpa5GuhRAdWWxzM=
Expand Down
2 changes: 1 addition & 1 deletion deployment/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/sethvargo/go-retry v0.2.4
github.com/smartcontractkit/ccip-owner-contracts v0.0.0-salt-fix
github.com/smartcontractkit/chain-selectors v1.0.37
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203130001-13e2609047e9
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250128074412-9b02e505b268
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130202959-6f1f48342e36
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250121205514-f73e2f86c23b
Expand Down
4 changes: 2 additions & 2 deletions deployment/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1394,8 +1394,8 @@ github.com/smartcontractkit/chain-selectors v1.0.37 h1:EKVl8wayhOVfnlqfVmEyZ8rXO
github.com/smartcontractkit/chain-selectors v1.0.37/go.mod h1:xsKM0aN3YGcQKTPRPDDtPx2l4mlTN1Djmg0VVXV40b8=
github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU=
github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49 h1:Y9mC8DCJQUjU7IwGi0FVsH2Q8ujv9Na8DLq1StsGbso=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203130001-13e2609047e9 h1:+/KEPuWctPObgOoEEBCnli1/H3XnjMdCY3Tn+J32XRM=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203130001-13e2609047e9/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250128074412-9b02e505b268 h1:R1fQXQL1AKLfRqZHlbGO0NHN3uZKEkI3r2uBlctwt7k=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250128074412-9b02e505b268/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130202959-6f1f48342e36 h1:bS51NFGHVjkCy7yu9L2Ss4sBsCW6jpa5GuhRAdWWxzM=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ require (
github.com/shopspring/decimal v1.4.0
github.com/smartcontractkit/chain-selectors v1.0.37
github.com/smartcontractkit/chainlink-automation v0.8.1
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203130001-13e2609047e9
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130202959-6f1f48342e36
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20250130125138-3df261e09ddc
github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250128203428-08031923fbe5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1154,8 +1154,8 @@ github.com/smartcontractkit/chain-selectors v1.0.37 h1:EKVl8wayhOVfnlqfVmEyZ8rXO
github.com/smartcontractkit/chain-selectors v1.0.37/go.mod h1:xsKM0aN3YGcQKTPRPDDtPx2l4mlTN1Djmg0VVXV40b8=
github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU=
github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49 h1:Y9mC8DCJQUjU7IwGi0FVsH2Q8ujv9Na8DLq1StsGbso=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203130001-13e2609047e9 h1:+/KEPuWctPObgOoEEBCnli1/H3XnjMdCY3Tn+J32XRM=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203130001-13e2609047e9/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130202959-6f1f48342e36 h1:bS51NFGHVjkCy7yu9L2Ss4sBsCW6jpa5GuhRAdWWxzM=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130202959-6f1f48342e36/go.mod h1:Z2e1ynSJ4pg83b4Qldbmryc5lmnrI3ojOdg1FUloa68=
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20250130125138-3df261e09ddc h1:WZERXv2hTYRA0NpWg79ci/ZZSxucmvkty39iUOV8d7I=
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ require (
github.com/slack-go/slack v0.15.0
github.com/smartcontractkit/chain-selectors v1.0.37
github.com/smartcontractkit/chainlink-automation v0.8.1
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203130001-13e2609047e9
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130202959-6f1f48342e36
github.com/smartcontractkit/chainlink-protos/job-distributor v0.6.0
github.com/smartcontractkit/chainlink-testing-framework/framework v0.4.7
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1422,8 +1422,8 @@ github.com/smartcontractkit/chain-selectors v1.0.37 h1:EKVl8wayhOVfnlqfVmEyZ8rXO
github.com/smartcontractkit/chain-selectors v1.0.37/go.mod h1:xsKM0aN3YGcQKTPRPDDtPx2l4mlTN1Djmg0VVXV40b8=
github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU=
github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49 h1:Y9mC8DCJQUjU7IwGi0FVsH2Q8ujv9Na8DLq1StsGbso=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203130001-13e2609047e9 h1:+/KEPuWctPObgOoEEBCnli1/H3XnjMdCY3Tn+J32XRM=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203130001-13e2609047e9/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250128074412-9b02e505b268 h1:R1fQXQL1AKLfRqZHlbGO0NHN3uZKEkI3r2uBlctwt7k=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250128074412-9b02e505b268/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130202959-6f1f48342e36 h1:bS51NFGHVjkCy7yu9L2Ss4sBsCW6jpa5GuhRAdWWxzM=
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/load/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/rs/zerolog v1.33.0
github.com/slack-go/slack v0.15.0
github.com/smartcontractkit/chain-selectors v1.0.37
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203130001-13e2609047e9
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130202959-6f1f48342e36
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.21
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.10
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/load/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1409,8 +1409,8 @@ github.com/smartcontractkit/chain-selectors v1.0.37 h1:EKVl8wayhOVfnlqfVmEyZ8rXO
github.com/smartcontractkit/chain-selectors v1.0.37/go.mod h1:xsKM0aN3YGcQKTPRPDDtPx2l4mlTN1Djmg0VVXV40b8=
github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU=
github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49 h1:Y9mC8DCJQUjU7IwGi0FVsH2Q8ujv9Na8DLq1StsGbso=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250130101703-5ba045c38d49/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203130001-13e2609047e9 h1:+/KEPuWctPObgOoEEBCnli1/H3XnjMdCY3Tn+J32XRM=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203130001-13e2609047e9/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250128074412-9b02e505b268 h1:R1fQXQL1AKLfRqZHlbGO0NHN3uZKEkI3r2uBlctwt7k=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250128074412-9b02e505b268/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250130202959-6f1f48342e36 h1:bS51NFGHVjkCy7yu9L2Ss4sBsCW6jpa5GuhRAdWWxzM=
Expand Down
116 changes: 116 additions & 0 deletions integration-tests/smoke/ccip/ccip_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/fee_quoter"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/offramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/onramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_proxy_contract"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_remote"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/relay/evm"
evmtypes "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/types"
Expand Down Expand Up @@ -180,6 +182,120 @@ func emitCommitReports(ctx context.Context, t *testing.T, s *testSetupData, numR
return firstReportTs
}

func TestCCIPReader_GetRMNRemoteConfig(t *testing.T) {
t.Parallel()
ctx := tests.Context(t)
sb, auth := setupSimulatedBackendAndAuth(t)

rmnRemoteAddr, _, _, err := rmn_remote.DeployRMNRemote(auth, sb.Client(), uint64(chainD), utils.RandomAddress())
require.NoError(t, err)
sb.Commit()

proxyAddr, _, _, err := rmn_proxy_contract.DeployRMNProxy(auth, sb.Client(), rmnRemoteAddr)
require.NoError(t, err)
sb.Commit()

t.Logf("Proxy address: %s, rmn remote address: %s", proxyAddr.Hex(), rmnRemoteAddr.Hex())

proxy, err := rmn_proxy_contract.NewRMNProxy(proxyAddr, sb.Client())
require.NoError(t, err)

currARM, err := proxy.GetARM(&bind.CallOpts{
Context: ctx,
})
require.NoError(t, err)
require.Equal(t, currARM, rmnRemoteAddr)

rmnRemote, err := rmn_remote.NewRMNRemote(rmnRemoteAddr, sb.Client())
require.NoError(t, err)

_, err = rmnRemote.SetConfig(auth, rmn_remote.RMNRemoteConfig{
RmnHomeContractConfigDigest: utils.RandomBytes32(),
Signers: []rmn_remote.RMNRemoteSigner{
{
OnchainPublicKey: utils.RandomAddress(),
NodeIndex: 0,
},
{
OnchainPublicKey: utils.RandomAddress(),
NodeIndex: 1,
},
{
OnchainPublicKey: utils.RandomAddress(),
NodeIndex: 2,
},
},
FSign: 1, // 2*FSign + 1 == 3
})
require.NoError(t, err)
sb.Commit()

db := pgtest.NewSqlxDB(t)
lggr := logger.TestLogger(t)
lggr.SetLogLevel(zapcore.ErrorLevel)
lpOpts := logpoller.Opts{
PollPeriod: time.Millisecond,
FinalityDepth: 1,
BackfillBatchSize: 10,
RpcBatchSize: 10,
KeepFinalizedBlocksDepth: 100000,
}
cl := client.NewSimulatedBackendClient(t, sb, big.NewInt(1337))
headTracker := headtracker.NewSimulatedHeadTracker(cl, lpOpts.UseFinalityTag, lpOpts.FinalityDepth)
orm := logpoller.NewORM(big.NewInt(1337), db, lggr)
lp := logpoller.NewLogPoller(
orm,
cl,
lggr,
headTracker,
lpOpts,
)
require.NoError(t, lp.Start(ctx))
t.Cleanup(func() { require.NoError(t, lp.Close()) })

cr, err := evm.NewChainReaderService(ctx, lggr, lp, headTracker, cl, evmconfig.DestReaderConfig)
require.NoError(t, err)
err = cr.Start(ctx)
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, cr.Close()) })

extendedCr := contractreader.NewExtendedContractReader(cr)
err = extendedCr.Bind(ctx, []types.BoundContract{
{
Address: proxyAddr.String(),
Name: consts.ContractNameRMNRemote,
},
})
require.NoError(t, err)

reader := ccipreaderpkg.NewCCIPReaderWithExtendedContractReaders(
ctx,
lggr,
map[cciptypes.ChainSelector]contractreader.Extended{
chainD: extendedCr,
},
nil,
chainD,
rmnRemoteAddr.Bytes(),
ccipcommon.NewExtraDataCodec(),
)

exp, err := rmnRemote.GetVersionedConfig(&bind.CallOpts{
Context: ctx,
})
require.NoError(t, err)

rmnRemoteConfig, err := reader.GetRMNRemoteConfig(ctx)
require.NoError(t, err)
require.Equal(t, exp.Config.RmnHomeContractConfigDigest[:], rmnRemoteConfig.ConfigDigest[:])
require.Equal(t, len(exp.Config.Signers), len(rmnRemoteConfig.Signers))
for i, signer := range exp.Config.Signers {
require.Equal(t, signer.OnchainPublicKey.Bytes(), []byte(rmnRemoteConfig.Signers[i].OnchainPublicKey))
require.Equal(t, signer.NodeIndex, rmnRemoteConfig.Signers[i].NodeIndex)
}
require.Equal(t, exp.Config.FSign, rmnRemoteConfig.FSign)
}

func TestCCIPReader_GetOffRampConfigDigest(t *testing.T) {
t.Parallel()
ctx := tests.Context(t)
Expand Down

0 comments on commit 26cd292

Please sign in to comment.