-
Notifications
You must be signed in to change notification settings - Fork 102
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
client/dcr: Add staking methods. #2290
Conversation
Would it make sense to have a separate VSP library in a new repo containing all the files you copied? And then vspd, dex, and other projects could just import it. |
@jholdstock wanted to put it in the vspd repo anyway. Maybe @JoeGruffins could open up a pull request over there too. But we don't want to wait for them either. We'll delete this stuff once it's available. |
If decred/dcrwallet#2224 (or something like it) happens, are we still left with a bunch of copied files? I didn't see the discussion with @jholdstock about putting this stuff in the vspd repo. |
I didn't know about #2224. @JoeGruffins shouldn't we be targeting a move to vspd? |
Asking on matrix if there were plans to move the rest of the dcrwallet/internal/vsp package to the decred/vspd repo. Not sure about the files in |
Echoing the diffs proposed on matrix: |
be0e3d7
to
80ef47a
Compare
Could do this while waiting for decred/vspd#382. |
I was playing with this a little. Please consider these changes.
*untested |
|
Made the buck change suggestions. For some reason go mod tidy does not error when I run it but does with the testing script. Oh yeah, loadbot's go.mod. Ok now. |
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.
Do we need to do something with (*AutoClient).ProcessUnprocessedTickets
?
client/asset/dcr/dcr.go
Outdated
} | ||
|
||
// PurchaseTickets purchases n amout of tickets. Ability to purchase should be | ||
// checked with CanPurchaseTickets. Part of the asset.TicketBuyer interface. |
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.
CanPurchaseTickets
?
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.
Yeah. The original plan was to check the wallet config before purchasing over rpc, and we would deny if not using a vsp. But, giving up on that since it seems we cannot get the config. User will just have to know what they are doing. Anyway, removing the reference to the removed method.
if !dcr.connected.Load() { | ||
return nil, errors.New("not connected, login first") | ||
} |
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'm wondering what these dcr.connected
checks do for us. We could theoretically add this check to almost any ExchangeWallet
method, but we don't because we expect the caller to know better, and continuing without being connected would generate an error anyway. What would happen if we didn't check this?
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.
My memory is fuzzy, but these will panic if the dcr.ctx is nil, which is so before the first connect.
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.
Yeah, I added this to any methods that use dcr.ctx
to avoid using a nil context and panic inside the rpcclient. Should I handle this differently?
|
||
func (w *rpcWallet) Tickets(ctx context.Context) ([]*asset.Ticket, error) { | ||
const includeImmature = true | ||
// GetTickets only works for clients with a dcrd backend. |
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.
Wow. I didn't know that. That's unfortunate. It looks like it's just for the extraTickets
checks in (*Wallet).LiveTicketHashes
. Otherwise all the data is just from the db.
client/asset/dcr/spv.go
Outdated
w.log.Warnf("unable to get VSP associated with ticket %s: %v", hash, err) | ||
return nil | ||
} | ||
info, err := vspInfo(vspHost) |
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.
Probably shouldn't call vspInfo
in a loop since it contains an http request. Maybe keep a cache map[string]*vspclient.AutoClient
that you can check first.
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.
Good idea. A map local to the function good enough?
Can get rid of the replace and rebase now, I think. Probably good to pull out of draft too. |
vsp still has several replaces, https://github.com/decred/vspd/blob/master/go.mod If we import vspd I guess we also need to use those replaces? And does the entire repo need to move to |
0eaf8a3
to
3f91df5
Compare
Maybe. Client could do this if wallet was reset from seed I think. Is it ok to make a todo for now? Because of automatic revocations now, its not a HUGE deal even if the vsp is not set up. Also, if the fee was paid, and the vspd is ok, the wallet doesnt need to worry about it, really. The vsp will vote and the wallet will get the funds back at some point. |
Made a TODO for managing unmanaged tickets https://github.com/decred/dcrdex/compare/be02793d87ec38b68e79012b4a1b0c047643f761..82014c37e3f680b799345fd1f08bdb429089594f |
So, copying the vspd client logic for now but using dcrwallet/v2. Hopefully can be removed sooner or later, but this seems like the only way to continue immediately. |
vspd cleaned up their go.mod and chappjc is working through the dcrwallet v3 upgrade now. |
Nice work. 💪 |
ce32862
to
674e179
Compare
client/cmd/dexc-desktop/go.mod
Outdated
@@ -5,7 +5,7 @@ go 1.18 | |||
replace decred.org/dcrdex => ../../.. | |||
|
|||
require ( | |||
decred.org/dcrdex v0.6.1 | |||
decred.org/dcrdex v0.6.0 |
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.
looks like an unintentional rollback
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.
Fixed! I guess this value doesn't really matter with the replace?
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.
Sorry to dwell on this, but all the indirect depends resulting from this are still changed. Best just to restore these files from master e.g. git restore --source=master go.mod
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.
Ok! Will add that command to my knowledge.
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.
utAck. Good work @JoeGruffins.
2f64728
to
e35ffb5
Compare
Just clone vspd for web files and fix some names https://github.com/decred/dcrdex/compare/83e734a95df1af93f6a5c3b1c4eb345bd816b10f..2f64728b70a0292a544718cd0b83d29c08eaa914 Fix dexc-desktop version in go.mod https://github.com/decred/dcrdex/compare/2f64728b70a0292a544718cd0b83d29c08eaa914..e35ffb5416101fe991099a47bfe0aabfbefd1039 |
|
|
||
// SetVSP sets the VSP provider. Ability to set should be checked with CanSetVSP | ||
// first. Part of the asset.TicketBuyer interface. | ||
func (dcr *ExchangeWallet) SetVSP(url string) error { |
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 seems SetVSP
and other TicketBuyer
methods are not consumed anywhere, except in simnet_test.go
, this means consumption of these new methods/features would be in a follow-up PR, no?
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.
Yes. With the rpcserver in #2316 and webserver not done yet.
client/asset/dcr/wallet.go
Outdated
// PurchaseTickets purchases n tickets. vsp arguments only needed for | ||
// internal wallets. | ||
PurchaseTickets(ctx context.Context, n int, vspHost, vspPubKey string) ([]string, error) |
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 can we specify the exact arguments that are not needed for RPC
wallets? I see only vspHost
and vspPubKey
are ignored and all other arguments are provided. vsp arguments
might not ring a bell the first time.
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.
vspHost and vspPubKey only needed for internal wallets.
okay?
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.
Mostly just some nits for now. Testing well.
MANUAL_TICKETS="1" | ||
"${HARNESS_DIR}/create-wallet.sh" "$SESSION:7" "vspdwallet" ${VSPD_WALLET_SEED} \ | ||
${VSPD_WALLET_RPC_PORT} ${USE_SPV} ${ENABLE_VOTING} "_" ${MANUAL_TICKETS} |
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 may not understand the config option, but why manualtickets=1
for this wallet?
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.
Oh I don't really know, just following the guide.
dcrwallet is also required to have the manual tickets option (--manualtickets) enabled which disables dcrwallet adding tickets arriving over the network.
https://github.com/decred/vspd/blob/master/docs/deployment.md#voting-servers
467337e
to
c3b9e76
Compare
Addressing reviews https://github.com/decred/dcrdex/compare/467337e1993823a1ffcac08d0e966282cc789548..c3b9e76eae170af3e91a6573d20c870ad2b36857 Notable changes are removing the vsp file and just getting the fee and pubkey on wallet start and adding some test parameters. |
ty @buck54321 https://github.com/decred/dcrdex/compare/877601896fc96501c2ba2ac01b837d234d21187b..bd79ca33db163d89bd2ae4e1080afb5109c2e1b8 Also using the separate file to save again. |
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.
Good stuff. I'll follow up with a couple of tweaks.
@@ -5134,6 +5174,125 @@ func (dcr *ExchangeWallet) EstimateSendTxFee(address string, sendAmount, feeRate | |||
return finalFee, isValidAddress, nil | |||
} | |||
|
|||
func (dcr *ExchangeWallet) isSPV() bool { | |||
return dcr.walletType == walletTypeSPV |
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.
This reminds me. There's a dcr.wallet.SpvMode()
which may be true even for a wallet connected via rpc. Put another way, isSPV could be true even if walletType isn't walletTypeSPV.
part of #2264
This pr only adds capabilities to the asset and simnet testing framework.
Many of the changes are files copied from vspd and wallet. Hopefully the fee paying logic can be exported from wallet so we won't need to add here.
This will be updated.