Skip to content

Commit

Permalink
revert all changes
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilchainani committed Dec 8, 2024
1 parent 663f8b0 commit c17911e
Show file tree
Hide file tree
Showing 19 changed files with 76 additions and 166 deletions.
6 changes: 1 addition & 5 deletions deployment/ccip/changeset/accept_ownership_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,14 @@ func Test_NewAcceptOwnershipChangeset(t *testing.T) {
source: state.Chains[source].Timelock,
dest: state.Chains[dest].Timelock,
}
callProxies := map[uint64]*gethwrappers.CallProxy{
source: state.Chains[source].CallProxy,
dest: state.Chains[dest].CallProxy,
}

// at this point we have the initial deploys done, now we need to transfer ownership
// to the timelock contract
state, err = LoadOnchainState(e.Env)
require.NoError(t, err)

// compose the transfer ownership and accept ownership changesets
_, err = commonchangeset.ApplyChangesets(t, e.Env, timelocks, callProxies, []commonchangeset.ChangesetApplication{
_, err = commonchangeset.ApplyChangesets(t, e.Env, timelocks, []commonchangeset.ChangesetApplication{
// note this doesn't have proposals.
{
Changeset: commonchangeset.WrapChangeSet(commonchangeset.TransferToMCMSWithTimelock),
Expand Down
12 changes: 4 additions & 8 deletions deployment/ccip/changeset/cs_active_candidate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,7 @@ func TestActiveCandidate(t *testing.T) {
for _, chain := range allChains {
timelocks[chain] = state.Chains[chain].Timelock
}
callProxies := make(map[uint64]*gethwrappers.CallProxy)
for _, chain := range allChains {
callProxies[chain] = state.Chains[chain].CallProxy
}
_, err = commonchangeset.ApplyChangesets(t, e, timelocks, callProxies, []commonchangeset.ChangesetApplication{
_, err = commonchangeset.ApplyChangesets(t, e, timelocks, []commonchangeset.ChangesetApplication{
// note this doesn't have proposals.
{
Changeset: commonchangeset.WrapChangeSet(commonchangeset.TransferToMCMSWithTimelock),
Expand Down Expand Up @@ -181,7 +177,7 @@ func TestActiveCandidate(t *testing.T) {
}}, "set new candidates on commit plugin", 0)
require.NoError(t, err)
setCommitCandidateSigned := commonchangeset.SignProposal(t, e, setCommitCandidateProposal)
commonchangeset.ExecuteProposal(t, e, setCommitCandidateSigned, state.Chains[tenv.HomeChainSel].Timelock, state.Chains[tenv.HomeChainSel].CallProxy, tenv.HomeChainSel)
commonchangeset.ExecuteProposal(t, e, setCommitCandidateSigned, state.Chains[tenv.HomeChainSel].Timelock, tenv.HomeChainSel)

// create the op for the commit plugin as well
setExecCandidateOp, err := setCandidateOnExistingDon(
Expand All @@ -199,7 +195,7 @@ func TestActiveCandidate(t *testing.T) {
}}, "set new candidates on commit and exec plugins", 0)
require.NoError(t, err)
setExecCandidateSigned := commonchangeset.SignProposal(t, e, setExecCandidateProposal)
commonchangeset.ExecuteProposal(t, e, setExecCandidateSigned, state.Chains[tenv.HomeChainSel].Timelock, state.Chains[tenv.HomeChainSel].CallProxy, tenv.HomeChainSel)
commonchangeset.ExecuteProposal(t, e, setExecCandidateSigned, state.Chains[tenv.HomeChainSel].Timelock, tenv.HomeChainSel)

// check setup was successful by confirming number of nodes from cap reg
donInfo, err = state.Chains[tenv.HomeChainSel].CapabilityRegistry.GetDON(nil, donID)
Expand All @@ -226,7 +222,7 @@ func TestActiveCandidate(t *testing.T) {
}}, "promote candidates and revoke actives", 0)
require.NoError(t, err)
promoteSigned := commonchangeset.SignProposal(t, e, promoteProposal)
commonchangeset.ExecuteProposal(t, e, promoteSigned, state.Chains[tenv.HomeChainSel].Timelock, state.Chains[tenv.HomeChainSel].CallProxy, tenv.HomeChainSel)
commonchangeset.ExecuteProposal(t, e, promoteSigned, state.Chains[tenv.HomeChainSel].Timelock, tenv.HomeChainSel)
// [NEW ACTIVE, NO CANDIDATE] done promoting

// [NEW ACTIVE, NO CANDIDATE] check onchain state
Expand Down
20 changes: 7 additions & 13 deletions deployment/ccip/changeset/cs_add_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ func TestAddChainInbound(t *testing.T) {
require.NoError(t, e.Env.ExistingAddresses.Merge(newAddresses))

cfg := commontypes.MCMSWithTimelockConfig{
Canceller: commonchangeset.SingleGroupMCMS(t),
Bypasser: commonchangeset.SingleGroupMCMS(t),
Proposer: commonchangeset.SingleGroupMCMS(t),
TimelockMinDelay: big.NewInt(0),
Canceller: commonchangeset.SingleGroupMCMS(t),
Bypasser: commonchangeset.SingleGroupMCMS(t),
Proposer: commonchangeset.SingleGroupMCMS(t),
TimelockExecutors: e.Env.AllDeployerKeys(),
TimelockMinDelay: big.NewInt(0),
}
e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, nil, nil, []commonchangeset.ChangesetApplication{
e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, nil, []commonchangeset.ChangesetApplication{
{
Changeset: commonchangeset.WrapChangeSet(commonchangeset.DeployLinkToken),
Config: initialDeploy,
Expand Down Expand Up @@ -106,7 +107,7 @@ func TestAddChainInbound(t *testing.T) {
require.NoError(t, err)

// Deploy contracts to new chain
e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, nil, nil, []commonchangeset.ChangesetApplication{
e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, nil, []commonchangeset.ChangesetApplication{
{
Changeset: commonchangeset.WrapChangeSet(commonchangeset.DeployLinkToken),
Config: []uint64{newChain},
Expand Down Expand Up @@ -149,10 +150,6 @@ func TestAddChainInbound(t *testing.T) {
initialDeploy[0]: state.Chains[initialDeploy[0]].Timelock,
initialDeploy[1]: state.Chains[initialDeploy[1]].Timelock,
initialDeploy[2]: state.Chains[initialDeploy[2]].Timelock,
}, map[uint64]*gethwrappers.CallProxy{
initialDeploy[0]: state.Chains[initialDeploy[0]].CallProxy,
initialDeploy[1]: state.Chains[initialDeploy[1]].CallProxy,
initialDeploy[2]: state.Chains[initialDeploy[2]].CallProxy,
}, []commonchangeset.ChangesetApplication{
{
Changeset: commonchangeset.WrapChangeSet(commonchangeset.TransferToMCMSWithTimelock),
Expand Down Expand Up @@ -185,9 +182,6 @@ func TestAddChainInbound(t *testing.T) {
_, err = commonchangeset.ApplyChangesets(t, e.Env, map[uint64]*gethwrappers.RBACTimelock{
e.HomeChainSel: state.Chains[e.HomeChainSel].Timelock,
newChain: state.Chains[newChain].Timelock,
}, map[uint64]*gethwrappers.CallProxy{
e.HomeChainSel: state.Chains[e.HomeChainSel].CallProxy,
newChain: state.Chains[newChain].CallProxy,
}, []commonchangeset.ChangesetApplication{
{
Changeset: commonchangeset.WrapChangeSet(AddDonAndSetCandidateChangeset),
Expand Down
11 changes: 6 additions & 5 deletions deployment/ccip/changeset/cs_deploy_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ func TestDeployChainContractsChangeset(t *testing.T) {
cfg := make(map[uint64]commontypes.MCMSWithTimelockConfig)
for _, chain := range e.AllChainSelectors() {
cfg[chain] = commontypes.MCMSWithTimelockConfig{
Canceller: commonchangeset.SingleGroupMCMS(t),
Bypasser: commonchangeset.SingleGroupMCMS(t),
Proposer: commonchangeset.SingleGroupMCMS(t),
TimelockMinDelay: big.NewInt(0),
Canceller: commonchangeset.SingleGroupMCMS(t),
Bypasser: commonchangeset.SingleGroupMCMS(t),
Proposer: commonchangeset.SingleGroupMCMS(t),
TimelockExecutors: e.AllDeployerKeys(),
TimelockMinDelay: big.NewInt(0),
}
}
e, err = commonchangeset.ApplyChangesets(t, e, nil, nil, []commonchangeset.ChangesetApplication{
e, err = commonchangeset.ApplyChangesets(t, e, nil, []commonchangeset.ChangesetApplication{
{
Changeset: commonchangeset.WrapChangeSet(DeployHomeChain),
Config: DeployHomeChainConfig{
Expand Down
1 change: 0 additions & 1 deletion deployment/ccip/changeset/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ func LoadChainState(chain deployment.Chain, addresses map[string]deployment.Type
for address, tvStr := range addresses {
switch tvStr.String() {
case deployment.NewTypeAndVersion(commontypes.RBACTimelock, deployment.Version1_0_0).String(),
deployment.NewTypeAndVersion(commontypes.CallProxy, deployment.Version1_0_0).String(),
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(),
Expand Down
17 changes: 8 additions & 9 deletions deployment/ccip/changeset/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,11 @@ func NewMemoryEnvironmentWithJobsAndContracts(t *testing.T, lggr logger.Logger,
mcmsCfg := make(map[uint64]commontypes.MCMSWithTimelockConfig)
for _, c := range e.Env.AllChainSelectors() {
mcmsCfg[c] = commontypes.MCMSWithTimelockConfig{
Canceller: commonchangeset.SingleGroupMCMS(t),
Bypasser: commonchangeset.SingleGroupMCMS(t),
Proposer: commonchangeset.SingleGroupMCMS(t),
TimelockMinDelay: big.NewInt(0),
Canceller: commonchangeset.SingleGroupMCMS(t),
Bypasser: commonchangeset.SingleGroupMCMS(t),
Proposer: commonchangeset.SingleGroupMCMS(t),
TimelockExecutors: e.Env.AllDeployerKeys(),
TimelockMinDelay: big.NewInt(0),
}
}
var (
Expand All @@ -297,7 +298,7 @@ func NewMemoryEnvironmentWithJobsAndContracts(t *testing.T, lggr logger.Logger,
}
// Need to deploy prerequisites first so that we can form the USDC config
// no proposals to be made, timelock can be passed as nil here
e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, nil, nil, []commonchangeset.ChangesetApplication{
e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, nil, []commonchangeset.ChangesetApplication{
{
Changeset: commonchangeset.WrapChangeSet(commonchangeset.DeployLinkToken),
Config: allChains,
Expand Down Expand Up @@ -366,15 +367,13 @@ func NewMemoryEnvironmentWithJobsAndContracts(t *testing.T, lggr logger.Logger,
// Build the per chain config.
chainConfigs := make(map[uint64]CCIPOCRParams)
timelocksPerChain := make(map[uint64]*gethwrappers.RBACTimelock)
callProxiesPerChain := make(map[uint64]*gethwrappers.CallProxy)
for _, chain := range allChains {
timelocksPerChain[chain] = state.Chains[chain].Timelock
callProxiesPerChain[chain] = state.Chains[chain].CallProxy
tokenInfo := tokenConfig.GetTokenInfo(e.Env.Logger, state.Chains[chain].LinkToken, state.Chains[chain].Weth9)
chainConfigs[chain] = DefaultOCRParams(e.FeedChainSel, tokenInfo, tokenDataProviders)
}
// Deploy second set of changesets to deploy and configure the CCIP contracts.
e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, timelocksPerChain, callProxiesPerChain, []commonchangeset.ChangesetApplication{
e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, timelocksPerChain, []commonchangeset.ChangesetApplication{
{
Changeset: commonchangeset.WrapChangeSet(ConfigureNewChains),
Config: NewChainsConfig{
Expand Down Expand Up @@ -824,7 +823,7 @@ func ProcessChangeset(t *testing.T, e deployment.Environment, c deployment.Chang

signed := commonchangeset.SignProposal(t, e, &prop)
for _, sel := range chains.ToSlice() {
commonchangeset.ExecuteProposal(t, e, signed, state.Chains[sel].Timelock, state.Chains[sel].CallProxy, sel)
commonchangeset.ExecuteProposal(t, e, signed, state.Chains[sel].Timelock, sel)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion deployment/common/changeset/deploy_link_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestDeployLinkToken(t *testing.T) {
Chains: 1,
})
chain1 := e.AllChainSelectors()[0]
e, err := changeset.ApplyChangesets(t, e, nil, nil, []changeset.ChangesetApplication{
e, err := changeset.ApplyChangesets(t, e, nil, []changeset.ChangesetApplication{
{
Changeset: changeset.WrapChangeSet(changeset.DeployLinkToken),
Config: []uint64{chain1},
Expand Down
41 changes: 4 additions & 37 deletions deployment/common/changeset/internal/mcms.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ type MCMSWithTimelockDeploy struct {
Bypasser *deployment.ContractDeploy[*owner_helpers.ManyChainMultiSig]
Proposer *deployment.ContractDeploy[*owner_helpers.ManyChainMultiSig]
Timelock *deployment.ContractDeploy[*owner_helpers.RBACTimelock]
CallProxy *deployment.ContractDeploy[*owner_helpers.CallProxy]
}

func DeployMCMSWithTimelockContractsBatch(
Expand Down Expand Up @@ -107,10 +106,10 @@ func DeployMCMSWithTimelockContracts(
// TODO: Could expose this as config?
// Or keep this enforced to follow the same pattern?
chain.DeployerKey.From,
[]common.Address{proposer.Address}, // proposers
[]common.Address{}, // executors
[]common.Address{canceller.Address, proposer.Address, bypasser.Address}, // cancellers
[]common.Address{bypasser.Address}, // bypassers
[]common.Address{proposer.Address}, // proposers
config.TimelockExecutors, //executors
[]common.Address{canceller.Address}, // cancellers
[]common.Address{bypasser.Address}, // bypassers
)
return deployment.ContractDeploy[*owner_helpers.RBACTimelock]{
timelock, cc, tx2, deployment.NewTypeAndVersion(types.RBACTimelock, deployment.Version1_0_0), err2,
Expand All @@ -120,37 +119,6 @@ func DeployMCMSWithTimelockContracts(
lggr.Errorw("Failed to deploy timelock", "chain", chain.String(), "err", err)
return nil, err
}

callProxy, err := deployment.DeployContract(lggr, chain, ab,
func(chain deployment.Chain) deployment.ContractDeploy[*owner_helpers.CallProxy] {
callProxy, tx2, cc, err2 := owner_helpers.DeployCallProxy(
chain.DeployerKey,
chain.Client,
timelock.Address,
)
return deployment.ContractDeploy[*owner_helpers.CallProxy]{
callProxy, cc, tx2, deployment.NewTypeAndVersion(types.CallProxy, deployment.Version1_0_0), err2,
}
})
if err != nil {
lggr.Errorw("Failed to deploy call proxy", "chain", chain.String(), "err", err)
return nil, err
}

grantRoleTx, err := timelock.Contract.GrantRole(
chain.DeployerKey,
v1_0.EXECUTOR_ROLE.ID,
callProxy.Address,
)
if err != nil {
lggr.Errorw("Failed to grant timelock executor role", "chain", chain.String(), "err", err)
return nil, err
}

if _, err := deployment.ConfirmIfNoError(chain, grantRoleTx, err); err != nil {
lggr.Errorw("Failed to grant timelock executor role", "chain", chain.String(), "err", err)
return nil, err
}
// We grant the timelock the admin role on the MCMS contracts.
tx, err := timelock.Contract.GrantRole(chain.DeployerKey,
v1_0.ADMIN_ROLE.ID, timelock.Address)
Expand All @@ -165,6 +133,5 @@ func DeployMCMSWithTimelockContracts(
Bypasser: bypasser,
Proposer: proposer,
Timelock: timelock,
CallProxy: callProxy,
}, nil
}
12 changes: 8 additions & 4 deletions deployment/common/changeset/internal/mcms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"math/big"
"testing"

"github.com/ethereum/go-ethereum/common"
chainsel "github.com/smartcontractkit/chain-selectors"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -36,15 +37,18 @@ func TestDeployMCMSWithTimelockContracts(t *testing.T) {
_, err := internal.DeployMCMSWithTimelockContracts(lggr,
chains[chainsel.TEST_90000001.Selector],
ab, types.MCMSWithTimelockConfig{
Canceller: changeset.SingleGroupMCMS(t),
Bypasser: changeset.SingleGroupMCMS(t),
Proposer: changeset.SingleGroupMCMS(t),
Canceller: changeset.SingleGroupMCMS(t),
Bypasser: changeset.SingleGroupMCMS(t),
Proposer: changeset.SingleGroupMCMS(t),
TimelockExecutors: []common.Address{
chains[chainsel.TEST_90000001.Selector].DeployerKey.From,
},
TimelockMinDelay: big.NewInt(0),
})
require.NoError(t, err)
addresses, err := ab.AddressesForChain(chainsel.TEST_90000001.Selector)
require.NoError(t, err)
require.Len(t, addresses, 5)
require.Len(t, addresses, 4)
mcmsState, err := changeset.MaybeLoadMCMSWithTimelockState(chains[chainsel.TEST_90000001.Selector], addresses)
require.NoError(t, err)
v, err := mcmsState.GenerateMCMSWithTimelockView()
Expand Down
5 changes: 2 additions & 3 deletions deployment/common/changeset/mcms_test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func SignProposal(t *testing.T, env deployment.Environment, proposal *timelock.M
}

func ExecuteProposal(t *testing.T, env deployment.Environment, executor *mcms.Executor,
timelock *owner_helpers.RBACTimelock, callProxy *owner_helpers.CallProxy, sel uint64) {
timelock *owner_helpers.RBACTimelock, sel uint64) {
t.Log("Executing proposal on chain", sel)
// Set the root.
tx, err2 := executor.SetRootOnChain(env.Chains[sel].Client, env.Chains[sel].DeployerKey, mcms.ChainIdentifier(sel))
Expand Down Expand Up @@ -104,8 +104,7 @@ func ExecuteProposal(t *testing.T, env deployment.Environment, executor *mcms.Ex
Value: it.Event.Value,
})
}
timelockExecutorProxy, err := owner_helpers.NewRBACTimelock(callProxy.Address(), env.Chains[sel].Client)
tx, err := timelockExecutorProxy.ExecuteBatch(
tx, err := timelock.ExecuteBatch(
env.Chains[sel].DeployerKey, calls, pred, salt)
require.NoError(t, err)
_, err = env.Chains[sel].Confirm(tx)
Expand Down
18 changes: 1 addition & 17 deletions deployment/common/changeset/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ type MCMSWithTimelockState struct {
BypasserMcm *owner_helpers.ManyChainMultiSig
ProposerMcm *owner_helpers.ManyChainMultiSig
Timelock *owner_helpers.RBACTimelock
CallProxy *owner_helpers.CallProxy
}

// Validate checks that all fields are non-nil, ensuring it's ready
Expand All @@ -41,9 +40,6 @@ func (state MCMSWithTimelockState) Validate() error {
if state.BypasserMcm == nil {
return errors.New("bypasser not found")
}
if state.CallProxy == nil {
return errors.New("call proxy not found")
}
return nil
}

Expand All @@ -55,10 +51,6 @@ func (state MCMSWithTimelockState) GenerateMCMSWithTimelockView() (v1_0.MCMSWith
if err != nil {
return v1_0.MCMSWithTimelockView{}, nil
}
callProxyView, err := v1_0.GenerateCallProxyView(*state.CallProxy)
if err != nil {
return v1_0.MCMSWithTimelockView{}, nil
}
bypasserView, err := v1_0.GenerateMCMSView(*state.BypasserMcm)
if err != nil {
return v1_0.MCMSWithTimelockView{}, nil
Expand All @@ -76,7 +68,6 @@ func (state MCMSWithTimelockState) GenerateMCMSWithTimelockView() (v1_0.MCMSWith
Bypasser: bypasserView,
Proposer: proposerView,
Canceller: cancellerView,
CallProxy: callProxyView,
}, nil
}

Expand All @@ -91,15 +82,14 @@ func MaybeLoadMCMSWithTimelockState(chain deployment.Chain, addresses map[string
state := MCMSWithTimelockState{}
// We expect one of each contract on the chain.
timelock := deployment.NewTypeAndVersion(types.RBACTimelock, deployment.Version1_0_0)
callProxy := deployment.NewTypeAndVersion(types.CallProxy, deployment.Version1_0_0)
proposer := deployment.NewTypeAndVersion(types.ProposerManyChainMultisig, deployment.Version1_0_0)
canceller := deployment.NewTypeAndVersion(types.CancellerManyChainMultisig, deployment.Version1_0_0)
bypasser := deployment.NewTypeAndVersion(types.BypasserManyChainMultisig, deployment.Version1_0_0)

// Ensure we either have the bundle or not.
_, err := deployment.AddressesContainBundle(addresses,
map[deployment.TypeAndVersion]struct{}{
timelock: {}, proposer: {}, canceller: {}, bypasser: {}, callProxy: {},
timelock: {}, proposer: {}, canceller: {}, bypasser: {},
})
if err != nil {
return nil, fmt.Errorf("unable to check MCMS contracts on chain %s error: %w", chain.Name(), err)
Expand All @@ -113,12 +103,6 @@ func MaybeLoadMCMSWithTimelockState(chain deployment.Chain, addresses map[string
return nil, err
}
state.Timelock = tl
case callProxy:
cp, err := owner_helpers.NewCallProxy(common.HexToAddress(address), chain.Client)
if err != nil {
return nil, err
}
state.CallProxy = cp
case proposer:
mcms, err := owner_helpers.NewManyChainMultiSig(common.HexToAddress(address), chain.Client)
if err != nil {
Expand Down
Loading

0 comments on commit c17911e

Please sign in to comment.