-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Improve the performace of LeaseOutput
#8961
Improve the performace of LeaseOutput
#8961
Conversation
Important Review skippedAuto reviews are limited to specific labels. Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
c77e7de
to
4cbc82a
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.
Solid improvement, thanks for looking into this!
But I think the first commit would break things in certain circumstances...
4cbc82a
to
4bd04b1
Compare
4bd04b1
to
e741a62
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 pending merge of dependent PR and re-arrangement of commits.
This commit replaces the usage of `FetchInputInfo` with `FetchOutpointInfo` and `FetchDerivationInfo` to remove unncessary fetching of the derivation path.
e741a62
to
31dc2b2
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 🎉
This method is no longer used. In addition, the `Derivation` field on the `Utxo` is also removed to avoid nil dereference.
This commit prepares the following commit where we change the `LeaseOutput` to be more efficient.
This commit removes the call toe `ListLeasedOutputs` in `LeaseOutput` - the returned info from `ListLeasedOutputs` can easily be accessed via `FetchInputInfo` and this info is only used at one callsite. `ListLeasedOutputs` then becomes unnecessary here, plus it's very slow and needs to be refactored in `btcwallet` instead.
This check has already been done when mining blocks.
31dc2b2
to
363e529
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 🪖
Nice optimization!
@@ -154,7 +154,7 @@ func (r *RPCKeyRing) SendOutputs(inputs fn.Set[wire.OutPoint], | |||
// watch-only wallet if it can map this outpoint into a coin we | |||
// own. If not, then we can't continue because our wallet state | |||
// is out of sync. | |||
info, err := r.WalletController.FetchInputInfo( | |||
info, err := r.WalletController.FetchOutpointInfo( |
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.
Makes sense, FetchInputInfo
ends up calling FetchOutpointInfo
under the covers: https://github.com/btcsuite/btcwallet/blob/6ecae9c12fde8ed4db9e3c88241a8aeabff37724/wallet/utxos.go#L112-L123
} | ||
|
||
lockedBalance += utxoInfo.Value | ||
lockedBalance += btcutil.Amount(leasedOutput.Value) |
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's a wrapper built around
btcwallet.LeaseOutput
inlnwallet
, which additionally callsListLeasedOutputs
to fetch the script and value info, which is rarely used and can be replaced with other queries when needed. More importantly thisListLeasedOutputs
is very slow (detailed in btcsuite/btcwallet#943), so we remove this call.Once removed, we gained roughly 30s back in this test,
On this branch
On master,
Fix #8809.