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

Update libwally to 0.8.8, Support PSBTv2 and PSETv2 #5898

Merged
merged 6 commits into from
Mar 23, 2023

Conversation

instagibbs
Copy link
Collaborator

@instagibbs instagibbs commented Jan 13, 2023

This contains support for taproot, PSBTv2, removesPSETv0 (elements support break)

For internal PSBT construction(e.g. fundpsbt), RPC still returns v0(unless PSET). If a v0/v2 is passed in RPC, the same version should be returned.

This PR also updates the elementsd binary being run to latest binary release.

@instagibbs
Copy link
Collaborator Author

Will rebase onto #5910 to break elements tests once merged

@instagibbs
Copy link
Collaborator Author

rebasing onto #5910 to see how much more breaks vs #5910

@instagibbs instagibbs marked this pull request as draft January 23, 2023 22:26
@instagibbs instagibbs force-pushed the libwally_update_2 branch 4 times, most recently from 75f1bdf to 7979c9d Compare January 31, 2023 15:05
@instagibbs instagibbs changed the title WIP Update libwally-core to 0.8.8 WIP Support PSBTv2 Jan 31, 2023
@instagibbs
Copy link
Collaborator Author

instagibbs commented Jan 31, 2023

All tests are passing locally for me now. Had to disable a bunch of Elements tests since PSETv0 has been killed off in libwally.

A python library for v2 would be great as a replacement for these bitcoind rpc checks.

edit: actually looks like I'm failing the same number of tests as master 🥇

@instagibbs instagibbs force-pushed the libwally_update_2 branch 5 times, most recently from 7fd3347 to a5366b2 Compare February 1, 2023 21:46
@instagibbs
Copy link
Collaborator Author

Ran the tests locally against bitcoin/bitcoin#21283 for bitcoind, and everything except the test relying on joinpsbt succeeded, which is expected since it's not supporting v2 yet. This demonstrates that the input is being handled correctly for both versions. Might be worth mulling over if this run can be made intermittently to catch regressions.

@instagibbs instagibbs force-pushed the libwally_update_2 branch 3 times, most recently from 5929954 to b008fef Compare February 6, 2023 18:51
@instagibbs
Copy link
Collaborator Author

Sounds like people want canned tests where possible instead of importing wallycore. I'll take a look at seeing what tests I can rescue or increase coverage of PSBTv2 as rpc input.

@instagibbs instagibbs force-pushed the libwally_update_2 branch 5 times, most recently from 77928e3 to 56aa3e7 Compare February 8, 2023 00:00
@instagibbs
Copy link
Collaborator Author

I probably should expose an rpc for converting PSBT versions to allow for easier debugging for end users when they get V2 in logs?

@instagibbs instagibbs force-pushed the libwally_update_2 branch 4 times, most recently from d6c0385 to a66db3a Compare March 2, 2023 21:39
@instagibbs instagibbs force-pushed the libwally_update_2 branch 5 times, most recently from 7ba0b5f to 002092d Compare March 3, 2023 03:22
Copy link
Contributor

@rustyrussell rustyrussell left a comment

Choose a reason for hiding this comment

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

This is glorious!

I went through with a fine-tooth comb, and added as many nits as I could pick.

wallet/test/run-wallet.c Show resolved Hide resolved
external/libwally-core Outdated Show resolved Hide resolved
@@ -264,7 +252,7 @@ void psbt_input_add_pubkey(struct wally_psbt *psbt, size_t in,
pubkey_to_der(pk_der, pubkey);

tal_wally_start();
wally_err = wally_psbt_input_add_keypath_item(&psbt->inputs[in],
wally_err = wally_psbt_input_keypath_add(&psbt->inputs[in],
pk_der, sizeof(pk_der),
Copy link
Contributor

Choose a reason for hiding this comment

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

This commit is so big, I suggest an indent fixup commit at the end, if anything.

bitcoin/psbt.c Show resolved Hide resolved
bitcoin/psbt.c Outdated Show resolved Hide resolved
tests/test_misc.py Outdated Show resolved Hide resolved
wallet/walletrpc.c Outdated Show resolved Hide resolved
wallet/walletrpc.c Outdated Show resolved Hide resolved
tests/test_wallet.py Outdated Show resolved Hide resolved
tests/test_wallet.py Outdated Show resolved Hide resolved
Which gets libwally upset post-update to 0.8.8
@rustyrussell
Copy link
Contributor

Deserves a changelog. I think two?

Changelog-Changed: JSON-RPC: elements network PSET now only supports PSETv2.
Changelog-Added: JSON-RPC: PSBTv2 supported for fundchannel_complete, openchannel_update, reserveinputs, sendpsbt, signpsbt, withdraw and unreserveinputs parameter psbt, openchannel_init and openchannel_bump parameter initialpsbt, openchannel_signed parameter signed_psbt and utxopsbt parameter utxopsbt

Copy link
Collaborator

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

There are a couple of other extra { } inside some if statements, but overall I guess LGTM , these are just style comments 😸

static struct wally_tx_input *wally_tx_input_from_outpoint_sequence(const struct bitcoin_outpoint *outpoint,
u32 sequence)
{
struct wally_tx_input *tx_in;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
struct wally_tx_input *tx_in;
struct wally_tx_input *tx_in;

here there is a space nit

Comment on lines +203 to +211
abort();
} else {
if (wally_tx_input_init_alloc(outpoint->txid.shad.sha.u.u8,
sizeof(outpoint->txid.shad.sha.u.u8),
outpoint->n,
sequence, NULL, 0, NULL,
&tx_in) != WALLY_OK)
abort();
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not a big expert on this part of the code but it is possible abort with some more useful message? I think this case will never be true in the same case, but do you think that it will be useful to print some more information?

Comment on lines +579 to +581
if (wally_psbt_extract(psbt, WALLY_PSBT_EXTRACT_NON_FINAL, &tx->wtx) != WALLY_OK) {
tx->wtx = NULL;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

we can remove the { .. } from here?

@@ -35,18 +35,16 @@ void psbt_finalize_input(const tal_t *ctx,
* on these just .. ignores it!? Murder. Anyway, here we do a final
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should open an issue for this? so at least we do not forget

common/psbt_internal.c Outdated Show resolved Hide resolved
common/psbt_open.c Outdated Show resolved Hide resolved
lightningd/dual_open_control.c Show resolved Hide resolved
@instagibbs
Copy link
Collaborator Author

instagibbs commented Mar 21, 2023

@rustyrussell what's the process for noting/aggregating changelog? got it

@instagibbs
Copy link
Collaborator Author

Pushed a couple more nit fixes and changelogs in commit messages

Libwally update breaks compatibility, so
we do this in one large step.

Changelog-Changed: JSON-RPC: elements network PSET now only supports PSETv2.
Changelog-Added: JSON-RPC: PSBTv2 supported for fundchannel_complete, openchannel_update, reserveinputs, sendpsbt, signpsbt, withdraw and unreserveinputs parameter psbt, openchannel_init and openchannel_bump parameter initialpsbt, openchannel_signed parameter signed_psbt and utxopsbt parameter utxopsbt
PSBTv2 support is quite low in the ecosystem, so having a call to convert
log messages and the like should be useful since they'll often be in v2.

Changelog-Added: Added setpsbtversion RPC to aid debugging and compatibility
Copy link
Contributor

@rustyrussell rustyrussell left a comment

Choose a reason for hiding this comment

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

Ack 63fbcec

@rustyrussell rustyrussell merged commit e7bf529 into ElementsProject:master Mar 23, 2023
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.

5 participants