Skip to content

Commit

Permalink
Deploy call proxy instead of using deployer executor keys
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilchainani committed Dec 6, 2024
1 parent ddd012e commit 4d007c3
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 53 deletions.
9 changes: 4 additions & 5 deletions deployment/ccip/changeset/cs_add_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@ 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),
TimelockExecutors: e.Env.AllDeployerKeys(),
TimelockMinDelay: big.NewInt(0),
Canceller: commonchangeset.SingleGroupMCMS(t),
Bypasser: commonchangeset.SingleGroupMCMS(t),
Proposer: commonchangeset.SingleGroupMCMS(t),
TimelockMinDelay: big.NewInt(0),
}
e.Env, err = commonchangeset.ApplyChangesets(t, e.Env, nil, []commonchangeset.ChangesetApplication{
{
Expand Down
9 changes: 4 additions & 5 deletions deployment/ccip/changeset/cs_deploy_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ 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),
TimelockExecutors: e.AllDeployerKeys(),
TimelockMinDelay: big.NewInt(0),
Canceller: commonchangeset.SingleGroupMCMS(t),
Bypasser: commonchangeset.SingleGroupMCMS(t),
Proposer: commonchangeset.SingleGroupMCMS(t),
TimelockMinDelay: big.NewInt(0),
}
}
e, err = commonchangeset.ApplyChangesets(t, e, nil, []commonchangeset.ChangesetApplication{
Expand Down
9 changes: 4 additions & 5 deletions deployment/ccip/changeset/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,10 @@ 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),
TimelockExecutors: e.Env.AllDeployerKeys(),
TimelockMinDelay: big.NewInt(0),
Canceller: commonchangeset.SingleGroupMCMS(t),
Bypasser: commonchangeset.SingleGroupMCMS(t),
Proposer: commonchangeset.SingleGroupMCMS(t),
TimelockMinDelay: big.NewInt(0),
}
}
var (
Expand Down
39 changes: 35 additions & 4 deletions deployment/common/changeset/internal/mcms.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,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
config.TimelockExecutors, //executors
[]common.Address{canceller.Address}, // cancellers
[]common.Address{bypasser.Address}, // bypassers
[]common.Address{proposer.Address}, // proposers
[]common.Address{}, // executors
[]common.Address{canceller.Address, proposer.Address, bypasser.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 @@ -119,6 +119,37 @@ 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 Down
12 changes: 4 additions & 8 deletions deployment/common/changeset/internal/mcms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ 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 @@ -37,18 +36,15 @@ 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),
TimelockExecutors: []common.Address{
chains[chainsel.TEST_90000001.Selector].DeployerKey.From,
},
Canceller: changeset.SingleGroupMCMS(t),
Bypasser: changeset.SingleGroupMCMS(t),
Proposer: changeset.SingleGroupMCMS(t),
TimelockMinDelay: big.NewInt(0),
})
require.NoError(t, err)
addresses, err := ab.AddressesForChain(chainsel.TEST_90000001.Selector)
require.NoError(t, err)
require.Len(t, addresses, 4)
require.Len(t, addresses, 5)
mcmsState, err := changeset.MaybeLoadMCMSWithTimelockState(chains[chainsel.TEST_90000001.Selector], addresses)
require.NoError(t, err)
v, err := mcmsState.GenerateMCMSWithTimelockView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ func TestTransferToMCMSWithTimelock(t *testing.T) {
Changeset: WrapChangeSet(DeployMCMSWithTimelock),
Config: map[uint64]types.MCMSWithTimelockConfig{
chain1: {
Canceller: SingleGroupMCMS(t),
Bypasser: SingleGroupMCMS(t),
Proposer: SingleGroupMCMS(t),
TimelockExecutors: e.AllDeployerKeys(),
TimelockMinDelay: big.NewInt(0),
Canceller: SingleGroupMCMS(t),
Bypasser: SingleGroupMCMS(t),
Proposer: SingleGroupMCMS(t),
TimelockMinDelay: big.NewInt(0),
},
},
},
Expand Down
11 changes: 5 additions & 6 deletions deployment/common/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"math/big"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/smartcontractkit/ccip-owner-contracts/pkg/config"

"github.com/smartcontractkit/chainlink/deployment"
Expand All @@ -16,6 +15,7 @@ const (
CancellerManyChainMultisig deployment.ContractType = "CancellerManyChainMultiSig"
ProposerManyChainMultisig deployment.ContractType = "ProposerManyChainMultiSig"
RBACTimelock deployment.ContractType = "RBACTimelock"
CallProxy deployment.ContractType = "CallProxy"
// LinkToken is the burn/mint link token. It should be used everywhere for
// new deployments. Corresponds to
// https://github.com/smartcontractkit/chainlink/blob/develop/core/gethwrappers/shared/generated/link_token/link_token.go#L34
Expand All @@ -29,11 +29,10 @@ const (
)

type MCMSWithTimelockConfig struct {
Canceller config.Config
Bypasser config.Config
Proposer config.Config
TimelockExecutors []common.Address
TimelockMinDelay *big.Int
Canceller config.Config
Bypasser config.Config
Proposer config.Config
TimelockMinDelay *big.Int
}

type OCRParameters struct {
Expand Down
9 changes: 4 additions & 5 deletions deployment/keystone/changeset/accept_ownership_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ func TestAcceptAllOwnership(t *testing.T) {
Changeset: commonchangeset.WrapChangeSet(commonchangeset.DeployMCMSWithTimelock),
Config: map[uint64]types.MCMSWithTimelockConfig{
registrySel: {
Canceller: commonchangeset.SingleGroupMCMS(t),
Bypasser: commonchangeset.SingleGroupMCMS(t),
Proposer: commonchangeset.SingleGroupMCMS(t),
TimelockExecutors: env.AllDeployerKeys(),
TimelockMinDelay: big.NewInt(0),
Canceller: commonchangeset.SingleGroupMCMS(t),
Bypasser: commonchangeset.SingleGroupMCMS(t),
Proposer: commonchangeset.SingleGroupMCMS(t),
TimelockMinDelay: big.NewInt(0),
},
},
},
Expand Down
9 changes: 4 additions & 5 deletions deployment/keystone/changeset/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,10 @@ func SetupTestEnv(t *testing.T, c TestConfig) TestEnv {
for sel := range env.Chains {
t.Logf("Enabling MCMS on chain %d", sel)
timelockCfgs[sel] = commontypes.MCMSWithTimelockConfig{
Canceller: commonchangeset.SingleGroupMCMS(t),
Bypasser: commonchangeset.SingleGroupMCMS(t),
Proposer: commonchangeset.SingleGroupMCMS(t),
TimelockExecutors: env.AllDeployerKeys(),
TimelockMinDelay: big.NewInt(0),
Canceller: commonchangeset.SingleGroupMCMS(t),
Bypasser: commonchangeset.SingleGroupMCMS(t),
Proposer: commonchangeset.SingleGroupMCMS(t),
TimelockMinDelay: big.NewInt(0),
}
}
env, err = commonchangeset.ApplyChangesets(t, env, nil, []commonchangeset.ChangesetApplication{
Expand Down
9 changes: 4 additions & 5 deletions integration-tests/testsetups/ccip/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,10 @@ func NewLocalDevEnvironment(
mcmsCfg := make(map[uint64]commontypes.MCMSWithTimelockConfig)
for _, c := range env.AllChainSelectors() {
mcmsCfg[c] = commontypes.MCMSWithTimelockConfig{
Canceller: commonchangeset.SingleGroupMCMS(t),
Bypasser: commonchangeset.SingleGroupMCMS(t),
Proposer: commonchangeset.SingleGroupMCMS(t),
TimelockExecutors: env.AllDeployerKeys(),
TimelockMinDelay: big.NewInt(0),
Canceller: commonchangeset.SingleGroupMCMS(t),
Bypasser: commonchangeset.SingleGroupMCMS(t),
Proposer: commonchangeset.SingleGroupMCMS(t),
TimelockMinDelay: big.NewInt(0),
}
}
// Need to deploy prerequisites first so that we can form the USDC config
Expand Down

0 comments on commit 4d007c3

Please sign in to comment.