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

[WIP] APIv3 #625

Closed
wants to merge 6 commits into from
Closed

[WIP] APIv3 #625

wants to merge 6 commits into from

Conversation

dajohi
Copy link
Member

@dajohi dajohi commented May 7, 2020

Work towards #574

Copy link
Member

@JoeGruffins JoeGruffins left a comment

Choose a reason for hiding this comment

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

Srry. I started looking at this before I realized it was a WIP. But, some comments anyway.

backend/stakepoold/rpc/server/server.go Show resolved Hide resolved
backend/stakepoold/stakepool/stakepool.go Outdated Show resolved Hide resolved
controllers/main.go Outdated Show resolved Hide resolved
controllers/main.go Show resolved Hide resolved
Copy link
Member

@itswisdomagain itswisdomagain left a comment

Choose a reason for hiding this comment

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

I recognize this is a WIP, and you'd likely have noted (some of) these reminders to circle back on. I was just reading the code to get a good idea of how to test this new feature out, noticed these and thought to leave comments.
PS: There's some nitpicking, please forgive. Those shouldn't belong in a WIP. There are a number of worth-checking out comments though.

backend/stakepoold/rpc/api.proto Show resolved Hide resolved
backend/stakepoold/rpc/api.proto Show resolved Hide resolved
return nil, nil, 0, 0, err
}
if resp.Confirmations < 2 || resp.BlockHeight < 0 {
return nil, nil, 0, 0, errors.New("ticket does not enough confirmations")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return nil, nil, 0, 0, errors.New("ticket does not enough confirmations")
return nil, nil, 0, 0, errors.New("ticket does not have enough confirmations")

sDiff := blockHeader.SBits

// get fee address
feeAddress, err := spd.WalletConnection.RPCClient().GetNewAddress(ctx, "fees")
Copy link
Member

Choose a reason for hiding this comment

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

Fees are currently derived off a cold wallet's xpub, which I think is safer. Is this a temporary measure? Or do VSP admins now need to create a fee account in each of their voting wallets? If we're using the voting wallets for collecting fees, might want to make the fee account configurable.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe it will be an imported account? ie, importxpub "name" "xpub" name being "fee"

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, there will be an importxpub

bytes FeeTx = 3;
}
message PayFeeResponse {
string Hash = 1;
Copy link
Member

Choose a reason for hiding this comment

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

FeeTxHash to avoid ambiguity.

TicketHash string
CommitmentSignature string
FeeAddress string
Address string
Copy link
Member

Choose a reason for hiding this comment

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

CommitmentAddress. Prolly immediately before or after CommitmentSignature.

}

// InsertFeeAddressVotingKey updates the fees table with a voting key for the given address.
func InsertFeeAddressVotingKey(dbMap *gorp.DbMap, address, votingKey string, voteBits uint16) error {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func InsertFeeAddressVotingKey(dbMap *gorp.DbMap, address, votingKey string, voteBits uint16) error {
func SetFeeAddressVotingKey(dbMap *gorp.DbMap, address, votingKey string, voteBits uint16) error {

func InsertFeeAddressVotingKey(dbMap *gorp.DbMap, address, votingKey string, voteBits uint16) error {
_, err := dbMap.Exec("UPDATE Fees SET VotingKey = ?, VoteBits = ? WHERE Address = ?", votingKey, voteBits, address)
if err != nil {
log.Warnf("InsertFeeAddressPrivKey: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

Needs update.

Comment on lines +741 to +751
for i, conn := range s.grpcConnections {
client := pb.NewStakepooldServiceClient(conn)
responses[i], err = client.GetFeeAddress(ctx, &pb.GetFeeAddressRequest{
Hash: txHash.String(),
Signature: signature,
})
if err != nil {
return nil, fmt.Errorf("GetFeeAddress RPC failed on stakepoold instance %s: %v", conn.Target(), err)
}
}
return responses[0], nil
Copy link
Member

Choose a reason for hiding this comment

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

2 questions here:

  • This method errors if any of the voting wallets do not return an address but the addresses returned from all backends are not compared for consistency. If it doesn't matter whether they all return the same address, I suppose it should likewise not matter if 1 or more backends do not return an address.
  • If a previous call to this method ends up deriving a new address for some wallets and not others, a new call to the method would produce different addresses. I expect the wallet that failed previously would be an index behind and would not be tracking usage for the newer address. I think that just means the balance may not be accurate on that wallet, so no biggie perhaps. If no biggie, could just ignore GetFeeAddress RPC failure on any failing backend.

I still think using a cold wallet's xpub is better anyways.

Copy link
Member Author

Choose a reason for hiding this comment

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

sql going away

Copy link
Member

Choose a reason for hiding this comment

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

🤔 reply meant for another comment perhaps?

Comment on lines +762 to +773
for i, conn := range s.grpcConnections {
client := pb.NewStakepooldServiceClient(conn)
responses[i], err = client.PayFee(ctx, &pb.PayFeeRequest{
TicketHash: txHash.String(),
VotingWIF: votingWIF.String(),
FeeTx: feeTxBuffer.Bytes(),
})
if err != nil {
return nil, fmt.Errorf("GetFeeAddress RPC failed on stakepoold instance %s: %v", conn.Target(), err)
}
}
return responses[0], nil
Copy link
Member

Choose a reason for hiding this comment

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

2 concerns here

  • Calling PayFee on multiple backends would cause multiple fee tx broadcast attempts. The broadcast could fail on any of those backends, no?
  • If PayFee errors on one backend, the fee tx might have been broadcasted by another backend. Should probably ignore errors if the PayFee call to the first backend succeeds.

@xaur
Copy link

xaur commented Jun 4, 2020

What is the status of this PR now that vspd is announced?

@jholdstock
Copy link
Member

https://github.com/decred/vspd

@jholdstock jholdstock closed this Oct 21, 2020
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.

5 participants