Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/tt/shouldBreakMcms' into tt/padd…
Browse files Browse the repository at this point in the history
…ingMcms
  • Loading branch information
tt-cll committed Feb 21, 2025
2 parents 3d3cdfa + 6df6280 commit 1174b5c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 37 deletions.
15 changes: 3 additions & 12 deletions deployment/common/changeset/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,15 @@ func ApplyChangesets(t *testing.T, e deployment.Environment, timelockContractsPe
for _, prop := range out.MCMSTimelockProposals {
mcmProp := proposalutils.SignMCMSTimelockProposal(t, e, &prop)
// return the error so devs can ensure expected reversions
err = proposalutils.ExecuteMCMSProposalV2(t, e, mcmProp)
if err != nil {
return deployment.Environment{}, err
}
err = proposalutils.ExecuteMCMSTimelockProposalV2(t, e, &prop)
if err != nil {
return deployment.Environment{}, err
}
proposalutils.ExecuteMCMSProposalV2(t, e, mcmProp)
proposalutils.ExecuteMCMSTimelockProposalV2(t, e, &prop)
}
}
if out.MCMSProposals != nil {
for _, prop := range out.MCMSProposals {
p := proposalutils.SignMCMSProposal(t, e, &prop)
// return the error so devs can ensure expected reversions
err = proposalutils.ExecuteMCMSProposalV2(t, e, p)
if err != nil {
return deployment.Environment{}, err
}
proposalutils.ExecuteMCMSProposalV2(t, e, p)
}
}
currentEnv = deployment.Environment{
Expand Down
33 changes: 8 additions & 25 deletions deployment/common/proposalutils/mcms_test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package proposalutils

import (
"crypto/ecdsa"
"fmt"
"math/big"
"slices"
"testing"
Expand Down Expand Up @@ -184,7 +183,7 @@ func SignMCMSProposal(t *testing.T, env deployment.Environment, proposal *mcmsli
}

// ExecuteMCMSProposalV2 - Executes an MCMS proposal on a chain. For timelock proposal, use ExecuteMCMSTimelockProposalV2 instead.
func ExecuteMCMSProposalV2(t *testing.T, env deployment.Environment, proposal *mcmslib.Proposal) error {
func ExecuteMCMSProposalV2(t *testing.T, env deployment.Environment, proposal *mcmslib.Proposal) {
t.Log("Executing proposal")

encoders, err := proposal.GetEncoders()
Expand Down Expand Up @@ -228,9 +227,7 @@ func ExecuteMCMSProposalV2(t *testing.T, env deployment.Environment, proposal *m
for chainSelector := range executorsMap {
t.Logf("[ExecuteMCMSProposalV2] Setting root on chain %d...", chainSelector)
root, err := executable.SetRoot(env.GetContext(), chainSelector)
if err != nil {
return fmt.Errorf("[ExecuteMCMSProposalV2] SetRoot failed: %w", err)
}
require.NoError(t, err, "[ExecuteMCMSProposalV2] SetRoot failed")

family, err := chainsel.GetSelectorFamily(uint64(chainSelector))
require.NoError(t, err)
Expand All @@ -241,19 +238,15 @@ func ExecuteMCMSProposalV2(t *testing.T, env deployment.Environment, proposal *m
evmTransaction := root.RawTransaction.(*gethtypes.Transaction)
t.Logf("[ExecuteMCMSProposalV2] SetRoot EVM tx hash: %s", evmTransaction.Hash().String())
_, err = chain.Confirm(evmTransaction)
if err != nil {
return fmt.Errorf("[ExecuteMCMSProposalV2] Confirm failed: %w", err)
}
require.NoError(t, err, "[ExecuteMCMSProposalV2] Confirm failed")
}
}

// execute each operation sequentially
for i, op := range proposal.Operations {
t.Logf("[ExecuteMCMSProposalV2] Executing operation index=%d on chain %d...", i, uint64(op.ChainSelector))
result, err := executable.Execute(env.GetContext(), i)
if err != nil {
return fmt.Errorf("[ExecuteMCMSProposalV2] Execute failed: %w", err)
}
require.NoError(t, err, "[ExecuteMCMSProposalV2] Execute failed")

family, err := chainsel.GetSelectorFamily(uint64(op.ChainSelector))
require.NoError(t, err)
Expand All @@ -263,18 +256,14 @@ func ExecuteMCMSProposalV2(t *testing.T, env deployment.Environment, proposal *m
evmTransaction := result.RawTransaction.(*gethtypes.Transaction)
t.Logf("[ExecuteMCMSProposalV2] Operation %d EVM tx hash: %s", i, evmTransaction.Hash().String())
_, err = chain.Confirm(evmTransaction)
if err != nil {
return fmt.Errorf("[ExecuteMCMSProposalV2] Confirm failed: %w", err)
}
require.NoError(t, err, "[ExecuteMCMSProposalV2] Confirm failed")
}
}

return nil
}

// ExecuteMCMSTimelockProposalV2 - Includes an option to set callProxy to execute the calls through a proxy.
// If the callProxy is not set, the calls will be executed directly to the timelock.
func ExecuteMCMSTimelockProposalV2(t *testing.T, env deployment.Environment, timelockProposal *mcmslib.TimelockProposal, opts ...mcmslib.Option) error {
func ExecuteMCMSTimelockProposalV2(t *testing.T, env deployment.Environment, timelockProposal *mcmslib.TimelockProposal, opts ...mcmslib.Option) {
t.Log("Executing timelock proposal")

// build a "chainSelector => executor" map
Expand Down Expand Up @@ -317,9 +306,7 @@ func ExecuteMCMSTimelockProposalV2(t *testing.T, env deployment.Environment, tim
}

tx, err = timelockExecutable.Execute(env.GetContext(), i, opOpts...)
if err != nil {
return fmt.Errorf("[ExecuteMCMSTimelockProposalV2] Execute failed: %w", err)
}
require.NoError(t, err)

family, err := chainsel.GetSelectorFamily(uint64(op.ChainSelector))
require.NoError(t, err)
Expand All @@ -329,13 +316,9 @@ func ExecuteMCMSTimelockProposalV2(t *testing.T, env deployment.Environment, tim
chain := env.Chains[uint64(op.ChainSelector)]
evmTransaction := tx.RawTransaction.(*gethtypes.Transaction)
_, err = chain.Confirm(evmTransaction)
if err != nil {
return fmt.Errorf("[ExecuteMCMSTimelockProposalV2] Confirm failed: %w", err)
}
require.NoError(t, err)
}
}

return nil
}

func SingleGroupTimelockConfig(t *testing.T) commontypes.MCMSWithTimelockConfig {
Expand Down

0 comments on commit 1174b5c

Please sign in to comment.