diff --git a/go.mod b/go.mod index fb10c76..84e8fbd 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( github.com/ethereum/go-ethereum v1.13.8 github.com/smartcontractkit/chain-selectors v1.0.23 github.com/stretchr/testify v1.8.4 - golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa golang.org/x/tools v0.15.0 ) @@ -71,6 +70,7 @@ require ( github.com/tklauser/numcpus v0.6.1 // indirect github.com/tyler-smith/go-bip39 v1.1.0 // indirect golang.org/x/crypto v0.17.0 // indirect + golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/sync v0.5.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/pkg/README.md b/pkg/README.md index 1567dc3..3774326 100644 --- a/pkg/README.md +++ b/pkg/README.md @@ -8,11 +8,11 @@ The packages in this directory provide a set of tools that users can use to inte Deploy the MCMS contract using the [`DeployManyChainMultiSig`](./gethwrappers/ManyChainMultiSig.go#L76) function -The default [`ManyChainMultiSigConfig`](./gethwrappers/ManyChainMultiSig.go#L32) is very unintuitive to define and construct based on the desired group structure. As a result, this library provides a [`Config` Wrapper](config/config.go#L13) which defines a more intuitive MCMS membership structure for ease of use. +The default [`ManyChainMultiSigConfig`](./gethwrappers/ManyChainMultiSig.go#L32) is very unintuitive to define and construct based on the desired group structure. As a result, this library provides a [`Config` Wrapper](./config/config.go#L13) which defines a more intuitive MCMS membership structure for ease of use. The configuration is a nested tree structure where a given group is considered at `quorum` if the sum of `Signers` with Signatures and `GroupSigners` that individually are at `quorum` are greater than or equal to the top-level `quorum` -For example, given the following [`Config`](config/config.go#L13): +For example, given the following [`Config`](./config/config.go#L13): ``` Config{ @@ -48,7 +48,11 @@ This configuration represents a membership structure that requires 3 entities to 11. [`0x2`, `0x4`, `0x5`] 12. [`0x2`, `0x4`, `0x6`] +<<<<<<< HEAD Once a satisfactory MCMS Membership configuration is constructed, users can use the [`ExtractSetConfigInputs`](config/config.go#L153) function to generate inputs and call [`SetConfig`](./gethwrappers/ManyChainMultiSig.go#L428) +======= +Once a satisfactory MCMS Membership configuration is constructed, users can use the [`ExtractSetConfigInputs`](./config/config.go#L153) function to generate inputs and call [`SetConfig`](./gethwrappers/ManyChainMultiSig.go#L428) +>>>>>>> develop Note: Signers cannot be repeated in this configuration (i.e. they cannot belong to multiple groups) diff --git a/pkg/config/config.go b/pkg/config/config.go index 1b7cc78..e3a099e 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -1,4 +1,4 @@ -package configwrappers +package config import ( "math/big" diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 5f22dab..767410a 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -1,4 +1,4 @@ -package configwrappers +package config import ( "testing" diff --git a/pkg/proposal/mcms/executor.go b/pkg/proposal/mcms/executor.go index 852a61b..7472f13 100644 --- a/pkg/proposal/mcms/executor.go +++ b/pkg/proposal/mcms/executor.go @@ -9,7 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" - "github.com/smartcontractkit/ccip-owner-contracts/pkg/config" + c "github.com/smartcontractkit/ccip-owner-contracts/pkg/config" "github.com/smartcontractkit/ccip-owner-contracts/pkg/errors" "github.com/smartcontractkit/ccip-owner-contracts/pkg/gethwrappers" "github.com/smartcontractkit/ccip-owner-contracts/pkg/merkle" @@ -188,8 +188,8 @@ func (e *Executor) CheckQuorum(client bind.ContractBackend, chain ChainIdentifie // spread the signers to get address from the configuration var contractSigners []common.Address - for _, c := range config.Signers { - contractSigners = append(contractSigners, c.Addr) + for _, s := range config.Signers { + contractSigners = append(contractSigners, s.Addr) } // Validate that all signers are valid @@ -205,12 +205,12 @@ func (e *Executor) CheckQuorum(client bind.ContractBackend, chain ChainIdentifie // Validate if the quorum is met - c, err := configwrappers.NewConfigFromRaw(config) + newConfig, err := c.NewConfigFromRaw(config) if err != nil { return false, err } - if !isReadyToSetRoot(*c, recoveredSigners) { + if !isReadyToSetRoot(*newConfig, recoveredSigners) { return false, &errors.ErrQuorumNotMet{ ChainIdentifier: uint64(chain), } @@ -276,11 +276,11 @@ func (e *Executor) ValidateSignatures(clients map[ChainIdentifier]ContractDeploy return true, nil } -func isReadyToSetRoot(rootGroup configwrappers.Config, recoveredSigners []common.Address) bool { +func isReadyToSetRoot(rootGroup c.Config, recoveredSigners []common.Address) bool { return isGroupAtConsensus(rootGroup, recoveredSigners) } -func isGroupAtConsensus(group configwrappers.Config, recoveredSigners []common.Address) bool { +func isGroupAtConsensus(group c.Config, recoveredSigners []common.Address) bool { signerApprovalsInGroup := 0 for _, signer := range group.Signers { for _, recoveredSigner := range recoveredSigners { diff --git a/pkg/proposal/mcms/executor_test.go b/pkg/proposal/mcms/executor_test.go index d264969..e9d3d03 100644 --- a/pkg/proposal/mcms/executor_test.go +++ b/pkg/proposal/mcms/executor_test.go @@ -68,10 +68,10 @@ func setupSimulatedBackendWithMCMS(numSigners uint64) ([]*ecdsa.PrivateKey, []*b } // Set the config - config := &configwrappers.Config{ + config := &config.Config{ Quorum: uint8(numSigners), Signers: signers, - GroupSigners: []configwrappers.Config{}, + GroupSigners: []config.Config{}, } quorums, parents, signersAddresses, signerGroups := config.ExtractSetConfigInputs() diff --git a/pkg/proposal/mcms/utils.go b/pkg/proposal/mcms/utils.go index 6cde19b..43f1003 100644 --- a/pkg/proposal/mcms/utils.go +++ b/pkg/proposal/mcms/utils.go @@ -42,10 +42,10 @@ func transformHashes(hashes []common.Hash) [][32]byte { return m } -func transformMCMSConfigs(configs map[ChainIdentifier]gethwrappers.ManyChainMultiSigConfig) (map[ChainIdentifier]*configwrappers.Config, error) { - m := make(map[ChainIdentifier]*configwrappers.Config) +func transformMCMSConfigs(configs map[ChainIdentifier]gethwrappers.ManyChainMultiSigConfig) (map[ChainIdentifier]*config.Config, error) { + m := make(map[ChainIdentifier]*config.Config) for k, v := range configs { - config, err := configwrappers.NewConfigFromRaw(v) + config, err := config.NewConfigFromRaw(v) if err != nil { return nil, err } diff --git a/pkg/proposal/timelock/mcm_with_timelock_test.go b/pkg/proposal/timelock/mcm_with_timelock_test.go index 66854c6..597b036 100644 --- a/pkg/proposal/timelock/mcm_with_timelock_test.go +++ b/pkg/proposal/timelock/mcm_with_timelock_test.go @@ -234,10 +234,10 @@ func setupSimulatedBackendWithMCMSAndTimelock(numSigners uint64) ([]*ecdsa.Priva } // Set the config - config := &configwrappers.Config{ + config := &config.Config{ Quorum: uint8(numSigners), Signers: signers, - GroupSigners: []configwrappers.Config{}, + GroupSigners: []config.Config{}, } quorums, parents, signersAddresses, signerGroups := config.ExtractSetConfigInputs()