From 241f6ed2a6c4a3d1b2afc5ad3609d3485af156e2 Mon Sep 17 00:00:00 2001 From: pavelkrolevets Date: Mon, 7 Oct 2024 14:32:45 +0300 Subject: [PATCH] pectra ready --- cli/flags/flags.go | 9 +- cli/initiator/initiator.go | 2 +- cli/initiator/reshare.go | 6 +- cli/initiator/resigning.go | 5 +- cli/utils/utils.go | 35 +++++ go.mod | 4 +- go.sum | 4 +- integration_test/init_bulk_test.go | 32 ++-- integration_test/init_integration_test.go | 73 ++++----- integration_test/reshare_bulk_test.go | 147 +++++++++++------- integration_test/reshare_eip1271_sig_test.go | 9 +- .../reshare_threshold_old_ops_test.go | 9 +- integration_test/resign_bulk_test.go | 77 ++++++--- integration_test/resign_eip1271_sig_test.go | 5 + integration_test/resign_integration_test.go | 13 +- pkgs/crypto/deposit_data.go | 9 +- pkgs/dkg/drand.go | 10 +- pkgs/dkg/drand_test.go | 4 +- pkgs/initiator/initiator.go | 26 ++-- pkgs/initiator/initiator_test.go | 12 +- pkgs/operator/operator_test.go | 2 + 21 files changed, 311 insertions(+), 182 deletions(-) diff --git a/cli/flags/flags.go b/cli/flags/flags.go index 23331e34..e104bdbc 100644 --- a/cli/flags/flags.go +++ b/cli/flags/flags.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/spf13/cobra" + spec_crypto "github.com/ssvlabs/dkg-spec/crypto" ) // Flag names. @@ -19,6 +20,7 @@ const ( operatorPort = "port" owner = "owner" nonce = "nonce" + amount = "amount" network = "network" outputPath = "outputPath" logLevel = "logLevel" @@ -66,11 +68,16 @@ func OwnerAddressFlag(c *cobra.Command) { AddPersistentStringFlag(c, owner, "", "Owner address", false) } -// NonceFlag owner nonce flag to the command +// NonceFlag adds nonce flag to the command func NonceFlag(c *cobra.Command) { AddPersistentIntFlag(c, nonce, 0, "Owner nonce", false) } +// AmountFlag adds amount in Gwei flag to the command (https://eips.ethereum.org/EIPS/eip-7251) +func AmountFlag(c *cobra.Command) { + AddPersistentIntFlag(c, amount, uint64(spec_crypto.MIN_ACTIVATION_BALANCE), "Amount in Gwei", false) +} + // NetworkFlag adds the fork version of the network flag to the command func NetworkFlag(c *cobra.Command) { AddPersistentStringFlag(c, network, "mainnet", "Network name: mainnet, prater, holesky", false) diff --git a/cli/initiator/initiator.go b/cli/initiator/initiator.go index d841a7f1..e3f92bc4 100644 --- a/cli/initiator/initiator.go +++ b/cli/initiator/initiator.go @@ -81,7 +81,7 @@ var StartDKG = &cobra.Command{ id := spec.NewID() nonce := cli_utils.Nonce + uint64(i) // Perform the ceremony. - depositData, keyShares, proofs, err := dkgInitiator.StartDKG(id, cli_utils.WithdrawAddress.Bytes(), operatorIDs, ethNetwork, cli_utils.OwnerAddress, nonce) + depositData, keyShares, proofs, err := dkgInitiator.StartDKG(id, cli_utils.WithdrawAddress.Bytes(), operatorIDs, ethNetwork, cli_utils.OwnerAddress, nonce, cli_utils.Amount) if err != nil { return nil, err } diff --git a/cli/initiator/reshare.go b/cli/initiator/reshare.go index 12d0ae32..e29c139c 100644 --- a/cli/initiator/reshare.go +++ b/cli/initiator/reshare.go @@ -86,7 +86,8 @@ var GenerateReshareMsg = &cobra.Command{ ethNetwork, cli_utils.WithdrawAddress[:], cli_utils.OwnerAddress, - nonce, + nonce, + cli_utils.Amount, signedProofs[i], ) if err != nil { @@ -191,7 +192,8 @@ var StartReshare = &cobra.Command{ ethNetwork, cli_utils.WithdrawAddress[:], cli_utils.OwnerAddress, - nonce, + nonce, + cli_utils.Amount, signedProofs[i], ) if err != nil { diff --git a/cli/initiator/resigning.go b/cli/initiator/resigning.go index 1fb6d322..a80d7d66 100644 --- a/cli/initiator/resigning.go +++ b/cli/initiator/resigning.go @@ -81,7 +81,8 @@ var GenerateResignMsg = &cobra.Command{ ethNetwork, cli_utils.WithdrawAddress[:], cli_utils.OwnerAddress, - nonce, + nonce, + cli_utils.Amount, signedProofs[i], ) if err != nil { @@ -180,7 +181,7 @@ var StartResigning = &cobra.Command{ ethNetwork, cli_utils.WithdrawAddress[:], cli_utils.OwnerAddress, - nonce, + nonce, cli_utils.Amount, signedProofs[i], ) if err != nil { diff --git a/cli/utils/utils.go b/cli/utils/utils.go index 04e77fad..b4f6c3d7 100644 --- a/cli/utils/utils.go +++ b/cli/utils/utils.go @@ -16,6 +16,7 @@ import ( "syscall" "time" + "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/bloxapp/ssv/logging" "github.com/ethereum/go-ethereum/common" "github.com/spf13/cobra" @@ -49,6 +50,7 @@ var ( Network string OwnerAddress common.Address Nonce uint64 + Amount uint64 Validators uint ClientCACertPath []string ) @@ -173,6 +175,7 @@ func SetInitFlags(cmd *cobra.Command) { flags.OperatorIDsFlag(cmd) flags.OwnerAddressFlag(cmd) flags.NonceFlag(cmd) + flags.AmountFlag(cmd) flags.NetworkFlag(cmd) flags.WithdrawAddressFlag(cmd) flags.ValidatorsFlag(cmd) @@ -205,6 +208,7 @@ func SetGenerateResignMsgFlags(cmd *cobra.Command) { flags.OperatorIDsFlag(cmd) flags.OwnerAddressFlag(cmd) flags.NonceFlag(cmd) + flags.AmountFlag(cmd) flags.NetworkFlag(cmd) flags.WithdrawAddressFlag(cmd) flags.ProofsFilePath(cmd) @@ -222,6 +226,7 @@ func SetGenerateReshareMsgFlags(cmd *cobra.Command) { flags.WithdrawAddressFlag(cmd) flags.OwnerAddressFlag(cmd) flags.NonceFlag(cmd) + flags.AmountFlag(cmd) flags.NetworkFlag(cmd) flags.ProofsFilePath(cmd) flags.ProofsStringFlag(cmd) @@ -236,6 +241,7 @@ func SetResigningFlags(cmd *cobra.Command) { flags.OperatorIDsFlag(cmd) flags.OwnerAddressFlag(cmd) flags.NonceFlag(cmd) + flags.AmountFlag(cmd) flags.NetworkFlag(cmd) flags.WithdrawAddressFlag(cmd) flags.ProofsFilePath(cmd) @@ -254,6 +260,7 @@ func SetReshareFlags(cmd *cobra.Command) { flags.WithdrawAddressFlag(cmd) flags.OwnerAddressFlag(cmd) flags.NonceFlag(cmd) + flags.AmountFlag(cmd) flags.NetworkFlag(cmd) flags.ProofsFilePath(cmd) flags.ProofsStringFlag(cmd) @@ -324,6 +331,9 @@ func BindInitiatorBaseFlags(cmd *cobra.Command) error { if err := viper.BindPFlag("nonce", cmd.PersistentFlags().Lookup("nonce")); err != nil { return err } + if err := viper.BindPFlag("amount", cmd.PersistentFlags().Lookup("amount")); err != nil { + return err + } if err := viper.BindPFlag("operatorsInfoPath", cmd.PersistentFlags().Lookup("operatorsInfoPath")); err != nil { return err } @@ -352,6 +362,10 @@ func BindInitiatorBaseFlags(cmd *cobra.Command) error { if owner == "" { return fmt.Errorf("😥 Failed to get owner address flag value") } + Amount = viper.GetUint64("amount") + if !spec.ValidAmountSet(phase0.Gwei(Amount)) { + return fmt.Errorf("🚨 Amount should be in range between 32 ETH and 2048 ETH") + } OwnerAddress, err = utils.HexToAddress(owner) if err != nil { return fmt.Errorf("😥 Failed to parse owner address: %s", err) @@ -416,6 +430,9 @@ func BindGenerateResignMsgFlags(cmd *cobra.Command) error { if err := viper.BindPFlag("nonce", cmd.PersistentFlags().Lookup("nonce")); err != nil { return err } + if err := viper.BindPFlag("amount", cmd.PersistentFlags().Lookup("amount")); err != nil { + return err + } if err := viper.BindPFlag("clientCACertPath", cmd.PersistentFlags().Lookup("clientCACertPath")); err != nil { return err } @@ -457,6 +474,10 @@ func BindGenerateResignMsgFlags(cmd *cobra.Command) error { return fmt.Errorf("😥 Failed to get owner address flag value") } Nonce = viper.GetUint64("nonce") + Amount = viper.GetUint64("amount") + if !spec.ValidAmountSet(phase0.Gwei(Amount)) { + return fmt.Errorf("🚨 Amount should be in range between 32 ETH and 2048 ETH") + } ClientCACertPath = viper.GetStringSlice("clientCACertPath") for _, certPath := range ClientCACertPath { if strings.Contains(filepath.Clean(certPath), "..") { @@ -543,6 +564,9 @@ func BindGenerateReshareMsgFlags(cmd *cobra.Command) error { if err := viper.BindPFlag("nonce", cmd.PersistentFlags().Lookup("nonce")); err != nil { return err } + if err := viper.BindPFlag("amount", cmd.PersistentFlags().Lookup("amount")); err != nil { + return err + } if err := viper.BindPFlag("proofsFilePath", cmd.PersistentFlags().Lookup("proofsFilePath")); err != nil { return err } @@ -607,6 +631,10 @@ func BindGenerateReshareMsgFlags(cmd *cobra.Command) error { return fmt.Errorf("😥 Failed to parse owner address: %s", err) } Nonce = viper.GetUint64("nonce") + Amount = viper.GetUint64("amount") + if !spec.ValidAmountSet(phase0.Gwei(Amount)) { + return fmt.Errorf("🚨 Amount should be in range between 32 ETH and 2048 ETH") + } ClientCACertPath = viper.GetStringSlice("clientCACertPath") for _, certPath := range ClientCACertPath { if strings.Contains(filepath.Clean(certPath), "..") { @@ -702,6 +730,9 @@ func BindVerifyFlags(cmd *cobra.Command) error { if err := viper.BindPFlag("nonce", cmd.PersistentFlags().Lookup("nonce")); err != nil { return err } + if err := viper.BindPFlag("amount", cmd.PersistentFlags().Lookup("amount")); err != nil { + return err + } if err := viper.BindPFlag("owner", cmd.PersistentFlags().Lookup("owner")); err != nil { return err } @@ -719,6 +750,10 @@ func BindVerifyFlags(cmd *cobra.Command) error { return fmt.Errorf("😥 Failed to parse owner address: %s", err) } Nonce = viper.GetUint64("nonce") + Amount = viper.GetUint64("amount") + if !spec.ValidAmountSet(phase0.Gwei(Amount)) { + return fmt.Errorf("🚨 Amount should be in range between 32 ETH and 2048 ETH") + } WithdrawAddress, err = utils.HexToAddress(viper.GetString("withdrawAddress")) if err != nil { return fmt.Errorf("😥 Failed to parse withdraw address: %s", err) diff --git a/go.mod b/go.mod index 753f1aa1..53ead1b5 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/sourcegraph/conc v0.3.0 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 - github.com/ssvlabs/dkg-spec v0.0.0-20240417085845-2f5e6b68f3ae + github.com/ssvlabs/dkg-spec v0.0.0-20241007074617-40e39a71b6bd github.com/stretchr/testify v1.9.0 github.com/wealdtech/go-eth2-util v1.8.1 go.uber.org/zap v1.24.0 @@ -112,4 +112,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/ssvlabs/dkg-spec v0.0.0-20240417085845-2f5e6b68f3ae => github.com/pavelkrolevets/dkg-spec v0.0.0-20240911132539-d3b223c79b34 +replace github.com/ssvlabs/dkg-spec v0.0.0-20241007074617-40e39a71b6bd => github.com/pavelkrolevets/dkg-spec v0.0.0-20241007101621-82596abc10c8 diff --git a/go.sum b/go.sum index ebf017a2..d79a7b83 100644 --- a/go.sum +++ b/go.sum @@ -327,8 +327,8 @@ github.com/onsi/ginkgo/v2 v2.10.0 h1:sfUl4qgLdvkChZrWCYndY2EAu9BRIw1YphNAzy1VNWs github.com/onsi/ginkgo/v2 v2.10.0/go.mod h1:UDQOh5wbQUlMnkLfVaIUMtQ1Vus92oM+P2JX1aulgcE= github.com/onsi/gomega v1.27.7 h1:fVih9JD6ogIiHUN6ePK7HJidyEDpWGVB5mzM7cWNXoU= github.com/onsi/gomega v1.27.7/go.mod h1:1p8OOlwo2iUUDsHnOrjE5UKYJ+e3W8eQ3qSlRahPmr4= -github.com/pavelkrolevets/dkg-spec v0.0.0-20240911132539-d3b223c79b34 h1:Dsrl64I9Mzm4nBt8/M8rlHUuYvQ5pbGqyGMufUdLBlI= -github.com/pavelkrolevets/dkg-spec v0.0.0-20240911132539-d3b223c79b34/go.mod h1:0nho9Kj4P+rrkdyj+KrlzUWGNWA50tnu17ejIHqcR74= +github.com/pavelkrolevets/dkg-spec v0.0.0-20241007101621-82596abc10c8 h1:sCpqeaw8MN/G8N+y0NTr1cn18gpE1MoY0NzIyss/ckY= +github.com/pavelkrolevets/dkg-spec v0.0.0-20241007101621-82596abc10c8/go.mod h1:0nho9Kj4P+rrkdyj+KrlzUWGNWA50tnu17ejIHqcR74= github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= diff --git a/integration_test/init_bulk_test.go b/integration_test/init_bulk_test.go index 01e45088..1b6098cd 100644 --- a/integration_test/init_bulk_test.go +++ b/integration_test/init_bulk_test.go @@ -43,7 +43,7 @@ func TestBulkHappyFlows4Ops(t *testing.T) { cli_initiator.StartDKG.Version = version cli_verify.Verify.Version = version t.Run("test 4 operators 1 validator bulk happy flow", func(t *testing.T) { - args := []string{"init", "--validators", "1", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44", "--nonce", "1", "--clientCACertPath", "./certs/rootCA.crt"} + args := []string{"init", "--validators", "1", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44", "--nonce", "1", "--amount", "32000000000", "--amount", "32000000000", "--clientCACertPath", "./certs/rootCA.crt"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -51,14 +51,14 @@ func TestBulkHappyFlows4Ops(t *testing.T) { }) t.Run("test 4 operators 10 validators bulk happy flow", func(t *testing.T) { - args := []string{"init", "--validators", "10", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44", "--nonce", "1", "--clientCACertPath", "./certs/rootCA.crt"} + args := []string{"init", "--validators", "10", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44", "--nonce", "1", "--amount", "32000000000", "--clientCACertPath", "./certs/rootCA.crt"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) resetFlags(RootCmd) }) t.Run("test 4 operators 100 validator bulk happy flow", func(t *testing.T) { - args := []string{"init", "--validators", "100", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44", "--nonce", "1", "--clientCACertPath", "./certs/rootCA.crt"} + args := []string{"init", "--validators", "100", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44", "--nonce", "1", "--amount", "32000000000", "--clientCACertPath", "./certs/rootCA.crt"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -69,7 +69,7 @@ func TestBulkHappyFlows4Ops(t *testing.T) { require.NoError(t, err) validators := []int{1, 10, 100} for i, c := range initCeremonies { - args := []string{"verify", "--ceremonyDir", "./output/" + c.Name(), "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--nonce", strconv.Itoa(1)} + args := []string{"verify", "--ceremonyDir", "./output/" + c.Name(), "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--nonce", strconv.Itoa(1), "--amount", "32000000000", "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -109,21 +109,21 @@ func TestBulkHappyFlows7Ops(t *testing.T) { cli_initiator.StartDKG.Version = version cli_verify.Verify.Version = version t.Run("test 7 operators 1 validator bulk happy flow", func(t *testing.T) { - args := []string{"init", "--validators", "1", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77", "--nonce", "1", "--clientCACertPath", "./certs/rootCA.crt"} + args := []string{"init", "--validators", "1", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77", "--nonce", "1", "--amount", "32000000000", "--clientCACertPath", "./certs/rootCA.crt"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) resetFlags(RootCmd) }) t.Run("test 7 operators 10 validators bulk happy flow", func(t *testing.T) { - args := []string{"init", "--validators", "10", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77", "--nonce", "1", "--clientCACertPath", "./certs/rootCA.crt"} + args := []string{"init", "--validators", "10", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77", "--nonce", "1", "--amount", "32000000000", "--clientCACertPath", "./certs/rootCA.crt"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) resetFlags(RootCmd) }) t.Run("test 7 operators 100 validator bulk happy flow", func(t *testing.T) { - args := []string{"init", "--validators", "100", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77", "--nonce", "1", "--clientCACertPath", "./certs/rootCA.crt"} + args := []string{"init", "--validators", "100", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77", "--nonce", "1", "--amount", "32000000000", "--clientCACertPath", "./certs/rootCA.crt"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -134,7 +134,7 @@ func TestBulkHappyFlows7Ops(t *testing.T) { require.NoError(t, err) validators := []int{1, 10, 100} for i, c := range initCeremonies { - args := []string{"verify", "--ceremonyDir", "./output/" + c.Name(), "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--nonce", strconv.Itoa(1)} + args := []string{"verify", "--ceremonyDir", "./output/" + c.Name(), "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--nonce", strconv.Itoa(1), "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -174,21 +174,21 @@ func TestBulkHappyFlows10Ops(t *testing.T) { cli_initiator.StartDKG.Version = version cli_verify.Verify.Version = version t.Run("test 10 operators 1 validator bulk happy flow", func(t *testing.T) { - args := []string{"init", "--validators", "1", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100", "--nonce", "1", "--clientCACertPath", "./certs/rootCA.crt"} + args := []string{"init", "--validators", "1", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100", "--nonce", "1", "--amount", "32000000000", "--clientCACertPath", "./certs/rootCA.crt"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) resetFlags(RootCmd) }) t.Run("test 10 operators 10 validators bulk happy flow", func(t *testing.T) { - args := []string{"init", "--validators", "10", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100", "--nonce", "1", "--clientCACertPath", "./certs/rootCA.crt"} + args := []string{"init", "--validators", "10", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100", "--nonce", "1", "--amount", "32000000000", "--clientCACertPath", "./certs/rootCA.crt"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) resetFlags(RootCmd) }) t.Run("test 10 operators 100 validator bulk happy flow", func(t *testing.T) { - args := []string{"init", "--validators", "100", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100", "--nonce", "1", "--clientCACertPath", "./certs/rootCA.crt"} + args := []string{"init", "--validators", "100", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100", "--nonce", "1", "--amount", "32000000000", "--clientCACertPath", "./certs/rootCA.crt"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -199,7 +199,7 @@ func TestBulkHappyFlows10Ops(t *testing.T) { require.NoError(t, err) validators := []int{1, 10, 100} for i, c := range initCeremonies { - args := []string{"verify", "--ceremonyDir", "./output/" + c.Name(), "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--nonce", strconv.Itoa(1)} + args := []string{"verify", "--ceremonyDir", "./output/" + c.Name(), "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--nonce", strconv.Itoa(1), "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -239,21 +239,21 @@ func TestBulkHappyFlows13Ops(t *testing.T) { cli_initiator.StartDKG.Version = version cli_verify.Verify.Version = version t.Run("test 13 operators 1 validator bulk happy flow", func(t *testing.T) { - args := []string{"init", "--validators", "1", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", "--nonce", "1", "--clientCACertPath", "./certs/rootCA.crt"} + args := []string{"init", "--validators", "1", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", "--nonce", "1", "--amount", "32000000000", "--clientCACertPath", "./certs/rootCA.crt"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) resetFlags(RootCmd) }) t.Run("test 13 operators 10 validators bulk happy flow", func(t *testing.T) { - args := []string{"init", "--validators", "10", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", "--nonce", "1", "--clientCACertPath", "./certs/rootCA.crt"} + args := []string{"init", "--validators", "10", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", "--nonce", "1", "--amount", "32000000000", "--clientCACertPath", "./certs/rootCA.crt"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) resetFlags(RootCmd) }) t.Run("test 13 operators 100 validator bulk happy flow", func(t *testing.T) { - args := []string{"init", "--validators", "100", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", "--nonce", "1", "--clientCACertPath", "./certs/rootCA.crt"} + args := []string{"init", "--validators", "100", "--operatorsInfo", string(operators), "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", "--nonce", "1", "--amount", "32000000000", "--clientCACertPath", "./certs/rootCA.crt"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -264,7 +264,7 @@ func TestBulkHappyFlows13Ops(t *testing.T) { require.NoError(t, err) validators := []int{1, 10, 100} for i, c := range initCeremonies { - args := []string{"verify", "--ceremonyDir", "./output/" + c.Name(), "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--nonce", strconv.Itoa(1)} + args := []string{"verify", "--ceremonyDir", "./output/" + c.Name(), "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--nonce", strconv.Itoa(1), "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) diff --git a/integration_test/init_integration_test.go b/integration_test/init_integration_test.go index 7183a7e1..0f638d4f 100644 --- a/integration_test/init_integration_test.go +++ b/integration_test/init_integration_test.go @@ -25,6 +25,7 @@ import ( "go.uber.org/zap" spec "github.com/ssvlabs/dkg-spec" + spec_crypto "github.com/ssvlabs/dkg-spec/crypto" "github.com/ssvlabs/dkg-spec/testing/stubs" "github.com/ssvlabs/ssv-dkg/pkgs/crypto" "github.com/ssvlabs/ssv-dkg/pkgs/initiator" @@ -57,28 +58,28 @@ func TestInitHappyFlows(t *testing.T) { owner := newEthAddress(t) t.Run("test 4 operators init happy flow", func(t *testing.T) { id := spec.NewID() - depositData, ks, proofs, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44}, "mainnet", owner, 0) + depositData, ks, proofs, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.NoError(t, err) err = validator.ValidateResults([]*wire.DepositDataCLI{depositData}, ks, [][]*wire.SignedProof{proofs}, 1, owner, 0, withdraw) require.NoError(t, err) }) t.Run("test 7 operators init happy flow", func(t *testing.T) { id := spec.NewID() - depositData, ks, proofs, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77}, "mainnet", owner, 0) + depositData, ks, proofs, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.NoError(t, err) err = validator.ValidateResults([]*wire.DepositDataCLI{depositData}, ks, [][]*wire.SignedProof{proofs}, 1, owner, 0, withdraw) require.NoError(t, err) }) t.Run("test 10 operators init happy flow", func(t *testing.T) { id := spec.NewID() - depositData, ks, proofs, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 100}, "mainnet", owner, 0) + depositData, ks, proofs, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 100}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.NoError(t, err) err = validator.ValidateResults([]*wire.DepositDataCLI{depositData}, ks, [][]*wire.SignedProof{proofs}, 1, owner, 0, withdraw) require.NoError(t, err) }) t.Run("test 13 operators init happy flow", func(t *testing.T) { id := spec.NewID() - depositData, ks, proofs, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 111, 122, 133}, "mainnet", owner, 0) + depositData, ks, proofs, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 111, 122, 133}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.NoError(t, err) err = validator.ValidateResults([]*wire.DepositDataCLI{depositData}, ks, [][]*wire.SignedProof{proofs}, 1, owner, 0, withdraw) require.NoError(t, err) @@ -106,7 +107,7 @@ func TestInitOperatorsThreshold(t *testing.T) { servers[0].HttpSrv.Close() t.Run("test 4 operators init unhappy flow, 1 not reachable", func(t *testing.T) { id := spec.NewID() - _, _, _, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44}, "holesky", owner, 0) + _, _, _, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44}, "holesky", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "some new operators returned errors, cant continue") }) for _, srv := range servers { @@ -132,7 +133,7 @@ func TestThreshold(t *testing.T) { t.Run("test 13 operators threshold", func(t *testing.T) { id := spec.NewID() ids := []uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 111, 122, 133} - _, ks, _, err := clnt.StartDKG(id, withdraw.Bytes(), ids, "mainnet", owner, 0) + _, ks, _, err := clnt.StartDKG(id, withdraw.Bytes(), ids, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.NoError(t, err) sharesDataSigned, err := hex.DecodeString(ks.Shares[0].Payload.SharesData[2:]) require.NoError(t, err) @@ -152,7 +153,7 @@ func TestThreshold(t *testing.T) { t.Run("test 10 operators threshold", func(t *testing.T) { id := spec.NewID() ids := []uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 100} - _, ks, _, err := clnt.StartDKG(id, withdraw.Bytes(), ids, "mainnet", owner, 0) + _, ks, _, err := clnt.StartDKG(id, withdraw.Bytes(), ids, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.NoError(t, err) sharesDataSigned, err := hex.DecodeString(ks.Shares[0].Payload.SharesData[2:]) require.NoError(t, err) @@ -172,7 +173,7 @@ func TestThreshold(t *testing.T) { t.Run("test 7 operators threshold", func(t *testing.T) { id := spec.NewID() ids := []uint64{11, 22, 33, 44, 55, 66, 77} - _, ks, _, err := clnt.StartDKG(id, withdraw.Bytes(), ids, "mainnet", owner, 0) + _, ks, _, err := clnt.StartDKG(id, withdraw.Bytes(), ids, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.NoError(t, err) sharesDataSigned, err := hex.DecodeString(ks.Shares[0].Payload.SharesData[2:]) require.NoError(t, err) @@ -191,7 +192,7 @@ func TestThreshold(t *testing.T) { }) t.Run("test 4 operators threshold", func(t *testing.T) { id := spec.NewID() - _, ks, _, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44}, "mainnet", owner, 0) + _, ks, _, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.NoError(t, err) sharesDataSigned, err := hex.DecodeString(ks.Shares[0].Payload.SharesData[2:]) require.NoError(t, err) @@ -233,7 +234,7 @@ func TestUnhappyFlows(t *testing.T) { withdraw := newEthAddress(t) owner := newEthAddress(t) id := spec.NewID() - depositData, ks, _, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44}, "mainnet", owner, 0) + depositData, ks, _, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.NoError(t, err) sharesDataSigned, err := hex.DecodeString(ks.Shares[0].Payload.SharesData[2:]) require.NoError(t, err) @@ -250,7 +251,7 @@ func TestUnhappyFlows(t *testing.T) { withdraw := newEthAddress(t) owner := newEthAddress(t) id := spec.NewID() - _, ks, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 111, 122, 133}, "mainnet", owner, 0) + _, ks, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 111, 122, 133}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.NoError(t, err) sharesDataSigned, err := hex.DecodeString(ks.Shares[0].Payload.SharesData[2:]) require.NoError(t, err) @@ -269,14 +270,14 @@ func TestUnhappyFlows(t *testing.T) { require.ErrorContains(t, err, "shares order is incorrect") }) t.Run("test same ID", func(t *testing.T) { - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "got init msg for existing instance") }) t.Run("test wrong operator IDs", func(t *testing.T) { withdraw := newEthAddress(t) owner := newEthAddress(t) id := spec.NewID() - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{101, 66, 77, 88}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{101, 66, 77, 88}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "operator is not in given operator data list") }) t.Run("test non 3f+1 operator set", func(t *testing.T) { @@ -284,62 +285,62 @@ func TestUnhappyFlows(t *testing.T) { owner := newEthAddress(t) id := spec.NewID() // 0 ops - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "amount of operators should be 4,7,10,13: got 0") // 1 op - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "amount of operators should be 4,7,10,13: got 1") // 2 ops - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "amount of operators should be 4,7,10,13: got 2") // 3 ops - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "amount of operators should be 4,7,10,13: got 3") // op with zero ID - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{0, 11, 22, 33}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{0, 11, 22, 33}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "operator ID cannot be 0") // 14 ops - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 111, 122, 133, 144}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 111, 122, 133, 144}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "amount of operators should be 4,7,10,13: got 14") // 15 ops - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 111, 122, 133, 144, 155}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 111, 122, 133, 144, 155}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "amount of operators should be 4,7,10,13: got 15") // 5 ops - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "amount of operators should be 4,7,10,13") // 6 ops - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "amount of operators should be 4,7,10,13") // 8 ops - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77, 88}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77, 88}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "amount of operators should be 4,7,10,13") // 9 ops - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "amount of operators should be 4,7,10,13") // 11 ops - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "amount of operators should be 4,7,10,13") // 12 ops - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "amount of operators should be 4,7,10,13") }) t.Run("test out of order operators (i.e 3,2,4,1) ", func(t *testing.T) { withdraw := newEthAddress(t) owner := newEthAddress(t) id := spec.NewID() - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{33, 22, 44, 11}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{33, 22, 44, 11}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "operators not unique or not ordered") - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{33, 22, 44, 11, 100, 111, 122}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{33, 22, 44, 11, 100, 111, 122}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "operators not unique or not ordered") - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{33, 22, 44, 11, 100, 111, 122, 99, 88, 77}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{33, 22, 44, 11, 100, 111, 122, 99, 88, 77}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "operators not unique or not ordered") - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{33, 22, 44, 11, 100, 111, 122, 99, 88, 77, 66, 55, 133}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{33, 22, 44, 11, 100, 111, 122, 99, 88, 77, 66, 55, 133}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "operators not unique or not ordered") - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{33, 33, 44, 11}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{33, 33, 44, 11}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "operators ids should be unique in the list") - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{33, 22, 44, 22, 100, 111, 122, 99, 88, 77}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{33, 22, 44, 22, 100, 111, 122, 99, 88, 77}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "operators ids should be unique in the list") - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{33, 22, 44, 11, 100, 111, 122, 99, 88, 77, 66, 55, 111}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{33, 22, 44, 11, 100, 111, 122, 99, 88, 77, 66, 55, 111}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "operators ids should be unique in the list") }) for _, srv := range servers { @@ -388,7 +389,7 @@ func TestLargeOperatorIDs(t *testing.T) { withdraw := newEthAddress(t) owner := newEthAddress(t) id := spec.NewID() - depositData, ks, proofs, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{1100, 2222, 3300, 4444, 5555, 6666, 7777, 8888, 9999, 10000, 11111, 12222, 13333}, "mainnet", owner, 0) + depositData, ks, proofs, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{1100, 2222, 3300, 4444, 5555, 6666, 7777, 8888, 9999, 10000, 11111, 12222, 13333}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.NoError(t, err) err = validator.ValidateResults([]*wire.DepositDataCLI{depositData}, ks, [][]*wire.SignedProof{proofs}, 1, owner, 0, withdraw) require.NoError(t, err) @@ -430,7 +431,7 @@ func TestWrongInitiatorVersion(t *testing.T) { withdraw := newEthAddress(t) owner := newEthAddress(t) id := spec.NewID() - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{1, 2, 3, 4}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{1, 2, 3, 4}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "wrong version") srv1.HttpSrv.Close() srv2.HttpSrv.Close() @@ -461,7 +462,7 @@ func TestWrongOperatorVersion(t *testing.T) { withdraw := newEthAddress(t) owner := newEthAddress(t) id := spec.NewID() - _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{1, 2, 3, 4}, "mainnet", owner, 0) + _, _, _, err = clnt.StartDKG(id, withdraw.Bytes(), []uint64{1, 2, 3, 4}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "wrong version") srv1.HttpSrv.Close() srv2.HttpSrv.Close() diff --git a/integration_test/reshare_bulk_test.go b/integration_test/reshare_bulk_test.go index 7c0af709..25bae476 100644 --- a/integration_test/reshare_bulk_test.go +++ b/integration_test/reshare_bulk_test.go @@ -55,7 +55,8 @@ func TestBulkReshareHappyFlows4Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44", - "--nonce", "1"} + "--nonce", "1", + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -69,7 +70,8 @@ func TestBulkReshareHappyFlows4Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44", - "--nonce", "1"} + "--nonce", "1", + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -82,7 +84,8 @@ func TestBulkReshareHappyFlows4Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44", - "--nonce", "1"} + "--nonce", "1", + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -98,7 +101,7 @@ func TestBulkReshareHappyFlows4Ops(t *testing.T) { "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", - "--nonce", strconv.Itoa(1)} + "--nonce", strconv.Itoa(1), "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -122,7 +125,8 @@ func TestBulkReshareHappyFlows4Ops(t *testing.T) { "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44", "--newOperatorIDs", "55,66,77,88", - "--nonce", "10"} + "--nonce", "10", + "--amount", "32000000000"} RootCmd.SetArgs(generateReshareMsgArgs) err = RootCmd.Execute() require.NoError(t, err) @@ -153,6 +157,7 @@ func TestBulkReshareHappyFlows4Ops(t *testing.T) { "--operatorIDs", "11,22,33,44", "--newOperatorIDs", "55,66,77,88", "--nonce", "10", + "--amount", "32000000000", "--signatures", signature} RootCmd.SetArgs(args) err = RootCmd.Execute() @@ -177,7 +182,8 @@ func TestBulkReshareHappyFlows4Ops(t *testing.T) { "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", - "--nonce", strconv.Itoa(10)} + "--nonce", strconv.Itoa(10), + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -226,7 +232,8 @@ func TestBulkReshareHappyFlows7Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77", - "--nonce", "1"} + "--nonce", "1", + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -240,25 +247,27 @@ func TestBulkReshareHappyFlows7Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77", - "--nonce", "1"} + "--nonce", "1", + "--amount", "32000000000"} + RootCmd.SetArgs(args) + err := RootCmd.Execute() + require.NoError(t, err) + resetFlags(RootCmd) + }) + t.Run("test 7 operators 100 validator bulk happy flow", func(t *testing.T) { + args := []string{"init", + "--validators", "100", + "--operatorsInfo", string(operators), + "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", + "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", + "--operatorIDs", "11,22,33,44,55,66,77", + "--nonce", "1", + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) resetFlags(RootCmd) }) - // t.Run("test 7 operators 100 validator bulk happy flow", func(t *testing.T) { - // args := []string{"init", - // "--validators", "100", - // "--operatorsInfo", string(operators), - // "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", - // "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", - // "--operatorIDs", "11,22,33,44,55,66,77", - // "--nonce", "1"} - // RootCmd.SetArgs(args) - // err := RootCmd.Execute() - // require.NoError(t, err) - // resetFlags(RootCmd) - // }) // validate results initCeremonies, err := os.ReadDir("./output") require.NoError(t, err) @@ -269,7 +278,8 @@ func TestBulkReshareHappyFlows7Ops(t *testing.T) { "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", - "--nonce", strconv.Itoa(1)} + "--nonce", strconv.Itoa(1), + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -293,7 +303,8 @@ func TestBulkReshareHappyFlows7Ops(t *testing.T) { "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77", "--newOperatorIDs", "77,88,99,100,111,122,133", - "--nonce", "10"} + "--nonce", "10", + "--amount", "32000000000"} RootCmd.SetArgs(generateReshareMsgArgs) err = RootCmd.Execute() require.NoError(t, err) @@ -324,6 +335,7 @@ func TestBulkReshareHappyFlows7Ops(t *testing.T) { "--operatorIDs", "11,22,33,44,55,66,77", "--newOperatorIDs", "77,88,99,100,111,122,133", "--nonce", "10", + "--amount", "32000000000", "--signatures", signature} RootCmd.SetArgs(args) err = RootCmd.Execute() @@ -348,7 +360,8 @@ func TestBulkReshareHappyFlows7Ops(t *testing.T) { "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", - "--nonce", strconv.Itoa(10)} + "--nonce", strconv.Itoa(10), + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -397,7 +410,8 @@ func TestBulkReshareHappyFlows10Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100", - "--nonce", "1"} + "--nonce", "1", + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -411,25 +425,27 @@ func TestBulkReshareHappyFlows10Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100", - "--nonce", "1"} + "--nonce", "1", + "--amount", "32000000000"} + RootCmd.SetArgs(args) + err := RootCmd.Execute() + require.NoError(t, err) + resetFlags(RootCmd) + }) + t.Run("test 10 operators 100 validator bulk happy flow", func(t *testing.T) { + args := []string{"init", + "--validators", "100", + "--operatorsInfo", string(operators), + "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", + "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", + "--operatorIDs", "11,22,33,44,55,66,77,88,99,100", + "--nonce", "1", + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) resetFlags(RootCmd) }) - // t.Run("test 10 operators 100 validator bulk happy flow", func(t *testing.T) { - // args := []string{"init", - // "--validators", "100", - // "--operatorsInfo", string(operators), - // "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", - // "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", - // "--operatorIDs", "11,22,33,44,55,66,77,88,99,100", - // "--nonce", "1"} - // RootCmd.SetArgs(args) - // err := RootCmd.Execute() - // require.NoError(t, err) - // resetFlags(RootCmd) - // }) // validate results initCeremonies, err := os.ReadDir("./output") require.NoError(t, err) @@ -440,7 +456,8 @@ func TestBulkReshareHappyFlows10Ops(t *testing.T) { "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", - "--nonce", strconv.Itoa(1)} + "--nonce", strconv.Itoa(1), + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -464,7 +481,8 @@ func TestBulkReshareHappyFlows10Ops(t *testing.T) { "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100", "--newOperatorIDs", "11,22,33,44", - "--nonce", "10"} + "--nonce", "10", + "--amount", "32000000000"} RootCmd.SetArgs(generateReshareMsgArgs) err = RootCmd.Execute() require.NoError(t, err) @@ -495,6 +513,7 @@ func TestBulkReshareHappyFlows10Ops(t *testing.T) { "--operatorIDs", "11,22,33,44,55,66,77,88,99,100", "--newOperatorIDs", "11,22,33,44", "--nonce", "10", + "--amount", "32000000000", "--signatures", signature} RootCmd.SetArgs(args) err = RootCmd.Execute() @@ -519,7 +538,8 @@ func TestBulkReshareHappyFlows10Ops(t *testing.T) { "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", - "--nonce", strconv.Itoa(10)} + "--nonce", strconv.Itoa(10), + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -568,7 +588,8 @@ func TestBulkReshareHappyFlows13Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", - "--nonce", "1"} + "--nonce", "1", + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -582,25 +603,27 @@ func TestBulkReshareHappyFlows13Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", - "--nonce", "1"} + "--nonce", "1", + "--amount", "32000000000"} + RootCmd.SetArgs(args) + err := RootCmd.Execute() + require.NoError(t, err) + resetFlags(RootCmd) + }) + t.Run("test 13 operators 100 validator bulk happy flow", func(t *testing.T) { + args := []string{"init", + "--validators", "100", + "--operatorsInfo", string(operators), + "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", + "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", + "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", + "--nonce", "1", + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) resetFlags(RootCmd) }) - // t.Run("test 13 operators 100 validator bulk happy flow", func(t *testing.T) { - // args := []string{"init", - // "--validators", "100", - // "--operatorsInfo", string(operators), - // "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", - // "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", - // "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", - // "--nonce", "1"} - // RootCmd.SetArgs(args) - // err := RootCmd.Execute() - // require.NoError(t, err) - // resetFlags(RootCmd) - // }) // validate results initCeremonies, err := os.ReadDir("./output") require.NoError(t, err) @@ -611,7 +634,8 @@ func TestBulkReshareHappyFlows13Ops(t *testing.T) { "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", - "--nonce", strconv.Itoa(1)} + "--nonce", strconv.Itoa(1), + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -635,7 +659,8 @@ func TestBulkReshareHappyFlows13Ops(t *testing.T) { "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", "--newOperatorIDs", "11,22,33,44", - "--nonce", "10"} + "--nonce", "10", + "--amount", "32000000000"} RootCmd.SetArgs(generateReshareMsgArgs) err = RootCmd.Execute() require.NoError(t, err) @@ -666,6 +691,7 @@ func TestBulkReshareHappyFlows13Ops(t *testing.T) { "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", "--newOperatorIDs", "11,22,33,44", "--nonce", "10", + "--amount", "32000000000", "--signatures", signature} RootCmd.SetArgs(args) err = RootCmd.Execute() @@ -690,7 +716,8 @@ func TestBulkReshareHappyFlows13Ops(t *testing.T) { "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", - "--nonce", strconv.Itoa(10)} + "--nonce", strconv.Itoa(10), + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) diff --git a/integration_test/reshare_eip1271_sig_test.go b/integration_test/reshare_eip1271_sig_test.go index 7aba0289..04260e86 100644 --- a/integration_test/reshare_eip1271_sig_test.go +++ b/integration_test/reshare_eip1271_sig_test.go @@ -15,6 +15,7 @@ import ( "go.uber.org/zap" spec "github.com/ssvlabs/dkg-spec" + spec_crypto "github.com/ssvlabs/dkg-spec/crypto" "github.com/ssvlabs/dkg-spec/eip1271" "github.com/ssvlabs/dkg-spec/testing/stubs" "github.com/ssvlabs/ssv-dkg/pkgs/initiator" @@ -50,7 +51,7 @@ func TestReshareValidEOASig(t *testing.T) { ids := []uint64{11, 22, 33, 44} newIds := []uint64{55, 66, 77, 88} newId := spec.NewID() - rMsg, err := clnt.ConstructReshareMessage(ids, newIds, signedProofs[0][0].Proof.ValidatorPubKey, "holesky", withdraw[:], owner, 0, signedProofs[0]) + rMsg, err := clnt.ConstructReshareMessage(ids, newIds, signedProofs[0][0].Proof.ValidatorPubKey, "holesky", withdraw[:], owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE), signedProofs[0]) require.NoError(t, err) rMsgs := []*wire.ReshareMessage{rMsg} signature, err := SignReshare(rMsgs, sk.PrivateKey) @@ -89,7 +90,7 @@ func TestReshareInvalidEOASig(t *testing.T) { t.Run("test reshare 4 new operators", func(t *testing.T) { ids := []uint64{11, 22, 33, 44} newIds := []uint64{55, 66, 77, 88} - _, err := clnt.ConstructReshareMessage(ids, newIds, signedProofs[0][0].Proof.ValidatorPubKey, "holesky", withdraw[:], [20]byte{0}, 0, signedProofs[0]) + _, err := clnt.ConstructReshareMessage(ids, newIds, signedProofs[0][0].Proof.ValidatorPubKey, "holesky", withdraw[:], [20]byte{0}, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE), signedProofs[0]) require.Error(t, err, "invalid owner address") }) for _, srv := range servers { @@ -131,7 +132,7 @@ func TestReshareValidContractSig(t *testing.T) { ids := []uint64{11, 22, 33, 44} newIds := []uint64{55, 66, 77, 88} newId := spec.NewID() - rMsg, err := clnt.ConstructReshareMessage(ids, newIds, signedProofs[0][0].Proof.ValidatorPubKey, "holesky", withdraw[:], owner, 0, signedProofs[0]) + rMsg, err := clnt.ConstructReshareMessage(ids, newIds, signedProofs[0][0].Proof.ValidatorPubKey, "holesky", withdraw[:], owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE), signedProofs[0]) require.NoError(t, err) rMsgs := []*wire.ReshareMessage{rMsg} signature, err := SignReshare(rMsgs, sk.PrivateKey) @@ -183,7 +184,7 @@ func TestReshareInvalidContractSig(t *testing.T) { ids := []uint64{11, 22, 33, 44} newIds := []uint64{55, 66, 77, 88} newId := spec.NewID() - rMsg, err := clnt.ConstructReshareMessage(ids, newIds, signedProofs[0][0].Proof.ValidatorPubKey, "holesky", withdraw[:], owner, 0, signedProofs[0]) + rMsg, err := clnt.ConstructReshareMessage(ids, newIds, signedProofs[0][0].Proof.ValidatorPubKey, "holesky", withdraw[:], owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE), signedProofs[0]) require.NoError(t, err) rMsgs := []*wire.ReshareMessage{rMsg} signature, err := SignReshare(rMsgs, sk.PrivateKey) diff --git a/integration_test/reshare_threshold_old_ops_test.go b/integration_test/reshare_threshold_old_ops_test.go index ffa86d6f..256de850 100644 --- a/integration_test/reshare_threshold_old_ops_test.go +++ b/integration_test/reshare_threshold_old_ops_test.go @@ -19,6 +19,7 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/zap" + spec_crypto "github.com/ssvlabs/dkg-spec/crypto" "github.com/ssvlabs/dkg-spec/testing/stubs" ) @@ -102,7 +103,7 @@ func TestReshareThresholdOldValidators4Ops(t *testing.T) { logger := zap.L().Named("integration-tests") clnt, err := initiator.New(ops, logger, version, rootCert) require.NoError(t, err) - reshareMsg, err := clnt.ConstructReshareMessage([]uint64{11, 22, 33, 44}, []uint64{22, 33, 44, 55}, signedProof[0][0].Proof.ValidatorPubKey, "holesky", common.HexToAddress("0x81592c3de184a3e2c0dcb5a261bc107bfa91f494").Bytes(), common.HexToAddress("0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9"), 10, signedProof[0]) + reshareMsg, err := clnt.ConstructReshareMessage([]uint64{11, 22, 33, 44}, []uint64{22, 33, 44, 55}, signedProof[0][0].Proof.ValidatorPubKey, "holesky", common.HexToAddress("0x81592c3de184a3e2c0dcb5a261bc107bfa91f494").Bytes(), common.HexToAddress("0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9"), 10, uint64(spec_crypto.MIN_ACTIVATION_BALANCE), signedProof[0]) require.NoError(t, err) signature, err := SignReshare([]*wire.ReshareMessage{reshareMsg}, sk.PrivateKey) require.NoError(t, err) @@ -230,7 +231,7 @@ func TestReshareThresholdOldValidators7Ops(t *testing.T) { logger := zap.L().Named("integration-tests") clnt, err := initiator.New(ops, logger, version, rootCert) require.NoError(t, err) - reshareMsg, err := clnt.ConstructReshareMessage([]uint64{11, 22, 33, 44, 55, 66, 77}, []uint64{44, 55, 66, 77, 88, 99, 110}, signedProof[0][0].Proof.ValidatorPubKey, "holesky", common.HexToAddress("0x81592c3de184a3e2c0dcb5a261bc107bfa91f494").Bytes(), common.HexToAddress("0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9"), 10, signedProof[0]) + reshareMsg, err := clnt.ConstructReshareMessage([]uint64{11, 22, 33, 44, 55, 66, 77}, []uint64{44, 55, 66, 77, 88, 99, 110}, signedProof[0][0].Proof.ValidatorPubKey, "holesky", common.HexToAddress("0x81592c3de184a3e2c0dcb5a261bc107bfa91f494").Bytes(), common.HexToAddress("0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9"), 10, uint64(spec_crypto.MIN_ACTIVATION_BALANCE), signedProof[0]) require.NoError(t, err) signature, err := SignReshare([]*wire.ReshareMessage{reshareMsg}, sk.PrivateKey) require.NoError(t, err) @@ -359,7 +360,7 @@ func TestReshareThresholdOldValidators10Ops(t *testing.T) { logger := zap.L().Named("integration-tests") clnt, err := initiator.New(ops, logger, version, rootCert) require.NoError(t, err) - reshareMsg, err := clnt.ConstructReshareMessage([]uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 110}, []uint64{77, 88, 99, 110, 111, 112, 113}, signedProof[0][0].Proof.ValidatorPubKey, "holesky", common.HexToAddress("0x81592c3de184a3e2c0dcb5a261bc107bfa91f494").Bytes(), common.HexToAddress("0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9"), 10, signedProof[0]) + reshareMsg, err := clnt.ConstructReshareMessage([]uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 110}, []uint64{77, 88, 99, 110, 111, 112, 113}, signedProof[0][0].Proof.ValidatorPubKey, "holesky", common.HexToAddress("0x81592c3de184a3e2c0dcb5a261bc107bfa91f494").Bytes(), common.HexToAddress("0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9"), 10, uint64(spec_crypto.MIN_ACTIVATION_BALANCE), signedProof[0]) require.NoError(t, err) signature, err := SignReshare([]*wire.ReshareMessage{reshareMsg}, sk.PrivateKey) require.NoError(t, err) @@ -489,7 +490,7 @@ func TestReshareThresholdOldValidators13Ops(t *testing.T) { logger := zap.L().Named("integration-tests") clnt, err := initiator.New(ops, logger, version, rootCert) require.NoError(t, err) - reshareMsg, err := clnt.ConstructReshareMessage([]uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 111, 112, 113}, []uint64{77, 88, 99, 110, 111, 112, 113}, signedProof[0][0].Proof.ValidatorPubKey, "holesky", common.HexToAddress("0x81592c3de184a3e2c0dcb5a261bc107bfa91f494").Bytes(), common.HexToAddress("0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9"), 10, signedProof[0]) + reshareMsg, err := clnt.ConstructReshareMessage([]uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 111, 112, 113}, []uint64{77, 88, 99, 110, 111, 112, 113}, signedProof[0][0].Proof.ValidatorPubKey, "holesky", common.HexToAddress("0x81592c3de184a3e2c0dcb5a261bc107bfa91f494").Bytes(), common.HexToAddress("0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9"), 10, uint64(spec_crypto.MIN_ACTIVATION_BALANCE), signedProof[0]) require.NoError(t, err) signature, err := SignReshare([]*wire.ReshareMessage{reshareMsg}, sk.PrivateKey) require.NoError(t, err) diff --git a/integration_test/resign_bulk_test.go b/integration_test/resign_bulk_test.go index 0b36c4bd..27b7392a 100644 --- a/integration_test/resign_bulk_test.go +++ b/integration_test/resign_bulk_test.go @@ -59,7 +59,8 @@ func TestBulkResignHappyFlows4Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44", - "--nonce", "1"} + "--nonce", "1", + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -73,7 +74,8 @@ func TestBulkResignHappyFlows4Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44", - "--nonce", "1"} + "--nonce", "1", + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -86,7 +88,8 @@ func TestBulkResignHappyFlows4Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44", - "--nonce", "1"} + "--nonce", "1", + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -102,7 +105,8 @@ func TestBulkResignHappyFlows4Ops(t *testing.T) { "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", - "--nonce", strconv.Itoa(1)} + "--nonce", strconv.Itoa(1), + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -125,7 +129,8 @@ func TestBulkResignHappyFlows4Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44", - "--nonce", "10"} + "--nonce", "10", + "--amount", "32000000000"} RootCmd.SetArgs(generateResignMsgArgs) err = RootCmd.Execute() require.NoError(t, err) @@ -155,6 +160,7 @@ func TestBulkResignHappyFlows4Ops(t *testing.T) { "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44", "--nonce", "10", + "--amount", "32000000000", "--signatures", signature} RootCmd.SetArgs(args) err = RootCmd.Execute() @@ -179,7 +185,8 @@ func TestBulkResignHappyFlows4Ops(t *testing.T) { "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", - "--nonce", strconv.Itoa(10)} + "--nonce", strconv.Itoa(10), + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -228,7 +235,8 @@ func TestBulkResignHappyFlows7Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77", - "--nonce", "1"} + "--nonce", "1", + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -241,7 +249,8 @@ func TestBulkResignHappyFlows7Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77", - "--nonce", "1"} + "--nonce", "1", + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -254,7 +263,8 @@ func TestBulkResignHappyFlows7Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77", - "--nonce", "1"} + "--nonce", "1", + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -270,7 +280,8 @@ func TestBulkResignHappyFlows7Ops(t *testing.T) { "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", - "--nonce", strconv.Itoa(1)} + "--nonce", strconv.Itoa(1), + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -293,7 +304,8 @@ func TestBulkResignHappyFlows7Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77", - "--nonce", "10"} + "--nonce", "10", + "--amount", "32000000000"} RootCmd.SetArgs(generateResignMsgArgs) err = RootCmd.Execute() require.NoError(t, err) @@ -323,6 +335,7 @@ func TestBulkResignHappyFlows7Ops(t *testing.T) { "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77", "--nonce", "10", + "--amount", "32000000000", "--signatures", signature} RootCmd.SetArgs(args) err = RootCmd.Execute() @@ -347,7 +360,8 @@ func TestBulkResignHappyFlows7Ops(t *testing.T) { "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", - "--nonce", strconv.Itoa(10)} + "--nonce", strconv.Itoa(10), + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -396,7 +410,8 @@ func TestBulkResignHappyFlows10Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100", - "--nonce", "1"} + "--nonce", "1", + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -409,7 +424,8 @@ func TestBulkResignHappyFlows10Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100", - "--nonce", "1"} + "--nonce", "1", + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -422,7 +438,8 @@ func TestBulkResignHappyFlows10Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100", - "--nonce", "1"} + "--nonce", "1", + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -438,7 +455,8 @@ func TestBulkResignHappyFlows10Ops(t *testing.T) { "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", - "--nonce", strconv.Itoa(1)} + "--nonce", strconv.Itoa(1), + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -461,7 +479,8 @@ func TestBulkResignHappyFlows10Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100", - "--nonce", "10"} + "--nonce", "10", + "--amount", "32000000000"} RootCmd.SetArgs(generateResignMsgArgs) err = RootCmd.Execute() require.NoError(t, err) @@ -491,6 +510,7 @@ func TestBulkResignHappyFlows10Ops(t *testing.T) { "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100", "--nonce", "10", + "--amount", "32000000000", "--signatures", signature} RootCmd.SetArgs(args) err = RootCmd.Execute() @@ -515,7 +535,8 @@ func TestBulkResignHappyFlows10Ops(t *testing.T) { "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", - "--nonce", strconv.Itoa(10)} + "--nonce", strconv.Itoa(10), + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -558,21 +579,21 @@ func TestBulkResingHappyFlows13Ops(t *testing.T) { cli_initiator.StartResigning.Version = version cli_verify.Verify.Version = version t.Run("test 13 operators 1 validator bulk happy flow", func(t *testing.T) { - args := []string{"init", "--validators", "1", "--operatorsInfo", string(operators), "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", "--nonce", "1"} + args := []string{"init", "--validators", "1", "--operatorsInfo", string(operators), "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", "--nonce", "1", "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) resetFlags(RootCmd) }) t.Run("test 13 operators 10 validators bulk happy flow", func(t *testing.T) { - args := []string{"init", "--validators", "10", "--operatorsInfo", string(operators), "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", "--nonce", "1", "--clientCACertPath", "./certs/rootCA.crt"} + args := []string{"init", "--validators", "10", "--operatorsInfo", string(operators), "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", "--nonce", "1", "--amount", "32000000000", "--clientCACertPath", "./certs/rootCA.crt"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) resetFlags(RootCmd) }) t.Run("test 13 operators 100 validator bulk happy flow", func(t *testing.T) { - args := []string{"init", "--validators", "100", "--operatorsInfo", string(operators), "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", "--nonce", "1", "--clientCACertPath", "./certs/rootCA.crt"} + args := []string{"init", "--validators", "100", "--operatorsInfo", string(operators), "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", "--nonce", "1", "--amount", "32000000000", "--clientCACertPath", "./certs/rootCA.crt"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -583,7 +604,7 @@ func TestBulkResingHappyFlows13Ops(t *testing.T) { require.NoError(t, err) validators := []int{1, 10, 100} for i, c := range initCeremonies { - args := []string{"verify", "--ceremonyDir", "./output/" + c.Name(), "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--nonce", strconv.Itoa(1)} + args := []string{"verify", "--ceremonyDir", "./output/" + c.Name(), "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--nonce", strconv.Itoa(1), "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) @@ -606,7 +627,8 @@ func TestBulkResingHappyFlows13Ops(t *testing.T) { "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", - "--nonce", "10"} + "--nonce", "10", + "--amount", "32000000000"} RootCmd.SetArgs(generateResignMsgArgs) err = RootCmd.Execute() require.NoError(t, err) @@ -636,6 +658,7 @@ func TestBulkResingHappyFlows13Ops(t *testing.T) { "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--operatorIDs", "11,22,33,44,55,66,77,88,99,100,111,122,133", "--nonce", "10", + "--amount", "32000000000", "--signatures", signature} RootCmd.SetArgs(args) err = RootCmd.Execute() @@ -655,7 +678,13 @@ func TestBulkResingHappyFlows13Ops(t *testing.T) { resignCeremonies, err := os.ReadDir("./output") require.NoError(t, err) for i, c := range resignCeremonies { - args := []string{"verify", "--ceremonyDir", "./output/" + c.Name(), "--validators", strconv.Itoa(validators[i]), "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", "--nonce", strconv.Itoa(10)} + args := []string{"verify", + "--ceremonyDir", "./output/" + c.Name(), + "--validators", strconv.Itoa(validators[i]), + "--withdrawAddress", "0x81592c3de184a3e2c0dcb5a261bc107bfa91f494", + "--owner", "0xDCc846fA10C7CfCE9e6Eb37e06eD93b666cFC5E9", + "--nonce", strconv.Itoa(10), + "--amount", "32000000000"} RootCmd.SetArgs(args) err := RootCmd.Execute() require.NoError(t, err) diff --git a/integration_test/resign_eip1271_sig_test.go b/integration_test/resign_eip1271_sig_test.go index 401ebeec..90801336 100644 --- a/integration_test/resign_eip1271_sig_test.go +++ b/integration_test/resign_eip1271_sig_test.go @@ -15,6 +15,7 @@ import ( "go.uber.org/zap" spec "github.com/ssvlabs/dkg-spec" + spec_crypto "github.com/ssvlabs/dkg-spec/crypto" "github.com/ssvlabs/dkg-spec/eip1271" "github.com/ssvlabs/dkg-spec/testing/stubs" "github.com/ssvlabs/ssv-dkg/pkgs/initiator" @@ -56,6 +57,7 @@ func TestResignValidEOASig(t *testing.T) { withdraw.Bytes(), owner, 10, + uint64(spec_crypto.MIN_ACTIVATION_BALANCE), signedProofs[0]) require.NoError(t, err) rMsgs := []*wire.ResignMessage{rMsg} @@ -110,6 +112,7 @@ func TestResignInvalidEOASig(t *testing.T) { withdraw.Bytes(), [20]byte{}, uint64(nonce), + uint64(spec_crypto.MIN_ACTIVATION_BALANCE), signedProofs[0]) require.ErrorContains(t, err, "invalid owner address") }) @@ -158,6 +161,7 @@ func TestResignValidContractSig(t *testing.T) { withdraw.Bytes(), owner, 10, + uint64(spec_crypto.MIN_ACTIVATION_BALANCE), signedProofs[0]) require.NoError(t, err) rMsgs := []*wire.ResignMessage{rMsg} @@ -216,6 +220,7 @@ func TestResignInvalidContractSig(t *testing.T) { withdraw.Bytes(), owner, 10, + uint64(spec_crypto.MIN_ACTIVATION_BALANCE), signedProofs[0]) require.NoError(t, err) rMsgs := []*wire.ResignMessage{rMsg} diff --git a/integration_test/resign_integration_test.go b/integration_test/resign_integration_test.go index 2dea2f6d..f4e6fe29 100644 --- a/integration_test/resign_integration_test.go +++ b/integration_test/resign_integration_test.go @@ -14,6 +14,7 @@ import ( "go.uber.org/zap" spec "github.com/ssvlabs/dkg-spec" + spec_crypto "github.com/ssvlabs/dkg-spec/crypto" "github.com/ssvlabs/dkg-spec/testing/stubs" ) @@ -36,7 +37,7 @@ func TestInitResignHappyFlows(t *testing.T) { owner := eth_crypto.PubkeyToAddress(sk.PublicKey) t.Run("test 4 operators resign happy flow", func(t *testing.T) { id := spec.NewID() - depositData, ks, proofs, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44}, "holesky", owner, 0) + depositData, ks, proofs, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44}, "holesky", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.NoError(t, err) err = validator.ValidateResults([]*wire.DepositDataCLI{depositData}, ks, [][]*wire.SignedProof{proofs}, 1, owner, 0, withdraw) require.NoError(t, err) @@ -62,6 +63,7 @@ func TestInitResignHappyFlows(t *testing.T) { withdraw.Bytes(), owner, 10, + uint64(spec_crypto.MIN_ACTIVATION_BALANCE), signedProofs, ) require.NoError(t, err) @@ -78,7 +80,7 @@ func TestInitResignHappyFlows(t *testing.T) { }) t.Run("test 7 operators resign happy flow", func(t *testing.T) { id := spec.NewID() - depositData, ks, proofs, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77}, "holesky", owner, 0) + depositData, ks, proofs, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77}, "holesky", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.NoError(t, err) err = validator.ValidateResults([]*wire.DepositDataCLI{depositData}, ks, [][]*wire.SignedProof{proofs}, 1, owner, 0, withdraw) require.NoError(t, err) @@ -96,6 +98,7 @@ func TestInitResignHappyFlows(t *testing.T) { withdraw.Bytes(), owner, 10, + uint64(spec_crypto.MIN_ACTIVATION_BALANCE), signedProofs, ) require.NoError(t, err) @@ -112,7 +115,7 @@ func TestInitResignHappyFlows(t *testing.T) { }) t.Run("test 10 operators resign happy flow", func(t *testing.T) { id := spec.NewID() - depositData, ks, proofs, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 100}, "holesky", owner, 0) + depositData, ks, proofs, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 100}, "holesky", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.NoError(t, err) err = validator.ValidateResults([]*wire.DepositDataCLI{depositData}, ks, [][]*wire.SignedProof{proofs}, 1, owner, 0, withdraw) require.NoError(t, err) @@ -130,6 +133,7 @@ func TestInitResignHappyFlows(t *testing.T) { withdraw.Bytes(), owner, 10, + uint64(spec_crypto.MIN_ACTIVATION_BALANCE), signedProofs, ) require.NoError(t, err) @@ -146,7 +150,7 @@ func TestInitResignHappyFlows(t *testing.T) { }) t.Run("test 13 operators resign happy flow", func(t *testing.T) { id := spec.NewID() - depositData, ks, proofs, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 111, 122, 133}, "holesky", owner, 0) + depositData, ks, proofs, err := clnt.StartDKG(id, withdraw.Bytes(), []uint64{11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 111, 122, 133}, "holesky", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.NoError(t, err) err = validator.ValidateResults([]*wire.DepositDataCLI{depositData}, ks, [][]*wire.SignedProof{proofs}, 1, owner, 0, withdraw) require.NoError(t, err) @@ -163,6 +167,7 @@ func TestInitResignHappyFlows(t *testing.T) { withdraw.Bytes(), owner, 10, + uint64(spec_crypto.MIN_ACTIVATION_BALANCE), signedProofs, ) require.NoError(t, err) diff --git a/pkgs/crypto/deposit_data.go b/pkgs/crypto/deposit_data.go index b00cfaca..51f0127d 100644 --- a/pkgs/crypto/deposit_data.go +++ b/pkgs/crypto/deposit_data.go @@ -10,6 +10,7 @@ import ( "github.com/bloxapp/eth2-key-manager/core" "github.com/ethereum/go-ethereum/common" "github.com/hashicorp/go-version" + spec "github.com/ssvlabs/dkg-spec" "github.com/ssvlabs/ssv-dkg/pkgs/wire" spec_crypto "github.com/ssvlabs/dkg-spec/crypto" @@ -18,7 +19,7 @@ import ( func BuildDepositDataCLI(network core.Network, depositData *phase0.DepositData, depositCLIVersion string) (*wire.DepositDataCLI, error) { depositMsg := &phase0.DepositMessage{ WithdrawalCredentials: depositData.WithdrawalCredentials, - Amount: spec_crypto.MaxEffectiveBalanceInGwei, + Amount: depositData.Amount, } copy(depositMsg.PublicKey[:], depositData.PublicKey[:]) depositMsgRoot, err := depositMsg.HashTreeRoot() @@ -32,14 +33,14 @@ func BuildDepositDataCLI(network core.Network, depositData *phase0.DepositData, } // Final checks of prepared deposit data - if !(spec_crypto.MaxEffectiveBalanceInGwei == depositData.Amount) { + if !spec.ValidAmountSet(depositData.Amount) { return nil, fmt.Errorf("deposit data is invalid. Wrong amount %d", depositData.Amount) } forkBytes := network.GenesisForkVersion() depositDataJson := &wire.DepositDataCLI{ PubKey: hex.EncodeToString(depositData.PublicKey[:]), WithdrawalCredentials: hex.EncodeToString(depositData.WithdrawalCredentials), - Amount: uint64(spec_crypto.MaxEffectiveBalanceInGwei), + Amount: uint64(depositData.Amount), Signature: hex.EncodeToString(depositData.Signature[:]), DepositMessageRoot: hex.EncodeToString(depositMsgRoot[:]), DepositDataRoot: hex.EncodeToString(depositDataRoot[:]), @@ -134,7 +135,7 @@ func validateFieldFormatting(d *wire.DepositDataCLI) error { } // check the deposit-cli version if v.LessThan(vMin) { - return fmt.Errorf("resulting deposit data json has wrong amount") + return fmt.Errorf("resulting deposit data json has wrong version") } return nil } diff --git a/pkgs/dkg/drand.go b/pkgs/dkg/drand.go index 642e4853..4eee394b 100644 --- a/pkgs/dkg/drand.go +++ b/pkgs/dkg/drand.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" + "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/drand/kyber" kyber_bls12381 "github.com/drand/kyber-bls12381" "github.com/drand/kyber/pairing" @@ -16,14 +17,14 @@ import ( "github.com/drand/kyber/util/random" "github.com/herumi/bls-eth-go-binary/bls" "github.com/pkg/errors" + + spec "github.com/ssvlabs/dkg-spec" + spec_crypto "github.com/ssvlabs/dkg-spec/crypto" "github.com/ssvlabs/ssv-dkg/pkgs/board" "github.com/ssvlabs/ssv-dkg/pkgs/crypto" "github.com/ssvlabs/ssv-dkg/pkgs/utils" "github.com/ssvlabs/ssv-dkg/pkgs/wire" "go.uber.org/zap" - - spec "github.com/ssvlabs/dkg-spec" - spec_crypto "github.com/ssvlabs/dkg-spec/crypto" ) // DKGdata structure to store at LocalOwner information about initial message parameters and secret scalar to be used as input for DKG protocol @@ -197,6 +198,7 @@ func (o *LocalOwner) PostDKG(res *kyber_dkg.OptionResult) error { o.data.init.WithdrawalCredentials, o.data.init.Fork, o.data.init.Nonce, + phase0.Gwei(o.data.init.Amount), ) if err != nil { return fmt.Errorf("failed to encrypt BLS share: %w", err) @@ -238,6 +240,7 @@ func (o *LocalOwner) PostReshare(res *kyber_dkg.OptionResult) error { o.data.reshare.WithdrawalCredentials, o.data.reshare.Fork, o.data.reshare.Nonce, + phase0.Gwei(o.data.reshare.Amount), ) if err != nil { return err @@ -586,6 +589,7 @@ func (o *LocalOwner) Resign(reqID [24]byte, r *wire.ResignMessage) (*wire.Transp r.Resign.WithdrawalCredentials, r.Resign.Fork, r.Resign.Nonce, + phase0.Gwei(r.Resign.Amount), ) if err != nil { return nil, fmt.Errorf("failed to build results message: %w", err) diff --git a/pkgs/dkg/drand_test.go b/pkgs/dkg/drand_test.go index 357de9d6..805b7e92 100644 --- a/pkgs/dkg/drand_test.go +++ b/pkgs/dkg/drand_test.go @@ -7,6 +7,7 @@ import ( "sync" "testing" + "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/bloxapp/ssv/utils/rsaencryption" kyber_bls "github.com/drand/kyber-bls12381" "github.com/ethereum/go-ethereum/common" @@ -144,6 +145,7 @@ func TestDKGInit(t *testing.T) { Fork: [4]byte{0, 0, 0, 0}, Nonce: 0, Owner: common.HexToAddress("0x1234"), + Amount: uint64(spec_crypto.MIN_ACTIVATION_BALANCE), } uid := spec.NewID() exch := map[uint64]*wire2.Transport{} @@ -179,7 +181,7 @@ func TestDKGInit(t *testing.T) { for _, res := range ts.results { validatorPK, err := spec.RecoverValidatorPKFromResults(res) require.NoError(t, err) - _, _, _, err = spec.ValidateResults(opsarr, init.WithdrawalCredentials, validatorPK, init.Fork, init.Owner, init.Nonce, uid, res) + _, _, _, err = spec.ValidateResults(opsarr, init.WithdrawalCredentials, validatorPK, init.Fork, init.Owner, init.Nonce, phase0.Gwei(init.Amount), uid, res) require.NoError(t, err) } ts.mu.Unlock() diff --git a/pkgs/initiator/initiator.go b/pkgs/initiator/initiator.go index 996db107..114f8dda 100644 --- a/pkgs/initiator/initiator.go +++ b/pkgs/initiator/initiator.go @@ -351,7 +351,7 @@ func (c *Initiator) ReshareMessageFlowHandling(id [24]byte, signedReshare *wire. } // StartDKG starts DKG ceremony at initiator with requested parameters -func (c *Initiator) StartDKG(id [24]byte, withdraw []byte, ids []uint64, network eth2_key_manager_core.Network, owner common.Address, nonce uint64) (*wire.DepositDataCLI, *wire.KeySharesCLI, []*wire.SignedProof, error) { +func (c *Initiator) StartDKG(id [24]byte, withdraw []byte, ids []uint64, network eth2_key_manager_core.Network, owner common.Address, nonce, amount uint64) (*wire.DepositDataCLI, *wire.KeySharesCLI, []*wire.SignedProof, error) { if len(withdraw) != len(common.Address{}) { return nil, nil, nil, fmt.Errorf("incorrect withdrawal address length") } @@ -371,6 +371,7 @@ func (c *Initiator) StartDKG(id [24]byte, withdraw []byte, ids []uint64, network Fork: network.GenesisForkVersion(), Owner: owner, Nonce: nonce, + Amount: amount, } c.Logger.Info("Outgoing init request fields", zap.String("network", hex.EncodeToString(init.Fork[:])), @@ -383,7 +384,7 @@ func (c *Initiator) StartDKG(id [24]byte, withdraw []byte, ids []uint64, network if err != nil { return nil, nil, nil, err } - return c.CreateCeremonyResults(dkgResultsBytes, id, init.Operators, init.WithdrawalCredentials, nil, init.Fork, init.Owner, init.Nonce) + return c.CreateCeremonyResults(dkgResultsBytes, id, init.Operators, init.WithdrawalCredentials, nil, init.Fork, init.Owner, init.Nonce, phase0.Gwei(init.Amount)) } func (c *Initiator) StartResigning(id [24]byte, signedResign *wire.SignedResign) ([]*wire.DepositDataCLI, []*wire.KeySharesCLI, [][]*wire.SignedProof, error) { @@ -438,6 +439,7 @@ func (c *Initiator) CreateCeremonyResults( fork [4]byte, ownerAddress [20]byte, nonce uint64, + amount phase0.Gwei, ) (*wire.DepositDataCLI, *wire.KeySharesCLI, []*wire.SignedProof, error) { dkgResults, err := parseDKGResultsFromBytes(resultsBytes) if err != nil { @@ -453,13 +455,14 @@ func (c *Initiator) CreateCeremonyResults( fork, ownerAddress, nonce, + amount, id, dkgResults) if err != nil { return nil, nil, nil, err } } - depositDataJson, keyshares, err := c.processDKGResultResponse(dkgResults, id, ops, withdrawalCredentials, fork, ownerAddress, nonce) + depositDataJson, keyshares, err := c.processDKGResultResponse(dkgResults, id, ops, withdrawalCredentials, fork, ownerAddress, nonce, amount) if err != nil { return nil, nil, nil, err } @@ -543,7 +546,8 @@ func (c *Initiator) processDKGResultResponse(dkgResults []*spec.Result, withdrawalCredentials []byte, fork [4]byte, ownerAddress [20]byte, - nonce uint64) (*wire.DepositDataCLI, *wire.KeySharesCLI, error) { + nonce uint64, + amount phase0.Gwei) (*wire.DepositDataCLI, *wire.KeySharesCLI, error) { // check results sorted by operatorID sorted := sort.SliceIsSorted(dkgResults, func(p, q int) bool { return dkgResults[p].OperatorID < dkgResults[q].OperatorID @@ -555,7 +559,7 @@ func (c *Initiator) processDKGResultResponse(dkgResults []*spec.Result, if err != nil { return nil, nil, err } - _, depositData, masterSigOwnerNonce, err := spec.ValidateResults(ops, withdrawalCredentials, validatorPK, fork, ownerAddress, nonce, requestID, dkgResults) + _, depositData, masterSigOwnerNonce, err := spec.ValidateResults(ops, withdrawalCredentials, validatorPK, fork, ownerAddress, nonce, amount, requestID, dkgResults) if err != nil { return nil, nil, err } @@ -809,7 +813,7 @@ func (c *Initiator) processPongMessage(res wire.PongResult) error { return nil } -func (c *Initiator) ConstructReshareMessage(oldOperatorIDs, newOperatorIDs []uint64, validatorPub []byte, ethnetwork e2m_core.Network, withdrawCreds []byte, owner common.Address, nonce uint64, proofsData []*spec.SignedProof) (*wire.ReshareMessage, error) { +func (c *Initiator) ConstructReshareMessage(oldOperatorIDs, newOperatorIDs []uint64, validatorPub []byte, ethnetwork e2m_core.Network, withdrawCreds []byte, owner common.Address, nonce, amount uint64, proofsData []*spec.SignedProof) (*wire.ReshareMessage, error) { if len(proofsData) == 0 { return nil, fmt.Errorf("🤖 proofs are empty") } @@ -844,6 +848,7 @@ func (c *Initiator) ConstructReshareMessage(oldOperatorIDs, newOperatorIDs []uin WithdrawalCredentials: withdrawCreds, Owner: owner, Nonce: nonce, + Amount: amount, } return &wire.ReshareMessage{ Reshare: reshare, @@ -851,7 +856,7 @@ func (c *Initiator) ConstructReshareMessage(oldOperatorIDs, newOperatorIDs []uin }, nil } -func (c *Initiator) ConstructResignMessage(operatorIDs []uint64, validatorPub []byte, ethnetwork e2m_core.Network, withdrawCreds []byte, owner common.Address, nonce uint64, proofsData []*spec.SignedProof) (*wire.ResignMessage, error) { +func (c *Initiator) ConstructResignMessage(operatorIDs []uint64, validatorPub []byte, ethnetwork e2m_core.Network, withdrawCreds []byte, owner common.Address, nonce, amount uint64, proofsData []*spec.SignedProof) (*wire.ResignMessage, error) { if len(proofsData) == 0 { return nil, fmt.Errorf("🤖 unmarshaled proofs object is empty") } @@ -870,7 +875,8 @@ func (c *Initiator) ConstructResignMessage(operatorIDs []uint64, validatorPub [] Fork: ethnetwork.GenesisForkVersion(), WithdrawalCredentials: withdrawCreds, Owner: owner, - Nonce: nonce} + Nonce: nonce, + Amount: amount} return &wire.ResignMessage{ Operators: ops, Resign: &resign, @@ -930,14 +936,14 @@ func (c *Initiator) createBulkResults(resultsBytes [][][]byte, signedMsg interfa case *wire.SignedResign: msgIDMap := msgIDMap.(map[[24]byte]*spec.Resign) expectedValidatorPubKey = msgIDMap[reqID].ValidatorPubKey - depositData, keyShares, Proofs, err = c.CreateCeremonyResults(ceremonyResult, reqID, signedMsg.Messages[0].Operators, signedMsg.Messages[0].Resign.WithdrawalCredentials, expectedValidatorPubKey, signedMsg.Messages[0].Resign.Fork, signedMsg.Messages[0].Resign.Owner, msgIDMap[reqID].Nonce) + depositData, keyShares, Proofs, err = c.CreateCeremonyResults(ceremonyResult, reqID, signedMsg.Messages[0].Operators, signedMsg.Messages[0].Resign.WithdrawalCredentials, expectedValidatorPubKey, signedMsg.Messages[0].Resign.Fork, signedMsg.Messages[0].Resign.Owner, msgIDMap[reqID].Nonce, phase0.Gwei(msgIDMap[reqID].Amount)) if err != nil { return nil, nil, nil, err } case *wire.SignedReshare: msgIDMap := msgIDMap.(map[[24]byte]*spec.Reshare) expectedValidatorPubKey = msgIDMap[reqID].ValidatorPubKey - depositData, keyShares, Proofs, err = c.CreateCeremonyResults(ceremonyResult, reqID, signedMsg.Messages[0].Reshare.NewOperators, signedMsg.Messages[0].Reshare.WithdrawalCredentials, expectedValidatorPubKey, signedMsg.Messages[0].Reshare.Fork, signedMsg.Messages[0].Reshare.Owner, msgIDMap[reqID].Nonce) + depositData, keyShares, Proofs, err = c.CreateCeremonyResults(ceremonyResult, reqID, signedMsg.Messages[0].Reshare.NewOperators, signedMsg.Messages[0].Reshare.WithdrawalCredentials, expectedValidatorPubKey, signedMsg.Messages[0].Reshare.Fork, signedMsg.Messages[0].Reshare.Owner, msgIDMap[reqID].Nonce, phase0.Gwei(msgIDMap[reqID].Amount)) if err != nil { return nil, nil, nil, err } diff --git a/pkgs/initiator/initiator_test.go b/pkgs/initiator/initiator_test.go index f547738e..81001920 100644 --- a/pkgs/initiator/initiator_test.go +++ b/pkgs/initiator/initiator_test.go @@ -84,7 +84,7 @@ func TestStartDKG(t *testing.T) { intr, err := initiator.New(ops, logger, "test.version", rootCert) require.NoError(t, err) id := spec.NewID() - depositData, keyshares, proofs, err := intr.StartDKG(id, withdraw.Bytes(), []uint64{1, 2, 3, 4}, "mainnet", owner, 0) + depositData, keyshares, proofs, err := intr.StartDKG(id, withdraw.Bytes(), []uint64{1, 2, 3, 4}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.NoError(t, err) err = validator.ValidateResults([]*wire.DepositDataCLI{depositData}, keyshares, [][]*wire.SignedProof{proofs}, 1, owner, 0, withdraw) require.NoError(t, err) @@ -93,21 +93,21 @@ func TestStartDKG(t *testing.T) { intr, err := initiator.New(ops, logger, "test.version", rootCert) require.NoError(t, err) id := spec.NewID() - _, _, _, err = intr.StartDKG(id, withdraw.Bytes(), []uint64{1, 2, 3}, "mainnet", owner, 0) + _, _, _, err = intr.StartDKG(id, withdraw.Bytes(), []uint64{1, 2, 3}, "mainnet", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "amount of operators should be 4,7,10,13: got 3") }) t.Run("test wrong amount of opeators > 13", func(t *testing.T) { intr, err := initiator.New(ops, logger, "test.version", rootCert) require.NoError(t, err) id := spec.NewID() - _, _, _, err = intr.StartDKG(id, withdraw.Bytes(), []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, "prater", owner, 0) + _, _, _, err = intr.StartDKG(id, withdraw.Bytes(), []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, "prater", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "amount of operators should be 4,7,10,13: got 14") }) t.Run("test opeators not unique", func(t *testing.T) { intr, err := initiator.New(ops, logger, "test.version", rootCert) require.NoError(t, err) id := spec.NewID() - _, _, _, err = intr.StartDKG(id, withdraw.Bytes(), []uint64{1, 2, 3, 4, 5, 6, 7, 7, 9, 10, 11, 12, 12}, "holesky", owner, 0) + _, _, _, err = intr.StartDKG(id, withdraw.Bytes(), []uint64{1, 2, 3, 4, 5, 6, 7, 7, 9, 10, 11, 12, 12}, "holesky", owner, 0, uint64(spec_crypto.MIN_ACTIVATION_BALANCE)) require.ErrorContains(t, err, "operator is not in given operator data list") }) @@ -388,7 +388,7 @@ func TestDepositDataSigningAndVerification(t *testing.T) { &phase0.DepositMessage{ PublicKey: phase0.BLSPubKey(test.validatorPubKey), WithdrawalCredentials: crypto.BLSWithdrawalCredentials(test.withdrawalPubKey), - Amount: spec_crypto.MaxEffectiveBalanceInGwei, + Amount: spec_crypto.MIN_ACTIVATION_BALANCE, }, ) require.NoError(t, err) @@ -405,7 +405,7 @@ func TestDepositDataSigningAndVerification(t *testing.T) { require.Equal(t, sk.GetPublicKey().SerializeToHexStr(), depositDataCLI.PubKey, "0x") require.Equal(t, test.expectedWithdrawalCredentials, depositData.WithdrawalCredentials) - require.Equal(t, spec_crypto.MaxEffectiveBalanceInGwei, depositData.Amount) + require.Equal(t, spec_crypto.MIN_ACTIVATION_BALANCE, depositData.Amount) require.Equal(t, hex.EncodeToString(test.expectedRoot), depositDataCLI.DepositDataRoot) require.Equal(t, hex.EncodeToString(test.expectedSig), depositDataCLI.Signature, "0x") }) diff --git a/pkgs/operator/operator_test.go b/pkgs/operator/operator_test.go index a19b45a5..7bd5e6a6 100644 --- a/pkgs/operator/operator_test.go +++ b/pkgs/operator/operator_test.go @@ -89,6 +89,7 @@ func TestRateLimit(t *testing.T) { Fork: [4]byte{0, 0, 0, 0}, Owner: common.HexToAddress("0x0000000000000000000000000000000000000007"), Nonce: 0, + Amount: uint64(spec_crypto.MIN_ACTIVATION_BALANCE), } sszinit, err := init.MarshalSSZ() require.NoError(t, err) @@ -274,6 +275,7 @@ func TestWrongInitiatorSignature(t *testing.T) { Fork: [4]byte{0, 0, 0, 0}, Owner: owner, Nonce: 0, + Amount: uint64(spec_crypto.MIN_ACTIVATION_BALANCE), } id := spec.NewID() sszinit, err := init.MarshalSSZ()