diff --git a/cmd/prysmctl/BUILD.bazel b/cmd/prysmctl/BUILD.bazel index bf8ce366e..924917020 100644 --- a/cmd/prysmctl/BUILD.bazel +++ b/cmd/prysmctl/BUILD.bazel @@ -14,6 +14,7 @@ go_library( "//cmd/prysmctl/checkpointsync:go_default_library", "//cmd/prysmctl/deprecated:go_default_library", "//cmd/prysmctl/p2p:go_default_library", + "//cmd/prysmctl/signing:go_default_library", "//cmd/prysmctl/testnet:go_default_library", "//cmd/prysmctl/weaksubjectivity:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", diff --git a/cmd/prysmctl/main.go b/cmd/prysmctl/main.go index 04c722291..71052a73e 100644 --- a/cmd/prysmctl/main.go +++ b/cmd/prysmctl/main.go @@ -6,6 +6,7 @@ import ( "github.com/prysmaticlabs/prysm/v3/cmd/prysmctl/checkpointsync" "github.com/prysmaticlabs/prysm/v3/cmd/prysmctl/deprecated" "github.com/prysmaticlabs/prysm/v3/cmd/prysmctl/p2p" + "github.com/prysmaticlabs/prysm/v3/cmd/prysmctl/signing" "github.com/prysmaticlabs/prysm/v3/cmd/prysmctl/testnet" "github.com/prysmaticlabs/prysm/v3/cmd/prysmctl/weaksubjectivity" log "github.com/sirupsen/logrus" @@ -33,4 +34,5 @@ func init() { prysmctlCommands = append(prysmctlCommands, p2p.Commands...) prysmctlCommands = append(prysmctlCommands, testnet.Commands...) prysmctlCommands = append(prysmctlCommands, weaksubjectivity.Commands...) + prysmctlCommands = append(prysmctlCommands, signing.Commands...) } diff --git a/cmd/prysmctl/signing/BUILD.bazel b/cmd/prysmctl/signing/BUILD.bazel new file mode 100644 index 000000000..4eba6982c --- /dev/null +++ b/cmd/prysmctl/signing/BUILD.bazel @@ -0,0 +1,17 @@ +load("@prysm//tools/go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["cmd.go"], + importpath = "github.com/prysmaticlabs/prysm/v3/cmd/prysmctl/signing", + visibility = ["//visibility:public"], + deps = [ + "//cmd:go_default_library", + "//cmd/validator/accounts:go_default_library", + "//cmd/validator/flags:go_default_library", + "//config/features:go_default_library", + "//runtime/tos:go_default_library", + "@com_github_sirupsen_logrus//:go_default_library", + "@com_github_urfave_cli_v2//:go_default_library", + ], +) diff --git a/cmd/prysmctl/signing/cmd.go b/cmd/prysmctl/signing/cmd.go new file mode 100644 index 000000000..089abba27 --- /dev/null +++ b/cmd/prysmctl/signing/cmd.go @@ -0,0 +1,63 @@ +package signing + +import ( + "os" + + "github.com/prysmaticlabs/prysm/v3/cmd" + "github.com/prysmaticlabs/prysm/v3/cmd/validator/accounts" + "github.com/prysmaticlabs/prysm/v3/cmd/validator/flags" + "github.com/prysmaticlabs/prysm/v3/config/features" + "github.com/prysmaticlabs/prysm/v3/runtime/tos" + log "github.com/sirupsen/logrus" + "github.com/urfave/cli/v2" +) + +var Commands = []*cli.Command{ + { + Name: "sign", + Usage: "signs a message and broadcasts it to the network through the beacon node", + Subcommands: []*cli.Command{ + { + Name: "voluntary-exit", + Description: "Performs a voluntary exit on selected accounts", + Flags: cmd.WrapFlags([]cli.Flag{ + flags.WalletDirFlag, + flags.WalletPasswordFileFlag, + flags.AccountPasswordFileFlag, + flags.VoluntaryExitPublicKeysFlag, + flags.BeaconRPCProviderFlag, + flags.Web3SignerURLFlag, + flags.Web3SignerPublicValidatorKeysFlag, + flags.InteropNumValidators, + flags.InteropStartIndex, + cmd.GrpcMaxCallRecvMsgSizeFlag, + flags.CertFlag, + flags.GrpcHeadersFlag, + flags.GrpcRetriesFlag, + flags.GrpcRetryDelayFlag, + flags.ExitAllFlag, + features.Mainnet, + features.PraterTestnet, + features.RopstenTestnet, + features.SepoliaTestnet, + cmd.AcceptTosFlag, + }), + Before: func(cliCtx *cli.Context) error { + if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil { + return err + } + if err := tos.VerifyTosAcceptedOrPrompt(cliCtx); err != nil { + return err + } + return features.ConfigureValidator(cliCtx) + }, + Action: func(cliCtx *cli.Context) error { + if err := accounts.AccountsExit(cliCtx, os.Stdin); err != nil { + log.WithError(err).Fatal("Could not perform voluntary exit") + } + return nil + }, + }, + }, + }, +} diff --git a/cmd/validator/accounts/BUILD.bazel b/cmd/validator/accounts/BUILD.bazel index 4c6fa1539..1309cf8b5 100644 --- a/cmd/validator/accounts/BUILD.bazel +++ b/cmd/validator/accounts/BUILD.bazel @@ -14,10 +14,12 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/v3/cmd/validator/accounts", visibility = ["//visibility:public"], deps = [ + "//api/grpc:go_default_library", "//cmd:go_default_library", "//cmd/validator/flags:go_default_library", "//config/features:go_default_library", "//io/prompt:go_default_library", + "//proto/prysm/v1alpha1:go_default_library", "//runtime/tos:go_default_library", "//validator/accounts:go_default_library", "//validator/accounts/iface:go_default_library", @@ -25,9 +27,14 @@ go_library( "//validator/accounts/wallet:go_default_library", "//validator/client:go_default_library", "//validator/keymanager:go_default_library", + "//validator/keymanager/local:go_default_library", + "//validator/keymanager/remote-web3signer:go_default_library", + "//validator/node:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@com_github_urfave_cli_v2//:go_default_library", + "@io_bazel_rules_go//proto/wkt:empty_go_proto", + "@org_golang_google_grpc//:go_default_library", ], ) @@ -38,6 +45,7 @@ go_test( "delete_test.go", "exit_test.go", "import_test.go", + "wallet_utils_test.go", ], embed = [":go_default_library"], deps = [ @@ -57,7 +65,9 @@ go_test( "//validator/keymanager:go_default_library", "//validator/keymanager/derived:go_default_library", "//validator/keymanager/local:go_default_library", + "//validator/node:go_default_library", "//validator/testing:go_default_library", + "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", "@com_github_golang_mock//gomock:go_default_library", "@com_github_google_uuid//:go_default_library", "@com_github_urfave_cli_v2//:go_default_library", diff --git a/cmd/validator/accounts/accounts.go b/cmd/validator/accounts/accounts.go index ac48fbef9..d6add8f79 100644 --- a/cmd/validator/accounts/accounts.go +++ b/cmd/validator/accounts/accounts.go @@ -1,8 +1,6 @@ package accounts import ( - "os" - "github.com/prysmaticlabs/prysm/v3/cmd" "github.com/prysmaticlabs/prysm/v3/cmd/validator/flags" "github.com/prysmaticlabs/prysm/v3/config/features" @@ -150,42 +148,5 @@ var Commands = &cli.Command{ return nil }, }, - { - Name: "voluntary-exit", - Description: "Performs a voluntary exit on selected accounts", - Flags: cmd.WrapFlags([]cli.Flag{ - flags.WalletDirFlag, - flags.WalletPasswordFileFlag, - flags.AccountPasswordFileFlag, - flags.VoluntaryExitPublicKeysFlag, - flags.BeaconRPCProviderFlag, - cmd.GrpcMaxCallRecvMsgSizeFlag, - flags.CertFlag, - flags.GrpcHeadersFlag, - flags.GrpcRetriesFlag, - flags.GrpcRetryDelayFlag, - flags.ExitAllFlag, - features.Mainnet, - features.PraterTestnet, - features.RopstenTestnet, - features.SepoliaTestnet, - cmd.AcceptTosFlag, - }), - Before: func(cliCtx *cli.Context) error { - if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil { - return err - } - if err := tos.VerifyTosAcceptedOrPrompt(cliCtx); err != nil { - return err - } - return features.ConfigureValidator(cliCtx) - }, - Action: func(cliCtx *cli.Context) error { - if err := accountsExit(cliCtx, os.Stdin); err != nil { - log.WithError(err).Fatal("Could not perform voluntary exit") - } - return nil - }, - }, }, } diff --git a/cmd/validator/accounts/exit.go b/cmd/validator/accounts/exit.go index 315b56cb9..84d8d69d2 100644 --- a/cmd/validator/accounts/exit.go +++ b/cmd/validator/accounts/exit.go @@ -4,19 +4,26 @@ import ( "io" "strings" + "github.com/golang/protobuf/ptypes/empty" "github.com/pkg/errors" + grpcutil "github.com/prysmaticlabs/prysm/v3/api/grpc" "github.com/prysmaticlabs/prysm/v3/cmd" "github.com/prysmaticlabs/prysm/v3/cmd/validator/flags" + ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v3/validator/accounts" + "github.com/prysmaticlabs/prysm/v3/validator/accounts/wallet" "github.com/prysmaticlabs/prysm/v3/validator/client" + "github.com/prysmaticlabs/prysm/v3/validator/keymanager" + "github.com/prysmaticlabs/prysm/v3/validator/keymanager/local" + "github.com/prysmaticlabs/prysm/v3/validator/node" "github.com/urfave/cli/v2" + "google.golang.org/grpc" ) -func accountsExit(c *cli.Context, r io.Reader) error { - w, km, err := walletWithKeymanager(c) - if err != nil { - return err - } +func AccountsExit(c *cli.Context, r io.Reader) error { + var w *wallet.Wallet + var km keymanager.IKeymanager + var err error dialOpts := client.ConstructDialOptions( c.Int(cmd.GrpcMaxCallRecvMsgSizeFlag.Name), c.String(flags.CertFlag.Name), @@ -24,15 +31,58 @@ func accountsExit(c *cli.Context, r io.Reader) error { c.Duration(flags.GrpcRetryDelayFlag.Name), ) grpcHeaders := strings.Split(c.String(flags.GrpcHeadersFlag.Name), ",") + beaconRPCProvider := c.String(flags.BeaconRPCProviderFlag.Name) + if !c.IsSet(flags.Web3SignerURLFlag.Name) && !c.IsSet(flags.WalletDirFlag.Name) && !c.IsSet(flags.InteropNumValidators.Name) { + return errors.Errorf("No validators found, please provide a prysm wallet directory via flag --%s "+ + "or a web3signer location with corresponding public keys via flags --%s and --%s ", + flags.WalletDirFlag.Name, + flags.Web3SignerURLFlag.Name, + flags.Web3SignerPublicValidatorKeysFlag, + ) + } + if c.IsSet(flags.InteropNumValidators.Name) { + km, err = local.NewInteropKeymanager(c.Context, c.Uint64(flags.InteropStartIndex.Name), c.Uint64(flags.InteropNumValidators.Name)) + if err != nil { + return errors.Wrap(err, "could not generate interop keys for key manager") + } + w = &wallet.Wallet{} + } else if c.IsSet(flags.Web3SignerURLFlag.Name) { + ctx := grpcutil.AppendHeaders(c.Context, grpcHeaders) + conn, err := grpc.DialContext(ctx, beaconRPCProvider, dialOpts...) + if err != nil { + return errors.Wrapf(err, "could not dial endpoint %s", beaconRPCProvider) + } + nodeClient := ethpb.NewNodeClient(conn) + resp, err := nodeClient.GetGenesis(c.Context, &empty.Empty{}) + if err != nil { + return errors.Wrapf(err, "failed to get genesis info") + } + if err := conn.Close(); err != nil { + log.WithError(err).Error("Failed to close connection") + } + config, err := node.Web3SignerConfig(c) + if err != nil { + return errors.Wrapf(err, "could not configure web3signer") + } + config.GenesisValidatorsRoot = resp.GenesisValidatorsRoot + w, km, err = walletWithWeb3SignerKeymanager(c, config) + if err != nil { + return err + } + } else { + w, km, err = walletWithKeymanager(c) + if err != nil { + return err + } + } opts := []accounts.Option{ accounts.WithWallet(w), accounts.WithKeymanager(km), accounts.WithGRPCDialOpts(dialOpts), - accounts.WithBeaconRPCProvider(c.String(flags.BeaconRPCProviderFlag.Name)), + accounts.WithBeaconRPCProvider(beaconRPCProvider), accounts.WithGRPCHeaders(grpcHeaders), } - // Get full set of public keys from the keymanager. validatingPublicKeys, err := km.FetchValidatingPublicKeys(c.Context) if err != nil { @@ -48,7 +98,6 @@ func accountsExit(c *cli.Context, r io.Reader) error { } opts = append(opts, accounts.WithRawPubKeys(rawPubKey)) opts = append(opts, accounts.WithFormattedPubKeys(formattedPubKeys)) - acc, err := accounts.NewCLIManager(opts...) if err != nil { return err diff --git a/cmd/validator/accounts/wallet_utils.go b/cmd/validator/accounts/wallet_utils.go index fd4308952..66a807f53 100644 --- a/cmd/validator/accounts/wallet_utils.go +++ b/cmd/validator/accounts/wallet_utils.go @@ -8,6 +8,7 @@ import ( "github.com/prysmaticlabs/prysm/v3/validator/accounts/iface" "github.com/prysmaticlabs/prysm/v3/validator/accounts/wallet" "github.com/prysmaticlabs/prysm/v3/validator/keymanager" + remote_web3signer "github.com/prysmaticlabs/prysm/v3/validator/keymanager/remote-web3signer" "github.com/urfave/cli/v2" ) @@ -18,8 +19,6 @@ func walletWithKeymanager(c *cli.Context) (*wallet.Wallet, keymanager.IKeymanage if err != nil { return nil, nil, errors.Wrap(err, "could not open wallet") } - // TODO(#9883) - Remove this when we have a better way to handle this. this is fine. - // genesis root is not set here which is used for sign function, but fetch keys should be fine. km, err := w.InitializeKeymanager(c.Context, iface.InitKeymanagerConfig{ListenForChanges: false}) if err != nil && strings.Contains(err.Error(), keymanager.IncorrectPasswordErrMsg) { return nil, nil, errors.New("wrong wallet password entered") @@ -28,4 +27,14 @@ func walletWithKeymanager(c *cli.Context) (*wallet.Wallet, keymanager.IKeymanage return nil, nil, errors.Wrap(err, accounts.ErrCouldNotInitializeKeymanager) } return w, km, nil + +} + +func walletWithWeb3SignerKeymanager(c *cli.Context, config *remote_web3signer.SetupConfig) (*wallet.Wallet, keymanager.IKeymanager, error) { + w := wallet.NewWalletForWeb3Signer() + km, err := w.InitializeKeymanager(c.Context, iface.InitKeymanagerConfig{ListenForChanges: false, Web3SignerConfig: config}) + if err != nil { + return nil, nil, err + } + return w, km, nil } diff --git a/cmd/validator/accounts/wallet_utils_test.go b/cmd/validator/accounts/wallet_utils_test.go new file mode 100644 index 000000000..2e2fae5ad --- /dev/null +++ b/cmd/validator/accounts/wallet_utils_test.go @@ -0,0 +1,94 @@ +package accounts + +import ( + "flag" + "os" + "path/filepath" + "testing" + "time" + + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/prysmaticlabs/prysm/v3/cmd/validator/flags" + "github.com/prysmaticlabs/prysm/v3/testing/require" + "github.com/prysmaticlabs/prysm/v3/validator/accounts" + "github.com/prysmaticlabs/prysm/v3/validator/keymanager" + "github.com/prysmaticlabs/prysm/v3/validator/keymanager/local" + "github.com/prysmaticlabs/prysm/v3/validator/node" + "github.com/urfave/cli/v2" +) + +func TestWalletWithKeymanager(t *testing.T) { + walletDir, passwordsDir, passwordFilePath := setupWalletAndPasswordsDir(t) + keysDir := filepath.Join(t.TempDir(), "keysDir") + require.NoError(t, os.MkdirAll(keysDir, os.ModePerm)) + + cliCtx := setupWalletCtx(t, &testWalletConfig{ + walletDir: walletDir, + passwordsDir: passwordsDir, + keysDir: keysDir, + keymanagerKind: keymanager.Local, + walletPasswordFile: passwordFilePath, + accountPasswordFile: passwordFilePath, + }) + + opts := []accounts.Option{ + accounts.WithWalletDir(walletDir), + accounts.WithKeymanagerType(keymanager.Local), + accounts.WithWalletPassword(password), + } + acc, err := accounts.NewCLIManager(opts...) + require.NoError(t, err) + w, err := acc.WalletCreate(cliCtx.Context) + require.NoError(t, err) + newKm, err := local.NewKeymanager( + cliCtx.Context, + &local.SetupConfig{ + Wallet: w, + ListenForChanges: false, + }, + ) + require.NoError(t, err) + + // Make sure there are no accounts at the start. + accNames, err := newKm.ValidatingAccountNames() + require.NoError(t, err) + require.Equal(t, len(accNames), 0) + + // Create 2 keys. + createKeystore(t, keysDir) + time.Sleep(time.Second) + createKeystore(t, keysDir) + require.NoError(t, accountsImport(cliCtx)) + + w, k, err := walletWithKeymanager(cliCtx) + require.NoError(t, err) + keys, err := k.FetchValidatingPublicKeys(cliCtx.Context) + require.NoError(t, err) + require.Equal(t, len(keys), 2) + require.Equal(t, w.KeymanagerKind(), keymanager.Local) +} + +func TestWalletWithKeymanager_web3signer(t *testing.T) { + app := cli.App{} + set := flag.NewFlagSet("test", 0) + set.String(flags.Web3SignerURLFlag.Name, "http://localhost:12345", "web3signer") + c := &cli.StringSliceFlag{ + Name: "validators-external-signer-public-keys", + } + err := c.Apply(set) + require.NoError(t, err) + require.NoError(t, set.Set(flags.Web3SignerURLFlag.Name, "http://localhost:12345")) + require.NoError(t, set.Set(flags.Web3SignerPublicValidatorKeysFlag.Name, "0xa2b5aaad9c6efefe7bb9b1243a043404f3362937cfb6b31833929833173f476630ea2cfeb0d9ddf15f97ca8685948820")) + ctx := cli.NewContext(&app, set, nil) + bytes, err := hexutil.Decode("0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2") + require.NoError(t, err) + config, err := node.Web3SignerConfig(ctx) + require.NoError(t, err) + config.GenesisValidatorsRoot = bytes + w, k, err := walletWithWeb3SignerKeymanager(ctx, config) + require.NoError(t, err) + keys, err := k.FetchValidatingPublicKeys(ctx.Context) + require.NoError(t, err) + require.Equal(t, len(keys), 1) + require.Equal(t, w.KeymanagerKind(), keymanager.Web3Signer) +} diff --git a/cmd/validator/flags/BUILD.bazel b/cmd/validator/flags/BUILD.bazel index b7778cecd..40d407670 100644 --- a/cmd/validator/flags/BUILD.bazel +++ b/cmd/validator/flags/BUILD.bazel @@ -8,6 +8,7 @@ go_library( ], importpath = "github.com/prysmaticlabs/prysm/v3/cmd/validator/flags", visibility = [ + "//cmd/prysmctl:__subpackages__", "//cmd/validator:__subpackages__", "//testing/endtoend:__subpackages__", "//validator:__subpackages__", diff --git a/config/params/values.go b/config/params/values.go index 04939a769..8aa9bf8c2 100644 --- a/config/params/values.go +++ b/config/params/values.go @@ -9,6 +9,7 @@ const ( MainnetTestName = "mainnet-test" MinimalName = "minimal" PraterName = "prater" + GoerliName = "goerli" RopstenName = "ropsten" SepoliaName = "sepolia" ) diff --git a/runtime/interop/generate_keys_test.go b/runtime/interop/generate_keys_test.go index 8850fb281..99acbb933 100644 --- a/runtime/interop/generate_keys_test.go +++ b/runtime/interop/generate_keys_test.go @@ -1,6 +1,7 @@ package interop_test import ( + "fmt" "os" "testing" @@ -27,7 +28,7 @@ func TestKeyGenerator(t *testing.T) { require.NoError(t, err) testCases := &KeyTest{} require.NoError(t, yaml.Unmarshal(file, testCases)) - priv, _, err := interop.DeterministicallyGenerateKeys(0, 1000) + priv, pubkeys, err := interop.DeterministicallyGenerateKeys(0, 1000) require.NoError(t, err) // cross-check with the first 1000 keys generated from the python spec for i, key := range priv { @@ -38,5 +39,6 @@ func TestKeyGenerator(t *testing.T) { continue } assert.DeepEqual(t, key.Marshal(), nKey) + fmt.Println(fmt.Sprintf("pubkey: %s privkey: %s ", hexutil.Encode(pubkeys[i].Marshal()), hexutil.Encode(key.Marshal()))) } } diff --git a/validator/accounts/accounts_exit.go b/validator/accounts/accounts_exit.go index 781e4631e..d3f0243bf 100644 --- a/validator/accounts/accounts_exit.go +++ b/validator/accounts/accounts_exit.go @@ -52,7 +52,7 @@ func (acm *AccountsCLIManager) Exit(ctx context.Context) error { return errors.New("could not get sync status") } - if (*syncStatus).Syncing { + if syncStatus.Syncing { return errors.New("could not perform exit: beacon node is syncing.") } @@ -126,8 +126,8 @@ func displayExitInfo(rawExitedKeys [][]byte, trimmedExitedKeys []string) { urlFormattedPubKeys := make([]string, len(rawExitedKeys)) for i, key := range rawExitedKeys { var baseUrl string - if params.BeaconConfig().ConfigName == params.PraterName { - baseUrl = "https://prater.beaconcha.in/validator/" + if params.BeaconConfig().ConfigName == params.PraterName || params.BeaconConfig().ConfigName == params.GoerliName { + baseUrl = "https://goerli.beaconcha.in/validator/" } else { baseUrl = "https://beaconcha.in/validator/" } diff --git a/validator/client/propose.go b/validator/client/propose.go index b789ba3bc..96d516a36 100644 --- a/validator/client/propose.go +++ b/validator/client/propose.go @@ -21,6 +21,7 @@ import ( validatorpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1/validator-client" "github.com/prysmaticlabs/prysm/v3/runtime/version" prysmTime "github.com/prysmaticlabs/prysm/v3/time" + "github.com/prysmaticlabs/prysm/v3/time/slots" "github.com/prysmaticlabs/prysm/v3/validator/client/iface" "github.com/sirupsen/logrus" "go.opencensus.io/trace" @@ -206,9 +207,9 @@ func ProposeExit( } totalSecondsPassed := prysmTime.Now().Unix() - genesisResponse.GenesisTime.Seconds currentEpoch := types.Epoch(uint64(totalSecondsPassed) / uint64(params.BeaconConfig().SlotsPerEpoch.Mul(params.BeaconConfig().SecondsPerSlot))) - + currentSlot := slots.CurrentSlot(uint64(genesisResponse.GenesisTime.AsTime().Unix())) exit := ðpb.VoluntaryExit{Epoch: currentEpoch, ValidatorIndex: indexResponse.Index} - sig, err := signVoluntaryExit(ctx, validatorClient, signer, pubKey, exit) + sig, err := signVoluntaryExit(ctx, validatorClient, signer, pubKey, exit, currentSlot) if err != nil { return errors.Wrap(err, "failed to sign voluntary exit") } @@ -294,6 +295,7 @@ func signVoluntaryExit( signer iface.SigningFunc, pubKey []byte, exit *ethpb.VoluntaryExit, + slot types.Slot, ) ([]byte, error) { req := ðpb.DomainRequest{ Epoch: exit.Epoch, @@ -318,6 +320,7 @@ func signVoluntaryExit( SigningRoot: exitRoot[:], SignatureDomain: domain.SignatureDomain, Object: &validatorpb.SignRequest_Exit{Exit: exit}, + SigningSlot: slot, }) if err != nil { return nil, errors.Wrap(err, signExitErr) diff --git a/validator/node/node.go b/validator/node/node.go index 9b8e50d77..a3d1c0fc2 100644 --- a/validator/node/node.go +++ b/validator/node/node.go @@ -8,6 +8,7 @@ import ( "encoding/json" "fmt" "io" + "net" "net/http" "net/url" "os" @@ -400,7 +401,7 @@ func (c *ValidatorClient) registerValidatorService(cliCtx *cli.Context) error { } } - wsc, err := web3SignerConfig(c.cliCtx) + wsc, err := Web3SignerConfig(c.cliCtx) if err != nil { return err } @@ -437,7 +438,7 @@ func (c *ValidatorClient) registerValidatorService(cliCtx *cli.Context) error { return c.services.RegisterService(v) } -func web3SignerConfig(cliCtx *cli.Context) (*remoteweb3signer.SetupConfig, error) { +func Web3SignerConfig(cliCtx *cli.Context) (*remoteweb3signer.SetupConfig, error) { var web3signerConfig *remoteweb3signer.SetupConfig if cliCtx.IsSet(flags.Web3SignerURLFlag.Name) { urlStr := cliCtx.String(flags.Web3SignerURLFlag.Name) @@ -525,7 +526,7 @@ func proposerSettings(cliCtx *cli.Context) (*validatorServiceConfig.ProposerSett if fileConfig == nil { return nil, nil } - //convert file config to proposer config for internal use + // convert file config to proposer config for internal use vpSettings := &validatorServiceConfig.ProposerSettings{} // default fileConfig is mandatory @@ -632,7 +633,7 @@ func reviewGasLimit(gasLimit validatorServiceConfig.Uint64) validatorServiceConf if gasLimit == 0 { return validatorServiceConfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit) } - //TODO(10810): add in warning for ranges + // TODO(10810): add in warning for ranges return gasLimit } @@ -691,8 +692,8 @@ func (c *ValidatorClient) registerRPCGatewayService(cliCtx *cli.Context) error { gatewayPort := cliCtx.Int(flags.GRPCGatewayPort.Name) rpcHost := cliCtx.String(flags.RPCHost.Name) rpcPort := cliCtx.Int(flags.RPCPort.Name) - rpcAddr := fmt.Sprintf("%s:%d", rpcHost, rpcPort) - gatewayAddress := fmt.Sprintf("%s:%d", gatewayHost, gatewayPort) + rpcAddr := net.JoinHostPort(rpcHost, fmt.Sprintf("%d", rpcPort)) + gatewayAddress := net.JoinHostPort(gatewayHost, fmt.Sprintf("%d", gatewayPort)) timeout := cliCtx.Int(cmd.ApiTimeoutFlag.Name) var allowedOrigins []string if cliCtx.IsSet(flags.GPRCGatewayCorsDomain.Name) { diff --git a/validator/node/node_test.go b/validator/node/node_test.go index 79e383eb7..818b5c51f 100644 --- a/validator/node/node_test.go +++ b/validator/node/node_test.go @@ -195,7 +195,7 @@ func TestWeb3SignerConfig(t *testing.T) { require.NoError(t, set.Set(flags.Web3SignerPublicValidatorKeysFlag.Name, key)) } cliCtx := cli.NewContext(&app, set, nil) - got, err := web3SignerConfig(cliCtx) + got, err := Web3SignerConfig(cliCtx) if tt.wantErrMsg != "" { require.ErrorContains(t, tt.wantErrMsg, err) return @@ -617,7 +617,7 @@ func TestProposerSettings(t *testing.T) { srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(200) w.Header().Set("Content-Type", "application/json") - _, err := fmt.Fprintf(w, string(content)) + _, err := fmt.Fprintf(w, "%s", content) require.NoError(t, err) })) defer srv.Close()