Skip to content

Commit

Permalink
Bump owner dep (#14531)
Browse files Browse the repository at this point in the history
* Bump owner dep

* Address mcms lib changes
  • Loading branch information
connorwstein authored Sep 23, 2024
1 parent 6b30027 commit b634d36
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 35 deletions.
33 changes: 20 additions & 13 deletions integration-tests/deployment/ccip/add_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ccipdeployment
import (
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/smartcontractkit/ccip-owner-contracts/tools/proposal/mcms"
"github.com/smartcontractkit/ccip-owner-contracts/tools/proposal/timelock"

Expand Down Expand Up @@ -33,7 +34,8 @@ func NewChainInboundProposal(
) (*timelock.MCMSWithTimelockProposal, error) {
// Generate proposal which enables new destination (from test router) on all source chains.
var batches []timelock.BatchChainOperation
metaDataPerChain := make(map[mcms.ChainIdentifier]timelock.MCMSWithTimelockChainMetadata)
metaDataPerChain := make(map[mcms.ChainIdentifier]mcms.ChainMetadata)
timelockAddresses := make(map[mcms.ChainIdentifier]common.Address)
for _, source := range sources {
chain, _ := chainsel.ChainBySelector(source)
enableOnRampDest, err := state.Chains[source].OnRamp.ApplyDestChainConfigUpdates(SimTransactOpts(), []onramp.OnRampDestChainConfigArgs{
Expand Down Expand Up @@ -92,13 +94,15 @@ func NewChainInboundProposal(
},
},
})
metaDataPerChain[mcms.ChainIdentifier(chain.Selector)] = timelock.MCMSWithTimelockChainMetadata{
ChainMetadata: mcms.ChainMetadata{
NonceOffset: 0,
MCMAddress: state.Chains[source].Mcm.Address(),
},
TimelockAddress: state.Chains[source].Timelock.Address(),
opCount, err := state.Chains[source].Mcm.GetOpCount(nil)
if err != nil {
return nil, err
}
metaDataPerChain[mcms.ChainIdentifier(chain.Selector)] = mcms.ChainMetadata{
StartingOpCount: opCount.Uint64(),
MCMAddress: state.Chains[source].Mcm.Address(),
}
timelockAddresses[mcms.ChainIdentifier(chain.Selector)] = state.Chains[source].Timelock.Address()
}

// Home chain new don.
Expand Down Expand Up @@ -146,13 +150,15 @@ func NewChainInboundProposal(
return nil, err
}
homeChain, _ := chainsel.ChainBySelector(homeChainSel)
metaDataPerChain[mcms.ChainIdentifier(homeChain.Selector)] = timelock.MCMSWithTimelockChainMetadata{
ChainMetadata: mcms.ChainMetadata{
NonceOffset: 0,
MCMAddress: state.Chains[homeChainSel].Mcm.Address(),
},
TimelockAddress: state.Chains[homeChainSel].Timelock.Address(),
opCount, err := state.Chains[homeChainSel].Mcm.GetOpCount(nil)
if err != nil {
return nil, err
}
metaDataPerChain[mcms.ChainIdentifier(homeChain.Selector)] = mcms.ChainMetadata{
StartingOpCount: opCount.Uint64(),
MCMAddress: state.Chains[homeChainSel].Mcm.Address(),
}
timelockAddresses[mcms.ChainIdentifier(homeChain.Selector)] = state.Chains[homeChainSel].Timelock.Address()
batches = append(batches, timelock.BatchChainOperation{
ChainIdentifier: mcms.ChainIdentifier(homeChain.Selector),
Batch: []mcms.Operation{
Expand All @@ -175,6 +181,7 @@ func NewChainInboundProposal(
[]mcms.Signature{},
false,
metaDataPerChain,
timelockAddresses,
"blah", // TODO
batches,
timelock.Schedule,
Expand Down
44 changes: 25 additions & 19 deletions integration-tests/deployment/ccip/propose.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ func SignProposal(t *testing.T, env deployment.Environment, proposal *timelock.M
chainSel := mcms.ChainIdentifier(chainselc.Selector)
executorClients[chainSel] = chain.Client
}
realProposal, err := proposal.ToMCMSOnlyProposal()
require.NoError(t, err)
executor, err := realProposal.ToExecutor(executorClients)
executor, err := proposal.ToExecutor(true)
require.NoError(t, err)
payload, err := executor.SigningHash()
require.NoError(t, err)
Expand All @@ -45,15 +43,15 @@ func SignProposal(t *testing.T, env deployment.Environment, proposal *timelock.M
require.NoError(t, err)
mcmSig, err := mcms.NewSignatureFromBytes(sig)
require.NoError(t, err)
executor.Proposal.Signatures = append(executor.Proposal.Signatures, mcmSig)
executor.Proposal.AddSignature(mcmSig)
require.NoError(t, executor.Proposal.Validate())
return executor
}

func ExecuteProposal(t *testing.T, env deployment.Environment, executor *mcms.Executor,
state CCIPOnChainState, sel uint64) {
// Set the root.
tx, err2 := executor.SetRootOnChain(env.Chains[sel].DeployerKey, mcms.ChainIdentifier(sel))
tx, err2 := executor.SetRootOnChain(env.Chains[sel].Client, env.Chains[sel].DeployerKey, mcms.ChainIdentifier(sel))
require.NoError(t, err2)
_, err2 = env.Chains[sel].Confirm(tx)
require.NoError(t, err2)
Expand All @@ -63,7 +61,7 @@ func ExecuteProposal(t *testing.T, env deployment.Environment, executor *mcms.Ex
for _, chainOp := range executor.Operations[mcms.ChainIdentifier(sel)] {
for idx, op := range executor.ChainAgnosticOps {
if bytes.Equal(op.Data, chainOp.Data) && op.To == chainOp.To {
opTx, err3 := executor.ExecuteOnChain(env.Chains[sel].DeployerKey, idx)
opTx, err3 := executor.ExecuteOnChain(env.Chains[sel].Client, env.Chains[sel].DeployerKey, idx)
require.NoError(t, err3)
block, err3 := env.Chains[sel].Confirm(opTx)
require.NoError(t, err3)
Expand Down Expand Up @@ -104,7 +102,8 @@ func GenerateAcceptOwnershipProposal(
) (*timelock.MCMSWithTimelockProposal, error) {
// TODO: Accept rest of contracts
var batches []timelock.BatchChainOperation
metaDataPerChain := make(map[mcms.ChainIdentifier]timelock.MCMSWithTimelockChainMetadata)
metaDataPerChain := make(map[mcms.ChainIdentifier]mcms.ChainMetadata)
timelockAddresses := make(map[mcms.ChainIdentifier]common.Address)
for _, sel := range chains {
chain, _ := chainsel.ChainBySelector(sel)
acceptOnRamp, err := state.Chains[sel].OnRamp.AcceptOwnership(SimTransactOpts())
Expand All @@ -116,13 +115,15 @@ func GenerateAcceptOwnershipProposal(
return nil, err
}
chainSel := mcms.ChainIdentifier(chain.Selector)
metaDataPerChain[chainSel] = timelock.MCMSWithTimelockChainMetadata{
ChainMetadata: mcms.ChainMetadata{
NonceOffset: 0,
MCMAddress: state.Chains[sel].Mcm.Address(),
},
TimelockAddress: state.Chains[sel].Timelock.Address(),
opCount, err := state.Chains[sel].Mcm.GetOpCount(nil)
if err != nil {
return nil, err
}
metaDataPerChain[chainSel] = mcms.ChainMetadata{
MCMAddress: state.Chains[sel].Mcm.Address(),
StartingOpCount: opCount.Uint64(),
}
timelockAddresses[chainSel] = state.Chains[sel].Timelock.Address()
batches = append(batches, timelock.BatchChainOperation{
ChainIdentifier: chainSel,
Batch: []mcms.Operation{
Expand All @@ -139,6 +140,7 @@ func GenerateAcceptOwnershipProposal(
},
})
}

acceptCR, err := state.Chains[homeChain].CapabilityRegistry.AcceptOwnership(SimTransactOpts())
if err != nil {
return nil, err
Expand All @@ -148,13 +150,15 @@ func GenerateAcceptOwnershipProposal(
return nil, err
}
homeChainID := mcms.ChainIdentifier(homeChain)
metaDataPerChain[homeChainID] = timelock.MCMSWithTimelockChainMetadata{
ChainMetadata: mcms.ChainMetadata{
NonceOffset: 0,
MCMAddress: state.Chains[homeChain].Mcm.Address(),
},
TimelockAddress: state.Chains[homeChain].Timelock.Address(),
opCount, err := state.Chains[homeChain].Mcm.GetOpCount(nil)
if err != nil {
return nil, err
}
metaDataPerChain[homeChainID] = mcms.ChainMetadata{
StartingOpCount: opCount.Uint64(),
MCMAddress: state.Chains[homeChain].Mcm.Address(),
}
timelockAddresses[homeChainID] = state.Chains[homeChain].Timelock.Address()
batches = append(batches, timelock.BatchChainOperation{
ChainIdentifier: homeChainID,
Batch: []mcms.Operation{
Expand All @@ -170,12 +174,14 @@ func GenerateAcceptOwnershipProposal(
},
},
})

return timelock.NewMCMSWithTimelockProposal(
"1",
2004259681, // TODO
[]mcms.Signature{},
false,
metaDataPerChain,
timelockAddresses,
"blah", // TODO
batches,
timelock.Schedule, "0s")
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ require (
github.com/sethvargo/go-retry v0.2.4
github.com/shopspring/decimal v1.4.0
github.com/slack-go/slack v0.12.2
github.com/smartcontractkit/ccip-owner-contracts v0.0.0-20240910151738-3f318badcfb5
github.com/smartcontractkit/ccip-owner-contracts v0.0.0-20240919155713-f4bf4ae0b9c6
github.com/smartcontractkit/chain-selectors v1.0.23
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240920150748-cf2125c094fe
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1417,8 +1417,8 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/slack-go/slack v0.12.2 h1:x3OppyMyGIbbiyFhsBmpf9pwkUzMhthJMRNmNlA4LaQ=
github.com/slack-go/slack v0.12.2/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw=
github.com/smartcontractkit/ccip-owner-contracts v0.0.0-20240910151738-3f318badcfb5 h1:m0HuGuVdRHqBBkHJpSR/QBV7gtLB+hFkXZQ9tEkjdzo=
github.com/smartcontractkit/ccip-owner-contracts v0.0.0-20240910151738-3f318badcfb5/go.mod h1:N60/wwocvZ5A3RGmYaMWo0fPFa5tTMlhI9lJ22DRktM=
github.com/smartcontractkit/ccip-owner-contracts v0.0.0-20240919155713-f4bf4ae0b9c6 h1:e4lR/xTK7iOeCniSwH6hdaNZZ/sJs1eYWpnJoz3CXxI=
github.com/smartcontractkit/ccip-owner-contracts v0.0.0-20240919155713-f4bf4ae0b9c6/go.mod h1:nlRI0m23HFMAHf7cKYdE58mPbXsTyY1y3ZLJxnuuoCM=
github.com/smartcontractkit/chain-selectors v1.0.23 h1:D2Eaex4Cw/O7Lg3tX6WklOqnjjIQAEBnutCtksPzVDY=
github.com/smartcontractkit/chain-selectors v1.0.23/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8=
Expand Down

0 comments on commit b634d36

Please sign in to comment.