Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable add chain test #14904

Merged
merged 40 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
be45932
Add FeeQuoter to SourceConfig
asoliman92 Oct 17, 2024
0f8fc41
Merge branch 'develop' into fix-fee-quoter
asoliman92 Oct 17, 2024
c276a80
cl-ccip bump
asoliman92 Oct 17, 2024
39e6338
Merge branch 'develop' into fix-fee-quoter
asoliman92 Oct 18, 2024
009f334
Debugging
asoliman92 Oct 18, 2024
ad5635f
Fix OnRamp.GetDestChainConfig
asoliman92 Oct 18, 2024
e58e79c
Cleaning
asoliman92 Oct 21, 2024
1adc8c0
Clean contract configs
asoliman92 Oct 21, 2024
085bd48
Clean contract configs
asoliman92 Oct 21, 2024
397420e
Add Gas Price test in initial_deploy_test.go
asoliman92 Oct 21, 2024
98e5ac2
Bump chainlink-ccip
asoliman92 Oct 21, 2024
ef99468
Merge branch 'develop' into fix-fee-quoter
asoliman92 Oct 21, 2024
157e441
Bump chainlink-ccip
asoliman92 Oct 21, 2024
3a68a95
Merge branch 'develop' into fix-fee-quoter
asoliman92 Oct 22, 2024
d2e5ac0
cleaning cmoments
asoliman92 Oct 22, 2024
83fa7c8
linting
asoliman92 Oct 22, 2024
36169af
skip failing test for now
asoliman92 Oct 22, 2024
3bb786a
unskip
asoliman92 Oct 22, 2024
ea86129
Add FeeQuoter to SourceConfig
asoliman92 Oct 17, 2024
c6230b4
Bump chainlink-ccip
winder Oct 22, 2024
0614569
Add weth feed
asoliman92 Oct 22, 2024
f95de90
Remove deprecated thing.
winder Oct 22, 2024
131211a
Add assertions for weth
asoliman92 Oct 22, 2024
0120ff5
Remove replacement.
winder Oct 22, 2024
e9d9681
linting
asoliman92 Oct 22, 2024
d84c55a
gomodtidy
winder Oct 22, 2024
21a5c0a
Make TestAddChainInbound test Bidirectional and rename to TestAddChain
asoliman92 Oct 22, 2024
fe8ff1f
Merge branch 'fix-fee-quoter' into add-weth-feed
asoliman92 Oct 22, 2024
596033f
updates
AnieeG Oct 22, 2024
7e0bfe0
enable testaddchain
AnieeG Oct 22, 2024
0dc1a11
changes
AnieeG Oct 22, 2024
355005a
more changes
AnieeG Oct 22, 2024
6b65996
updates
AnieeG Oct 22, 2024
739cedf
go mod update
AnieeG Oct 22, 2024
a6da0cd
more fix
AnieeG Oct 22, 2024
2952a0c
fix lint
AnieeG Oct 22, 2024
b4b7913
fix lint
AnieeG Oct 22, 2024
62a0290
fix conflicts
AnieeG Oct 23, 2024
201ea59
go mod
AnieeG Oct 23, 2024
bd58ad7
merge
AnieeG Oct 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
enable testaddchain
  • Loading branch information
AnieeG committed Oct 22, 2024
commit 7e0bfe0decf7d86ba9732f3b1d8208be66a9aba1
92 changes: 1 addition & 91 deletions integration-tests/deployment/ccip/add_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,76 +15,6 @@
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/onramp"
)

func NewChainOutboundProposal(
state CCIPOnChainState,
newChainSel uint64,
dests []uint64,
) (*timelock.MCMSWithTimelockProposal, error) {
// Generate proposal which enables new source (from test router) on all existing destination chains.
var batches []timelock.BatchChainOperation
var onRampDestChainConfigArgs []onramp.OnRampDestChainConfigArgs
var fqDestChainConfigArgs []fee_quoter.FeeQuoterDestChainConfigArgs
for _, dest := range dests {
onRampDestChainConfigArgs = append(onRampDestChainConfigArgs, onramp.OnRampDestChainConfigArgs{
DestChainSelector: dest,
Router: state.Chains[newChainSel].TestRouter.Address(),
})
fqDestChainConfigArgs = append(fqDestChainConfigArgs, fee_quoter.FeeQuoterDestChainConfigArgs{
DestChainSelector: dest,
DestChainConfig: defaultFeeQuoterDestChainConfig(),
})
}

enableOnRampDest, err := state.Chains[newChainSel].OnRamp.ApplyDestChainConfigUpdates(
deployment.SimTransactOpts(),
onRampDestChainConfigArgs,
)
if err != nil {
return nil, err
}
enableFeeQuoterDest, err := state.Chains[newChainSel].FeeQuoter.ApplyDestChainConfigUpdates(
deployment.SimTransactOpts(),
fqDestChainConfigArgs,
)
if err != nil {
return nil, err
}

batches = append(batches, timelock.BatchChainOperation{
ChainIdentifier: mcms.ChainIdentifier(newChainSel),
Batch: []mcms.Operation{
{
// Enable the source in on ramp
To: state.Chains[newChainSel].OnRamp.Address(),
Data: enableOnRampDest.Data(),
Value: big.NewInt(0),
},
{
To: state.Chains[newChainSel].FeeQuoter.Address(),
Data: enableFeeQuoterDest.Data(),
Value: big.NewInt(0),
},
},
})

timelockAddresses, metaDataPerChain, err := BuildProposalMetadata(state, []uint64{newChainSel})
if err != nil {
return nil, err
}
return timelock.NewMCMSWithTimelockProposal(
"1",
2004259681, // TODO: should be parameterized and based on current block timestamp.
[]mcms.Signature{},
false,
metaDataPerChain,
timelockAddresses,
"blah", // TODO
batches,
timelock.Schedule,
"0s", // TODO: Should be parameterized.
)
}

// NewChainInboundProposal generates a proposal
// to connect the new chain to the existing chains.
func NewChainInboundProposal(
Expand Down Expand Up @@ -118,20 +48,6 @@
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(source),
Batch: []mcms.Operation{
Expand All @@ -141,12 +57,6 @@
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 @@ -157,7 +67,7 @@
chains = append(chains, source)
}

addChainOp, err := ApplyChainConfigUpdatesOp(e, state, homeChainSel, []uint64{newChainSel})

Check failure on line 70 in integration-tests/deployment/ccip/add_chain.go

View workflow job for this annotation

GitHub Actions / Lint integration-tests

ineffectual assignment to err (ineffassign)

timelockAddresses, metaDataPerChain, err := BuildProposalMetadata(state, append(chains, homeChainSel))
if err != nil {
Expand Down Expand Up @@ -200,7 +110,7 @@
state.Chains[newChainSel].OffRamp,
e.Chains[newChainSel],
feedChainSel,
tokenConfig.GetLinkInfo(e.Logger, state.Chains[newChainSel].LinkToken, state.Chains[newChainSel].Weth9),
tokenConfig.GetTokenInfo(e.Logger, state.Chains[newChainSel].LinkToken, state.Chains[newChainSel].Weth9),
nodes.NonBootstraps(),
rmnHomeAddress,
)
Expand Down
107 changes: 95 additions & 12 deletions integration-tests/deployment/ccip/add_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (

"github.com/ethereum/go-ethereum/common"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/fee_quoter"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/onramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_home"

cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
Expand All @@ -23,6 +25,10 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/logger"
)

// TestAddChain tests adding a new chain to the existing setup.
// It deploys contracts to a set chains and sets up lanes between them.
// Once the existing chain related contracts are transferred to timelock,
// it tries to add a new chain and sets up the new chain as source and destination with the existing chains.
func TestAddChain(t *testing.T) {
// 4 chains where the 4th is added after initial deployment.
e := NewMemoryEnvironmentWithJobs(t, logger.TestLogger(t), 4)
Expand Down Expand Up @@ -72,10 +78,6 @@ func TestAddChain(t *testing.T) {
}
}

// Initial state for tokens and gas prices
//initialGasUpdates := GetInitialGasUpdates(t, initialDeploy, state)
//initialTokenUpdates := GetInitialTokenUpdates(t, initialDeploy, state)

rmnHomeAddress, err := deployment.SearchAddressBook(e.Ab, e.HomeChainSel, RMNHome)
require.NoError(t, err)
require.True(t, common.IsHexAddress(rmnHomeAddress))
Expand All @@ -89,7 +91,7 @@ func TestAddChain(t *testing.T) {
require.NoError(t, err)

// Transfer onramp/fq ownership to timelock.
// Enable the new dest on the test router.
// Enable the new dest and source on the test router.
for _, source := range initialDeploy {
tx, err := state.Chains[source].OnRamp.TransferOwnership(e.Env.Chains[source].DeployerKey, state.Chains[source].Timelock.Address())
require.NoError(t, err)
Expand All @@ -99,7 +101,7 @@ func TestAddChain(t *testing.T) {
require.NoError(t, err)
_, err = deployment.ConfirmIfNoError(e.Env.Chains[source], tx, err)
require.NoError(t, err)
// enable the new chain as source and dest on the router.
// enable the new chain as source and dest on the test router.
tx, err = state.Chains[source].TestRouter.ApplyRampUpdates(e.Env.Chains[source].DeployerKey, []router.RouterOnRamp{
{
DestChainSelector: newChain,
Expand All @@ -113,6 +115,19 @@ func TestAddChain(t *testing.T) {
})
_, err = deployment.ConfirmIfNoError(e.Env.Chains[source], tx, err)
require.NoError(t, err)
tx, err = state.Chains[source].OffRamp.ApplySourceChainConfigUpdates(e.Env.Chains[source].DeployerKey, []offramp.OffRampSourceChainConfigArgs{
{
Router: state.Chains[newChain].TestRouter.Address(),
SourceChainSelector: newChain,
IsEnabled: true,
OnRamp: common.LeftPadBytes(state.Chains[newChain].OnRamp.Address().Bytes(), 32),
},
})
if err != nil {
return
}
_, err = deployment.ConfirmIfNoError(e.Env.Chains[source], tx, err)
require.NoError(t, err)
}
// Transfer CR contract ownership
tx, err := state.Chains[e.HomeChainSel].CapabilityRegistry.TransferOwnership(e.Env.Chains[e.HomeChainSel].DeployerKey, state.Chains[e.HomeChainSel].Timelock.Address())
Expand Down Expand Up @@ -158,7 +173,11 @@ func TestAddChain(t *testing.T) {
//SendRequest(t, e.Env, state, initialDeploy[0], newChain, true)

t.Logf("Executing add don and set candidate proposal for commit plugin on chain %d", newChain)
addDonProp, err := AddDonAndSetCandidateForCommitProposal(state, e.Env, nodes, deployment.XXXGenerateTestOCRSecrets(), e.HomeChainSel, e.FeedChainSel, newChain, tokenConfig, common.HexToAddress(rmnHomeAddress))
addDonProp, err := AddDonAndSetCandidateForCommitProposal(
state, e.Env, nodes, deployment.XXXGenerateTestOCRSecrets(),
e.HomeChainSel, e.FeedChainSel, newChain,
tokenConfig, common.HexToAddress(rmnHomeAddress),
)
require.NoError(t, err)

addDonExec := SignProposal(t, e.Env, addDonProp)
Expand Down Expand Up @@ -187,18 +206,39 @@ func TestAddChain(t *testing.T) {

// Now configure the new chain using deployer key (not transferred to timelock yet).
var offRampEnables []offramp.OffRampSourceChainConfigArgs
var fqDestChainConfigArgs []fee_quoter.FeeQuoterDestChainConfigArgs
var onRampUpdates []onramp.OnRampDestChainConfigArgs
var onRampRouterAdds []router.RouterOnRamp
var offRampRouterAdds []router.RouterOffRamp
for _, source := range initialDeploy {
offRampEnables = append(offRampEnables, offramp.OffRampSourceChainConfigArgs{
Router: state.Chains[newChain].Router.Address(),
SourceChainSelector: source,
IsEnabled: true,
OnRamp: common.LeftPadBytes(state.Chains[source].OnRamp.Address().Bytes(), 32),
})
fqDestChainConfigArgs = append(fqDestChainConfigArgs, fee_quoter.FeeQuoterDestChainConfigArgs{
DestChainSelector: source,
DestChainConfig: defaultFeeQuoterDestChainConfig(),
})
onRampUpdates = append(onRampUpdates, onramp.OnRampDestChainConfigArgs{
DestChainSelector: source,
Router: state.Chains[newChain].TestRouter.Address(),
})
onRampRouterAdds = append(onRampRouterAdds, router.RouterOnRamp{
DestChainSelector: source,
OnRamp: state.Chains[newChain].OnRamp.Address(),
})
offRampRouterAdds = append(offRampRouterAdds, router.RouterOffRamp{
SourceChainSelector: source,
OffRamp: state.Chains[newChain].OffRamp.Address(),
})
}
tx, err = state.Chains[newChain].OffRamp.ApplySourceChainConfigUpdates(e.Env.Chains[newChain].DeployerKey, offRampEnables)
require.NoError(t, err)
_, err = deployment.ConfirmIfNoError(e.Env.Chains[newChain], tx, err)
require.NoError(t, err)
require.NoError(t, err)
// Set the OCR3 config on new 4th chain to enable the plugin.
latestDON, err := LatestCCIPDON(state.Chains[e.HomeChainSel].CapabilityRegistry)
require.NoError(t, err)
Expand All @@ -209,6 +249,46 @@ func TestAddChain(t *testing.T) {
_, err = deployment.ConfirmIfNoError(e.Env.Chains[newChain], tx, err)
require.NoError(t, err)

// set up the new chain as source chain as a chain always need to be added as a bi-directional lane
tx, err = state.Chains[newChain].OnRamp.ApplyDestChainConfigUpdates(e.Env.Chains[newChain].DeployerKey, onRampUpdates)
require.NoError(t, err)
_, err = deployment.ConfirmIfNoError(e.Env.Chains[newChain], tx, err)
require.NoError(t, err)

tx, err = state.Chains[newChain].FeeQuoter.ApplyDestChainConfigUpdates(e.Env.Chains[newChain].DeployerKey, fqDestChainConfigArgs)
require.NoError(t, err)
_, err = deployment.ConfirmIfNoError(e.Env.Chains[newChain], tx, err)
require.NoError(t, err)
// TODO:CCIP-3957 this should be removed once FeeQuoter can receive price updates from offRamp
// set initial prices
_, err = state.Chains[newChain].FeeQuoter.UpdatePrices(
e.Env.Chains[newChain].DeployerKey, fee_quoter.InternalPriceUpdates{
TokenPriceUpdates: []fee_quoter.InternalTokenPriceUpdate{
{
SourceToken: state.Chains[newChain].LinkToken.Address(),
UsdPerToken: InitialLinkPrice,
},
{
SourceToken: state.Chains[newChain].Weth9.Address(),
UsdPerToken: InitialWethPrice,
},
},
GasPriceUpdates: []fee_quoter.InternalGasPriceUpdate{
{
DestChainSelector: newChain,
UsdPerUnitGas: InitialGasPrice,
},
}})
require.NoError(t, err)
_, err = deployment.ConfirmIfNoError(e.Env.Chains[newChain], tx, err)
require.NoError(t, err)

// enable test router for the new chain
tx, err = state.Chains[newChain].TestRouter.ApplyRampUpdates(e.Env.Chains[newChain].DeployerKey, onRampRouterAdds, nil, offRampRouterAdds)
require.NoError(t, err)
_, err = deployment.ConfirmIfNoError(e.Env.Chains[newChain], tx, err)
require.NoError(t, err)

// Assert the inbound lanes to the new chain are wired correctly.
state, err = LoadOnchainState(e.Env, e.Ab)
require.NoError(t, err)
Expand All @@ -233,16 +313,19 @@ func TestAddChain(t *testing.T) {
require.NoError(t, err)
startBlock := latesthdr.Number.Uint64()
seqNr := SendRequest(t, e.Env, state, initialDeploy[0], newChain, true)
// send request to other lane as well
latestHdr, err := e.Env.Chains[initialDeploy[1]].Client.HeaderByNumber(testcontext.Get(t), nil)
require.NoError(t, err)
startBlockOther := latestHdr.Number.Uint64()

seqNrOther := SendRequest(t, e.Env, state, newChain, initialDeploy[1], true)
require.NoError(t,
ConfirmCommitWithExpectedSeqNumRange(t, e.Env.Chains[initialDeploy[0]], e.Env.Chains[newChain], state.Chains[newChain].OffRamp, &startBlock, cciptypes.SeqNumRange{
cciptypes.SeqNum(1),
cciptypes.SeqNum(seqNr),
}))
require.NoError(t,
ConfirmExecWithSeqNr(t, e.Env.Chains[initialDeploy[0]], e.Env.Chains[newChain], state.Chains[newChain].OffRamp, &startBlock, seqNr))

// TODO: Properly assert by checking events
// Token and Gas prices should be updated in FeeQuoter
//AssertUpdatedGas(t, []uint64{e.HomeChainSel}, state, initialGasUpdates)
//AssertUpdatedTokens(t, []uint64{e.HomeChainSel}, state, initialTokenUpdates)
require.NoError(t,
ConfirmExecWithSeqNr(t, e.Env.Chains[newChain], e.Env.Chains[initialDeploy[1]], state.Chains[initialDeploy[1]].OffRamp, &startBlockOther, seqNrOther))
}
18 changes: 4 additions & 14 deletions integration-tests/deployment/ccip/add_lane.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,13 @@ 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),
}
}

func EnableOffRampOps(
state CCIPOnChainState,
destination uint64,
sources []uint64,
) ([]mcms.Operation, error) {
var ops []mcms.Operation
return ops, nil
}

func EnableRampsOnRouterOp(
state CCIPOnChainState,
chain uint64,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ func TestInitialDeploy(t *testing.T) {
// Send a message from each chain to every other chain.
expectedSeqNum := make(map[uint64]uint64)

////Initial state for tokens and gas prices
//chainSelectors := maps.Keys(e.Chains)
//initialGasUpdates := ccdeploy.GetInitialGasUpdates(t, chainSelectors, state)
//initialTokenUpdates := ccdeploy.GetInitialTokenUpdates(t, chainSelectors, state)

for src := range e.Chains {
for dest, destChain := range e.Chains {
if src == dest {
Expand All @@ -104,11 +99,7 @@ func TestInitialDeploy(t *testing.T) {

// Wait for all commit reports to land.
ccdeploy.ConfirmCommitForAllWithExpectedSeqNums(t, e, state, expectedSeqNum, startBlocks)

// Token and Gas prices should be updated in FeeQuoter
// TODO: Properly assert by checking events
//ccdeploy.AssertUpdatedGas(t, chainSelectors, state, initialGasUpdates)
//ccdeploy.AssertUpdatedTokens(t, chainSelectors, state, initialTokenUpdates)
// TODO: use proper assertions to check gas and token prices using events

// Wait for all exec reports to land
ccdeploy.ConfirmExecWithSeqNrForAll(t, e, state, expectedSeqNum, startBlocks)
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/deployment/ccip/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func DeployCCIPContracts(e deployment.Environment, ab deployment.AddressBook, c
return err
}

tokenInfo := c.TokenConfig.GetLinkInfo(e.Logger, c.FeeTokenContracts[chainSel].LinkToken, c.FeeTokenContracts[chainSel].Weth9)
tokenInfo := c.TokenConfig.GetTokenInfo(e.Logger, c.FeeTokenContracts[chainSel].LinkToken, c.FeeTokenContracts[chainSel].Weth9)
// TODO: Do we want to extract this?
// Add chain config for each chain.
_, err = AddChainConfig(
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/deployment/ccip/propose_home_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func SetCandidateExecPluginProposal(
state.Chains[newChainSel].OffRamp,
e.Chains[newChainSel],
feedChainSel,
tokenConfig.GetLinkInfo(e.Logger, state.Chains[newChainSel].LinkToken, state.Chains[newChainSel].Weth9),
tokenConfig.GetTokenInfo(e.Logger, state.Chains[newChainSel].LinkToken, state.Chains[newChainSel].Weth9),
nodes.NonBootstraps(),
rmnHomeAddress,
)
Expand Down
Loading
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.