Skip to content
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

mulit: remove voting public key from config and check fee public key on start up #422

Closed
wants to merge 10 commits into from

Conversation

JoeGruffins
Copy link
Member

@JoeGruffins JoeGruffins commented Jun 25, 2019

After stakepools are confirmed running, loop through them sending a grpc request to perform rpc requests on their respective dcrd to get maps of master pubkeys to account. found pairs are printed and then the user defined key values are compared to the found keys. The voting key must be found to continue, the fee key must not be found.

Still want to write some tests for the grpc and rpc methods.

closes #407

@JoeGruffins
Copy link
Member Author

Hmm. rpc tests are a little more than I bargained for. It's on my todo list... I will test a little more manually.

Copy link
Member

@jholdstock jholdstock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of smal

stakepooldclient/stakepooldclient.go Outdated Show resolved Hide resolved
backend/stakepoold/rpc/rpcserver/context.go Outdated Show resolved Hide resolved
backend/stakepoold/rpc/rpcserver/context.go Outdated Show resolved Hide resolved
@JoeGruffins JoeGruffins force-pushed the checkpubs branch 3 times, most recently from 2c90725 to da980ec Compare July 18, 2019 12:53
@JoeGruffins
Copy link
Member Author

Ok. The coldwalletextpub is checked to not belong to the voting wallets. The votingwalletextpub is found automatically. votingwalletextpub is deprecated and there is a warning if set. It has been removed from the readme and a warning is in the config file.

@JoeGruffins JoeGruffins changed the title [WIP]Check pubkeys on start up mulit: remove voting public key from config and check fee public key on start up Jul 18, 2019
@JoeGruffins
Copy link
Member Author

I'm not sure that this travis build error is my fault. Google says I can close and reopen the issue to trigger a rebuild. Trying.

@JoeGruffins JoeGruffins reopened this Jul 18, 2019
README.md Show resolved Hide resolved
backend/stakepoold/rpc/rpcserver/context.go Outdated Show resolved Hide resolved
backend/stakepoold/rpc/rpcserver/context.go Outdated Show resolved Hide resolved
stakepooldclient/stakepooldclient.go Outdated Show resolved Hide resolved
@jholdstock
Copy link
Member

I'm not sure that this travis build error is my fault. Google says I can close and reopen the issue to trigger a rebuild. Trying.

I didnt know you could trigger a rebuild like that. Alternatively you can just log into travis with your github ID and it should allow you to press a button which rebuilds. Not sure if you need any repo permissions to do that though...

@JoeGruffins
Copy link
Member Author

JoeGruffins commented Jul 22, 2019

I didnt know you could trigger a rebuild like that. Alternatively you can just log into travis with your github ID and it should allow you to press a button which rebuilds. Not sure if you need any repo permissions to do that though...

I just do what google tells me to do. I should start a new religion. Would you too like to become a Goober?

@JoeGruffins
Copy link
Member Author

Should this increment the api version major, since it is a breaking change?

@jholdstock
Copy link
Member

Should this increment the api version major, since it is a breaking change?

Yes please.

@jholdstock
Copy link
Member

The latest changes look good, just the API version to increment and one outstanding comment from me.

Needs to be rebased also, some conflicts have popped up.

@JoeGruffins
Copy link
Member Author

Rebased and breaking this pr into its parts. The final check will also be broken into two methods.

@JoeGruffins JoeGruffins changed the title mulit: remove voting public key from config and check fee public key on start up [WIP]mulit: remove voting public key from config and check fee public key on start up Jul 25, 2019
@JoeGruffins JoeGruffins force-pushed the checkpubs branch 2 times, most recently from 1edecf6 to 8e2d812 Compare July 27, 2019 01:37
@JoeGruffins
Copy link
Member Author

@jholdstock what do you think?

README.md Outdated Show resolved Hide resolved
backend/stakepoold/rpc/rpcserver/context.go Outdated Show resolved Hide resolved
config.go Outdated Show resolved Hide resolved
sample-dcrstakepool.conf Outdated Show resolved Hide resolved
server.go Outdated Show resolved Hide resolved
stakepooldclient/stakepooldclient.go Outdated Show resolved Hide resolved
stakepooldclient/stakepooldclient.go Outdated Show resolved Hide resolved
stakepooldclient/stakepooldclient.go Outdated Show resolved Hide resolved
stakepooldclient/stakepooldclient.go Outdated Show resolved Hide resolved
stakepooldclient/stakepooldclient.go Outdated Show resolved Hide resolved
@JoeGruffins JoeGruffins force-pushed the checkpubs branch 3 times, most recently from d57e816 to 55b3d77 Compare August 1, 2019 02:56
@JoeGruffins
Copy link
Member Author

@chappjc thank you for the review and sorry about the basic formatting mistakes. They won't happen again.

@JoeGruffins JoeGruffins changed the title [WIP]mulit: remove voting public key from config and check fee public key on start up mulit: remove voting public key from config and check fee public key on start up Aug 1, 2019
@chappjc
Copy link
Member

chappjc commented Aug 1, 2019

Oh, no worries. It's small stuff.

@JoeGruffins JoeGruffins force-pushed the checkpubs branch 3 times, most recently from 9aae095 to 1748d12 Compare August 8, 2019 23:23
Copy link
Member

@jholdstock jholdstock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two more minor things noted. Otherwise I am happy with this. @chappjc are you satisfied all of your points were addressed?

config.go Outdated Show resolved Hide resolved
config.go Outdated Show resolved Hide resolved
@JoeGruffins
Copy link
Member Author

Will rebase after release.

stakepooldclient/stakepooldclient.go Outdated Show resolved Hide resolved
// error if pubkeys for the "default" account are not the same accross all
// stakepoold wallets or any gRPC commands fail.
func (s *StakepooldManager) DefaultAccountPubKey() (string, error) {
var pubkey string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could rename to validDefaultAccountPubKey to signify that

  • the pubkey of interest is for the default account (should be obvious but could become confusing if my previous suggestion is applied)
  • the value stored here at the end of the day ought to be the same for all stakepoold instances (hence the valid prefix)

Could probably just use named return variables as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jholdstock isn't a fan of naked returns.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dajohi isn't either

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just rename the variable then

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Named return variables (as suggested by itswisdomagain) are fine. I actually kind of wish naming return values was enforced and not optional.

It's just naked returns which are icky.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of it as a package deal, but you mean naming them, and then placing their names in the return I guess. Never even thought about that.

@itswisdomagain sorry, my naked comments on your pr are in the wrong place.

}
for _, v := range resp.MasterPubKeys {
if fn(v.Account, v.PubKey) {
return true, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This return statement in this loop implies that the grpc request may likely not be made to ALL stakepoold instances. Not sure if this was intended, PR description says After stakepools are confirmed running, loop through them sending a grpc request to perform rpc requests on their respective dcrd to get maps of master pubkeys to account; which I read to mean perform the grpc request on ALL stakepoold instances.

It's also important to check all instances to confirm/verify that the wallets on each backend server were all restored from the same seed; i.e. checking that the master pub key is the same across all the backend server wallets.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first true is sufficient for what I use it for. Return true if a default xpub is different and return true if xpub is found. Once a true if found there is no need to continue, and if no trues then all accounts on all wallets have been iterated.

It is checking that the master pub key for the default account is the same across all servers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote it like this to avoid iterating the map twice. Perhaps the complexity is not worth it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't really quite get you. What I mean to confirm is this:
Does this code retrieve the voting wallet xpub key from ALL stakepoold instances and confirm that the xpub key is the same across ALL stakepoold instances?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

It should. Does it not? 😬


// WalletsHavePubKey sends gRPC commands to all stakepoold and returns whether
// pubkey exists on any wallets. Returns an error if any gRPC commands fail.
func (s *StakepooldManager) WalletsHavePubKey(pubkey string) (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that this is only used to confirm that the coldwalletextpub does not belong to the voting wallets. I think this check can be done at the same time as the master pub key for the default account is read to prevent performing the stakepoold WalletMasterPubKeys grpc request more than once.

1 idea is to invoke that grpc method once for ALL instances, ensuring that all the stakepoold instances return the same result (equal number of account-key pairs, with the same key value for each account on each backend server). Then the vetted account-key map is parsed to retrieve the default account pub key and also checked to ensure it does not contain the coldwalletextpub.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather keep the functions separate, for easier testing and such, but you are right that we only need to call the grpc once. Because this operation only ever happens on start-up, I didn't think it was necessary, but we could cache the results, or use a clever closure scheme.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's all the same, I've already had numerous reviews on this pr, and it's working ok. Unless you think the gRPC commands will need to change, I'd rather further changes be made in another pr. That alright @itswisdomagain ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, haven't tested myself but if others have tested and it works ok, further changes can be made in a subsequent PR.

@@ -33,8 +33,8 @@ const (
// collection cycle to also trigger a timeout but the current allocation
// pattern of stakepoold is not known to cause such conditions at this time.
GRPCCommandTimeout = time.Millisecond * 100
semverString = "8.0.0"
semverMajor = 8
semverString = "9.0.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be updated to 9.1.0. We incremented to 9.0.0 in #526, and this PR adds a new method without breaking backwards compatability.

@JoeGruffins
Copy link
Member Author

I think I will close this because I think this change will ultimately become pointless. It's not worth the time to rebase and review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Config: Check that cold wallet key and voting wallet key are not the same
5 participants