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

deployment/ccip/changeset: add chain test #15891

Draft
wants to merge 31 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ded3f4c
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 7, 2024
10314c8
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 10, 2024
5f14bf0
remove deployCCIPContracts
AnieeG Dec 10, 2024
75c676f
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 10, 2024
b31ec5a
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 10, 2024
5f6d2d5
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 13, 2024
65616ff
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 13, 2024
6dd9c4a
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 13, 2024
813cc6e
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 18, 2024
a299e7c
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Dec 19, 2024
1837b21
deprecate existing add lane
AnieeG Dec 20, 2024
bda53fc
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Jan 3, 2025
e171316
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Jan 6, 2025
f8574e7
new migration test
AnieeG Jan 6, 2025
950caa3
first version
AnieeG Jan 7, 2025
0b75a79
more updates
AnieeG Jan 8, 2025
1216211
fix tests
AnieeG Jan 8, 2025
e45b045
more fixes
AnieeG Jan 8, 2025
dfe7a2a
include in pipeline
AnieeG Jan 8, 2025
f0ecc26
enabling test
AnieeG Jan 8, 2025
d5d1df3
merge
AnieeG Jan 8, 2025
843e228
upgrade chainlink ccip fixing router binding issues in migration
asoliman92 Jan 9, 2025
ec2391a
Merge branch 'develop' into ccip-4110-migration-test
asoliman92 Jan 9, 2025
810fda5
Merge branch 'develop' into ccip-4110-migration-test
asoliman92 Jan 9, 2025
7558959
upgrade chainlink ccip fixing router binding issues in migration
asoliman92 Jan 9, 2025
7d74ac6
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG Jan 9, 2025
06cbc31
review comments
AnieeG Jan 9, 2025
d9f7594
Merge branch 'ccip-4110-migration-test' of github.com:smartcontractki…
AnieeG Jan 9, 2025
ed7c298
deployment/ccip/changeset: add chain test
makramkd Jan 10, 2025
e799a28
set rmn proxy arm address correctly
makramkd Jan 10, 2025
cd3f6b5
gomodtidy
makramkd Jan 10, 2025
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
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
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 @@ -323,7 +323,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
2 changes: 1 addition & 1 deletion deployment/ccip/changeset/cs_active_candidate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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
160 changes: 160 additions & 0 deletions deployment/ccip/changeset/cs_add_chain_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
package changeset

import (
"testing"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"
changesetcommon "github.com/smartcontractkit/chainlink/deployment/common/changeset"
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"

"github.com/stretchr/testify/require"
"golang.org/x/exp/maps"
)

func Test_AddChain(t *testing.T) {
t.Parallel()

const (
numChains = 4
usersPerChain = 2
)

// Set up an env with 4 chains but initially
// only deploy and configure 3 of them.
e, tEnv := NewMemoryEnvironment(
t,
WithChains(numChains),
WithNodes(4),
WithPrerequisiteDeployment(),
WithUsersPerChain(usersPerChain),
WithNoJobsAndContracts(),
)

allChains := maps.Keys(e.Env.Chains)
toDeploy := e.Env.AllChainSelectorsExcluding([]uint64{allChains[0]})
require.Len(t, toDeploy, numChains-1)
e = AddCCIPContractsToEnvironment(t, toDeploy, tEnv)

// Need to update what the RMNProxy is pointing to, otherwise plugin will not work.
var err error
e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, nil, []commonchangeset.ChangesetApplication{
{
Changeset: commonchangeset.WrapChangeSet(SetRMNRemoteOnRMNProxy),
Config: SetRMNRemoteOnRMNProxyConfig{
ChainSelectors: toDeploy,
},
},
})
require.NoError(t, err)

state, err := LoadOnchainState(e.Env)
require.NoError(t, err)

// Setup densely connected lanes between all chains.
for _, source := range toDeploy {
for _, dest := range toDeploy {
if source == dest {
continue
}
AddLaneWithDefaultPricesAndFeeQuoterConfig(t, &e, state, source, dest, false)
}
}

// Transfer ownership of all contracts to the MCMS and renounce the timelock deployer.
transferToMCMSAndRenounceTimelockDeployer(t, e, toDeploy, state)

// At this stage we can send some requests and confirm the setup is working.
sendMsgs := func(chains []uint64) {
var (
startBlocks = make(map[uint64]*uint64)
expectedSeqNum = make(map[SourceDestPair]uint64)
expectedSeqNumExec = make(map[SourceDestPair][]uint64)
)
for _, source := range chains {
for _, dest := range chains {
if source == dest {
continue
}
latesthdr, err := e.Env.Chains[dest].Client.HeaderByNumber(testcontext.Get(t), nil)
require.NoError(t, err)
block := latesthdr.Number.Uint64()
msgSentEvent := TestSendRequest(t, e.Env, state, source, dest, false, router.ClientEVM2AnyMessage{
Receiver: common.LeftPadBytes(state.Chains[dest].Receiver.Address().Bytes(), 32),
Data: []byte("hello world"),
TokenAmounts: nil,
FeeToken: common.HexToAddress("0x0"),
ExtraArgs: nil,
})

startBlocks[dest] = &block
expectedSeqNum[SourceDestPair{
SourceChainSelector: source,
DestChainSelector: dest,
}] = msgSentEvent.SequenceNumber
expectedSeqNumExec[SourceDestPair{
SourceChainSelector: source,
DestChainSelector: dest,
}] = append(expectedSeqNumExec[SourceDestPair{
SourceChainSelector: source,
DestChainSelector: dest,
}], msgSentEvent.SequenceNumber)
}
}

// Confirm execution of the message
ConfirmCommitForAllWithExpectedSeqNums(t, e.Env, state, expectedSeqNum, startBlocks)
ConfirmExecWithSeqNrsForAll(t, e.Env, state, expectedSeqNumExec, startBlocks)
}

// check RMNRemote is up.
for _, chain := range toDeploy {
require.NotEqual(t, common.Address{}, state.Chains[chain].RMNRemote.Address())
_, err := state.Chains[chain].RMNRemote.GetCursedSubjects(&bind.CallOpts{
Context: tests.Context(t),
})
require.NoError(t, err)

// check which address RMNProxy is pointing to
rmnAddress, err := state.Chains[chain].RMNProxy.GetARM(&bind.CallOpts{
Context: tests.Context(t),
})
require.NoError(t, err)
require.Equal(t, state.Chains[chain].RMNRemote.Address(), rmnAddress)

t.Log("RMNRemote address for chain", chain, "is:", state.Chains[chain].RMNRemote.Address().Hex())
t.Log("RMNProxy address for chain", chain, "is:", state.Chains[chain].RMNProxy.Address().Hex())
}

// wait for plugins to come up.
time.Sleep(30 * time.Second)
sendMsgs(toDeploy)
}

func transferToMCMSAndRenounceTimelockDeployer(
t *testing.T,
e DeployedEnv,
chains []uint64,
state CCIPOnChainState,
) {
var apps []changesetcommon.ChangesetApplication

Check failure on line 144 in deployment/ccip/changeset/cs_add_chain_test.go

View workflow job for this annotation

GitHub Actions / GolangCI Lint (deployment)

Consider pre-allocating `apps` (prealloc)
apps = append(apps, changesetcommon.ChangesetApplication{
Changeset: changesetcommon.WrapChangeSet(changesetcommon.TransferToMCMSWithTimelock),
Config: genTestTransferOwnershipConfig(e, chains, state),
})
for _, chain := range chains {
apps = append(apps, changesetcommon.ChangesetApplication{
Changeset: changesetcommon.WrapChangeSet(changesetcommon.RenounceTimelockDeployer),
Config: changesetcommon.RenounceTimelockDeployerConfig{
ChainSel: chain,
},
})
}
var err error
e.Env, err = changesetcommon.ApplyChangesets(t, e.Env, e.TimelockContracts(t), apps)
require.NoError(t, err)
}
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
Loading
Loading