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: add support for enabling/disabling a dex account #2946

Merged
merged 10 commits into from
Oct 14, 2024

Conversation

ukane-philemon
Copy link
Contributor

@ukane-philemon ukane-philemon commented Sep 3, 2024

Closes #2943

This PR introduces a new behaviour for disabled dex accounts. The account is no longer deleted and will be loaded into memory when core is initialized as an inactive dexConnection to facilitate active bond refunds(if any) every bond rotation. Users can now disable an account with active unspent bonds if they wish to.

Screen.Recording.2024-09-04.at.10.07.53.AM.mov

disabledAccountsBucket was removed. This means previously disabled accounts are lost. If we intend to allow users to re-enable a previously disabled account without having to add it again, I would restore disabledAccountsBucket and allow for backward compatibility.

As a follow up, I'll implement an endpoint to support deleting a dex server from the db. @buck54321 what do you think?

@ukane-philemon ukane-philemon marked this pull request as ready for review September 4, 2024 09:11
@ukane-philemon ukane-philemon changed the title multi: update AccountDisable method on core and db multi: add support for enabling/disabling a dex account Sep 4, 2024
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.

utAck just some comments for now. I'm OK with just ignoring the old disabledAccountsBucket from now on. As far as permanent deletion, it has to occur after all bonds are refunded of course, but yeah, do it in a follow up. We'll need this PR or a minimal version of this PR to go on top of release-v1.0 branch too.

client/core/account.go Show resolved Hide resolved
client/core/bond.go Outdated Show resolved Hide resolved
client/core/core.go Outdated Show resolved Hide resolved
client/core/bond.go Show resolved Hide resolved
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 good testing fine.

client/core/account.go Outdated Show resolved Hide resolved
client/core/account.go Outdated Show resolved Hide resolved
client/webserver/site/src/js/dexsettings.ts Outdated Show resolved Hide resolved
client/webserver/site/src/js/forms.ts Outdated Show resolved Hide resolved
client/webserver/site/src/js/dexsettings.ts Outdated Show resolved Hide resolved
client/webserver/site/src/js/forms.ts Outdated Show resolved Hide resolved
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.

Trying to re-enable the account is resulting in a panic.

@buck54321
Copy link
Member

@ukane-philemon please look into the panic. I'd like to get this into a patch release asap.

@ukane-philemon
Copy link
Contributor Author

Sure, I’ll look into it in a moment:

@ukane-philemon
Copy link
Contributor Author

ukane-philemon commented Oct 10, 2024

@buck54321 do you have a trace log?

EDIT: Is this what you saw? #3013

- Rename AccountDisable to ToggleAccountStatus and allow
  re-enabling a disabled account.

Signed-off-by: Philemon Ukane <[email protected]>
Signed-off-by: Philemon Ukane <[email protected]>
Signed-off-by: Philemon Ukane <[email protected]>
@ukane-philemon
Copy link
Contributor Author

Screen.Recording.2024-10-10.at.2.30.53.AM.mov

Tested again, and noticed no panic concerning this.

The only unrelated panic I got is #3013 and I'm unable to reproduce it.

@buck54321
Copy link
Member

This first one simulates what we might encounter if a server goes offline permanently or just happens to be offline when we try to re-enable it. This results in a panic.

  1. Fresh simnet node
  2. Create account, view-only or bonded, doesn't matter
  3. Shut down client
  4. Shut down server
  5. Restart client
  6. Disable account
  7. Enable account
panic serving 127.0.0.1:54230: runtime error: slice bounds out of range [-1:]
decred.org/dcrdex/client/core.(*Core).initializeDEXConnection(0xc00043ee00, 0x0, {0x2a1eba0, 0xc0007ec320})
	/home/buck/github/decred/dcrdex/client/core/core.go:5144 +0x3a
decred.org/dcrdex/client/core.(*Core).ToggleAccountStatus(0xc00043ee00, {0xc000e00550?, 0xc000388c80?, 0x1a26aa0?}, {0xc000e004e0, 0xf}, 0x0)
	/home/buck/github/decred/dcrdex/client/core/account.go:100 +0x495
decred.org/dcrdex/client/webserver.(*WebServer).apiToggleAccountStatus(0xc0003823c0, {0x7fd1fc7d5ff8, 0xc000153800}, 0xc000388c80)
	/home/buck/github/decred/dcrdex/client/webserver/api.go:863 +0x21d

This other one is just something I stumbled across.

  1. Fresh simnet node
  2. Create view-only account during initial setup
  3. Disable account
  4. Re-enable account
[ERR] CORE: notify: |ERROR| (feepayment) Account unlock error - error unlocking account for 127.0.0.1:17273: DecodeBlob: zero length blob not allowed`

@ukane-philemon
Copy link
Contributor Author

Both issues have been resolved in separate commits.

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.

Just for convenience, here's the changes I think are needed buck54321/dcrdex@c9bf340...buck54321:dcrdex:toggle-account-fixes

Comment on lines 5148 to 5150
if initialized, _ := dc.acct.status(); !initialized {
return // dex account is not yet initialized, so we can't unlock it.
}
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 necessary. The problem you had before was that you were using connectDEX in ToggleAccountStatus, and connectDEX doesn't set the connectDEXFlag so dc.acct.viewOnly was not being set correctly. Now that you're using connectAccount, this isn't a problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I traced your last error report to this: dc.acct.encKey was not set hence the error, which means it hasn't been initialized and this was an attempt to fix that.

Copy link
Member

Choose a reason for hiding this comment

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

Please read again and look at the code. Nothing I said was incorrect. Your use of connectDEX, which doesn't set the connectDEXFlag correctly, was the problem.

client/core/account.go Outdated Show resolved Hide resolved
client/core/account.go Show resolved Hide resolved
client/core/account.go Outdated Show resolved Hide resolved
@ukane-philemon
Copy link
Contributor Author

Just for convenience, here's the changes I think are needed buck54321/[email protected]:dcrdex:toggle-account-fixes

Thanks, cherry-picked as is.

@buck54321 buck54321 merged commit 7b24153 into decred:master Oct 14, 2024
5 checks passed
buck54321 added a commit to buck54321/dcrdex that referenced this pull request Oct 17, 2024
* multi: update AccountDisable method on core and db

- Rename AccountDisable to ToggleAccountStatus and allow
  re-enabling a disabled account.

---------

Signed-off-by: Philemon Ukane <[email protected]>
Co-authored-by: Brian Stafford <[email protected]>
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.

core: need a way to disable dex server accounts without deleting
3 participants