Skip to content

Commit

Permalink
Ccip-4110 migration test (#15854)
Browse files Browse the repository at this point in the history
* remove deployCCIPContracts

* deprecate existing add lane

* new migration test

* first version

* more updates

* fix tests

* more fixes

* include in pipeline

* enabling test

* upgrade chainlink ccip fixing router binding issues in migration

* upgrade chainlink ccip fixing router binding issues in migration

* review comments

* review comments

* review comments

* fix

* fix imports

* upgrade ccip

* fix

---------

Co-authored-by: asoliman <[email protected]>
  • Loading branch information
AnieeG and asoliman92 authored Jan 10, 2025
1 parent 5156cfe commit 6a91c28
Show file tree
Hide file tree
Showing 42 changed files with 551 additions and 273 deletions.
7 changes: 7 additions & 0 deletions .github/integration-in-memory-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
#
runner-test-matrix:
# START: CCIPv1.6 tests
- id: smoke/ccip/ccip_migration_to_v_1_6_test.go:*
path: integration-tests/smoke/ccip/ccip_migration_to_v_1_6_test.go.go
test_env_type: in-memory
runs_on: ubuntu-latest
triggers:
- PR Integration CCIP Tests
test_cmd: cd integration-tests/smoke/ccip && go test ccip_migration_to_v_1_6_test.go -timeout 12m -test.parallel=1 -count=1 -json

- id: smoke/ccip/ccip_fees_test.go:*
path: integration-tests/smoke/ccip/ccip_fees_test.go
Expand Down
2 changes: 1 addition & 1 deletion core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,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.36 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250109124515-ff9d86b874ba // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 // indirect
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b // indirect
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e // indirect
github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20241216163550-fa030d178ba3 // 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 @@ -1158,8 +1158,8 @@ github.com/smartcontractkit/chain-selectors v1.0.36 h1:KSpO8I+JOiuyN4FuXsV471sPo
github.com/smartcontractkit/chain-selectors v1.0.36/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-20250109124515-ff9d86b874ba h1:gisAer1YxKKui6LhxDgfuZ3OyrHVjHm/oK/0idusFeI=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250109124515-ff9d86b874ba/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 h1:TeWnxdgSO2cYCKcBMwdkRcs/YdhSvXoWqqw7QWz/KeI=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b h1:UBXi9Yj8YSMHDDaxQLu273x1fWjyEL9xP58nuJsqZfg=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60=
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250108194320-2ebd63bbb16e h1:8BStiP1F4W8AvjBRga0TYtjvAtkwN8oHYnHJztAlSF4=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ type JobType string
const (
Commit JobType = "commit"
Execution JobType = "exec"
Boostrap JobType = "bootstrap"
Bootstrap JobType = "bootstrap"
)

func JobName(jobType JobType, source string, destination, version string) string {
Expand Down Expand Up @@ -329,7 +329,7 @@ func (params CCIPJobSpecParams) BootstrapJob(contractID string) *OCR2TaskJobSpec
},
}
return &OCR2TaskJobSpec{
Name: fmt.Sprintf("%s-%s", Boostrap, params.DestChainName),
Name: fmt.Sprintf("%s-%s-%s", Bootstrap, params.SourceChainName, params.DestChainName),
JobType: "bootstrap",
OCR2OracleSpec: bootstrapSpec,
}
Expand Down
2 changes: 1 addition & 1 deletion deployment/ccip/changeset/accept_ownership_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

func Test_NewAcceptOwnershipChangeset(t *testing.T) {
t.Parallel()
e := NewMemoryEnvironment(t)
e, _ := NewMemoryEnvironment(t)
state, err := LoadOnchainState(e.Env)
require.NoError(t, err)

Expand Down
3 changes: 2 additions & 1 deletion deployment/ccip/changeset/cs_active_candidate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"golang.org/x/exp/maps"

"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"

"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal"
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"

Expand All @@ -25,7 +26,7 @@ func Test_ActiveCandidate(t *testing.T) {
// We want to have the active instance execute a few messages
// and then setup a candidate instance. The candidate instance
// should not be able to transmit anything until we make it active.
tenv := NewMemoryEnvironment(t,
tenv, _ := NewMemoryEnvironment(t,
WithChains(2),
WithNodes(4))
state, err := LoadOnchainState(tenv.Env)
Expand Down
84 changes: 2 additions & 82 deletions deployment/ccip/changeset/cs_add_lane_test.go
Original file line number Diff line number Diff line change
@@ -1,106 +1,26 @@
package changeset

import (
"math/big"
"testing"

"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"

commoncs "github.com/smartcontractkit/chainlink/deployment/common/changeset"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/fee_quoter"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"
)

func TestAddLanesWithTestRouter(t *testing.T) {
t.Parallel()
e := NewMemoryEnvironment(t)
e, _ := NewMemoryEnvironment(t)
// Here we have CR + nodes set up, but no CCIP contracts deployed.
state, err := LoadOnchainState(e.Env)
require.NoError(t, err)

selectors := e.Env.AllChainSelectors()
chain1, chain2 := selectors[0], selectors[1]

stateChain1 := state.Chains[chain1]
e.Env, err = commoncs.ApplyChangesets(t, e.Env, e.TimelockContracts(t), []commoncs.ChangesetApplication{
{
Changeset: commoncs.WrapChangeSet(UpdateOnRampsDests),
Config: UpdateOnRampDestsConfig{
UpdatesByChain: map[uint64]map[uint64]OnRampDestinationUpdate{
chain1: {
chain2: {
IsEnabled: true,
TestRouter: true,
AllowListEnabled: false,
},
},
},
},
},
{
Changeset: commoncs.WrapChangeSet(UpdateFeeQuoterPricesCS),
Config: UpdateFeeQuoterPricesConfig{
PricesByChain: map[uint64]FeeQuoterPriceUpdatePerSource{
chain1: {
TokenPrices: map[common.Address]*big.Int{
stateChain1.LinkToken.Address(): DefaultLinkPrice,
stateChain1.Weth9.Address(): DefaultWethPrice,
},
GasPrices: map[uint64]*big.Int{
chain2: DefaultGasPrice,
},
},
},
},
},
{
Changeset: commoncs.WrapChangeSet(UpdateFeeQuoterDests),
Config: UpdateFeeQuoterDestsConfig{
UpdatesByChain: map[uint64]map[uint64]fee_quoter.FeeQuoterDestChainConfig{
chain1: {
chain2: DefaultFeeQuoterDestChainConfig(),
},
},
},
},
{
Changeset: commoncs.WrapChangeSet(UpdateOffRampSources),
Config: UpdateOffRampSourcesConfig{
UpdatesByChain: map[uint64]map[uint64]OffRampSourceUpdate{
chain2: {
chain1: {
IsEnabled: true,
TestRouter: true,
},
},
},
},
},
{
Changeset: commoncs.WrapChangeSet(UpdateRouterRamps),
Config: UpdateRouterRampsConfig{
TestRouter: true,
UpdatesByChain: map[uint64]RouterUpdates{
// onRamp update on source chain
chain1: {
OnRampUpdates: map[uint64]bool{
chain2: true,
},
},
// offramp update on dest chain
chain2: {
OffRampUpdates: map[uint64]bool{
chain1: true,
},
},
},
},
},
})
require.NoError(t, err)
AddLaneWithDefaultPricesAndFeeQuoterConfig(t, &e, state, chain1, chain2, true)
// Need to keep track of the block number for each chain so that event subscription can be done from that block.
startBlocks := make(map[uint64]*uint64)
// Send a message from each chain to every other chain.
Expand Down
8 changes: 4 additions & 4 deletions deployment/ccip/changeset/cs_ccip_home_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func Test_PromoteCandidate(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
ctx := testcontext.Get(t)
tenv := NewMemoryEnvironment(t,
tenv, _ := NewMemoryEnvironment(t,
WithChains(2),
WithNodes(4))
state, err := LoadOnchainState(tenv.Env)
Expand Down Expand Up @@ -130,7 +130,7 @@ func Test_SetCandidate(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
ctx := testcontext.Get(t)
tenv := NewMemoryEnvironment(t,
tenv, _ := NewMemoryEnvironment(t,
WithChains(2),
WithNodes(4))
state, err := LoadOnchainState(tenv.Env)
Expand Down Expand Up @@ -251,7 +251,7 @@ func Test_RevokeCandidate(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
ctx := testcontext.Get(t)
tenv := NewMemoryEnvironment(t,
tenv, _ := NewMemoryEnvironment(t,
WithChains(2),
WithNodes(4))
state, err := LoadOnchainState(tenv.Env)
Expand Down Expand Up @@ -442,7 +442,7 @@ func Test_UpdateChainConfigs(t *testing.T) {
},
} {
t.Run(tc.name, func(t *testing.T) {
tenv := NewMemoryEnvironment(t, WithChains(3))
tenv, _ := NewMemoryEnvironment(t, WithChains(3))
state, err := LoadOnchainState(tenv.Env)
require.NoError(t, err)

Expand Down
10 changes: 8 additions & 2 deletions deployment/ccip/changeset/cs_chain_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,8 +792,14 @@ func (cfg UpdateRouterRampsConfig) Validate(e deployment.Environment) error {
if chainState.OffRamp == nil {
return fmt.Errorf("missing onramp onramp for chain %d", chainSel)
}
if err := commoncs.ValidateOwnership(e.GetContext(), cfg.MCMS != nil, e.Chains[chainSel].DeployerKey.From, chainState.Timelock.Address(), chainState.Router); err != nil {
return err
if cfg.TestRouter {
if err := commoncs.ValidateOwnership(e.GetContext(), cfg.MCMS != nil, e.Chains[chainSel].DeployerKey.From, chainState.Timelock.Address(), chainState.TestRouter); err != nil {
return err
}
} else {
if err := commoncs.ValidateOwnership(e.GetContext(), cfg.MCMS != nil, e.Chains[chainSel].DeployerKey.From, chainState.Timelock.Address(), chainState.Router); err != nil {
return err
}
}

for source := range update.OffRampUpdates {
Expand Down
10 changes: 5 additions & 5 deletions deployment/ccip/changeset/cs_chain_contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestUpdateOnRampsDests(t *testing.T) {
ctx := testcontext.Get(t)
// Default env just has 2 chains with all contracts
// deployed but no lanes.
tenv := NewMemoryEnvironment(t)
tenv, _ := NewMemoryEnvironment(t)
state, err := LoadOnchainState(tenv.Env)
require.NoError(t, err)

Expand Down Expand Up @@ -106,7 +106,7 @@ func TestUpdateOffRampsSources(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
ctx := testcontext.Get(t)
tenv := NewMemoryEnvironment(t)
tenv, _ := NewMemoryEnvironment(t)
state, err := LoadOnchainState(tenv.Env)
require.NoError(t, err)

Expand Down Expand Up @@ -176,7 +176,7 @@ func TestUpdateFQDests(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
ctx := testcontext.Get(t)
tenv := NewMemoryEnvironment(t)
tenv, _ := NewMemoryEnvironment(t)
state, err := LoadOnchainState(tenv.Env)
require.NoError(t, err)

Expand Down Expand Up @@ -244,7 +244,7 @@ func TestUpdateRouterRamps(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
ctx := testcontext.Get(t)
tenv := NewMemoryEnvironment(t)
tenv, _ := NewMemoryEnvironment(t)
state, err := LoadOnchainState(tenv.Env)
require.NoError(t, err)

Expand Down Expand Up @@ -320,7 +320,7 @@ func TestUpdateNonceManagersCS(t *testing.T) {
},
} {
t.Run(tc.name, func(t *testing.T) {
tenv := NewMemoryEnvironment(t)
tenv, _ := NewMemoryEnvironment(t)
state, err := LoadOnchainState(tenv.Env)
require.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletion deployment/ccip/changeset/cs_deploy_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestDeployChainContractsChangeset(t *testing.T) {

func TestDeployCCIPContracts(t *testing.T) {
t.Parallel()
e := NewMemoryEnvironment(t)
e, _ := NewMemoryEnvironment(t)
// Deploy all the CCIP contracts.
state, err := LoadOnchainState(e.Env)
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions deployment/ccip/changeset/cs_home_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestDeployHomeChain(t *testing.T) {
}

func TestRemoveDonsValidate(t *testing.T) {
e := NewMemoryEnvironment(t)
e, _ := NewMemoryEnvironment(t)
s, err := LoadOnchainState(e.Env)
require.NoError(t, err)
homeChain := s.Chains[e.HomeChainSel]
Expand Down Expand Up @@ -117,7 +117,7 @@ func TestRemoveDonsValidate(t *testing.T) {
}

func TestRemoveDons(t *testing.T) {
e := NewMemoryEnvironment(t)
e, _ := NewMemoryEnvironment(t)
s, err := LoadOnchainState(e.Env)
require.NoError(t, err)
homeChain := s.Chains[e.HomeChainSel]
Expand Down
19 changes: 17 additions & 2 deletions deployment/ccip/changeset/cs_update_rmn_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestUpdateRMNConfig(t *testing.T) {
}

func updateRMNConfig(t *testing.T, tc updateRMNConfigTestCase) {
e := NewMemoryEnvironment(t)
e, _ := NewMemoryEnvironment(t)

state, err := LoadOnchainState(e.Env)
require.NoError(t, err)
Expand Down Expand Up @@ -220,7 +220,7 @@ func buildRMNRemoteAddressPerChain(e deployment.Environment, state CCIPOnChainSt

func TestSetRMNRemoteOnRMNProxy(t *testing.T) {
t.Parallel()
e := NewMemoryEnvironment(t, WithNoJobsAndContracts())
e, _ := NewMemoryEnvironment(t, WithNoJobsAndContracts())
allChains := e.Env.AllChainSelectors()
mcmsCfg := make(map[uint64]commontypes.MCMSWithTimelockConfig)
var err error
Expand Down Expand Up @@ -265,6 +265,8 @@ func TestSetRMNRemoteOnRMNProxy(t *testing.T) {
CallProxy: state.Chains[chain].CallProxy,
}
}
envNodes, err := deployment.NodeInfo(e.Env.NodeIDs, e.Env.Offchain)
require.NoError(t, err)
e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, timelockContractsPerChain, []commonchangeset.ChangesetApplication{
// transfer ownership of RMNProxy to timelock
{
Expand All @@ -274,6 +276,19 @@ func TestSetRMNRemoteOnRMNProxy(t *testing.T) {
MinDelay: 0,
},
},

{
Changeset: commonchangeset.WrapChangeSet(DeployHomeChain),
Config: DeployHomeChainConfig{
HomeChainSel: e.HomeChainSel,
RMNDynamicConfig: NewTestRMNDynamicConfig(),
RMNStaticConfig: NewTestRMNStaticConfig(),
NodeOperators: NewTestNodeOperator(e.Env.Chains[e.HomeChainSel].DeployerKey.From),
NodeP2PIDsPerNodeOpAdmin: map[string][][32]byte{
"NodeOperator": envNodes.NonBootstraps().PeerIDs(),
},
},
},
{
Changeset: commonchangeset.WrapChangeSet(DeployChainContracts),
Config: DeployChainContractsConfig{
Expand Down
2 changes: 1 addition & 1 deletion deployment/ccip/changeset/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func TestSmokeState(t *testing.T) {
tenv := NewMemoryEnvironment(t, WithChains(3))
tenv, _ := NewMemoryEnvironment(t, WithChains(3))
state, err := LoadOnchainState(tenv.Env)
require.NoError(t, err)
_, err = state.View(tenv.Env.AllChainSelectors())
Expand Down
Loading

0 comments on commit 6a91c28

Please sign in to comment.