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

multi: gui staking #2482

Merged
merged 10 commits into from
Sep 1, 2023
Merged

multi: gui staking #2482

merged 10 commits into from
Sep 1, 2023

Conversation

buck54321
Copy link
Member

Enables the following staking related features through the client GUI

  • Select a VSP
  • Viewi current ticket price and voting rewards
  • Purchase tickets
  • View historical wallet staking stats
  • View a paginated table of wallet tickets
  • View agenda, tspends, and pi keys and update voting preferences

Implementation is minimal. My goal is to get a basic framework for staking on the front end. We can get all the bells and whistles added later.

There are still some unresolved questions around staking in general, marked with DRAFT NOTE:, though I am not opening this PR in draft because it's ready for review.

Tickets statuses are not updated on the front end. The front end has no tip change notification. If there was a tip change notification and we requested a new TicketStakingStatus every block, merging that info with the existing front-end state will require some finesse. e.g. if a user is looking at the paginated ticket table, we can't just delete the current history underneath of them, as it would be inefficient and it would cause errors when the user tried to navigate. Leaving this as a project for later.

dcrwallet's PurchaseTickets sometimes reduces the number of tickets purchased if there some utxo math it doesn't like. This is obviously terrible for UX, so a solution is needed. See draft notes.

Copy link
Contributor

@martonp martonp left a comment

Choose a reason for hiding this comment

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

Working well, just noticed some issues. No matter how many tickets I try to buy, it always only buys one ticket. After I buy a ticket, and the block has not yet been mined, if I try to buy another one it will say "insufficient funds", but the wallet page shows I have plenty of funds.

client/asset/dcr/spv.go Outdated Show resolved Hide resolved
endBlock = wallet.NewBlockIdentifierFromHeight(upperHeight)
}
if lowerHeight == lowerHeightAutomatic {
bn := upperHeight - int32(p.TicketExpiry+uint32(p.TicketMaturity)-requiredConfs)
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for subtracting requiredConfs and why is it 6 + 2?

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 this in dcrwallet, and I probably copied it from there, but unsure what it is about. Unless it wants the block when the ticket purchasing started? If the mined block it should be revoked after p.TicketExpiry+p.TicketMaturity?

https://github.com/decred/dcrwallet/blob/a87fa843495ec57c1d3b478c2ceb3876c3749af5/wallet/wallet.go#L5911

Copy link
Member Author

Choose a reason for hiding this comment

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

It's used in ForUnspentUnexpiredTickets without comment, but yes, I agree it seems unneeded. I guess I'll just remove it.

client/asset/interface.go Show resolved Hide resolved
@buck54321
Copy link
Member Author

Working well, just noticed some issues. No matter how many tickets I try to buy, it always only buys one ticket. After I buy a ticket, and the block has not yet been mined, if I try to buy another one it will say "insufficient funds", but the wallet page shows I have plenty of funds.

I've got a DRAFT NOTE: about it in (*spvWallet).PurchaseTickets.

// DRAFT NOTE: When purchasing N tickets, if there is utxo contention, the
// dcrwallet algorithm will reduce the Count until resolved.
// https://github.com/decred/dcrwallet/blob/a87fa843495ec57c1d3b478c2ceb3876c3749af5/wallet/createtx.go#L1480-L1490
// As a result, the user will get an actual ticket count somewhere in the
// range 1 <= tickets_purchased <= n.
// How do we handle that here? Or do we just let the front end handle it?
// If we set MinConf to 0 can we just loop until we have enough?

I can try to loop and see if that works.

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.

Looks great! It looks like the simnet vspd cannot handle the vote ids. Should we use a newer vspd version or is that not the issue?

Will try this out on testnet.

client/asset/dcr/dcr.go Outdated Show resolved Hide resolved
client/asset/dcr/dcr.go Outdated Show resolved Hide resolved
client/asset/dcr/dcr.go Outdated Show resolved Hide resolved
client/asset/dcr/dcr.go Outdated Show resolved Hide resolved
client/asset/dcr/rpcwallet.go Outdated Show resolved Hide resolved
Comment on lines 913 to 915
// DRAFT NOTE: Why not 0? We count zero-conf as available, so this
// doesn't match.
MinConf: 1,
Copy link
Member

Choose a reason for hiding this comment

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

I guess 0 is fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to zero. For SPV wallets, new outputs aren't even seen until they have 1 confirmation, so any zero confirmation outputs seen by an spv wallet would be our own e.g. change outputs.

endBlock = wallet.NewBlockIdentifierFromHeight(upperHeight)
}
if lowerHeight == lowerHeightAutomatic {
bn := upperHeight - int32(p.TicketExpiry+uint32(p.TicketMaturity)-requiredConfs)
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 this in dcrwallet, and I probably copied it from there, but unsure what it is about. Unless it wants the block when the ticket purchasing started? If the mined block it should be revoked after p.TicketExpiry+p.TicketMaturity?

https://github.com/decred/dcrwallet/blob/a87fa843495ec57c1d3b478c2ceb3876c3749af5/wallet/wallet.go#L5911

client/core/core.go Show resolved Hide resolved
@itswisdomagain
Copy link
Member

Seems it's not currently possible / allowed to change the VSP?

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.

Working on testnet! But as Wisdom said cannot change the vsp in the UI after choosing one.

@JoeGruffins
Copy link
Member

It also seems it will show the ticket price as it syncs, so will have wrong info that could be way off during initial sync. Maybe should disable purchasing if not synced anyway?

@buck54321
Copy link
Member Author

buck54321 commented Aug 30, 2023

It looks like the simnet vspd cannot handle the vote ids. Should we use a newer vspd version or is that not the issue?

What are you seeing, @JoeGruffins? I'm on vspd version 1.2.1+ee0a6fa5b and I don't see any issues.

@buck54321
Copy link
Member Author

Seems it's not currently possible / allowed to change the VSP?

Fixed in 35c2516

@buck54321
Copy link
Member Author

It also seems it will show the ticket price as it syncs, so will have wrong info that could be way off during initial sync. Maybe should disable purchasing if not synced anyway?

Yes. Will leave this for followup.

@buck54321
Copy link
Member Author

I think #2492 will be a big help for us with remaining hurdles for staking, and with other new wallet features. I don't plan on waiting for that here. Once this PR is merged, we can start addressing remaining issues with separate, targeted efforts.

@JoeGruffins
Copy link
Member

What are you seeing, @JoeGruffins? I'm on vspd version 1.2.1+ee0a6fa5b and I don't see any issues.

oh. doh. It's my installed version is the problem. Let me update and try again.

@JoeGruffins
Copy link
Member

$ vspd --homedir=/home/joe/dextest/dcr/vspd; tmux wait-for -S vspd loadConfig error: error parsing config file: /home/joe/dextest/dcr/vspd/vspd.conf:2: Invalid value simnet' for option --network'. Allowed values are: testnet or mainnet grr

@JoeGruffins
Copy link
Member

decred/vspd#419

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.

My vspd install was the problem. Looks great.

@buck54321 buck54321 merged commit 1b79545 into decred:master Sep 1, 2023
5 checks passed
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.

4 participants