Skip to content

Commit

Permalink
fix commit test
Browse files Browse the repository at this point in the history
  • Loading branch information
makramkd committed Jul 25, 2024
1 parent 4363b3d commit 8e85758
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 20 deletions.
2 changes: 1 addition & 1 deletion core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions core/scripts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
1 change: 1 addition & 0 deletions core/services/ccipcapability/oraclecreator/inprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
9 changes: 9 additions & 0 deletions core/services/ocr3/plugins/ccip_integration_tests/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
100 changes: 92 additions & 8 deletions core/services/ocr3/plugins/ccip_integration_tests/ocr3_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ccip_integration_tests
import (
"fmt"
"math/big"
"sync"
"testing"
"time"

Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {

Check failure on line 313 in core/services/ocr3/plugins/ccip_integration_tests/ocr3_node_test.go

View workflow job for this annotation

GitHub Actions / lint

indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
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
}
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
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 @@ -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
)
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 @@ -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=
Expand Down

0 comments on commit 8e85758

Please sign in to comment.