From 8e85758fb0665736cb23d08cfd6547845207812c Mon Sep 17 00:00:00 2001 From: Makram Kamaleddine Date: Thu, 25 Jul 2024 12:30:25 +0200 Subject: [PATCH] fix commit test --- core/scripts/go.mod | 2 +- core/scripts/go.sum | 4 +- .../ccipcapability/oraclecreator/inprocess.go | 1 + .../plugins/ccip_integration_tests/helpers.go | 9 ++ .../ccip_integration_tests/ocr3_node_test.go | 100 ++++++++++++++++-- go.mod | 2 +- go.sum | 4 +- integration-tests/go.mod | 2 +- integration-tests/go.sum | 4 +- integration-tests/load/go.mod | 2 +- integration-tests/load/go.sum | 4 +- 11 files changed, 114 insertions(+), 20 deletions(-) diff --git a/core/scripts/go.mod b/core/scripts/go.mod index ec33a39f39..b9880f17bc 100644 --- a/core/scripts/go.mod +++ b/core/scripts/go.mod @@ -274,7 +274,7 @@ require ( github.com/sethvargo/go-retry v0.2.4 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/shirou/gopsutil/v3 v3.24.3 // indirect - github.com/smartcontractkit/chainlink-ccip v0.0.0-20240718144623-dad238eb17c1 // indirect + github.com/smartcontractkit/chainlink-ccip v0.0.0-20240725101427-a27956011544 // indirect github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45 // indirect github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240718160222-2dc0c8136bfa // indirect github.com/smartcontractkit/chainlink-feeds v0.0.0-20240710170203-5b41615da827 // indirect diff --git a/core/scripts/go.sum b/core/scripts/go.sum index a3f84f9ccd..9f9c158981 100644 --- a/core/scripts/go.sum +++ b/core/scripts/go.sum @@ -1070,8 +1070,8 @@ github.com/smartcontractkit/chain-selectors v1.0.18 h1:ackCMDOlWuwULAyBNj9fQeQme github.com/smartcontractkit/chain-selectors v1.0.18/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE= github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8= github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20240718144623-dad238eb17c1 h1:YGfq0GHxuDR/gAmd6OZiW/Oxo9lyE7S8zi2MEL96bdE= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20240718144623-dad238eb17c1/go.mod h1:K67FldZZmg+//7yyI0yBMXEw6uvYevTj/ErBEvXaBXM= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20240725101427-a27956011544 h1:pT+PNPf2B+5Q4cpxRqku3fmn9bPOU9QII16qO71EX20= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20240725101427-a27956011544/go.mod h1:K67FldZZmg+//7yyI0yBMXEw6uvYevTj/ErBEvXaBXM= github.com/smartcontractkit/chainlink-common v0.2.1-0.20240717132349-ee5af9b79834 h1:pTf4xdcmiWBqWZ6rTy2RMTDBzhHk89VC1pM7jXKQztI= github.com/smartcontractkit/chainlink-common v0.2.1-0.20240717132349-ee5af9b79834/go.mod h1:fh9eBbrReCmv31bfz52ENCAMa7nTKQbdhb2B3+S2VGo= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45 h1:NBQLtqk8zsyY4qTJs+NElI3aDFTcAo83JHvqD04EvB0= diff --git a/core/services/ccipcapability/oraclecreator/inprocess.go b/core/services/ccipcapability/oraclecreator/inprocess.go index c07aed6039..0eaef462b5 100644 --- a/core/services/ccipcapability/oraclecreator/inprocess.go +++ b/core/services/ccipcapability/oraclecreator/inprocess.go @@ -257,6 +257,7 @@ func (i *inprocessOracleCreator) CreatePluginOracle(pluginType cctypes.PluginTyp i.lggr. Named("CCIPCommitPlugin"). Named(destRelayID.String()). + Named(fmt.Sprintf("%d", config.Config.ChainSelector)). Named(hexutil.Encode(config.Config.OfframpAddress)), ccipreaderpkg.OCR3ConfigWithMeta(config), ccipevm.NewCommitPluginCodecV1(), diff --git a/core/services/ocr3/plugins/ccip_integration_tests/helpers.go b/core/services/ocr3/plugins/ccip_integration_tests/helpers.go index 18c4c2d17a..3e86d87ea0 100644 --- a/core/services/ocr3/plugins/ccip_integration_tests/helpers.go +++ b/core/services/ocr3/plugins/ccip_integration_tests/helpers.go @@ -626,6 +626,15 @@ func wireOffRamp(t *testing.T, uni onchainUniverse, universes map[uint64]onchain _, err := uni.offramp.ApplySourceChainConfigUpdates(owner, offrampSourceChainConfigArgs) require.NoErrorf(t, err, "failed to apply source chain config updates on offramp on chain id %d", uni.chainID) uni.backend.Commit() + for remoteChainID, remoteUniverse := range universes { + if remoteChainID == uni.chainID { + continue + } + sourceCfg, err2 := uni.offramp.GetSourceChainConfig(&bind.CallOpts{}, getSelector(remoteChainID)) + require.NoError(t, err2) + require.True(t, sourceCfg.IsEnabled, "source chain config should be enabled") + require.Equal(t, remoteUniverse.onramp.Address(), common.BytesToAddress(sourceCfg.OnRamp), "source chain config onRamp address mismatch") + } } func getSelector(chainID uint64) uint64 { diff --git a/core/services/ocr3/plugins/ccip_integration_tests/ocr3_node_test.go b/core/services/ocr3/plugins/ccip_integration_tests/ocr3_node_test.go index f74be8e563..5d89a84221 100644 --- a/core/services/ocr3/plugins/ccip_integration_tests/ocr3_node_test.go +++ b/core/services/ocr3/plugins/ccip_integration_tests/ocr3_node_test.go @@ -3,6 +3,7 @@ package ccip_integration_tests import ( "fmt" "math/big" + "sync" "testing" "time" @@ -23,8 +24,6 @@ import ( ) func TestIntegration_OCR3Nodes(t *testing.T) { - t.Skip("Currently failing, will fix in follow-ups") - numChains := 3 homeChainUni, universes := createUniverses(t, numChains) numNodes := 4 @@ -209,14 +208,94 @@ func TestIntegration_OCR3Nodes(t *testing.T) { } } + numUnis := len(universes) + var wg sync.WaitGroup + for _, uni := range universes { + wg.Add(1) + go func(uni onchainUniverse) { + defer wg.Done() + waitForCommit(t, uni, numUnis, nil) + }(uni) + } + + t.Log("waiting for commit reports") + wg.Wait() + + var preRequestBlocks = make(map[uint64]uint64) + for _, uni := range universes { + preRequestBlocks[uni.chainID] = uni.backend.Blockchain().CurrentBlock().Number.Uint64() + } + + for chainID, uni := range universes { + for otherChain, pingPong := range pingPongs[chainID] { + t.Log("PingPong again From: ", chainID, " To: ", otherChain) + + expNextSeqNr, err1 := uni.onramp.GetExpectedNextSequenceNumber(&bind.CallOpts{}, getSelector(otherChain)) + require.NoError(t, err1) + require.Equal(t, uint64(2), expNextSeqNr, "expected next sequence number should be 1") + + uni.backend.Commit() + + _, err2 := pingPong.StartPingPong(uni.owner) + require.NoError(t, err2) + uni.backend.Commit() + + endBlock := uni.backend.Blockchain().CurrentBlock().Number.Uint64() + logIter, err3 := uni.onramp.FilterCCIPSendRequested(&bind.FilterOpts{ + Start: endBlock - 1, + End: &endBlock, + }, []uint64{getSelector(otherChain)}) + require.NoError(t, err3) + // Iterate until latest event + var count int + for logIter.Next() { + count++ + } + require.Equal(t, 1, count, "expected 1 CCIPSendRequested log only") + + log := logIter.Event + require.Equal(t, getSelector(otherChain), log.DestChainSelector) + require.Equal(t, pingPong.Address(), log.Message.Sender) + chainPingPongAddr := pingPongs[otherChain][chainID].Address().Bytes() + + // Receiver address is abi-encoded if destination is EVM. + paddedAddr := common.LeftPadBytes(chainPingPongAddr, len(log.Message.Receiver)) + require.Equal(t, paddedAddr, log.Message.Receiver) + + // check that sequence number is equal to the expected next sequence number. + // and that the sequence number is bumped in the onramp. + require.Equalf(t, log.Message.Header.SequenceNumber, expNextSeqNr, "incorrect sequence number in CCIPSendRequested event on chain %d", log.DestChainSelector) + newExpNextSeqNr, err := uni.onramp.GetExpectedNextSequenceNumber(&bind.CallOpts{}, getSelector(otherChain)) + require.NoError(t, err) + require.Equal(t, expNextSeqNr+1, newExpNextSeqNr, "expected next sequence number should be bumped by 1") + + _, ok := messageIDs[chainID] + if !ok { + messageIDs[chainID] = make(map[uint64][32]byte) + } + messageIDs[chainID][otherChain] = log.Message.Header.MessageId + } + } + for _, uni := range universes { - waitForCommit(t, uni) + startBlock := preRequestBlocks[uni.chainID] + wg.Add(1) + go func(uni onchainUniverse, startBlock *uint64) { + defer wg.Done() + waitForCommit(t, uni, numUnis, nil) + }(uni, &startBlock) } + + t.Log("waiting for second batch of commit reports") + wg.Wait() } -func waitForCommit(t *testing.T, uni onchainUniverse) { +func waitForCommit(t *testing.T, uni onchainUniverse, numUnis int, startBlock *uint64) { sink := make(chan *evm_2_evm_multi_offramp.EVM2EVMMultiOffRampCommitReportAccepted) - subscipriton, err := uni.offramp.WatchCommitReportAccepted(&bind.WatchOpts{}, sink) + subscipriton, err := uni.offramp.WatchCommitReportAccepted(&bind.WatchOpts{ + Start: startBlock, + Context: testutils.Context(t), + }, sink) require.NoError(t, err) for { @@ -227,11 +306,16 @@ func waitForCommit(t *testing.T, uni onchainUniverse) { t.Fatalf("Subscription error: %+v", subErr) case report := <-sink: if len(report.Report.MerkleRoots) > 0 { - t.Logf("Received commit report with merkle roots: %+v", report) + if len(report.Report.MerkleRoots) == numUnis-1 { + t.Logf("Received commit report with %d merkle roots on chain id %d (selector %d): %+v", + len(report.Report.MerkleRoots), uni.chainID, getSelector(uni.chainID), report) + return + } else { + t.Fatalf("Received commit report with %d merkle roots, expected %d", len(report.Report.MerkleRoots), numUnis) + } } else { - t.Logf("Received commit report without merkle roots: %+v", report) + t.Logf("Received commit report without merkle roots on chain id %d (selector %d): %+v", uni.chainID, getSelector(uni.chainID), report) } - return } } } diff --git a/go.mod b/go.mod index 0a6aabce72..d3dcae073e 100644 --- a/go.mod +++ b/go.mod @@ -74,7 +74,7 @@ require ( github.com/shopspring/decimal v1.4.0 github.com/smartcontractkit/chain-selectors v1.0.18 github.com/smartcontractkit/chainlink-automation v1.0.4 - github.com/smartcontractkit/chainlink-ccip v0.0.0-20240718144623-dad238eb17c1 + github.com/smartcontractkit/chainlink-ccip v0.0.0-20240725101427-a27956011544 github.com/smartcontractkit/chainlink-common v0.2.1-0.20240717132349-ee5af9b79834 github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45 github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240718160222-2dc0c8136bfa diff --git a/go.sum b/go.sum index 5d9620f03f..378669e37a 100644 --- a/go.sum +++ b/go.sum @@ -1027,8 +1027,8 @@ github.com/smartcontractkit/chain-selectors v1.0.18 h1:ackCMDOlWuwULAyBNj9fQeQme github.com/smartcontractkit/chain-selectors v1.0.18/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE= github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8= github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20240718144623-dad238eb17c1 h1:YGfq0GHxuDR/gAmd6OZiW/Oxo9lyE7S8zi2MEL96bdE= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20240718144623-dad238eb17c1/go.mod h1:K67FldZZmg+//7yyI0yBMXEw6uvYevTj/ErBEvXaBXM= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20240725101427-a27956011544 h1:pT+PNPf2B+5Q4cpxRqku3fmn9bPOU9QII16qO71EX20= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20240725101427-a27956011544/go.mod h1:K67FldZZmg+//7yyI0yBMXEw6uvYevTj/ErBEvXaBXM= github.com/smartcontractkit/chainlink-common v0.2.1-0.20240717132349-ee5af9b79834 h1:pTf4xdcmiWBqWZ6rTy2RMTDBzhHk89VC1pM7jXKQztI= github.com/smartcontractkit/chainlink-common v0.2.1-0.20240717132349-ee5af9b79834/go.mod h1:fh9eBbrReCmv31bfz52ENCAMa7nTKQbdhb2B3+S2VGo= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45 h1:NBQLtqk8zsyY4qTJs+NElI3aDFTcAo83JHvqD04EvB0= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 156260c85f..89b4f54e34 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -384,7 +384,7 @@ require ( github.com/shirou/gopsutil/v3 v3.24.3 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/sirupsen/logrus v1.9.3 // indirect - github.com/smartcontractkit/chainlink-ccip v0.0.0-20240718144623-dad238eb17c1 // indirect + github.com/smartcontractkit/chainlink-ccip v0.0.0-20240725101427-a27956011544 // indirect github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45 // indirect github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240718160222-2dc0c8136bfa // indirect github.com/smartcontractkit/chainlink-feeds v0.0.0-20240710170203-5b41615da827 // indirect diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 758ed22d4e..893336ebd8 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1392,8 +1392,8 @@ github.com/smartcontractkit/chain-selectors v1.0.18 h1:ackCMDOlWuwULAyBNj9fQeQme github.com/smartcontractkit/chain-selectors v1.0.18/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE= github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8= github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20240718144623-dad238eb17c1 h1:YGfq0GHxuDR/gAmd6OZiW/Oxo9lyE7S8zi2MEL96bdE= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20240718144623-dad238eb17c1/go.mod h1:K67FldZZmg+//7yyI0yBMXEw6uvYevTj/ErBEvXaBXM= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20240725101427-a27956011544 h1:pT+PNPf2B+5Q4cpxRqku3fmn9bPOU9QII16qO71EX20= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20240725101427-a27956011544/go.mod h1:K67FldZZmg+//7yyI0yBMXEw6uvYevTj/ErBEvXaBXM= github.com/smartcontractkit/chainlink-common v0.2.1-0.20240717132349-ee5af9b79834 h1:pTf4xdcmiWBqWZ6rTy2RMTDBzhHk89VC1pM7jXKQztI= github.com/smartcontractkit/chainlink-common v0.2.1-0.20240717132349-ee5af9b79834/go.mod h1:fh9eBbrReCmv31bfz52ENCAMa7nTKQbdhb2B3+S2VGo= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45 h1:NBQLtqk8zsyY4qTJs+NElI3aDFTcAo83JHvqD04EvB0= diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index 8e4b211294..0d7a881b08 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -40,7 +40,7 @@ require ( github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect - github.com/smartcontractkit/chainlink-ccip v0.0.0-20240718144623-dad238eb17c1 // indirect + github.com/smartcontractkit/chainlink-ccip v0.0.0-20240725101427-a27956011544 // indirect github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45 // indirect k8s.io/apimachinery v0.30.2 // indirect ) diff --git a/integration-tests/load/go.sum b/integration-tests/load/go.sum index a62cbf4941..b2421b3b96 100644 --- a/integration-tests/load/go.sum +++ b/integration-tests/load/go.sum @@ -1374,8 +1374,8 @@ github.com/smartcontractkit/chain-selectors v1.0.18 h1:ackCMDOlWuwULAyBNj9fQeQme github.com/smartcontractkit/chain-selectors v1.0.18/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE= github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8= github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20240718144623-dad238eb17c1 h1:YGfq0GHxuDR/gAmd6OZiW/Oxo9lyE7S8zi2MEL96bdE= -github.com/smartcontractkit/chainlink-ccip v0.0.0-20240718144623-dad238eb17c1/go.mod h1:K67FldZZmg+//7yyI0yBMXEw6uvYevTj/ErBEvXaBXM= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20240725101427-a27956011544 h1:pT+PNPf2B+5Q4cpxRqku3fmn9bPOU9QII16qO71EX20= +github.com/smartcontractkit/chainlink-ccip v0.0.0-20240725101427-a27956011544/go.mod h1:K67FldZZmg+//7yyI0yBMXEw6uvYevTj/ErBEvXaBXM= github.com/smartcontractkit/chainlink-common v0.2.1-0.20240717132349-ee5af9b79834 h1:pTf4xdcmiWBqWZ6rTy2RMTDBzhHk89VC1pM7jXKQztI= github.com/smartcontractkit/chainlink-common v0.2.1-0.20240717132349-ee5af9b79834/go.mod h1:fh9eBbrReCmv31bfz52ENCAMa7nTKQbdhb2B3+S2VGo= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45 h1:NBQLtqk8zsyY4qTJs+NElI3aDFTcAo83JHvqD04EvB0=