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

Ccip-4693 deprecate add lane replaced with granular changesets #15784

Merged
merged 20 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
add a test
  • Loading branch information
AnieeG committed Dec 20, 2024
commit 9adf70ff38e2a13c882a4ec615684aef327da972
14 changes: 7 additions & 7 deletions deployment/ccip/changeset/cs_chain_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
type PreviousRampCfg struct {
RemoteChainSelector uint64
OverrideExisting bool
OnRamp bool
OffRamp bool
EnableOnRamp bool
EnableOffRamp bool
}

func (cfg UpdateNonceManagerConfig) Validate(e deployment.Environment) error {
Expand Down Expand Up @@ -85,17 +85,17 @@
if _, ok := state.Chains[prevRamp.RemoteChainSelector]; !ok {
return fmt.Errorf("dest chain %d not found in onchain state for chain %d", prevRamp.RemoteChainSelector, sourceSel)
}
if !prevRamp.OnRamp && !prevRamp.OffRamp {
if !prevRamp.EnableOnRamp && !prevRamp.EnableOffRamp {
return errors.New("must specify either onramp or offramp")
}
if prevRamp.OnRamp {
if prevRamp.EnableOnRamp {
if prevOnRamp := state.Chains[sourceSel].EVM2EVMOnRamp; prevOnRamp == nil {
return fmt.Errorf("no previous onramp for source chain %d", sourceSel)
} else if prevOnRamp[prevRamp.RemoteChainSelector] == nil {
return fmt.Errorf("no previous onramp for source chain %d and dest chain %d", sourceSel, prevRamp.RemoteChainSelector)
}
}
if prevRamp.OffRamp {
if prevRamp.EnableOffRamp {
if prevOffRamp := state.Chains[sourceSel].EVM2EVMOffRamp; prevOffRamp == nil {
return fmt.Errorf("missing previous offramps for chain %d", sourceSel)
} else if prevOffRamp[prevRamp.RemoteChainSelector] == nil {
Expand Down Expand Up @@ -138,10 +138,10 @@
previousRampsArgs := make([]nonce_manager.NonceManagerPreviousRampsArgs, 0)
for _, prevRamp := range updates.PreviousRampsArgs {
var onRamp, offRamp common.Address
if prevRamp.OnRamp {
if prevRamp.EnableOnRamp {
onRamp = s.Chains[chainSel].EVM2EVMOnRamp[prevRamp.RemoteChainSelector].Address()
}
if prevRamp.OffRamp {
if prevRamp.EnableOffRamp {
offRamp = s.Chains[chainSel].EVM2EVMOffRamp[prevRamp.RemoteChainSelector].Address()
}
previousRampsArgs = append(previousRampsArgs, nonce_manager.NonceManagerPreviousRampsArgs{
Expand Down Expand Up @@ -552,7 +552,7 @@
return fmt.Errorf("failed to get onramp static config %s: %w", chainState.OnRamp.Address(), err)
}
if destination == sc.ChainSelector {
return fmt.Errorf("source and destination chain cannot be the same")

Check failure on line 555 in deployment/ccip/changeset/cs_chain_contracts.go

View workflow job for this annotation

GitHub Actions / GolangCI Lint (deployment)

fmt.Errorf can be replaced with errors.New (perfsprint)
}
}
}
Expand Down
58 changes: 58 additions & 0 deletions deployment/ccip/changeset/cs_chain_contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"golang.org/x/exp/maps"

"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"

commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/fee_quoter"
)
Expand Down Expand Up @@ -303,3 +304,60 @@ func TestUpdateRouterRamps(t *testing.T) {
})
}
}

func TestUpdateNonceManagersCS(t *testing.T) {
for _, tc := range []struct {
name string
mcmsEnabled bool
}{
{
name: "MCMS enabled",
mcmsEnabled: true,
},
{
name: "MCMS disabled",
mcmsEnabled: false,
},
} {
t.Run(tc.name, func(t *testing.T) {
tenv := NewMemoryEnvironment(t)
state, err := LoadOnchainState(tenv.Env)
require.NoError(t, err)

allChains := maps.Keys(tenv.Env.Chains)
source := allChains[0]
dest := allChains[1]

if tc.mcmsEnabled {
// Transfer ownership to timelock so that we can promote the zero digest later down the line.
transferToTimelock(t, tenv, state, source, dest)
}

var mcmsConfig *MCMSConfig
if tc.mcmsEnabled {
mcmsConfig = &MCMSConfig{
MinDelay: 0,
}
}

_, err = commonchangeset.ApplyChangesets(t, tenv.Env, tenv.TimelockContracts(t), []commonchangeset.ChangesetApplication{
{
Changeset: commonchangeset.WrapChangeSet(UpdateNonceManagersCS),
Config: UpdateNonceManagerConfig{
UpdatesByChain: map[uint64]NonceManagerUpdate{
source: {
RemovedAuthCallers: []common.Address{state.Chains[source].OnRamp.Address()},
},
},
MCMS: mcmsConfig,
},
},
})
require.NoError(t, err)
// Assert the nonce manager configuration is as we expect.
callers, err := state.Chains[source].NonceManager.GetAllAuthorizedCallers(nil)
require.NoError(t, err)
require.NotContains(t, callers, state.Chains[source].OnRamp.Address())
})
}
}
Loading