Skip to content

Commit

Permalink
Fix mcms state in CCIP load chain state (#16599)
Browse files Browse the repository at this point in the history
* fix loachain state for new mcms

* more validation

* fix lint

* add comment
  • Loading branch information
AnieeG authored Feb 26, 2025
1 parent 7c5efbe commit 7a74f14
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
11 changes: 9 additions & 2 deletions deployment/ccip/changeset/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,7 @@ func LoadChainState(ctx context.Context, chain deployment.Chain, addresses map[s
state.ABIByAddress[address] = gethwrappers.CallProxyABI
case deployment.NewTypeAndVersion(commontypes.ProposerManyChainMultisig, deployment.Version1_0_0).String(),
deployment.NewTypeAndVersion(commontypes.CancellerManyChainMultisig, deployment.Version1_0_0).String(),
deployment.NewTypeAndVersion(commontypes.BypasserManyChainMultisig, deployment.Version1_0_0).String(),
deployment.NewTypeAndVersion(commontypes.ManyChainMultisig, deployment.Version1_0_0).String():
deployment.NewTypeAndVersion(commontypes.BypasserManyChainMultisig, deployment.Version1_0_0).String():
state.ABIByAddress[address] = gethwrappers.ManyChainMultiSigABI
case deployment.NewTypeAndVersion(commontypes.LinkToken, deployment.Version1_0_0).String():
state.ABIByAddress[address] = link_token.LinkTokenABI
Expand Down Expand Up @@ -1050,6 +1049,14 @@ func LoadChainState(ctx context.Context, chain deployment.Chain, addresses map[s
state.MockRMN = mockRMN
state.ABIByAddress[address] = mock_rmn_contract.MockRMNContractABI
default:
// ManyChainMultiSig 1.0.0 can have any of these labels, it can have either 1,2 or 3 of these -
// bypasser, proposer and canceller
// if you try to compare tvStr.String() you will have to compare all combinations of labels
// so we will compare the type and version only
if tvStr.Type == commontypes.ManyChainMultisig && tvStr.Version == deployment.Version1_0_0 {
state.ABIByAddress[address] = gethwrappers.ManyChainMultiSigABI
continue
}
return state, fmt.Errorf("unknown contract %s", tvStr)
}
}
Expand Down
21 changes: 21 additions & 0 deletions deployment/ccip/changeset/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ import (

"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink-integrations/evm/utils"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers"
"github.com/smartcontractkit/chainlink/deployment/common/types"
)

func TestSmokeState(t *testing.T) {
Expand All @@ -17,4 +21,21 @@ func TestSmokeState(t *testing.T) {
require.NoError(t, err)
}

func TestMCMSState(t *testing.T) {
tenv, _ := testhelpers.NewMemoryEnvironment(t, testhelpers.WithNoJobsAndContracts())
addressbook := deployment.NewMemoryAddressBook()
newTv := deployment.NewTypeAndVersion(types.ManyChainMultisig, deployment.Version1_0_0)
newTv.AddLabel(types.BypasserRole.String())
newTv.AddLabel(types.CancellerRole.String())
newTv.AddLabel(types.ProposerRole.String())
addr := utils.RandomAddress()
require.NoError(t, addressbook.Save(tenv.HomeChainSel, addr.String(), newTv))
require.NoError(t, tenv.Env.ExistingAddresses.Merge(addressbook))
state, err := changeset.LoadOnchainState(tenv.Env)
require.NoError(t, err)
require.Equal(t, addr.String(), state.Chains[tenv.HomeChainSel].BypasserMcm.Address().String())
require.Equal(t, addr.String(), state.Chains[tenv.HomeChainSel].ProposerMcm.Address().String())
require.Equal(t, addr.String(), state.Chains[tenv.HomeChainSel].CancellerMcm.Address().String())
}

// TODO: add solana state test

0 comments on commit 7a74f14

Please sign in to comment.