Skip to content

Commit

Permalink
Enable add chain test (#14904)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Will Winder <[email protected]>
  • Loading branch information
3 people authored Oct 24, 2024
1 parent a48b264 commit eb03ec3
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 72 deletions.
60 changes: 4 additions & 56 deletions integration-tests/deployment/ccip/add_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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,
Expand All @@ -56,35 +48,15 @@ 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
To: state.Chains[source].OnRamp.Address(),
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(),
Expand All @@ -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(
Expand Down
1 change: 0 additions & 1 deletion integration-tests/deployment/ccip/add_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions integration-tests/deployment/ccip/add_lane.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
41 changes: 40 additions & 1 deletion integration-tests/deployment/ccip/deploy_home_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions integration-tests/deployment/ccip/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 (
Expand Down Expand Up @@ -557,5 +558,4 @@ func deploySingleFeed(
}

return mockTokenFeed.Address, desc, nil

}
1 change: 1 addition & 0 deletions integration-tests/deployment/ccip/token_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

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

0 comments on commit eb03ec3

Please sign in to comment.