Skip to content

Commit e3149c4

Browse files
ahadda5rkapkarauljordanterencechain
authored
Slashing Protection RPC Endpoints for Web Backend (#8723)
* 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>
1 parent 0808c02 commit e3149c4

File tree

10 files changed

+1656
-423
lines changed

10 files changed

+1656
-423
lines changed

proto/beacon/rpc/v1_gateway/debug.pb.gw.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/validator/accounts/v2/web_api.pb.go

Lines changed: 621 additions & 143 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/validator/accounts/v2/web_api.proto

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,21 @@ service Beacon {
110110
}
111111
}
112112

113+
service SlashingProtection {
114+
rpc ExportSlashingProtection(google.protobuf.Empty) returns (ExportSlashingProtectionResponse) {
115+
option (google.api.http) = {
116+
post: "/v2/validator/slashing-protection/export"
117+
body: "*"
118+
};
119+
}
120+
rpc ImportSlashingProtection(ImportSlashingProtectionRequest) returns (google.protobuf.Empty) {
121+
option (google.api.http) = {
122+
post: "/v2/validator/slashing-protection/import"
123+
body: "*"
124+
};
125+
}
126+
}
127+
113128
service Health {
114129
rpc GetBeaconNodeConnection(google.protobuf.Empty) returns (NodeConnectionResponse) {
115130
option (google.api.http) = {
@@ -371,3 +386,12 @@ message DeleteAccountsResponse {
371386
// List of public keys successfully deleted.
372387
repeated bytes deleted_keys = 1;
373388
}
389+
message ExportSlashingProtectionResponse {
390+
// JSON representation of the slash protection
391+
string file = 1;
392+
}
393+
394+
message ImportSlashingProtectionRequest {
395+
// JSON representation of the slash protection
396+
string slashing_protection_json = 1;
397+
}

proto/validator/accounts/v2_gateway/web_api.pb.go

Lines changed: 542 additions & 278 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/validator/accounts/v2_gateway/web_api.pb.gw.go

Lines changed: 217 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

validator/rpc/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ go_library(
1111
"intercepter.go",
1212
"log.go",
1313
"server.go",
14+
"slashing.go",
1415
"wallet.go",
1516
],
1617
importpath = "github.com/prysmaticlabs/prysm/validator/rpc",
@@ -40,6 +41,7 @@ go_library(
4041
"//validator/keymanager:go_default_library",
4142
"//validator/keymanager/derived:go_default_library",
4243
"//validator/keymanager/imported:go_default_library",
44+
"//validator/slashing-protection/local/standard-protection-format:go_default_library",
4345
"@com_github_dgrijalva_jwt_go//:go_default_library",
4446
"@com_github_gogo_protobuf//types:go_default_library",
4547
"@com_github_grpc_ecosystem_go_grpc_middleware//:go_default_library",
@@ -60,6 +62,7 @@ go_library(
6062
"@org_golang_google_grpc//metadata:go_default_library",
6163
"@org_golang_google_grpc//reflection:go_default_library",
6264
"@org_golang_google_grpc//status:go_default_library",
65+
"@org_golang_google_protobuf//types/known/emptypb:go_default_library",
6366
"@org_golang_x_crypto//bcrypt:go_default_library",
6467
],
6568
)
@@ -73,6 +76,7 @@ go_test(
7376
"health_test.go",
7477
"intercepter_test.go",
7578
"server_test.go",
79+
"slashing_test.go",
7680
"wallet_test.go",
7781
],
7882
embed = [":go_default_library"],
@@ -92,10 +96,12 @@ go_test(
9296
"//validator/accounts/iface:go_default_library",
9397
"//validator/accounts/wallet:go_default_library",
9498
"//validator/client:go_default_library",
99+
"//validator/db/kv:go_default_library",
95100
"//validator/db/testing:go_default_library",
96101
"//validator/keymanager:go_default_library",
97102
"//validator/keymanager/derived:go_default_library",
98103
"//validator/keymanager/imported:go_default_library",
104+
"//validator/slashing-protection/local/standard-protection-format/format:go_default_library",
99105
"//validator/testing:go_default_library",
100106
"@com_github_dgrijalva_jwt_go//:go_default_library",
101107
"@com_github_gogo_protobuf//types:go_default_library",

validator/rpc/gateway/gateway.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func (g *Gateway) Start() {
6262
pb.RegisterHealthHandlerFromEndpoint,
6363
pb.RegisterAccountsHandlerFromEndpoint,
6464
pb.RegisterBeaconHandlerFromEndpoint,
65+
pb.RegisterSlashingProtectionHandlerFromEndpoint,
6566
}
6667
for _, h := range handlers {
6768
if err := h(ctx, gwmux, g.remoteAddr, opts); err != nil {

validator/rpc/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ func (s *Server) Start() {
187187
pb.RegisterHealthServer(s.grpcServer, s)
188188
pb.RegisterBeaconServer(s.grpcServer, s)
189189
pb.RegisterAccountsServer(s.grpcServer, s)
190+
pb.RegisterSlashingProtectionServer(s.grpcServer, s)
190191

191192
go func() {
192193
if s.listener != nil {

0 commit comments

Comments
 (0)