Skip to content

Commit

Permalink
Remote Key Manager API(web3signer) (#10302)
Browse files Browse the repository at this point in the history
* removing flag requirement, can run web3signer without predefined public keys

* placeholders for remote-keymanager-api

* adding proto and accountschangedfeed

* updating generated code

* fix imports

* fixing interface

* adding work in progress apimiddleware code

* started implementing functions for remote keymanager api

* fixing generted code from proto

* fixing protos

* fixing import format

* fixing proto generation again , didn't fix the first time

* fixing imports again

* continuing on implementing functions

* implementing add function

* implementing delete API function

* handling errors for API

* removing unusedcode and fixing format

* fixing bazel

* wip enable --web when running web3signer

* fixing wallet check for web3signer

* fixing apis

* adding list remote keys unit test

* import remote keys test

* delete pubkeys tests

* moving location of tests

* adding unit tests

* adding placeholder functions

* adding more unit tests

* fixing bazel

* fixing build

* fixing already slice issue with unit test

* fixing linting

* Update validator/client/validator.go

Co-authored-by: Raul Jordan <[email protected]>

* Update validator/keymanager/types.go

Co-authored-by: Raul Jordan <[email protected]>

* Update validator/node/node.go

Co-authored-by: Raul Jordan <[email protected]>

* Update validator/keymanager/types.go

Co-authored-by: Raul Jordan <[email protected]>

* Update validator/client/validator.go

Co-authored-by: Raul Jordan <[email protected]>

* adding comment on proto based on review

* Update validator/keymanager/remote-web3signer/keymanager.go

Co-authored-by: Radosław Kapka <[email protected]>

* Update validator/keymanager/remote-web3signer/keymanager.go

Co-authored-by: Radosław Kapka <[email protected]>

* Update validator/rpc/standard_api.go

Co-authored-by: Radosław Kapka <[email protected]>

* Update validator/rpc/standard_api.go

Co-authored-by: Radosław Kapka <[email protected]>

* Update validator/rpc/standard_api.go

Co-authored-by: Radosław Kapka <[email protected]>

* Update validator/rpc/standard_api.go

Co-authored-by: Radosław Kapka <[email protected]>

* adding generated code based on review

* updating based on feedback

* fixing imports

* fixing formatting

* Update validator/rpc/standard_api.go

Co-authored-by: Radosław Kapka <[email protected]>

* fixing event call

* fixing dependency

* updating bazel

* Update validator/rpc/standard_api.go

Co-authored-by: Radosław Kapka <[email protected]>

* Update validator/rpc/standard_api.go

Co-authored-by: Radosław Kapka <[email protected]>

* Update validator/rpc/standard_api.go

Co-authored-by: Radosław Kapka <[email protected]>

* Update validator/rpc/standard_api.go

Co-authored-by: Radosław Kapka <[email protected]>

* addressing comment from review

Co-authored-by: Raul Jordan <[email protected]>
Co-authored-by: Radosław Kapka <[email protected]>
  • Loading branch information
3 people authored Apr 11, 2022
1 parent e700557 commit 64f64f0
Show file tree
Hide file tree
Showing 18 changed files with 1,982 additions and 194 deletions.
1,170 changes: 1,031 additions & 139 deletions proto/eth/service/key_management.pb.go

Large diffs are not rendered by default.

227 changes: 227 additions & 0 deletions proto/eth/service/key_management.pb.gw.go

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

73 changes: 73 additions & 0 deletions proto/eth/service/key_management.proto
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,27 @@ service KeyManagement {
body: "*"
};
}


rpc ListRemoteKeys(google.protobuf.Empty) returns (ListRemoteKeysResponse) {
option (google.api.http) = {
get: "/internal/eth/v1/remotekeys"
};
}

rpc ImportRemoteKeys(ImportRemoteKeysRequest) returns (ImportRemoteKeysResponse) {
option (google.api.http) = {
post: "/internal/eth/v1/remotekeys",
body: "*"
};
}

rpc DeleteRemoteKeys(DeleteRemoteKeysRequest) returns (DeleteRemoteKeysResponse) {
option (google.api.http) = {
delete: "/internal/eth/v1/remotekeys",
body: "*"
};
}
}

message ListKeystoresResponse {
Expand Down Expand Up @@ -133,3 +154,55 @@ message DeletedKeystoreStatus {
Status status = 1;
string message = 2;
}


message ListRemoteKeysResponse {
message Keystore {
bytes pubkey = 1;
string url = 2;
bool readonly = 3;
}
repeated Keystore data = 1;
}

message ImportRemoteKeysRequest {
message Keystore {
bytes pubkey = 1;
string url = 2;
}
repeated Keystore remote_keys = 1;
}

message ImportRemoteKeysResponse {
repeated ImportedRemoteKeysStatus data = 1;
}

message DeleteRemoteKeysRequest {
repeated bytes pubkeys = 1;
}

message DeleteRemoteKeysResponse {
repeated DeletedRemoteKeysStatus data = 1;
}

message ImportedRemoteKeysStatus {
enum Status {
UNKNOWN = 0;
IMPORTED = 1;
DUPLICATE = 2;
ERROR = 3;
}
Status status = 1;
string message = 2;
}

message DeletedRemoteKeysStatus {
enum Status {
NOT_FOUND = 0;
DELETED = 1;
ERROR = 3; // skips 2 to match Delete KeyStore status which has error = 3.
}
Status status = 1;
string message = 2;
}

6 changes: 3 additions & 3 deletions validator/client/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type ValidatorService struct {
db db.Database
grpcHeaders []string
graffiti []byte
web3SignerConfig *remote_web3signer.SetupConfig
Web3SignerConfig *remote_web3signer.SetupConfig
feeRecipientConfig *validator_service_config.FeeRecipientConfig
}

Expand Down Expand Up @@ -122,7 +122,7 @@ func NewValidatorService(ctx context.Context, cfg *Config) (*ValidatorService, e
interopKeysConfig: cfg.InteropKeysConfig,
graffitiStruct: cfg.GraffitiStruct,
logDutyCountDown: cfg.LogDutyCountDown,
web3SignerConfig: cfg.Web3SignerConfig,
Web3SignerConfig: cfg.Web3SignerConfig,
feeRecipientConfig: cfg.FeeRecipientConfig,
}, nil
}
Expand Down Expand Up @@ -204,7 +204,7 @@ func (v *ValidatorService) Start() {
graffitiOrderedIndex: graffitiOrderedIndex,
eipImportBlacklistedPublicKeys: slashablePublicKeys,
logDutyCountDown: v.logDutyCountDown,
Web3SignerConfig: v.web3SignerConfig,
Web3SignerConfig: v.Web3SignerConfig,
feeRecipientConfig: v.feeRecipientConfig,
walletIntializedChannel: make(chan *wallet.Wallet, 1),
}
Expand Down
1 change: 1 addition & 0 deletions validator/client/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func (v *validator) WaitForKeymanagerInitialization(ctx context.Context) error {
}

if v.useWeb && v.wallet == nil {
log.Info("Waiting for keymanager to initialize validator client with web UI")
// if wallet is not set, wait for it to be set through the UI
km, err := waitForWebWalletInitialization(ctx, v.walletInitializedFeed, v.walletIntializedChannel)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions validator/keymanager/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ go_test(
"//validator/keymanager/derived:go_default_library",
"//validator/keymanager/local:go_default_library",
"//validator/keymanager/remote:go_default_library",
"//validator/keymanager/remote-web3signer:go_default_library",
],
)
Loading

0 comments on commit 64f64f0

Please sign in to comment.