Skip to content

Commit

Permalink
Merge branch 'ccip-develop' into amaechi/bump-chain-selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
amaechiokolobi authored Jul 25, 2024
2 parents 594933d + 8ad2a30 commit 663ea86
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Please define less specific codeowner paths before more specific codeowner paths in order for the more specific rule to have priority

# Root
* @smartcontractkit/foundations
* @smartcontractkit/ccip

# Chains
/common @smartcontractkit/bix-framework
Expand Down
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-20240725105722-fb2380a3f739 // 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.19 h1:y82TyWaOA6gSvi26bbyDYgfZv
github.com/smartcontractkit/chain-selectors v1.0.19/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-20240725105722-fb2380a3f739 h1:eYe/NS0b97yJV5ffLB+v6ww6R9FcUZV1k07tuArhCdY=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240725105722-fb2380a3f739/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
95 changes: 68 additions & 27 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,13 +3,16 @@ package ccip_integration_tests
import (
"fmt"
"math/big"
"sync"
"testing"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/hashicorp/consul/sdk/freeport"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ping_pong_demo"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_multi_offramp"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
Expand All @@ -23,8 +26,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 @@ -136,14 +137,66 @@ func TestIntegration_OCR3Nodes(t *testing.T) {
// map[uint64] chainID, blocks
var replayBlocks = make(map[uint64]uint64)
pingPongs := initializePingPongContracts(t, universes)

sendPingPong(t, universes, pingPongs, messageIDs, replayBlocks, 1)
// HACK: wait for the oracles to come up.
// Need some data driven way to do this.
time.Sleep(30 * time.Second)

// replay the log poller on all the chains so that the logs are in the db.
// otherwise the plugins won't pick them up.
// TODO: this is happening too early, we need to wait for the chain readers to get their config
// and register the LP filters before this has any effect.
for _, node := range nodes {
for chainID, replayBlock := range replayBlocks {
t.Logf("Replaying logs for chain %d from block %d", chainID, replayBlock)
require.NoError(t, node.app.ReplayFromBlock(big.NewInt(int64(chainID)), replayBlock, false), "failed to replay logs")
}
}

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()
}

t.Log("PingPong AGAIN")
sendPingPong(t, universes, pingPongs, messageIDs, replayBlocks, 2)

for _, uni := range universes {
startBlock := preRequestBlocks[uni.chainID]
wg.Add(1)
go func(uni onchainUniverse, startBlock *uint64) {
defer wg.Done()
waitForCommit(t, uni, numUnis, startBlock)
}(uni, &startBlock)
}

t.Log("waiting for second batch of commit reports")
wg.Wait()
}

func sendPingPong(t *testing.T, universes map[uint64]onchainUniverse, pingPongs map[uint64]map[uint64]*ping_pong_demo.PingPongDemo, messageIDs map[uint64]map[uint64][32]byte, replayBlocks map[uint64]uint64, expectedSeqNum uint64) {
for chainID, uni := range universes {
var replayBlock uint64
for otherChain, pingPong := range pingPongs[chainID] {
t.Log("PingPong From: ", chainID, " To: ", otherChain)

expNextSeqNr, err1 := uni.onramp.GetExpectedNextSequenceNumber(&bind.CallOpts{}, getSelector(otherChain))
require.NoError(t, err1)
require.Equal(t, uint64(1), expNextSeqNr, "expected next sequence number should be 1")
require.Equal(t, expectedSeqNum, expNextSeqNr, "expected next sequence number should be 1")

uni.backend.Commit()

Expand Down Expand Up @@ -193,30 +246,14 @@ func TestIntegration_OCR3Nodes(t *testing.T) {
}
replayBlocks[chainID] = replayBlock
}

// HACK: wait for the oracles to come up.
// Need some data driven way to do this.
time.Sleep(30 * time.Second)

// replay the log poller on all the chains so that the logs are in the db.
// otherwise the plugins won't pick them up.
// TODO: this is happening too early, we need to wait for the chain readers to get their config
// and register the LP filters before this has any effect.
for _, node := range nodes {
for chainID, replayBlock := range replayBlocks {
t.Logf("Replaying logs for chain %d from block %d", chainID, replayBlock)
require.NoError(t, node.app.ReplayFromBlock(big.NewInt(int64(chainID)), replayBlock, false), "failed to replay logs")
}
}

for _, uni := range universes {
waitForCommit(t, uni)
}
}

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 +264,15 @@ 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
}
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.19
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-20240725105722-fb2380a3f739
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.19 h1:y82TyWaOA6gSvi26bbyDYgfZv
github.com/smartcontractkit/chain-selectors v1.0.19/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-20240725105722-fb2380a3f739 h1:eYe/NS0b97yJV5ffLB+v6ww6R9FcUZV1k07tuArhCdY=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240725105722-fb2380a3f739/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-20240725105722-fb2380a3f739 // 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.19 h1:y82TyWaOA6gSvi26bbyDYgfZv
github.com/smartcontractkit/chain-selectors v1.0.19/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-20240725105722-fb2380a3f739 h1:eYe/NS0b97yJV5ffLB+v6ww6R9FcUZV1k07tuArhCdY=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240725105722-fb2380a3f739/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-20240725105722-fb2380a3f739 // 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.19 h1:y82TyWaOA6gSvi26bbyDYgfZv
github.com/smartcontractkit/chain-selectors v1.0.19/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-20240725105722-fb2380a3f739 h1:eYe/NS0b97yJV5ffLB+v6ww6R9FcUZV1k07tuArhCdY=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240725105722-fb2380a3f739/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 663ea86

Please sign in to comment.