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

lightningd: fix occasional missing txid detection. #2776

Merged

Conversation

rustyrussell
Copy link
Contributor

I was working on rewriting our (somewhat chaotic) tx watching code
for 0.7.2, when I found this bug: we don't always notice the funding
tx in corner cases where more than one block is detected at
once.

This is just the one commit needed to fix the problem: it has some
unnecessary changes, but I'd prefer not to diverge too far from my
cleanup-txwatch branch.

Fixes: #2352
Signed-off-by: Rusty Russell rusty@rustcorp.com.au

I was working on rewriting our (somewhat chaotic) tx watching code
for 0.7.2, when I found this bug: we don't always notice the funding
tx in corner cases where more than one block is detected at
once.

This is just the one commit needed to fix the problem: it has some
unnecessary changes, but I'd prefer not to diverge too far from my
cleanup-txwatch branch.

Fixes: ElementsProject#2352
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
@rustyrussell rustyrussell added this to the 0.7.1 milestone Jun 28, 2019
@rustyrussell rustyrussell requested review from cdecker and niftynei June 28, 2019 02:14
txw = txwatch_hash_get(&topo->txwatches, txid);

if (txw && !txw->tx)
txw->tx = tal_steal(txw, tx_may_steal);
Copy link
Contributor

Choose a reason for hiding this comment

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

In case multiple watchers are watching the same txid (channel factories in the far future, where multiple peer-daemons want to see the confirmation depth of the same tx holding the channel factory), would not this stealing be troublesome? Would not be better to tal_dup instead?

Copy link
Contributor Author

@rustyrussell rustyrussell Jun 28, 2019

Choose a reason for hiding this comment

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

We need a deep copy, hence the FIXME in the header. libwally doesn't provide a copy function, which would make it easy to implement bitcoin_tx_dup().

Copy link
Contributor

@ZmnSCPxj ZmnSCPxj Jun 28, 2019

Choose a reason for hiding this comment

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

A lousy deep copy would be to serialize, then deserialize, i.e. the "JSON.parse(JSON.stringify())" trick.

Though I suppose, this is fine for now, we can always panic later when we actually have channel factories.

Copy link
Contributor

@ZmnSCPxj ZmnSCPxj left a comment

Choose a reason for hiding this comment

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

ACK 8e3a13b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Channel stuck: CHANNELD_AWAITING_LOCKIN
2 participants