Skip to content

Commit

Permalink
Merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
connorwstein committed Sep 27, 2024
2 parents 666c9e1 + a6deabd commit ec2bd16
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions pkg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package configwrappers
package config

import (
"math/big"
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package configwrappers
package config

import (
"testing"
Expand Down
14 changes: 7 additions & 7 deletions pkg/proposal/mcms/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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),
}
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/proposal/mcms/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
6 changes: 3 additions & 3 deletions pkg/proposal/mcms/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/proposal/timelock/mcm_with_timelock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit ec2bd16

Please sign in to comment.