-
Notifications
You must be signed in to change notification settings - Fork 127
implement live wallet reconfiguration #1686
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
Conversation
c7d43ca
to
61e7751
Compare
Looks like you're building on #1657, in spirit. I'm fine with that one so wanna merge that so this can get rebased? |
I'm opening this up for review. I can add other assets here, but following up is good too. |
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.
Works well. I just see two minor UI issues:
-
If I try to switch wallet types while I have an active order, it fails with an error message as it should, but on the UI the wallet is shown as locked and unsynced. This fixes itself after refreshing the screen.
-
If I'm trying to switch from the SPV wallet to the external wallet while I have a trade running, it fails as it should, but if I navigate away to the markets page, then come back to the reconfigure screen, the RPC wallet settings are still showing even though I'm not using an SPV wallet. When I'm using the RPC wallet and I fail at switching to the SPV wallet, then I navigate away and come back to the reconfigure screen, the RPC wallet configs are still showing as they are supposed to. The issue only happens when attempting to switch from SPV to RPC.
client/asset/btc/rpcclient.go
Outdated
// Check the RPC configuration. | ||
newCfg := &parsedCfg.RPCConfig | ||
if err := dexbtc.CheckRPCConfig(&newCfg.RPCConfig, wc.cloneParams.WalletInfo.Name, wc.cloneParams.Network, wc.cloneParams.Ports); err != nil { | ||
return false, err |
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.
You can just do return
here as you did earlier in the function.
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 fine and tests well.
client/asset/btc/spv.go
Outdated
if err := w.updateDBBirthday(newBday); err != nil { | ||
return false, fmt.Errorf("error storing new birthday") | ||
} | ||
w.birthdayV.Store(newBday) | ||
if rescanRequired { | ||
if err = w.rescanWalletAsync(); err != nil { | ||
return false, fmt.Errorf("error initiating rescan after birthday adjustment") | ||
} | ||
} |
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.
Could include the error in these two.
c.log.Warnf("Error getting balance for wallet %s: %v", unbip(assetID), err) | ||
// Do not fail in case this requires an unlocked 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.
I guess this would also fail if the wallet was rescanning because the birthday was set lower?
return nil | ||
} | ||
|
||
clearTickGovernors := func() { |
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 can't figure out why it is necessary to clear these tick blocking timers. Why do we do 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.
The tick governor meters attempts at swapping when there is repeating error. A new wallet might fix the issue, so we allow a tick to occur immediately.
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. I didn't realize this method is expected to be used if something was erroring. No problem.
fromID = tracker.Base() | ||
} | ||
|
||
denom, marketMult, limitMult := lcm(uint64(len(tracker.matches)), trade.Quantity) |
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.
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.
That's fine. May not go that way for a while if things are OK for now. Can rebase it in the future.
However, there are a number of bug fixes and simplifications I listed that we should probably get eyes on and extract: #1653 (review)
9b7ac90
to
b5d792f
Compare
f8baeba
to
814d34f
Compare
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.
LGTM. @JoeGruffins please circle back on your review when convenient. Thx.
Switching wallet types, rpc to spv looks fine, but spv to rpc will say I have no peers and not let me trade until I restart dexc. |
Our current scheme for configuration changes requires killing the existing wallet and creating a new one. Unfortunately, even though we allow reconfiguration with active matches/orders, we've made no accomodations for re-establishing locked coins on the new wallet. client/asset: Introduce the LiveReconfigurer interface with a single method, Reconfigure(WalletConfig) (restartRequired bool, err error). If a wallet implements LiverReconfigurer, client/core: Core will call Reconfigure early in (*Core).ReconfigureWallet, and if there is no error and restartRequired is false, then the reconfiguration is considered complete and no new wallet is created. If, on the other hand, the LiveReconfigurer indicates that a restart is required, we use our existing ReconfigureWallet code without modification, but add a step at the end to re-reserve funding coin and refund/redeem reserves. This new method (*Core).reReserveFunding is modeled closely after resumeTrades, but optimized for only 1 asset an no audits. client/asset/btc: Implement Reconfigure. Puts user-configurable baseWallet configuration in a seperate struct, stored as an atomic.Value baseWallet field, with the settings themselves readable through new getters. rpcWallet does something similar with its an atomic.Value for its requester RawRequesterWithContext field. The only thing that requires a restart now is a wallet type change, though an error is generated if there is an attempt to reduce the spv wallet birthday with special:activelyUsed set.
3044c39
to
edeb1c9
Compare
Starts resolving #1492 . Just sketching this out for now. I can add other wallets here, or that can be followup work. The btc changes are in anticipation of changes coming in #1657.