Skip to content

Conversation

itswisdomagain
Copy link
Member

Resolves #1882. Also resolves #726.

This adds a new flow for connecting to a DEX.

  • The registration page shows a checkbox to connect a DEX in view-only mode (no registration required).

Screenshot 2022-12-05 at 22 15 06

  • The markets page shows a "Create Account" button for view-only DEX connections.

Screenshot 2022-12-05 at 22 15 26

  • The "Create Account" button from the markets page redirects to the register page with a confirmation form that performs account discovery on submission, and if necessary, starts the fee payment process.

Screenshot 2022-12-05 at 22 17 17

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.

Damn good work! Looks and tests great. Just a couple little things.

Copy link
Member

@chappjc chappjc left a comment

Choose a reason for hiding this comment

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

I think we're conflating two concepts: (a) being registered at the DEX host, and (b) having a generated account identity/keys for authentication/authorization purposes regardless of registration and fee/bond status.

In Register of course we are concerned with both, particularly the first one so we don't pay a fee twice.

In many other places, we really don't need to know about fee coins or bonds or anything like that; we just want to know if we've run setupCryptoV2 and created account keys. I think that is what distinguishes a view-only account from one intended for authorization (regardless of payment details).

See my comments on the new (*dexAccount).isRegistered method.

@itswisdomagain
Copy link
Member Author

we really don't need to know about fee coins or bonds or anything like that; we just want to know if we've run setupCryptoV2 and created account keys. I think that is what distinguishes a view-only account from one intended for authorization (regardless of payment details).

Hmm. A dexAccount that started as a view-only account (no keys setup) but later has keys setup is still a view-only account unless the fee is paid? If not, how would the markets page UI look for such a dexAccount?

@chappjc
Copy link
Member

chappjc commented Dec 6, 2022

we really don't need to know about fee coins or bonds or anything like that; we just want to know if we've run setupCryptoV2 and created account keys. I think that is what distinguishes a view-only account from one intended for authorization (regardless of payment details).

Hmm. A dexAccount that started as a view-only account (no keys setup) but later has keys setup is still a view-only account unless the fee is paid? If not, how would the markets page UI look for such a dexAccount?

I think I just answered this in #1986 (comment), but no, it is no longer a view-only account if it has it's keys set. Fee is a legacy concept, and feeCoin is deprecated. It is expected for accounts created via postbond to have no feeCoin ever set. Further, it's expected to have no live bonds if they've all expired. Neither of these things means the account is not intended for trading, or non-existent on the server. Trading should only be blocked if tier<1, and that's for authDEX to determine.

As far as how the UI looks, note that with the legacy registration fee, there's a "pending" state between when you broadcast the fee transaction and when it gets confirmed and then submitted to the DEX. Similarly, with bonds, if you create an account with a bond ('postbond') or post a bond on an existing account that is presently tier<1, there's a period where the client waits for confirmations before submitting the bond for acceptance (and subsequent tier adjustment). In both cases, the UI has to have special handling. For the legacy fee, it's the confirmation countdown that takes the place of the order form. With bonds, it needs to be something indicating "tier zero, you must post new bonds", and that state can come and go as bond are posted and expire.

I don't know exactly what "not completed" Register outcomes there might be, but we indeed would either need to zero the keys to revert the conversion from view-only to active trading, or have UI handling to indicate this state when they need to attempt to Register again (after funding the wallet or fixing some connectivity issue perhaps?).

@itswisdomagain
Copy link
Member Author

Your explanations above clarify things for me @chappjc, thanks.

I think we're conflating two concepts: (a) being registered at the DEX host, and (b) having a generated account identity/keys for authentication/authorization purposes regardless of registration and fee/bond status.

So, this PR adds a third concept (c) view-only DEX (not registered, no keys).

Among other changes in my last commit,

  • authDEX continues to be done for (a) and (b), excluding only (c)
  • markets page shows "Create account to trade" prompt even if keys have been generated as long as the account is not yet registered with the server.

@JoeGruffins
Copy link
Member

JoeGruffins commented Dec 8, 2022

There is a limit on the number of websocket connections to a server.

// rpcMaxClients is the maximum number of active websocket connections
// allowed.
rpcMaxClients = 10000

If dex becomes popular, unpaid users could, accidentally, shut the dex down when paid/bond posted users cannot connect. Is it possible to limit the number of unpaid connections, and give them a time limit where they are kicked and must re-connect, maybe with a forced wait buffer if we are close to max unpaid connections?

Can be a todo, imo.

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.

Starting fresh on simnet not working

image

@itswisdomagain
Copy link
Member Author

Starting fresh on simnet not working

Silly if statement bug. Fixed.

@itswisdomagain
Copy link
Member Author

With bonds, it needs to be something indicating "tier zero, you must post new bonds", and that state can come and go as bond are posted and expire.

Also, a "tier zero, bond posted, waiting confirmations" state.

Is the UI bits something you're working on in your next bond PR @chappjc?

@chappjc
Copy link
Member

chappjc commented Dec 8, 2022

Also, a "tier zero, bond posted, waiting confirmations" state.

Is the UI bits something you're working on in your next bond PR @chappjc?

I'm starting the next "in progress" item on the project page here: DCRDEX Fidelity Bonds (view)

@chappjc
Copy link
Member

chappjc commented Dec 8, 2022

Next bond steps include UI, updated messaging (suspended -> sub-tier or whatever), client bond maintenance, settings, switches, etc.

I'm starting client db and core work for maintaining a certain tier with limits on total bonding amount.

For the UI, what we do depends on if we intend to support both the legacy fee and bonds in the next release. I don't think we should give the choice, only bonds.

So, while we transition in development, I think we should start by showing two options at /register - one that uses the legacy fee and one that uses a bond. But since it's only for developers to use either as needed, I don't think we should make it a single polished form with a selector. In fact, two separate forms shown simultaneously where you just use one of the forms might make the most sense (not intended for release that way). Otherwise if we make a nice selector on a single form, we're going to have to change that when the legacy fee is dropped. If there are just two forms shown, we just remove one when it's time to drop the fee.

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

One nit is that the viewing dex will appear in the settings under Registered Dexes:
image

None of the functions there seem to work, so maybe just don't show it there if possible.

if ai.LegacyFeePaid || len(ai.LegacyFeeCoin) > 0 {
return true
}
return len(ai.Bonds) > 0
Copy link
Member

@chappjc chappjc Dec 16, 2022

Choose a reason for hiding this comment

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

One tangential but fundamental improvement with the bonds registration protocol is that the account is not created server-side until the bond is confirmed. Thus, we need the Confirmed loop in 91d6124#diff-592072666205a423f50bc3061a74c2cda51bfe4689d4044315ff285d29645bc3R196-R199 to discern if the account should exist on the server ("may auth"). If there is a need to discern the pending initial bond state, we'll have to account for and flag that separately.

Copy link
Member Author

@itswisdomagain itswisdomagain Dec 19, 2022

Choose a reason for hiding this comment

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

I see. Yeah, there's a need to discern if a bond tx or the legacy fee tx has been broadcast to prevent re-attempting a new legacy tx. But that's about it, and since legacy registration will soon be a thing of the past, I'm beginning to wonder if there's any need to account for this.

The only thing we'd need to know is if there's NO active/pending bond and then display a prompt on the UI to post a bond to trade. If there's a pending bond, we display a confirmations counter.

We may also choose to prevent posting a new bond if there's a pending bond.

Copy link
Member

Choose a reason for hiding this comment

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

Alright, sounds fine for now. Will test it all out today.

@chappjc chappjc requested review from buck54321 and chappjc and removed request for buck54321 December 19, 2022 22:27
@chappjc
Copy link
Member

chappjc commented Dec 19, 2022

Sorry, didn't mean to request review from you @buck54321. Feel free to review of course, but no urgent need.

@itswisdomagain itswisdomagain force-pushed the no-reg-dex branch 2 times, most recently from c5d7c26 to b872504 Compare December 20, 2022 21:07
@chappjc chappjc added this to the 0.6/1.0 milestone Dec 27, 2022
@chappjc chappjc changed the title client: allow skipping registration when adding a dex client: allow skipping registration when adding a dex (view-only) Dec 29, 2022
@chappjc chappjc linked an issue Jan 4, 2023 that may be closed by this pull request
Comment on lines +87 to +89
// Host is optional. If provided, the register page will not display the add
// dex form, instead this host will be pre-selected for registration.
Host string
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 #2025 goes in first (I think it should), I'd use the dexsettings page for this instead of the register page. It would already contain the mechanics for posting bond for an existing dex connection and would naturally fit.

@itswisdomagain itswisdomagain force-pushed the no-reg-dex branch 2 times, most recently from b079447 to 6237a08 Compare January 10, 2023 14:32
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.

Testing well.

@@ -1195,6 +1196,10 @@ func (c *Core) connectedDEX(addr string) (*dexConnection, error) {
return nil, err
}

if dc.acct.isViewOnly() {
Copy link
Member

Choose a reason for hiding this comment

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

This method maybe doesn't make sense named connectedDEX anymore. A view-only connection is still a connection.

Comment on lines 587 to 588
// TODO: Accept a viewOnly bool param to prevent unintentionally saving
// zero-length Enckey.
Copy link
Member

Choose a reason for hiding this comment

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

Still applicable?

const page = this.page
page.appPW.value = ''
Doc.hide(page.err)
const hidePWBox = State.passwordIsCached() || (this.pwCache && this.pwCache.pw)
Copy link
Member

Choose a reason for hiding this comment

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

Could we skip this form altogether if the password is cached?

// TODO: Use dexsettings page?
const registerBttn = Doc.tmplElement(page.notRegistered, 'registerBttn')
bind(registerBttn, 'click', () => {
window.location.assign(`/register/${this.market.dex.host}`)
Copy link
Member

Choose a reason for hiding this comment

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

This isn't our preferred method of navigation, since it forces the js and css to be reloaded. How about using loadPage with a data argument?

@chappjc chappjc merged commit 02374f7 into decred:master Feb 18, 2023
@itswisdomagain itswisdomagain deleted the no-reg-dex branch February 18, 2023 20:33
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.

client: allow adding a dexConnection with no dexAccount dexc: view only support Lite book subscriptions
4 participants