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

bonds: UI updates and import/export #2200

Merged
merged 8 commits into from
Mar 20, 2023
Merged

bonds: UI updates and import/export #2200

merged 8 commits into from
Mar 20, 2023

Conversation

chappjc
Copy link
Member

@chappjc chappjc commented Mar 3, 2023

This PR contains:

  • some final UI updates for the fee-->bonds change
  • includes bonds when doing account import/export, fix need to restart after import
  • a few minor client/core fixes
  • dep updates flagged by dependabot

Copy link
Collaborator

@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.

During registration, on the wallet funding screen, it allows you to only deposit the amount required for 1 bond, but then when it's time to post the bond, it will reject if there is not enough for the second bond. Either we should allow the user to not have to reserve enough for the second bond, or not go to the next page.

Another issue I found was when exporting the account. I exported, created a fresh dexc with the same seed, then imported. The imported server did not show up, but after I restarted the dexc, I could see it. Might be a pre-existing issue.

"Confirm Registration": "Confirm Registration",
"app_pw_reg": "Enter your app password to confirm DEX registration.",
"reg_confirm_submit": `When you submit this form, funds will be spent from your wallet to pay the registration fee.`,
"Skip Registration": "No account (view-only mode)",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should these be re-translated as well?

Copy link
Member Author

@chappjc chappjc Mar 15, 2023

Choose a reason for hiding this comment

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

Would be nice if we had a "stale" flag like with the notifications because some of these aren't bad still.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed some and flagged some others with comments if they were still accurate.

@@ -396,7 +396,9 @@ func (c *Core) rotateBonds(ctx context.Context) {

bondAsset := bondAssets[bondAssetID]
if bondAsset == nil {
c.log.Warnf("Bond asset %d not supported by DEX %v", bondAssetID, dc.acct.host)
if targetTier > 0 {
c.log.Warnf("Bond asset %d not supported by DEX %v", bondAssetID, dc.acct.host)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would this only happen if the dex stopped supporting a bond asset they previously used to support?

@chappjc
Copy link
Member Author

chappjc commented Mar 14, 2023

The imported server did not show up, but after I restarted the dexc, I could see it. Might be a pre-existing issue.

Yeah, this is the annoying initializeDEXconnections call. I'll look at avoiding the restart but I think it might need to stay this way for now.

@chappjc
Copy link
Member Author

chappjc commented Mar 15, 2023

During registration, on the wallet funding screen, it allows you to only deposit the amount required for 1 bond, but then when it's time to post the bond, it will reject if there is not enough for the second bond. Either we should allow the user to not have to reserve enough for the second bond, or not go to the next page.

This was one of the things I was still considering. You're absolutely right of course, with the current UI. What I was pondering is a new user that might want to post a single bond without maintenance. Seeing as we'll need to add a check box for that and probably handle other edges, I think we can put that idea on the back burner until 1.0 or maybe 0.6.1. The normal user will have a maintained account.

Will change the wallet wait form so it waits for the amount that it suggests, which accounts for the overlap with maintenance running.

"1 Sync the Blockchain": "1: Zsynchronizuj blockchain",
"Progress": "Postęp",
"remaining": "pozostało",
"2 Fund the Registration Fee": "2: Wnieś opłatę rejestracyjną",
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 couldn't see a way to tame gofmt here, not without leaving these incorrect translations.

@chappjc chappjc force-pushed the bond-ui branch 2 times, most recently from 2d1e13f to e6547ec Compare March 15, 2023 20:56
@chappjc
Copy link
Member Author

chappjc commented Mar 15, 2023

image

image

image

image

image
(I missed the conf countdown).

image

@chappjc chappjc marked this pull request as ready for review March 15, 2023 20:59
@chappjc
Copy link
Member Author

chappjc commented Mar 16, 2023

The need to restart after import should also be resolved @martonp but I've not tested that. If the required changes somehow turn out to be much bigger we'll have to punt on this.

@martonp
Copy link
Collaborator

martonp commented Mar 16, 2023

The import basically works now, but if there was an active bond then it is not able to do a refund

2023-03-16 15:47:05.836 [WRN] CORE: Bond output not found, possibly already spent or never mined! Marking refunded. Backup refund transaction: 
2023-03-16 15:47:05.836 [ERR] CORE: Failed to mark bond as refunded: bond bucket does not exist: 376aae28be249c5c0494b21433d5df1144085b50cf957a3a2cba850e72cba8ac

I think this will require a more extensive change.

@martonp
Copy link
Collaborator

martonp commented Mar 16, 2023

It's not a huge deal, but I think the text You may deposit as much as you like might make people think you can deposit just the 10 DCR. Maybe below the Bond Amount: 10 DCR there could also be Minimum Deposit: 20.01 in the same size text.

@chappjc
Copy link
Member Author

chappjc commented Mar 16, 2023

The import basically works now, but if there was an active bond then it is not able to do a refund

2023-03-16 15:47:05.836 [WRN] CORE: Bond output not found, possibly already spent or never mined! Marking refunded. Backup refund transaction: 
2023-03-16 15:47:05.836 [ERR] CORE: Failed to mark bond as refunded: bond bucket does not exist: 376aae28be249c5c0494b21433d5df1144085b50cf957a3a2cba850e72cba8ac

I think this will require a more extensive change.

Was there really no refund tx in the log or did you remove it for brevity? I don't see why it wouldn't be exported and imported given

RefundTx   []byte `json:"refundTx"`

but it really needs to be.

@chappjc
Copy link
Member Author

chappjc commented Mar 16, 2023

Oh wait, I think the server may have reported an unknown bond there. I guess I'll toy with this some more.

@chappjc
Copy link
Member Author

chappjc commented Mar 16, 2023

Ah I need to update the async exportAccount () { in dexsettings.ts. The JSON that the browser downloads lacks bonds.

@chappjc chappjc force-pushed the bond-ui branch 2 times, most recently from a133419 to bcb8286 Compare March 17, 2023 15:36
@chappjc
Copy link
Member Author

chappjc commented Mar 17, 2023

Yeesh, finally got bond import working. General cases:

  • Restore from same seed, discover account done, then import account used to import previous bonds. The bond key index will derive the correct private key. We need to update any placeholder live and unspent bonds when importing, otherwise append new unspent bonds that are likely expired and need refund.
  • New seed used, registered fresh, then import account used to import previous bonds. The bonds do not apply to the account, so we must block this. Further, the bond key index will NOT derive the correct private key. The user must manually broadcast the refund tx from the JSON file.
  • New seed used, import the account with its bonds. The bonds do apply to the account, but as with the previous case the bond key index will NOT derive the correct private key, so automatic refund must use the backup refund tx (in rotateBonds). However, this pays to the old wallet. This is a messy case and should only be considered as a recovery aid.

In the last two points above, this is an unfortunate consequence of how we switched from storing the bond private key in the DB to storing the key index since that is only helpful if the app seed is unchanged. Since the backup refund tx pays to the old wallet, this is suboptimal, but at least they can restore the wallet if they had the original seed.

Copy link
Collaborator

@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.

LGTM, all the import cases work well. Could optionally export the bond private keys so they can be used when imported with a dexc that was initialized with another seed. It's probably a niche use case though so probably not worth the time.

Copy link
Member

@buck54321 buck54321 left a comment

Choose a reason for hiding this comment

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

I sent the exact recommended amount, but the registration sequence did not progress. I had to send more.
image

Comment on lines +197 to +198
// TODO: less heavy handed approach to append or update
// dc.acct.{bonds,pendingBonds,expiredBonds}, using server config...
Copy link
Member

Choose a reason for hiding this comment

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

Is the more sophisticated technique to roughly 1) add the bond to appropriate map, 2) update tier, and 3) call monitorBondConfs?

Copy link
Member Author

Choose a reason for hiding this comment

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

add or update. Probably other error prone stuff.

@chappjc
Copy link
Member Author

chappjc commented Mar 20, 2023

I sent the exact recommended amount, but the registration sequence did not progress. I had to send more.

Dang, that was a whoopsie from my previous fixup for @martonp's review. Updated and fixed in f55b3f2. Verification:

walletwaitfix.mp4

One more commit coming shortly for the other nits.

chappjc added 2 commits March 20, 2023 10:20
Also, connect acct on import.

On import detect and log foreign account keys.

Import now tries to merge bonds if the account already exists.
If the account ID and dex pubkey do not match, import is blocked.
client/{asset,core}

This adds the BondsFeeBuffer asset.Bonder method to return a generous
estimate (e.g. 150%) of how much extra the user should fund their
wallet to successfully post their initial bond with ReserveBondFunds.
This also adds a Core method to obtain this amount for a bond wallet.

client/webserver

Add the "/bondsfeebuffer" endpoint, which is intended to inform the
UI's WalletWaitForm.
chappjc added 2 commits March 20, 2023 10:21
This silences a spammy log message that is show when a DEX server does
not support the user's selected bond asset AND bond maintenance is
enabled for that server. This would only happen if they were using
bonds with that server and it had then stopped supporting that asset.
chappjc added 4 commits March 20, 2023 10:24
This rewords the UI's registration forms for the fee->bond change.

This also changes the wallet funding step to use the new
/bondsfeebuffer http API endpoint. The overlap factor (2) is *advised*
at the level of the frontend, assuming the user wants uninterrupted
bond maintainance. However, the wallet fail form will allow proceeding
with the just bond amount plus a fee buffer.
RESERVES DEFICIT may show in balance if the user posts a single bond
and then decided to enable bond maintanence (target tier).

remove stale web translations
@chappjc chappjc merged commit ac18594 into decred:master Mar 20, 2023
@chappjc chappjc deleted the bond-ui branch March 20, 2023 15:36
@chappjc chappjc added the bonds fidelity bonds label Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bonds fidelity bonds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants