From eb03ec3abd51b45f19fe227d84231a880d00fe37 Mon Sep 17 00:00:00 2001 From: Anindita Ghosh <88458927+AnieeG@users.noreply.github.com> Date: Wed, 23 Oct 2024 19:32:11 -0700 Subject: [PATCH] Enable add chain test (#14904) * Add FeeQuoter to SourceConfig Add missing function from DestConfig * cl-ccip bump * Debugging * Fix OnRamp.GetDestChainConfig All destChain configs have same Router address which is the same as the chainSel. We just need to call with a different destChainSelector * Cleaning * Clean contract configs * Clean contract configs * Add Gas Price test in initial_deploy_test.go * Bump chainlink-ccip * Bump chainlink-ccip * cleaning cmoments * linting * skip failing test for now * unskip * Add FeeQuoter to SourceConfig Add missing function from DestConfig Debugging Fix OnRamp.GetDestChainConfig All destChain configs have same Router address which is the same as the chainSel. We just need to call with a different destChainSelector Cleaning Clean contract configs Clean contract configs Add Gas Price test in initial_deploy_test.go Bump chainlink-ccip Bump chainlink-ccip cleaning cmoments linting skip failing test for now unskip * Bump chainlink-ccip * Add weth feed * Remove deprecated thing. * Add assertions for weth * Remove replacement. * linting * gomodtidy * Make TestAddChainInbound test Bidirectional and rename to TestAddChain * updates * changes * more changes * updates * go mod update * more fix * fix lint * fix lint * go mod --------- Co-authored-by: asoliman Co-authored-by: Will Winder --- .../deployment/ccip/add_chain.go | 60 ++----------------- .../deployment/ccip/add_chain_test.go | 1 - integration-tests/deployment/ccip/add_lane.go | 9 ++- .../ccip/changeset/initial_deploy_test.go | 12 ++-- .../deployment/ccip/deploy_home_chain.go | 41 ++++++++++++- .../deployment/ccip/test_helpers.go | 4 +- .../deployment/ccip/token_info.go | 1 + integration-tests/load/go.mod | 2 +- 8 files changed, 58 insertions(+), 72 deletions(-) diff --git a/integration-tests/deployment/ccip/add_chain.go b/integration-tests/deployment/ccip/add_chain.go index 3dc1f2db5eb..bc6ff67ba1c 100644 --- a/integration-tests/deployment/ccip/add_chain.go +++ b/integration-tests/deployment/ccip/add_chain.go @@ -9,15 +9,8 @@ import ( "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/mcms" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" - chainsel "github.com/smartcontractkit/chain-selectors" - - "github.com/smartcontractkit/chainlink-ccip/chainconfig" - - "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" - "github.com/smartcontractkit/chainlink/integration-tests/deployment" "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ccip_home" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/fee_quoter" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/onramp" ) @@ -35,7 +28,6 @@ func NewChainInboundProposal( var batches []timelock.BatchChainOperation var chains []uint64 for _, source := range sources { - chain, _ := chainsel.ChainBySelector(source) enableOnRampDest, err := state.Chains[source].OnRamp.ApplyDestChainConfigUpdates(deployment.SimTransactOpts(), []onramp.OnRampDestChainConfigArgs{ { DestChainSelector: newChainSel, @@ -56,22 +48,8 @@ func NewChainInboundProposal( if err != nil { return nil, err } - initialPrices, err := state.Chains[source].FeeQuoter.UpdatePrices( - deployment.SimTransactOpts(), - fee_quoter.InternalPriceUpdates{ - TokenPriceUpdates: []fee_quoter.InternalTokenPriceUpdate{}, - GasPriceUpdates: []fee_quoter.InternalGasPriceUpdate{ - { - DestChainSelector: newChainSel, - // TODO: parameterize - UsdPerUnitGas: big.NewInt(2e12), - }, - }}) - if err != nil { - return nil, err - } batches = append(batches, timelock.BatchChainOperation{ - ChainIdentifier: mcms.ChainIdentifier(chain.Selector), + ChainIdentifier: mcms.ChainIdentifier(source), Batch: []mcms.Operation{ { // Enable the source in on ramp @@ -79,12 +57,6 @@ func NewChainInboundProposal( Data: enableOnRampDest.Data(), Value: big.NewInt(0), }, - { - // Set initial dest prices to unblock testing. - To: state.Chains[source].FeeQuoter.Address(), - Data: initialPrices.Data(), - Value: big.NewInt(0), - }, { To: state.Chains[source].FeeQuoter.Address(), Data: enableFeeQuoterDest.Data(), @@ -95,42 +67,18 @@ func NewChainInboundProposal( chains = append(chains, source) } - homeChain, _ := chainsel.ChainBySelector(homeChainSel) - nodes, err := deployment.NodeInfo(e.NodeIDs, e.Offchain) + addChainOp, err := ApplyChainConfigUpdatesOp(e, state, homeChainSel, []uint64{newChainSel}) if err != nil { return nil, err } - encodedExtraChainConfig, err := chainconfig.EncodeChainConfig(chainconfig.ChainConfig{ - GasPriceDeviationPPB: ccipocr3.NewBigIntFromInt64(1000), - DAGasPriceDeviationPPB: ccipocr3.NewBigIntFromInt64(0), - OptimisticConfirmations: 1, - }) - if err != nil { - return nil, err - } - chainConfig := SetupConfigInfo(newChainSel, nodes.NonBootstraps().PeerIDs(), - nodes.DefaultF(), encodedExtraChainConfig) - addChain, err := state.Chains[homeChainSel].CCIPHome.ApplyChainConfigUpdates( - deployment.SimTransactOpts(), nil, []ccip_home.CCIPHomeChainConfigArgs{ - chainConfig, - }) - if err != nil { - return nil, err - } - timelockAddresses, metaDataPerChain, err := BuildProposalMetadata(state, append(chains, homeChainSel)) if err != nil { return nil, err } batches = append(batches, timelock.BatchChainOperation{ - ChainIdentifier: mcms.ChainIdentifier(homeChain.Selector), + ChainIdentifier: mcms.ChainIdentifier(homeChainSel), Batch: []mcms.Operation{ - { - // Add the chain first, don needs it to be there. - To: state.Chains[homeChainSel].CCIPHome.Address(), - Data: addChain.Data(), - Value: big.NewInt(0), - }, + addChainOp, }, }) return timelock.NewMCMSWithTimelockProposal( diff --git a/integration-tests/deployment/ccip/add_chain_test.go b/integration-tests/deployment/ccip/add_chain_test.go index 1860e603a19..025e8aeaa45 100644 --- a/integration-tests/deployment/ccip/add_chain_test.go +++ b/integration-tests/deployment/ccip/add_chain_test.go @@ -24,7 +24,6 @@ import ( ) func TestAddChainInbound(t *testing.T) { - t.Skip("Skipping test. Working on it in another PR") // 4 chains where the 4th is added after initial deployment. e := NewMemoryEnvironmentWithJobs(t, logger.TestLogger(t), 4) state, err := LoadOnchainState(e.Env, e.Ab) diff --git a/integration-tests/deployment/ccip/add_lane.go b/integration-tests/deployment/ccip/add_lane.go index cfcb906096a..ab1e8f3d91b 100644 --- a/integration-tests/deployment/ccip/add_lane.go +++ b/integration-tests/deployment/ccip/add_lane.go @@ -119,10 +119,9 @@ func defaultFeeQuoterDestChainConfig() fee_quoter.FeeQuoterDestChainConfig { DestGasPerDataAvailabilityByte: 100, DestDataAvailabilityMultiplierBps: 1, DefaultTokenDestGasOverhead: 125_000, - //DefaultTokenDestBytesOverhead: 32, - DefaultTxGasLimit: 200_000, - GasMultiplierWeiPerEth: 1, - NetworkFeeUSDCents: 1, - ChainFamilySelector: [4]byte(evmFamilySelector), + DefaultTxGasLimit: 200_000, + GasMultiplierWeiPerEth: 1, + NetworkFeeUSDCents: 1, + ChainFamilySelector: [4]byte(evmFamilySelector), } } diff --git a/integration-tests/deployment/ccip/changeset/initial_deploy_test.go b/integration-tests/deployment/ccip/changeset/initial_deploy_test.go index ea2b74185c2..280147f463c 100644 --- a/integration-tests/deployment/ccip/changeset/initial_deploy_test.go +++ b/integration-tests/deployment/ccip/changeset/initial_deploy_test.go @@ -6,15 +6,16 @@ import ( cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink-ccip/pluginconfig" - "github.com/stretchr/testify/require" - - "github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext" + "github.com/smartcontractkit/chainlink/integration-tests/deployment" + ccdeploy "github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip" jobv1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/job" - "github.com/smartcontractkit/chainlink/integration-tests/deployment" - ccdeploy "github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip" + "github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext" + "github.com/smartcontractkit/chainlink/v2/core/logger" + + "github.com/stretchr/testify/require" ) func TestInitialDeploy(t *testing.T) { @@ -98,7 +99,6 @@ func TestInitialDeploy(t *testing.T) { // Wait for all commit reports to land. ccdeploy.ConfirmCommitForAllWithExpectedSeqNums(t, e, state, expectedSeqNum, startBlocks) - // TODO: use proper assertions to check gas and token prices using events // Wait for all exec reports to land diff --git a/integration-tests/deployment/ccip/deploy_home_chain.go b/integration-tests/deployment/ccip/deploy_home_chain.go index a3233aa3c6d..24057863acc 100644 --- a/integration-tests/deployment/ccip/deploy_home_chain.go +++ b/integration-tests/deployment/ccip/deploy_home_chain.go @@ -12,7 +12,6 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/pkg/errors" - "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/mcms" "github.com/smartcontractkit/chainlink-ccip/chainconfig" @@ -1075,3 +1074,43 @@ func AddDON( return nil } + +func ApplyChainConfigUpdatesOp( + e deployment.Environment, + state CCIPOnChainState, + homeChainSel uint64, + chains []uint64, +) (mcms.Operation, error) { + nodes, err := deployment.NodeInfo(e.NodeIDs, e.Offchain) + if err != nil { + return mcms.Operation{}, err + } + encodedExtraChainConfig, err := chainconfig.EncodeChainConfig(chainconfig.ChainConfig{ + GasPriceDeviationPPB: ccipocr3.NewBigIntFromInt64(1000), + DAGasPriceDeviationPPB: ccipocr3.NewBigIntFromInt64(0), + OptimisticConfirmations: 1, + }) + if err != nil { + return mcms.Operation{}, err + } + var chainConfigUpdates []ccip_home.CCIPHomeChainConfigArgs + for _, chainSel := range chains { + chainConfig := SetupConfigInfo(chainSel, nodes.NonBootstraps().PeerIDs(), + nodes.DefaultF(), encodedExtraChainConfig) + chainConfigUpdates = append(chainConfigUpdates, chainConfig) + } + + addChain, err := state.Chains[homeChainSel].CCIPHome.ApplyChainConfigUpdates( + deployment.SimTransactOpts(), + nil, + chainConfigUpdates, + ) + if err != nil { + return mcms.Operation{}, err + } + return mcms.Operation{ + To: state.Chains[homeChainSel].CCIPHome.Address(), + Data: addChain.Data(), + Value: big.NewInt(0), + }, nil +} diff --git a/integration-tests/deployment/ccip/test_helpers.go b/integration-tests/deployment/ccip/test_helpers.go index 09fbd34e05e..58a7c64a551 100644 --- a/integration-tests/deployment/ccip/test_helpers.go +++ b/integration-tests/deployment/ccip/test_helpers.go @@ -31,6 +31,8 @@ import ( jobv1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/job" "github.com/smartcontractkit/chainlink/integration-tests/deployment" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/mock_ethusd_aggregator_wrapper" + "github.com/smartcontractkit/chainlink/integration-tests/deployment/memory" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" "github.com/smartcontractkit/chainlink/integration-tests/testconfig" @@ -42,7 +44,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/mock_v3_aggregator_contract" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/aggregator_v3_interface" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/mock_ethusd_aggregator_wrapper" ) const ( @@ -557,5 +558,4 @@ func deploySingleFeed( } return mockTokenFeed.Address, desc, nil - } diff --git a/integration-tests/deployment/ccip/token_info.go b/integration-tests/deployment/ccip/token_info.go index 5760ba9eb21..b02402f603e 100644 --- a/integration-tests/deployment/ccip/token_info.go +++ b/integration-tests/deployment/ccip/token_info.go @@ -3,6 +3,7 @@ package ccipdeployment import ( "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" "github.com/smartcontractkit/chainlink-ccip/pluginconfig" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/weth9" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/burn_mint_erc677" diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index bb66f3911ce..b829150728c 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -57,6 +57,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-20241022184834-e8564a286a47 // indirect github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f // indirect github.com/smartcontractkit/chainlink-testing-framework/havoc v1.50.0 // indirect github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 // indirect @@ -406,7 +407,6 @@ require ( github.com/sirupsen/logrus v1.9.3 // indirect github.com/smartcontractkit/chain-selectors v1.0.27 // indirect github.com/smartcontractkit/chainlink-automation v1.0.0-alpha.0.0.20241023165837-8c05ee9b97d5 // indirect - github.com/smartcontractkit/chainlink-ccip v0.0.0-20241022184834-e8564a286a47 // indirect github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20241018134907-a00ba3729b5e // indirect github.com/smartcontractkit/chainlink-feeds v0.1.1 // indirect github.com/smartcontractkit/chainlink-protos/orchestrator v0.3.0 // indirect