-
Notifications
You must be signed in to change notification settings - Fork 977
splice: Enable cross splice in script #8450
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
Open
ddustin
wants to merge
25
commits into
ElementsProject:master
Choose a base branch
from
ddustin:ddustin/cross_splice_script
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
splice: Enable cross splice in script #8450
ddustin
wants to merge
25
commits into
ElementsProject:master
from
ddustin:ddustin/cross_splice_script
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3f5ce3e to
a8b6647
Compare
bcf603c to
858ca51
Compare
a1c8215 to
89e3067
Compare
bff76fd to
21e6d62
Compare
Adds tests for multi channel wallet scripts and complex situations involving difficult fee calculations.
In splicing logs we’re often outputting msat values next to sat values, making understanding the logs difficult. Adding a way to output msats as sats with a decimal makes these logs much easier to read.
Just a convenient method for checking if a given signed sat value can be subtracted from an msat value.
On the rare chance a channel id starts with 02 or 03 we need to check of it’s referring to a channel before parsing it node id, instead of after.
When using wetlog we might not also have debug log enabled.
In some splice script failure modes, some memory is leaked. These don’t occur in normal operation — just when an error occurs. This cleans up those memory leaks.
Since channeld handles splicing, it makes sense that it knows the opening feerate now. This is needed for rounding out splice script errors and logging.
This new feerate gives us more careful control of what feerate splices should be at.
Adds the new `splice` feerate to the RPC
Add lots of logging to help debug and develop splice related work
Here we update `psbt_input_get_weight` to allow the caller to specify what kind of input size estimation they would like. Before it was just “zero witness bytes” which we now move to the default behavior and add an assumption option for P2WSH -> 2of2 multisig which is what we typically see in splicing. At the same time we move channeld over to using the opening feerate estimation instead of the less useful “max feerate.” We make splice script use this same feerate. After auditing the feerates for these two places against each other and the actually created transaction, we implement some fixes making them all match. While we’re here, we add relevant debug log messages.
If the channel has multiple splice candidates pending at once, `tx_abort` needs to know which candidate is being aborted.
The splice will fail if not enough funds are provided but failing earlier with a clear error message makes for a better user experience and clearer RPC results.
Splicing can create stale announcements where the original funding output gets spent creating spruious “channel_announcement: no unspent txout” warnings. This happens particuarlly often with agressive splice tests in CI, so we downgrade this from a warning to a log message.
When executing splices with many channels at once the `channel_ids` and `results` arrays could be reallocted via `tal_arr_remove` and `tal_arr_expand`. Since these values are shared across multiple `splice_command` objects, when these functions reallocated the arrays the other `splice_command` would be referencing an invalid pointer. The solution is to make an explicit shared object `stfu_req_info` that is shared amoung the `splice_command`s and holds pointers to the arrays so they can mutate.
We need a new pending state to handle complex wallet funding situations (ie, wallet takes a percentage of funds but pays the onchain fee). While we’re moving the function earlier in the file along with the debug log function which we move and improve at the same time
To prepare for dynamic wallet funding abilities, we pre-process the wallet withdrawls and move them to `needed_funds`. These wallet withdrawl amounts are zero’d out and will have their total withdrawl amount caluclated later on.
Treat the `*` as if it were `100%` for wallets. 100% is a special case that means “100% of needed funds” not “100% of wallet funds.” since taking out all of the wallet’s inputs is wasteful.
To help manage state around dynamic wallets, we allow `out_ppm` to stay on even after its result is calculated.
Implement some helper functions to make implemetning dynamic wallet and fee amounts easier.
Implementing dynamic wallet amounts and the ability for the wallet to pay fee. Because wallets increase the fee paying for the fee (due to inputs increasing transaction size), this process must be inherently recursive. Adding to the complication is that wallets may take a percentage of total funds in the splice before accomodating the fee. Finally, any percentage based receiver or contributor of funds may also be responsible for the fee. Supporting all this means we need to build a solver that can be executed repeatidly, solving what can be solved on each pass. Some answers inherently require answers from prior passes. `calc_in_ppm_and_fee` is the workhorse that handles this recursive problem.
Switch to dynamic fees and stop using `force_feerate` on all tests so we get stricter testing around feerates
Enables multi channel splices in splice script Enables dynamic wallet calculations Enables dynamic fee calculations Changelog-Added: Added support for multi (ie 3+) channel splices, dynamic wallet funding, and dynamic fee calculating.
e87eb61 to
1e08ddb
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Status::Ready for Review
The work has been completed and is now awaiting evaluation or approval.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While we're there we enable dynamic amounts for wallets, fees, and everywhere.
This nearly brings splice script into a releasable state and allows for the creation of
splicein#8856,spliceout#8857, and much more to come.This PR tackles rather complex problems around figuring out fees and dynamic amounts for arbitrary splices, solving them in an elegant way that allows us to build on top of it later.
As an example think of needing to fund fees from the onchain wallet. Adding funds adds 1 or more inputs to the transaction. These extra input(s) add bytes, increasing the needed fee. This extra weight may require the adding more inputs from the wallet. This is what wallet's do to make payments but we need it done in a splice context.
That is solved by this PR along with more rich and complex reentrant needs things that splice script needs.
Super excited to get these complex issues finished!