mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
Prysm Web V1 Release (#7921)
* even more cors * auth fixes for web v1 * ensure web works * include web ui v1 release * new site data * fmt * test * tests pass * gaz * build fix * no ssz * unused type Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
This commit is contained in:
parent
f871e1f3ef
commit
0c5c246ee7
@ -352,9 +352,9 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
sha256 = "6bb16ff0dc9348090cc31a9ea453643d32b617e66ac6e7bb38985d530070631b",
|
||||
sha256 = "09a8377bd3abf76d3bd14570f001cc7f00ef0e11fe314cee626d3a3ccbae506e",
|
||||
urls = [
|
||||
"https://github.com/prysmaticlabs/prysm-web-ui/releases/download/0.0.2-alpha/prysm-web-ui.tar.gz",
|
||||
"https://github.com/prysmaticlabs/prysm-web-ui/releases/download/v1.0.0-beta.0/prysm-web-ui.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -12,7 +12,6 @@ import (
|
||||
"github.com/prysmaticlabs/go-ssz"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
webpb "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2"
|
||||
"github.com/prysmaticlabs/prysm/shared/params/spectest"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
@ -105,10 +104,11 @@ func UnmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (i
|
||||
obj = ðpb.Checkpoint{}
|
||||
case "Deposit":
|
||||
obj = ðpb.Deposit{}
|
||||
case "DepositMessage":
|
||||
t.Skip("Unused type")
|
||||
return nil, nil
|
||||
case "DepositData":
|
||||
obj = ðpb.Deposit_Data{}
|
||||
case "DepositMessage":
|
||||
obj = &webpb.DepositMessage{}
|
||||
case "Eth1Data":
|
||||
obj = ðpb.Eth1Data{}
|
||||
case "Eth1Block":
|
||||
|
@ -1,7 +1,6 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
|
||||
load("@com_github_prysmaticlabs_ethereumapis//tools:ssz.bzl", "SSZ_DEPS", "ssz_gen_marshal")
|
||||
|
||||
# gazelle:ignore
|
||||
proto_library(
|
||||
@ -19,14 +18,6 @@ proto_library(
|
||||
],
|
||||
)
|
||||
|
||||
ssz_gen_marshal(
|
||||
name = "ssz_generated_files",
|
||||
go_proto = ":ethereum_validator_account_go_proto",
|
||||
objs = [
|
||||
"DepositMessage",
|
||||
],
|
||||
)
|
||||
|
||||
go_proto_library(
|
||||
name = "ethereum_validator_account_gateway_proto",
|
||||
compilers = [
|
||||
@ -61,9 +52,7 @@ go_proto_library(
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [":ssz_generated_files"],
|
||||
embed = [":ethereum_validator_account_go_proto"],
|
||||
importpath = "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = SSZ_DEPS,
|
||||
)
|
||||
|
@ -1,97 +0,0 @@
|
||||
// Code generated by fastssz. DO NOT EDIT.
|
||||
package ethereum_validator_accounts_v2
|
||||
|
||||
import (
|
||||
ssz "github.com/ferranbt/fastssz"
|
||||
)
|
||||
|
||||
// MarshalSSZ ssz marshals the DepositMessage object
|
||||
func (d *DepositMessage) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(d)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the DepositMessage object to a target array
|
||||
func (d *DepositMessage) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
|
||||
// Field (0) 'Pubkey'
|
||||
if len(d.Pubkey) != 48 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, d.Pubkey...)
|
||||
|
||||
// Field (1) 'WithdrawalCredentials'
|
||||
if len(d.WithdrawalCredentials) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
dst = append(dst, d.WithdrawalCredentials...)
|
||||
|
||||
// Field (2) 'Amount'
|
||||
dst = ssz.MarshalUint64(dst, d.Amount)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the DepositMessage object
|
||||
func (d *DepositMessage) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size != 88 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
// Field (0) 'Pubkey'
|
||||
if cap(d.Pubkey) == 0 {
|
||||
d.Pubkey = make([]byte, 0, len(buf[0:48]))
|
||||
}
|
||||
d.Pubkey = append(d.Pubkey, buf[0:48]...)
|
||||
|
||||
// Field (1) 'WithdrawalCredentials'
|
||||
if cap(d.WithdrawalCredentials) == 0 {
|
||||
d.WithdrawalCredentials = make([]byte, 0, len(buf[48:80]))
|
||||
}
|
||||
d.WithdrawalCredentials = append(d.WithdrawalCredentials, buf[48:80]...)
|
||||
|
||||
// Field (2) 'Amount'
|
||||
d.Amount = ssz.UnmarshallUint64(buf[80:88])
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the DepositMessage object
|
||||
func (d *DepositMessage) SizeSSZ() (size int) {
|
||||
size = 88
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the DepositMessage object
|
||||
func (d *DepositMessage) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(d)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the DepositMessage object with a hasher
|
||||
func (d *DepositMessage) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'Pubkey'
|
||||
if len(d.Pubkey) != 48 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(d.Pubkey)
|
||||
|
||||
// Field (1) 'WithdrawalCredentials'
|
||||
if len(d.WithdrawalCredentials) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.PutBytes(d.WithdrawalCredentials)
|
||||
|
||||
// Field (2) 'Amount'
|
||||
hh.PutUint64(d.Amount)
|
||||
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
1567
proto/validator/accounts/v2/web_api.pb.go
generated
1567
proto/validator/accounts/v2/web_api.pb.go
generated
File diff suppressed because it is too large
Load Diff
@ -5,25 +5,13 @@ import "google/api/annotations.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
|
||||
|
||||
|
||||
service Wallet {
|
||||
rpc HasWallet(google.protobuf.Empty) returns (HasWalletResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/v2/validator/wallet/exists"
|
||||
};
|
||||
}
|
||||
rpc CreateWallet(CreateWalletRequest) returns (CreateWalletResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v2/validator/wallet/create",
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
rpc EditConfig(EditWalletConfigRequest) returns (WalletResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v2/validator/wallet/config/edit",
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
rpc WalletConfig(google.protobuf.Empty) returns (WalletResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/v2/validator/wallet"
|
||||
@ -65,6 +53,11 @@ service Health {
|
||||
}
|
||||
|
||||
service Auth {
|
||||
rpc HasUsedWeb(google.protobuf.Empty) returns (HasUsedWebResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/v2/validator/initialized",
|
||||
};
|
||||
}
|
||||
rpc Login(AuthRequest) returns (AuthResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v2/validator/login",
|
||||
@ -94,29 +87,27 @@ enum KeymanagerKind {
|
||||
|
||||
message CreateWalletRequest {
|
||||
// Path on disk where the wallet will be stored.
|
||||
string wallet_path = 1;
|
||||
KeymanagerKind keymanager = 2;
|
||||
KeymanagerKind keymanager = 1;
|
||||
|
||||
// Password for the wallet.
|
||||
string wallet_password = 3;
|
||||
string wallet_password = 2;
|
||||
// Mnemonic in case the user is creating a derived wallet.
|
||||
string mnemonic = 4;
|
||||
string mnemonic = 3;
|
||||
// Number of accounts.
|
||||
uint64 num_accounts = 5;
|
||||
uint64 num_accounts = 4;
|
||||
|
||||
// Remote address such as host.example.com:4000 for a gRPC remote signer server.
|
||||
string remote_addr = 6;
|
||||
string remote_addr = 5;
|
||||
// Path to client.crt for secure TLS connections to a remote signer server.
|
||||
string remote_crt_path = 7;
|
||||
string remote_crt_path = 6;
|
||||
// Path to client.key for secure TLS connections to a remote signer server.
|
||||
string remote_key_path = 8;
|
||||
string remote_key_path = 7;
|
||||
// Path to ca.crt for secure TLS connections to a remote signer server.
|
||||
string remote_ca_crt_path = 9;
|
||||
string remote_ca_crt_path = 8;
|
||||
}
|
||||
|
||||
message CreateWalletResponse {
|
||||
WalletResponse wallet = 1;
|
||||
DepositDataResponse accounts_created = 2;
|
||||
}
|
||||
|
||||
message EditWalletConfigRequest {
|
||||
@ -184,7 +175,7 @@ message AccountRequest {
|
||||
|
||||
message AuthRequest {
|
||||
string password = 1;
|
||||
string wallet_dir = 2;
|
||||
string password_confirmation = 2;
|
||||
}
|
||||
|
||||
message AuthResponse {
|
||||
@ -230,28 +221,8 @@ message ImportKeystoresResponse {
|
||||
repeated bytes imported_public_keys = 1;
|
||||
}
|
||||
|
||||
message DepositMessage {
|
||||
bytes pubkey = 1 [(gogoproto.moretags) = "ssz-size:\"48\""];
|
||||
bytes withdrawal_credentials = 2 [(gogoproto.moretags) = "ssz-size:\"32\""];
|
||||
uint64 amount = 3;
|
||||
message HasUsedWebResponse {
|
||||
bool has_signed_up = 1;
|
||||
bool has_wallet = 2;
|
||||
}
|
||||
|
||||
message DepositDataResponse {
|
||||
// The deposit data for each created account
|
||||
// represented as a list in the same format as
|
||||
// the deposit_data.json file from the eth2.0-deposit-cli.
|
||||
repeated DepositData deposit_data_list = 1;
|
||||
message DepositData {
|
||||
map<string, string> data = 1;
|
||||
}
|
||||
}
|
||||
|
||||
message DeleteAccountsRequest {
|
||||
// List of public keys to delete.
|
||||
repeated bytes public_keys = 1;
|
||||
}
|
||||
|
||||
message DeleteAccountsResponse {
|
||||
// List of public keys successfully deleted.
|
||||
repeated bytes deleted_keys = 1;
|
||||
}
|
||||
|
1066
proto/validator/accounts/v2_gateway/web_api.pb.go
generated
1066
proto/validator/accounts/v2_gateway/web_api.pb.go
generated
File diff suppressed because it is too large
Load Diff
@ -32,24 +32,6 @@ var _ = runtime.String
|
||||
var _ = utilities.NewDoubleArray
|
||||
var _ = descriptor.ForMessage
|
||||
|
||||
func request_Wallet_HasWallet_0(ctx context.Context, marshaler runtime.Marshaler, client WalletClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq empty.Empty
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := client.HasWallet(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Wallet_HasWallet_0(ctx context.Context, marshaler runtime.Marshaler, server WalletServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq empty.Empty
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := server.HasWallet(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Wallet_CreateWallet_0(ctx context.Context, marshaler runtime.Marshaler, client WalletClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq CreateWalletRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
@ -84,40 +66,6 @@ func local_request_Wallet_CreateWallet_0(ctx context.Context, marshaler runtime.
|
||||
|
||||
}
|
||||
|
||||
func request_Wallet_EditConfig_0(ctx context.Context, marshaler runtime.Marshaler, client WalletClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq EditWalletConfigRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.EditConfig(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Wallet_EditConfig_0(ctx context.Context, marshaler runtime.Marshaler, server WalletServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq EditWalletConfigRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.EditConfig(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Wallet_WalletConfig_0(ctx context.Context, marshaler runtime.Marshaler, client WalletClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq empty.Empty
|
||||
var metadata runtime.ServerMetadata
|
||||
@ -276,6 +224,24 @@ func local_request_Health_GetBeaconNodeConnection_0(ctx context.Context, marshal
|
||||
|
||||
}
|
||||
|
||||
func request_Auth_HasUsedWeb_0(ctx context.Context, marshaler runtime.Marshaler, client AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq empty.Empty
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := client.HasUsedWeb(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Auth_HasUsedWeb_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq empty.Empty
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := server.HasUsedWeb(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Auth_Login_0(ctx context.Context, marshaler runtime.Marshaler, client AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq AuthRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
@ -383,26 +349,6 @@ func local_request_Auth_Logout_0(ctx context.Context, marshaler runtime.Marshale
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
func RegisterWalletHandlerServer(ctx context.Context, mux *runtime.ServeMux, server WalletServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Wallet_HasWallet_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Wallet_HasWallet_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Wallet_HasWallet_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_Wallet_CreateWallet_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
@ -423,26 +369,6 @@ func RegisterWalletHandlerServer(ctx context.Context, mux *runtime.ServeMux, ser
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_Wallet_EditConfig_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Wallet_EditConfig_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Wallet_EditConfig_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Wallet_WalletConfig_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
@ -587,6 +513,26 @@ func RegisterHealthHandlerServer(ctx context.Context, mux *runtime.ServeMux, ser
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
func RegisterAuthHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AuthServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Auth_HasUsedWeb_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Auth_HasUsedWeb_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Auth_HasUsedWeb_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_Auth_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
@ -688,26 +634,6 @@ func RegisterWalletHandler(ctx context.Context, mux *runtime.ServeMux, conn *grp
|
||||
// "WalletClient" to call the correct interceptors.
|
||||
func RegisterWalletHandlerClient(ctx context.Context, mux *runtime.ServeMux, client WalletClient) error {
|
||||
|
||||
mux.Handle("GET", pattern_Wallet_HasWallet_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Wallet_HasWallet_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Wallet_HasWallet_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_Wallet_CreateWallet_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
@ -728,26 +654,6 @@ func RegisterWalletHandlerClient(ctx context.Context, mux *runtime.ServeMux, cli
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_Wallet_EditConfig_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Wallet_EditConfig_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Wallet_EditConfig_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Wallet_WalletConfig_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
@ -812,12 +718,8 @@ func RegisterWalletHandlerClient(ctx context.Context, mux *runtime.ServeMux, cli
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Wallet_HasWallet_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v2", "validator", "wallet", "exists"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Wallet_CreateWallet_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v2", "validator", "wallet", "create"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Wallet_EditConfig_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"v2", "validator", "wallet", "config", "edit"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Wallet_WalletConfig_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "validator", "wallet"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Wallet_GenerateMnemonic_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v2", "validator", "mnemonic", "generate"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
@ -826,12 +728,8 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
forward_Wallet_HasWallet_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Wallet_CreateWallet_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Wallet_EditConfig_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Wallet_WalletConfig_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Wallet_GenerateMnemonic_0 = runtime.ForwardResponseMessage
|
||||
@ -1039,6 +937,26 @@ func RegisterAuthHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.
|
||||
// "AuthClient" to call the correct interceptors.
|
||||
func RegisterAuthHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AuthClient) error {
|
||||
|
||||
mux.Handle("GET", pattern_Auth_HasUsedWeb_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Auth_HasUsedWeb_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Auth_HasUsedWeb_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_Auth_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
@ -1103,6 +1021,8 @@ func RegisterAuthHandlerClient(ctx context.Context, mux *runtime.ServeMux, clien
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Auth_HasUsedWeb_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "validator", "initialized"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Auth_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "validator", "login"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Auth_Signup_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "validator", "signup"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
@ -1111,6 +1031,8 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
forward_Auth_HasUsedWeb_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Auth_Login_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Auth_Signup_0 = runtime.ForwardResponseMessage
|
||||
|
@ -402,6 +402,8 @@ func (s *ValidatorClient) registerRPCService(cliCtx *cli.Context, km keymanager.
|
||||
if err := s.services.FetchService(&vs); err != nil {
|
||||
return err
|
||||
}
|
||||
validatorGatewayHost := cliCtx.String(flags.GRPCGatewayHost.Name)
|
||||
validatorGatewayPort := cliCtx.Int(flags.GRPCGatewayPort.Name)
|
||||
rpcHost := cliCtx.String(flags.RPCHost.Name)
|
||||
rpcPort := cliCtx.Int(flags.RPCPort.Name)
|
||||
nodeGatewayEndpoint := cliCtx.String(flags.BeaconRPCGatewayProviderFlag.Name)
|
||||
@ -418,6 +420,8 @@ func (s *ValidatorClient) registerRPCService(cliCtx *cli.Context, km keymanager.
|
||||
WalletDir: walletDir,
|
||||
Wallet: s.wallet,
|
||||
Keymanager: km,
|
||||
ValidatorGatewayHost: validatorGatewayHost,
|
||||
ValidatorGatewayPort: validatorGatewayPort,
|
||||
})
|
||||
return s.services.RegisterService(server)
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package rpc
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
@ -13,6 +12,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/promptutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/timeutils"
|
||||
"github.com/prysmaticlabs/prysm/validator/accounts/wallet"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
@ -33,8 +33,8 @@ const (
|
||||
// a sufficiently strong password check.
|
||||
func (s *Server) Signup(ctx context.Context, req *pb.AuthRequest) (*pb.AuthResponse, error) {
|
||||
walletDir := s.walletDir
|
||||
if strings.TrimSpace(req.WalletDir) != "" {
|
||||
walletDir = req.WalletDir
|
||||
if req.Password != req.PasswordConfirmation {
|
||||
return nil, status.Error(codes.InvalidArgument, "Password confirmation does not match")
|
||||
}
|
||||
// First, we check if the validator already has a password. In this case,
|
||||
// the user should be logged in as normal.
|
||||
@ -65,9 +65,6 @@ func (s *Server) Signup(ctx context.Context, req *pb.AuthRequest) (*pb.AuthRespo
|
||||
// Login to authenticate with the validator RPC API using a password.
|
||||
func (s *Server) Login(ctx context.Context, req *pb.AuthRequest) (*pb.AuthResponse, error) {
|
||||
walletDir := s.walletDir
|
||||
if strings.TrimSpace(req.WalletDir) != "" {
|
||||
walletDir = req.WalletDir
|
||||
}
|
||||
// We check the strength of the password to ensure it is high-entropy,
|
||||
// has the required character count, and contains only unicode characters.
|
||||
if err := promptutil.ValidatePasswordInput(req.Password); err != nil {
|
||||
@ -88,6 +85,19 @@ func (s *Server) Login(ctx context.Context, req *pb.AuthRequest) (*pb.AuthRespon
|
||||
return s.sendAuthResponse()
|
||||
}
|
||||
|
||||
// HasUsedWeb checks if the user has authenticated via the web interface.
|
||||
func (s *Server) HasUsedWeb(ctx context.Context, _ *ptypes.Empty) (*pb.HasUsedWebResponse, error) {
|
||||
walletExists, err := wallet.Exists(s.walletDir)
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, "Could not check if wallet exists")
|
||||
}
|
||||
hashedPasswordPath := filepath.Join(s.walletDir, HashedRPCPassword)
|
||||
return &pb.HasUsedWebResponse{
|
||||
HasSignedUp: fileutil.FileExists(hashedPasswordPath),
|
||||
HasWallet: walletExists,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Logout a user by invalidating their JWT key.
|
||||
func (s *Server) Logout(ctx context.Context, _ *ptypes.Empty) (*ptypes.Empty, error) {
|
||||
// Invalidate the old JWT key, making all requests done with its token fail.
|
||||
@ -164,10 +174,12 @@ func (s *Server) checkUserSignup(ctx context.Context) {
|
||||
if fileutil.FileExists(hashedPasswordPath) {
|
||||
return
|
||||
}
|
||||
log.Warn(
|
||||
"You are using the --web option but have not yet signed via a browser. " +
|
||||
"If your web host and port are exposed to the Internet, someone else can attempt to sign up " +
|
||||
"for you!",
|
||||
log.Warnf(
|
||||
"You are using the --web option but have not yet signed via a browser. "+
|
||||
"If your web host and port are exposed to the Internet, someone else can attempt to sign up "+
|
||||
"for you! You can visit http://%s:%d to view the Prysm web interface",
|
||||
s.validatorGatewayHost,
|
||||
s.validatorGatewayPort,
|
||||
)
|
||||
case <-s.ctx.Done():
|
||||
return
|
||||
|
@ -40,13 +40,15 @@ func TestServer_SignupAndLogin_RoundTrip(t *testing.T) {
|
||||
}
|
||||
weakPass := "password"
|
||||
_, err := ss.Signup(ctx, &pb.AuthRequest{
|
||||
Password: weakPass,
|
||||
Password: weakPass,
|
||||
PasswordConfirmation: weakPass,
|
||||
})
|
||||
require.ErrorContains(t, "Could not validate RPC password input", err)
|
||||
|
||||
// We assert we are able to signup with a strong password.
|
||||
_, err = ss.Signup(ctx, &pb.AuthRequest{
|
||||
Password: strongPass,
|
||||
Password: strongPass,
|
||||
PasswordConfirmation: strongPass,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -19,6 +19,7 @@ var (
|
||||
noAuthPaths = map[string]bool{
|
||||
"/ethereum.validator.accounts.v2.Auth/Signup": true,
|
||||
"/ethereum.validator.accounts.v2.Auth/Login": true,
|
||||
"/ethereum.validator.accounts.v2.Auth/HasUsedWeb": true,
|
||||
"/ethereum.validator.accounts.v2.Wallet/HasWallet": true,
|
||||
"/ethereum.validator.accounts.v2.Wallet/GenerateMnemonic": true,
|
||||
}
|
||||
|
@ -33,6 +33,8 @@ func init() {
|
||||
|
||||
// Config options for the gRPC server.
|
||||
type Config struct {
|
||||
ValidatorGatewayHost string
|
||||
ValidatorGatewayPort int
|
||||
Host string
|
||||
Port string
|
||||
CertFlag string
|
||||
@ -70,6 +72,8 @@ type Server struct {
|
||||
walletInitializedFeed *event.Feed
|
||||
walletInitialized bool
|
||||
nodeGatewayEndpoint string
|
||||
validatorGatewayHost string
|
||||
validatorGatewayPort int
|
||||
}
|
||||
|
||||
// NewServer instantiates a new gRPC server.
|
||||
@ -92,6 +96,8 @@ func NewServer(ctx context.Context, cfg *Config) *Server {
|
||||
wallet: cfg.Wallet,
|
||||
keymanager: cfg.Keymanager,
|
||||
nodeGatewayEndpoint: cfg.NodeGatewayEndpoint,
|
||||
validatorGatewayHost: cfg.ValidatorGatewayHost,
|
||||
validatorGatewayPort: cfg.ValidatorGatewayPort,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"github.com/pkg/errors"
|
||||
@ -25,30 +24,10 @@ const (
|
||||
invalidWalletMsg = "Directory does not contain a valid wallet"
|
||||
)
|
||||
|
||||
// HasWallet checks if a user has created a wallet before as well as whether or not
|
||||
// they have used the web UI before to set a wallet password.
|
||||
func (s *Server) HasWallet(_ context.Context, _ *ptypes.Empty) (*pb.HasWalletResponse, error) {
|
||||
exists, err := wallet.Exists(s.walletDir)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not check if wallet exists: %v", err)
|
||||
}
|
||||
if !exists {
|
||||
return &pb.HasWalletResponse{
|
||||
WalletExists: false,
|
||||
}, nil
|
||||
}
|
||||
return &pb.HasWalletResponse{
|
||||
WalletExists: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// CreateWallet via an API request, allowing a user to save a new
|
||||
// derived, imported, or remote wallet.
|
||||
func (s *Server) CreateWallet(ctx context.Context, req *pb.CreateWalletRequest) (*pb.CreateWalletResponse, error) {
|
||||
walletDir := s.walletDir
|
||||
if strings.TrimSpace(req.WalletPath) != "" {
|
||||
walletDir = req.WalletPath
|
||||
}
|
||||
exists, err := wallet.Exists(walletDir)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not check for existing wallet: %v", err)
|
||||
@ -136,11 +115,6 @@ func (s *Server) CreateWallet(ctx context.Context, req *pb.CreateWalletRequest)
|
||||
}
|
||||
}
|
||||
|
||||
// EditConfig allows the user to edit their wallet's configuration.
|
||||
func (s *Server) EditConfig(_ context.Context, _ *pb.EditWalletConfigRequest) (*pb.WalletResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "Unimplemented")
|
||||
}
|
||||
|
||||
// WalletConfig returns the wallet's configuration. If no wallet exists, we return an empty response.
|
||||
func (s *Server) WalletConfig(ctx context.Context, _ *ptypes.Empty) (*pb.WalletResponse, error) {
|
||||
exists, err := wallet.Exists(s.walletDir)
|
||||
|
@ -31,12 +31,11 @@ func TestServer_CreateWallet_Imported(t *testing.T) {
|
||||
walletDir: defaultWalletPath,
|
||||
}
|
||||
_, err := s.Signup(ctx, &pb.AuthRequest{
|
||||
Password: strongPass,
|
||||
WalletDir: defaultWalletPath,
|
||||
Password: strongPass,
|
||||
PasswordConfirmation: strongPass,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
req := &pb.CreateWalletRequest{
|
||||
WalletPath: localWalletDir,
|
||||
Keymanager: pb.KeymanagerKind_IMPORTED,
|
||||
WalletPassword: strongPass,
|
||||
}
|
||||
@ -86,9 +85,9 @@ func TestServer_CreateWallet_Derived(t *testing.T) {
|
||||
strongPass := "29384283xasjasd32%%&*@*#*"
|
||||
s := &Server{
|
||||
walletInitializedFeed: new(event.Feed),
|
||||
walletDir: localWalletDir,
|
||||
}
|
||||
req := &pb.CreateWalletRequest{
|
||||
WalletPath: localWalletDir,
|
||||
Keymanager: pb.KeymanagerKind_DERIVED,
|
||||
WalletPassword: strongPass,
|
||||
NumAccounts: 0,
|
||||
@ -150,48 +149,6 @@ func TestServer_WalletConfig(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestServer_HasWallet(t *testing.T) {
|
||||
localWalletDir := setupWalletDir(t)
|
||||
defaultWalletPath = localWalletDir
|
||||
ctx := context.Background()
|
||||
strongPass := "29384283xasjasd32%%&*@*#*"
|
||||
ss := &Server{
|
||||
walletDir: defaultWalletPath,
|
||||
}
|
||||
// First delete the created folder and check the response
|
||||
require.NoError(t, os.RemoveAll(defaultWalletPath))
|
||||
resp, err := ss.HasWallet(ctx, &ptypes.Empty{})
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, &pb.HasWalletResponse{
|
||||
WalletExists: false,
|
||||
}, resp)
|
||||
|
||||
// We now create the folder but without a valid wallet, i.e. lacking a subdirectory such as 'imported'
|
||||
// We expect an empty directory to behave similarly as if there were no directory
|
||||
require.NoError(t, os.MkdirAll(defaultWalletPath, os.ModePerm))
|
||||
resp, err = ss.HasWallet(ctx, &ptypes.Empty{})
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, &pb.HasWalletResponse{
|
||||
WalletExists: false,
|
||||
}, resp)
|
||||
|
||||
// We attempt to create the wallet.
|
||||
_, err = accounts.CreateWalletWithKeymanager(ctx, &accounts.CreateWalletConfig{
|
||||
WalletCfg: &wallet.Config{
|
||||
WalletDir: defaultWalletPath,
|
||||
KeymanagerKind: keymanager.Imported,
|
||||
WalletPassword: strongPass,
|
||||
},
|
||||
SkipMnemonicConfirm: true,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
resp, err = ss.HasWallet(ctx, &ptypes.Empty{})
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, &pb.HasWalletResponse{
|
||||
WalletExists: true,
|
||||
}, resp)
|
||||
}
|
||||
|
||||
func TestServer_ImportKeystores_FailedPreconditions_WrongKeymanagerKind(t *testing.T) {
|
||||
localWalletDir := setupWalletDir(t)
|
||||
defaultWalletPath = localWalletDir
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user