Skip to content

Commit

Permalink
Slashing Protection RPC Endpoints for Web Backend (#8723)
Browse files Browse the repository at this point in the history
* added the removed RPC delete account to accounts.go  and the rpc in proto

* reverted the 3 unit tests namely the failed derived delete, no pub keys provided and the successful imported account with provided public keys; also  brought back the createImportedWalletWithAccounts back in wallet_test.go

* strong password defined elsewhere- removed

* Update validator/rpc/accounts_test.go

Co-authored-by: Radosław Kapka <rkapka@wp.pl>

* added PublicKeys Nil test case

* changed ss to s. ss was a bad name inthe first place

* goimports -w root

* fixed the goimports before running the proto scripts, also changed the deleterequest variable to PublicKeysToDelete

* removed unneeded comment

* added test case for derived, changed delete account to be for both imported and derived

* gofmt

* unrelated files

* unrelated files

* unrelatedfiles restored

* revert unrelated files

* changed the last ss

* adding slashign endpoints

* adding the rpc export and import funcs, still need more testing and add unit tests

* added import slashing unit test

* clean up

* remove less

* Update proto/validator/accounts/v2/web_api.proto

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>

* Update proto/validator/accounts/v2/web_api.proto

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>

* Update proto/validator/accounts/v2/web_api.proto

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>

* Update proto/validator/accounts/v2/web_api.proto

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>

* camelCase Proto

* update slashing_protection_json

* update proto

* register in validator/rpc/gateway

* removed the server db creation, the validator cannot begin with a null db

* round trip test

* gofmt

* Update validator/rpc/slashing.go

* Update validator/rpc/slashing.go

* Update validator/rpc/slashing.go

* Update validator/rpc/slashing.go

* Update validator/rpc/slashing.go

* Update validator/rpc/slashing.go

* Update validator/rpc/slashing.go

Co-authored-by: Radosław Kapka <rkapka@wp.pl>
Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
Co-authored-by: terence tsao <terence@prysmaticlabs.com>
  • Loading branch information
4 people authored Apr 9, 2021
1 parent 0808c02 commit e3149c4
Show file tree
Hide file tree
Showing 10 changed files with 1,656 additions and 423 deletions.
2 changes: 1 addition & 1 deletion proto/beacon/rpc/v1_gateway/debug.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

764 changes: 621 additions & 143 deletions proto/validator/accounts/v2/web_api.pb.go

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions proto/validator/accounts/v2/web_api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,21 @@ service Beacon {
}
}

service SlashingProtection {
rpc ExportSlashingProtection(google.protobuf.Empty) returns (ExportSlashingProtectionResponse) {
option (google.api.http) = {
post: "/v2/validator/slashing-protection/export"
body: "*"
};
}
rpc ImportSlashingProtection(ImportSlashingProtectionRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
post: "/v2/validator/slashing-protection/import"
body: "*"
};
}
}

service Health {
rpc GetBeaconNodeConnection(google.protobuf.Empty) returns (NodeConnectionResponse) {
option (google.api.http) = {
Expand Down Expand Up @@ -371,3 +386,12 @@ message DeleteAccountsResponse {
// List of public keys successfully deleted.
repeated bytes deleted_keys = 1;
}
message ExportSlashingProtectionResponse {
// JSON representation of the slash protection
string file = 1;
}

message ImportSlashingProtectionRequest {
// JSON representation of the slash protection
string slashing_protection_json = 1;
}
820 changes: 542 additions & 278 deletions proto/validator/accounts/v2_gateway/web_api.pb.go

Large diffs are not rendered by default.

218 changes: 217 additions & 1 deletion proto/validator/accounts/v2_gateway/web_api.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions validator/rpc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ go_library(
"intercepter.go",
"log.go",
"server.go",
"slashing.go",
"wallet.go",
],
importpath = "github.com/prysmaticlabs/prysm/validator/rpc",
Expand Down Expand Up @@ -40,6 +41,7 @@ go_library(
"//validator/keymanager:go_default_library",
"//validator/keymanager/derived:go_default_library",
"//validator/keymanager/imported:go_default_library",
"//validator/slashing-protection/local/standard-protection-format:go_default_library",
"@com_github_dgrijalva_jwt_go//:go_default_library",
"@com_github_gogo_protobuf//types:go_default_library",
"@com_github_grpc_ecosystem_go_grpc_middleware//:go_default_library",
Expand All @@ -60,6 +62,7 @@ go_library(
"@org_golang_google_grpc//metadata:go_default_library",
"@org_golang_google_grpc//reflection:go_default_library",
"@org_golang_google_grpc//status:go_default_library",
"@org_golang_google_protobuf//types/known/emptypb:go_default_library",
"@org_golang_x_crypto//bcrypt:go_default_library",
],
)
Expand All @@ -73,6 +76,7 @@ go_test(
"health_test.go",
"intercepter_test.go",
"server_test.go",
"slashing_test.go",
"wallet_test.go",
],
embed = [":go_default_library"],
Expand All @@ -92,10 +96,12 @@ go_test(
"//validator/accounts/iface:go_default_library",
"//validator/accounts/wallet:go_default_library",
"//validator/client:go_default_library",
"//validator/db/kv:go_default_library",
"//validator/db/testing:go_default_library",
"//validator/keymanager:go_default_library",
"//validator/keymanager/derived:go_default_library",
"//validator/keymanager/imported:go_default_library",
"//validator/slashing-protection/local/standard-protection-format/format:go_default_library",
"//validator/testing:go_default_library",
"@com_github_dgrijalva_jwt_go//:go_default_library",
"@com_github_gogo_protobuf//types:go_default_library",
Expand Down
1 change: 1 addition & 0 deletions validator/rpc/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func (g *Gateway) Start() {
pb.RegisterHealthHandlerFromEndpoint,
pb.RegisterAccountsHandlerFromEndpoint,
pb.RegisterBeaconHandlerFromEndpoint,
pb.RegisterSlashingProtectionHandlerFromEndpoint,
}
for _, h := range handlers {
if err := h(ctx, gwmux, g.remoteAddr, opts); err != nil {
Expand Down
1 change: 1 addition & 0 deletions validator/rpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ func (s *Server) Start() {
pb.RegisterHealthServer(s.grpcServer, s)
pb.RegisterBeaconServer(s.grpcServer, s)
pb.RegisterAccountsServer(s.grpcServer, s)
pb.RegisterSlashingProtectionServer(s.grpcServer, s)

go func() {
if s.listener != nil {
Expand Down
Loading

0 comments on commit e3149c4

Please sign in to comment.