Skip to content

Commit

Permalink
integration-tests/smoke/ccip: add the add chain test (#15903)
Browse files Browse the repository at this point in the history
* deployment/ccip/changeset: add the add chain test

* inbound working

* outbound from new chain

* fix inbound on toDeploy

* send msg from new chain to toDeploy

* fix lint, build

* transfer to mcms and wire to real router

* first pass at high level abstraction

separate cs apps to setup inbound & outbound

* move test to integration-tests

* fix

* goimports

* fixes, fee boosting cfg

* fix test

* axe duplicate

* remove time.Sleep, update docstrings

* add onramp equality check
  • Loading branch information
makramkd authored Jan 17, 2025
1 parent 410b3d0 commit 0796288
Show file tree
Hide file tree
Showing 19 changed files with 895 additions and 39 deletions.
8 changes: 8 additions & 0 deletions .github/integration-in-memory-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ runner-test-matrix:
triggers:
- PR Integration CCIP Tests
test_cmd: cd integration-tests/smoke/ccip && go test ccip_batching_test.go -timeout 12m -test.parallel=2 -count=1 -json

- id: smoke/ccip/ccip_add_chain_test.go:*
path: integration-tests/smoke/ccip/ccip_add_chain_test.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_add_chain_test.go -timeout 15m -test.parallel=1 -count=1 -json

- id: smoke/ccip/ccip_reader_test.go:*
path: integration-tests/smoke/ccip/ccip_reader_test.go
Expand Down
9 changes: 6 additions & 3 deletions deployment/ccip/changeset/cs_chain_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ func UpdateNonceManagersChangeset(e deployment.Environment, cfg UpdateNonceManag
if err != nil {
return deployment.ChangesetOutput{}, fmt.Errorf("error updating previous ramps for chain %s: %w", e.Chains[chainSel].String(), err)
}
if err != nil {
return deployment.ChangesetOutput{}, fmt.Errorf("error updating previous ramps for chain %s: %w", e.Chains[chainSel].String(), err)
}
}
if cfg.MCMS == nil {
if authTx != nil {
Expand Down Expand Up @@ -219,6 +216,7 @@ func UpdateNonceManagersChangeset(e deployment.Environment, cfg UpdateNonceManag
}

type UpdateOnRampDestsConfig struct {
// UpdatesByChain is a mapping of source -> dest -> update.
UpdatesByChain map[uint64]map[uint64]OnRampDestinationUpdate
// Disallow mixing MCMS/non-MCMS per chain for simplicity.
// (can still be achieved by calling this function multiple times)
Expand Down Expand Up @@ -490,6 +488,8 @@ func UpdateFeeQuoterPricesChangeset(e deployment.Environment, cfg UpdateFeeQuote
},
},
})
timelocks[chainSel] = s.Chains[chainSel].Timelock.Address()
proposers[chainSel] = s.Chains[chainSel].ProposerMcm
}
}
if cfg.MCMS == nil {
Expand All @@ -512,6 +512,7 @@ func UpdateFeeQuoterPricesChangeset(e deployment.Environment, cfg UpdateFeeQuote
}

type UpdateFeeQuoterDestsConfig struct {
// UpdatesByChain is a mapping from source -> dest -> config update.
UpdatesByChain map[uint64]map[uint64]fee_quoter.FeeQuoterDestChainConfig
// Disallow mixing MCMS/non-MCMS per chain for simplicity.
// (can still be achieved by calling this function multiple times)
Expand Down Expand Up @@ -627,6 +628,8 @@ func UpdateFeeQuoterDestsChangeset(e deployment.Environment, cfg UpdateFeeQuoter
}

type UpdateOffRampSourcesConfig struct {
// UpdatesByChain is a mapping from dest chain -> source chain -> source chain
// update on the dest chain offramp.
UpdatesByChain map[uint64]map[uint64]OffRampSourceUpdate
MCMS *MCMSConfig
}
Expand Down
52 changes: 36 additions & 16 deletions deployment/ccip/changeset/testhelpers/test_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ func NewEnvironmentWithJobsAndContracts(t *testing.T, tEnv TestEnvironment) Depl
})
require.NoError(t, err)
tEnv.UpdateDeployedEnvironment(e)
e = AddCCIPContractsToEnvironment(t, e.Env.AllChainSelectors(), tEnv)
e = AddCCIPContractsToEnvironment(t, e.Env.AllChainSelectors(), tEnv, true, true, false)
// now we update RMNProxy to point to RMNRemote
e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, nil, []commonchangeset.ChangesetApplication{
{
Expand All @@ -473,15 +473,17 @@ func NewEnvironmentWithJobsAndContracts(t *testing.T, tEnv TestEnvironment) Depl
return e
}

func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEnvironment) DeployedEnv {
func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEnvironment, deployJobs, deployHomeChain, mcmsEnabled bool) DeployedEnv {
tc := tEnv.TestConfigs()
e := tEnv.DeployedEnvironment()
envNodes, err := deployment.NodeInfo(e.Env.NodeIDs, e.Env.Offchain)
require.NoError(t, err)

// Need to deploy prerequisites first so that we can form the USDC config
// no proposals to be made, timelock can be passed as nil here
e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, nil, []commonchangeset.ChangesetApplication{
{
var apps []commonchangeset.ChangesetApplication
if deployHomeChain {
apps = append(apps, commonchangeset.ChangesetApplication{
Changeset: commonchangeset.WrapChangeSet(changeset.DeployHomeChainChangeset),
Config: changeset.DeployHomeChainConfig{
HomeChainSel: e.HomeChainSel,
Expand All @@ -492,15 +494,16 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn
TestNodeOperator: envNodes.NonBootstraps().PeerIDs(),
},
},
},
{
Changeset: commonchangeset.WrapChangeSet(changeset.DeployChainContractsChangeset),
Config: changeset.DeployChainContractsConfig{
ChainSelectors: allChains,
HomeChainSelector: e.HomeChainSel,
},
})
}
apps = append(apps, commonchangeset.ChangesetApplication{
Changeset: commonchangeset.WrapChangeSet(changeset.DeployChainContractsChangeset),
Config: changeset.DeployChainContractsConfig{
ChainSelectors: allChains,
HomeChainSelector: e.HomeChainSel,
},
})
e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, nil, apps)
require.NoError(t, err)

state, err := changeset.LoadOnchainState(e.Env)
Expand Down Expand Up @@ -570,14 +573,25 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn
},
}
}
// Deploy second set of changesets to deploy and configure the CCIP contracts.
e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, timelockContractsPerChain, []commonchangeset.ChangesetApplication{
timelockContractsPerChain[e.HomeChainSel] = &proposalutils.TimelockExecutionContracts{
Timelock: state.Chains[e.HomeChainSel].Timelock,
CallProxy: state.Chains[e.HomeChainSel].CallProxy,
}
// Apply second set of changesets to configure the CCIP contracts.
var mcmsConfig *changeset.MCMSConfig
if mcmsEnabled {
mcmsConfig = &changeset.MCMSConfig{
MinDelay: 0,
}
}
apps = []commonchangeset.ChangesetApplication{
{
// Add the chain configs for the new chains.
Changeset: commonchangeset.WrapChangeSet(changeset.UpdateChainConfigChangeset),
Config: changeset.UpdateChainConfigConfig{
HomeChainSelector: e.HomeChainSel,
RemoteChainAdds: chainConfigs,
MCMS: mcmsConfig,
},
},
{
Expand All @@ -587,6 +601,7 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn
SetCandidateConfigBase: changeset.SetCandidateConfigBase{
HomeChainSelector: e.HomeChainSel,
FeedChainSelector: e.FeedChainSel,
MCMS: mcmsConfig,
},
PluginInfo: changeset.SetCandidatePluginInfo{
OCRConfigPerRemoteChainSelector: ocrConfigs,
Expand All @@ -601,6 +616,7 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn
SetCandidateConfigBase: changeset.SetCandidateConfigBase{
HomeChainSelector: e.HomeChainSel,
FeedChainSelector: e.FeedChainSel,
MCMS: mcmsConfig,
},
PluginInfo: []changeset.SetCandidatePluginInfo{
{
Expand All @@ -625,6 +641,7 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn
RemoteChainSelectors: allChains,
},
},
MCMS: mcmsConfig,
},
},
{
Expand All @@ -635,10 +652,13 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn
RemoteChainSels: allChains,
},
},
{
}
if deployJobs {
apps = append(apps, commonchangeset.ChangesetApplication{
Changeset: commonchangeset.WrapChangeSet(changeset.CCIPCapabilityJobspecChangeset),
},
})
})
}
e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, timelockContractsPerChain, apps)
require.NoError(t, err)

ReplayLogs(t, e.Env.Offchain, e.ReplayBlocks)
Expand Down
16 changes: 14 additions & 2 deletions deployment/ccip/changeset/testhelpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,15 @@ func MakeEVMExtraArgsV2(gasLimit uint64, allowOOO bool) []byte {
return extraArgs
}

func AddLane(t *testing.T, e *DeployedEnv, from, to uint64, isTestRouter bool, gasprice map[uint64]*big.Int, tokenPrices map[common.Address]*big.Int, fqCfg fee_quoter.FeeQuoterDestChainConfig) {
func AddLane(
t *testing.T,
e *DeployedEnv,
from, to uint64,
isTestRouter bool,
gasprice map[uint64]*big.Int,
tokenPrices map[common.Address]*big.Int,
fqCfg fee_quoter.FeeQuoterDestChainConfig,
) {
var err error
e.Env, err = commoncs.ApplyChangesets(t, e.Env, e.TimelockContracts(t), []commoncs.ChangesetApplication{
{
Expand Down Expand Up @@ -475,7 +483,11 @@ func AddLane(t *testing.T, e *DeployedEnv, from, to uint64, isTestRouter bool, g

func AddLaneWithDefaultPricesAndFeeQuoterConfig(t *testing.T, e *DeployedEnv, state changeset.CCIPOnChainState, from, to uint64, isTestRouter bool) {
stateChainFrom := state.Chains[from]
AddLane(t, e, from, to, isTestRouter,
AddLane(
t,
e,
from, to,
isTestRouter,
map[uint64]*big.Int{
to: DefaultGasPrice,
}, map[common.Address]*big.Int{
Expand Down
8 changes: 4 additions & 4 deletions deployment/environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import (

func TestNode_OCRConfigForChainSelector(t *testing.T) {
var m = map[chain_selectors.ChainDetails]OCRConfig{
chain_selectors.ChainDetails{
{
ChainSelector: chain_selectors.APTOS_TESTNET.Selector,
ChainName: chain_selectors.APTOS_TESTNET.Name,
}: OCRConfig{
}: {
KeyBundleID: "aptos bundle 1",
},
chain_selectors.ChainDetails{
{
ChainSelector: chain_selectors.ETHEREUM_MAINNET_ARBITRUM_1.Selector,
ChainName: chain_selectors.ETHEREUM_MAINNET_ARBITRUM_1.Name,
}: OCRConfig{
}: {
KeyBundleID: "arb bundle 1",
},
}
Expand Down
Loading

0 comments on commit 0796288

Please sign in to comment.