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

Collaborative transaction building #5287

Merged
merged 1 commit into from
Nov 2, 2022

Conversation

ddustin
Copy link
Collaborator

@ddustin ddustin commented May 24, 2022

Takes @niftynei's dualopen collaborative transaction building and makes it available for other daemons to use.

This is to make it available for channeld to do splicing and also other code that may want to us it in the future!

@ddustin ddustin force-pushed the ddustin/interactivetx branch 10 times, most recently from c1e118a to 465a318 Compare May 24, 2022 22:02
@ddustin ddustin marked this pull request as ready for review May 24, 2022 22:57
@ddustin ddustin force-pushed the ddustin/interactivetx branch 2 times, most recently from 5ca53bf to 7a8813f Compare May 26, 2022 00:40
Copy link
Contributor

@niftynei niftynei left a comment

Choose a reason for hiding this comment

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

Bunch of small nits and things, but overall lgtm! Biggest thing is that there's a decent amount of setup needed for the ictx -- do you have a new_ictx method somewhere that encapsulates this?

common/interactivetx.h Outdated Show resolved Hide resolved
common/interactivetx.h Outdated Show resolved Hide resolved
common/interactivetx.c Outdated Show resolved Hide resolved
common/interactivetx.h Outdated Show resolved Hide resolved
common/interactivetx.c Outdated Show resolved Hide resolved
common/interactivetx.c Outdated Show resolved Hide resolved
common/interactivetx.c Outdated Show resolved Hide resolved
common/interactivetx.c Outdated Show resolved Hide resolved
common/interactivetx.c Outdated Show resolved Hide resolved
common/interactivetx.c Outdated Show resolved Hide resolved
@niftynei niftynei added this to the v22.10 milestone Jul 11, 2022
@cdecker
Copy link
Member

cdecker commented Sep 12, 2022

This appears to duplicate a lot of code that, when changed, will cause things to slowly drift apart. Any chance of not just extracting this but also to rewire the existing uses to use interactivetx.c?

@ddustin
Copy link
Collaborator Author

ddustin commented Sep 12, 2022

This appears to duplicate a lot of code that, when changed, will cause things to slowly drift apart. Any chance of not just extracting this but also to rewire the existing uses to use interactivetx.c?

Yeah definitely. The plan is to make dual open use this code, cutting out its internal implementation, probably next release ish? Also a good moment for some interim tests to look for behavior changes in the refactor.

Dual open is currently the only user of interactivetx but splicing and dual close will want to use it.

@cdecker
Copy link
Member

cdecker commented Sep 19, 2022

Excellent, thanks @ddustin. Want me to wait for dualopend to be migrated on top of interactivetx.c or would you like to hand this PR over as is (and create an issue so we don't forget about the migration) and I can shepherd it through CI as is.

common/interactivetx.h Outdated Show resolved Hide resolved
@ddustin ddustin force-pushed the ddustin/interactivetx branch 3 times, most recently from 4366fca to 6f1f6e7 Compare October 27, 2022 18:26
Copy link
Contributor

@niftynei niftynei left a comment

Choose a reason for hiding this comment

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

ACK with a few changes! lgtm, let's goo!

ictx->channel_id = channel_id;
ictx->tx_msg_count[TX_ADD_INPUT] = 0;
ictx->tx_msg_count[TX_ADD_OUTPUT] = 0;
ictx->tx_msg_count[TX_RM_INPUT] = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

i think we can remove the "RM" counts, as the spec only counts adds (for the reason that you'll hit the add limit first!)

struct channel_id channel_id);

/* Blocks the thread until we run out of changes (and we send tx_complete),
* or an error occurs. If 'pause_when_complete' is set, this behavior changes
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* or an error occurs. If 'pause_when_complete' is set, this behavior changes
* or an error occurs. If 'pause_when_complete' on the `interactivetx_context` is set, this behavior changes

struct interactivetx_context {

/* Users can set this to their own context */
void *ctx;
Copy link
Contributor

Choose a reason for hiding this comment

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

ctx means "allocation context", should we call it data_ptr?

char *error = NULL;
struct wally_psbt *next_psbt;

if (ictx->current_psbt == NULL)
Copy link
Contributor

Choose a reason for hiding this comment

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

move this to the new_itctx method?

* Otherwise we advance `current_psbt` to `next_psbt` and begin
* processing the change set in `ictx->change_set` */
if (ictx->current_psbt != next_psbt) {
tal_free(ictx->current_psbt);
Copy link
Contributor

Choose a reason for hiding this comment

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

cannot free this until the change_set is free'd!

struct channel_id *cid = &ictx->channel_id;
struct psbt_changeset *set = ictx->change_set;
u64 serial_id;
u8 *msg = NULL;
Copy link
Contributor

Choose a reason for hiding this comment

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

do not set msg here, leave for later code to fill in.

@cdecker
Copy link
Member

cdecker commented Oct 31, 2022

ACK with a few changes! lgtm, let's goo!

Gotcha, I'll shepherd this through CI and merge ASAP ^^

ACK 6f1f6e7

@cdecker cdecker force-pushed the ddustin/interactivetx branch 2 times, most recently from 141f96c to 2fae6ba Compare November 1, 2022 12:01
Takes the dualopen collaborative transaction building and makes it available for other daemons to use

Changelog-Added: Added interactive transaction building routine
@cdecker cdecker force-pushed the ddustin/interactivetx branch from 2fae6ba to 1bb20c3 Compare November 1, 2022 16:07
@cdecker cdecker merged commit 76623b2 into ElementsProject:master Nov 2, 2022
rustyrussell added a commit to rustyrussell/lightning that referenced this pull request Nov 19, 2022
And internal changes don't get CHANGELOG entries, so removed
"- Added interactive transaction building routine ([ElementsProject#5287])".

We need to come up with some way of marking rust crate changes,
as it's not immediately obvious what "- cln-plugin" means?

Maybe we switch from JSON-RPC to Control as a more general
prefix?

Signed-off-by: Rusty Russell <[email protected]>
rustyrussell added a commit to rustyrussell/lightning that referenced this pull request Nov 24, 2022
And internal changes don't get CHANGELOG entries, so removed
"- Added interactive transaction building routine ([ElementsProject#5287])".

We need to come up with some way of marking rust crate changes,
as it's not immediately obvious what "- cln-plugin" means?

Maybe we switch from JSON-RPC to Control as a more general
prefix?

Signed-off-by: Rusty Russell <[email protected]>
cdecker pushed a commit that referenced this pull request Nov 25, 2022
And internal changes don't get CHANGELOG entries, so removed
"- Added interactive transaction building routine ([#5287])".

We need to come up with some way of marking rust crate changes,
as it's not immediately obvious what "- cln-plugin" means?

Maybe we switch from JSON-RPC to Control as a more general
prefix?

Signed-off-by: Rusty Russell <[email protected]>
ddustin pushed a commit to ddustin/lightning that referenced this pull request Apr 11, 2023
And internal changes don't get CHANGELOG entries, so removed
"- Added interactive transaction building routine ([ElementsProject#5287])".

We need to come up with some way of marking rust crate changes,
as it's not immediately obvious what "- cln-plugin" means?

Maybe we switch from JSON-RPC to Control as a more general
prefix?

Signed-off-by: Rusty Russell <[email protected]>
ddustin pushed a commit to ddustin/lightning that referenced this pull request May 12, 2023
And internal changes don't get CHANGELOG entries, so removed
"- Added interactive transaction building routine ([ElementsProject#5287])".

We need to come up with some way of marking rust crate changes,
as it's not immediately obvious what "- cln-plugin" means?

Maybe we switch from JSON-RPC to Control as a more general
prefix?

Signed-off-by: Rusty Russell <[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.

3 participants