-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Web Backend Revert delete rpc #8681
Web Backend Revert delete rpc #8681
Conversation
…ys provided and the successful imported account with provided public keys; also brought back the createImportedWalletWithAccounts back in wallet_test.go
… webbackendrevertDeleteRPC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please run goimports
. We should have local imports first, followed by an empty line, followed by external imports. Changes to most pb
files' imports are unnecessary.
validator/rpc/accounts.go
Outdated
func (s *Server) DeleteAccounts( | ||
ctx context.Context, req *pb.DeleteAccountsRequest, | ||
) (*pb.DeleteAccountsResponse, error) { | ||
if req.DeletePublicKeys == nil || len(req.DeletePublicKeys) < 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to also add a test for this precondition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added.
validator/rpc/accounts_test.go
Outdated
} | ||
|
||
func TestServer_DeleteAccounts_OK(t *testing.T) { | ||
ss, pubKeys := createImportedWalletWithAccounts(t, 3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ss
is a really bad name. Can we change it to server
?
validator/rpc/wallet_test.go
Outdated
//require.NoError(t, w.SaveHashedPassword(ctx)) | ||
km, err := w.InitializeKeymanager(ctx, iface.InitKeymanagerConfig{ListenForChanges: false}) | ||
require.NoError(t, err) | ||
ss := &Server{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ss
is a weird name. Why not s
or server
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to s
|
||
message DeleteAccountsRequest { | ||
// List of public keys to delete. | ||
repeated bytes delete_public_keys = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete_public_keys
sounds like a good function name, but parameter names should be nouns. I would prefer simply public_keys
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed. Although, I was trying to be consistent with the accounts.Config . Should i change the protobuf?
type Config struct {
| Wallet *wallet.Wallet
| Keymanager keymanager.IKeymanager
| DeletePublicKeys [][]byte
| }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's OK if they are not the same. Config's name is also a bit awkward, I think PublicKeysToDelete
makes more sense (I would not call it simply PublicKeys
because the type Config
does not convey any information as to what these public keys are, as opposed to the protobuf type name).
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
…5/prysm into webbackendrevertDeleteRPC
AFter running goimports on the root proto libs , DeepSource complains about this below. What is that would you know? |
So it looks like 7348624 removed an import from |
…e deleterequest variable to PublicKeysToDelete
I think its because i ran update proto scripts before goimports. It is fixed now. Thanks |
Unfortunately your last commit again mixed up imports. I am not sure why this happens. Can you maybe just revert these changes manually in case the tooling does not work properly? |
validator/rpc/accounts.go
Outdated
if s.wallet == nil || s.keymanager == nil { | ||
return nil, status.Error(codes.FailedPrecondition, "No wallet found") | ||
} | ||
if s.wallet.KeymanagerKind() != keymanager.Imported { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have since changed the requirements and now both imported and derived keymanagers can delete keys. Remote cannot, so we should update here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would one test a derived wallet delete? accounts.DeleteAccounts supports both imported and derived but only tests the imported wallets (check here
If i get it to work in rpc , we can update the accounts module as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A derived wallet is internally implemented as an imported wallet, that's why testing an imported wallet is enough for the most part.
An example of setting up a derived wallet for testing can be found here:
t.Run("Derived keymanager", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you might need to do gofmt -w -s .
or goimports to prevent changing all those other unrelated proto files
validator/rpc/wallet_test.go
Outdated
SkipMnemonicConfirm: true, | ||
}) | ||
require.NoError(t, err) | ||
//require.NoError(t, w.SaveHashedPassword(ctx)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's delete the commented code
… webbackendrevertDeleteRPC
…5/prysm into webbackendrevertDeleteRPC
Codecov Report
@@ Coverage Diff @@
## develop #8681 +/- ##
===========================================
+ Coverage 61.15% 61.18% +0.03%
===========================================
Files 498 498
Lines 34711 34729 +18
===========================================
+ Hits 21227 21250 +23
+ Misses 10332 10316 -16
- Partials 3152 3163 +11 |
PTAL @rkapka |
What type of PR is this?
Feature #8664
What does this PR do? Why is it needed?
WebUI needs to allow for the deletion of accounts. We will revert back this feature which existed before.
Which issues(s) does this PR fix?
Fixes #8664 The portion about adding back the delete accounts RPC endpoints, previously reverted from Prysm
Other notes for review
On reverting the code the following considerations were accounted for.
createImportedWalletWithAccounts
, originally part of wallet_test.go which , as the name implies, creates a wallet and imports a test-generated keystore.