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

RBF: Final part #4399

Merged
merged 23 commits into from
Mar 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
84d7b29
df-rbf: init an rbf for real, using openchannel_bumpfee
niftynei Jan 25, 2021
e49a241
df-rbf: handle rbf failures in lightningd
niftynei Jan 25, 2021
fc051d1
df: update reserve calculation
niftynei Feb 3, 2021
fee2c15
df-rbf: only permit the channel initiator to init RBF
niftynei Feb 4, 2021
24ea527
df-rbf: separate first-time channel save from update (RBF)
niftynei Feb 4, 2021
17c3382
rbf: consolidate failure paths, use "warnings"
niftynei Feb 8, 2021
2f40c6b
rbf: clean up channel on error
niftynei Feb 9, 2021
d04de94
df: move methods around so we can call them elsewhere
niftynei Feb 9, 2021
6fb06fa
df: handle funding_locked + tx_signatures messages out of order
niftynei Feb 9, 2021
e2f0987
listpeers: include info on channels that are in-process
niftynei Feb 24, 2021
4c5024c
channel: move inflight + feerate methods to channel.c
niftynei Feb 19, 2021
8acc78f
listpeers: include feerate info for RBF-candidate channels
niftynei Feb 24, 2021
ea06a4c
df-rbf: update rejection criteria for tx_sigs
niftynei Feb 10, 2021
97f0fe8
df: cleanup error handling on lightningd side
niftynei Feb 16, 2021
2773688
df-tests: happy path rbf test
niftynei Feb 4, 2021
10fb911
df-rbf: reconnection tests (init_rbf + ack_rbf)
niftynei Feb 10, 2021
1401761
df-rbf: test for interrupts during tx construction
niftynei Feb 10, 2021
796b4ea
df-tests: check that multiple RBFs and tx-sigs errors during RBF work
niftynei Feb 11, 2021
3ac665b
df-tests: check that rbf includes overlapping inputs
niftynei Feb 11, 2021
3dd2166
Revert "df: turn off integration tests that depend on v2 funding"
niftynei Feb 27, 2021
edb888b
df-memleak: expose memleak error and fix
niftynei Mar 4, 2021
36460c9
df: add (over zealous?) note about the usage of `psbt_has_req_fields`
niftynei Mar 5, 2021
4b7af79
connectd: clean up the channel stuffs when we get a reconnect
niftynei Mar 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,6 @@ static void peer_in(struct peer *peer, const u8 *msg)
return;
case WIRE_INIT_RBF:
case WIRE_ACK_RBF:
case WIRE_FAIL_RBF:
case WIRE_BLACKLIST_PODLE:
#endif
break;
Expand Down
1 change: 0 additions & 1 deletion gossipd/gossipd.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,6 @@ static struct io_plan *peer_msg_in(struct io_conn *conn,
case WIRE_ACCEPT_CHANNEL2:
case WIRE_INIT_RBF:
case WIRE_ACK_RBF:
case WIRE_FAIL_RBF:
case WIRE_BLACKLIST_PODLE:
#endif
status_broken("peer %s: relayed unexpected msg of type %s",
Expand Down
52 changes: 51 additions & 1 deletion lightningd/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,47 @@ void channel_fail_forget(struct channel *channel, const char *fmt, ...)
tal_free(why);
}

struct channel_inflight *
channel_current_inflight(const struct channel *channel)
{
struct channel_inflight *inflight;
/* The last inflight should always be the one in progress */
inflight = list_tail(&channel->inflights,
struct channel_inflight,
list);
if (inflight)
assert(bitcoin_txid_eq(&channel->funding_txid,
&inflight->funding->txid));
return inflight;
}

u32 channel_last_funding_feerate(const struct channel *channel)
{
struct channel_inflight *inflight;
inflight = channel_current_inflight(channel);
if (!inflight)
return 0;
return inflight->funding->feerate;
}

void channel_cleanup_commands(struct channel *channel, const char *why)
{
if (channel->open_attempt) {
struct open_attempt *oa = channel->open_attempt;
if (oa->cmd)
was_pending(command_fail(oa->cmd, LIGHTNINGD,
"%s", why));
notify_channel_open_failed(channel->peer->ld, &channel->cid);
channel->open_attempt = tal_free(channel->open_attempt);
}

if (channel->openchannel_signed_cmd) {
was_pending(command_fail(channel->openchannel_signed_cmd,
LIGHTNINGD, "%s", why));
channel->openchannel_signed_cmd = NULL;
}
}

void channel_internal_error(struct channel *channel, const char *fmt, ...)
{
va_list ap;
Expand All @@ -724,9 +765,18 @@ void channel_internal_error(struct channel *channel, const char *fmt, ...)
why = tal_vfmt(channel, fmt, ap);
va_end(ap);

log_broken(channel->log, "Peer internal error %s: %s",
log_broken(channel->log, "Internal error %s: %s",
channel_state_name(channel), why);

channel_cleanup_commands(channel, why);

if (channel_unsaved(channel)) {
subd_release_channel(channel->owner, channel);
delete_channel(channel);
tal_free(why);
return;
}

/* Don't expose internal error causes to remove unless doing dev */
#if DEVELOPER
channel_fail_permanent(channel, REASON_LOCAL, "Internal error: %s", why);
Expand Down
10 changes: 10 additions & 0 deletions lightningd/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,13 @@ new_inflight(struct channel *channel,
struct channel_inflight *channel_inflight_find(struct channel *channel,
const struct bitcoin_txid *txid);

/* What's the most recent inflight for this channel? */
struct channel_inflight *
channel_current_inflight(const struct channel *channel);

/* What's the last feerate used for a funding tx on this channel? */
u32 channel_last_funding_feerate(const struct channel *channel);

void delete_channel(struct channel *channel STEALS);

const char *channel_state_name(const struct channel *channel);
Expand All @@ -311,6 +318,9 @@ void channel_fail_forget(struct channel *channel, const char *fmt, ...);
/* Permanent error, but due to internal problems, not peer. */
void channel_internal_error(struct channel *channel, const char *fmt, ...);

/* Clean up any in-progress commands for a channel */
void channel_cleanup_commands(struct channel *channel, const char *why);

void channel_set_state(struct channel *channel,
enum channel_state old_state,
enum channel_state state,
Expand Down
6 changes: 4 additions & 2 deletions lightningd/connect_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,16 @@ static void peer_please_disconnect(struct lightningd *ld, const u8 *msg)
c = active_channel_by_id(ld, &id, &uc);
if (uc)
kill_uncommitted_channel(uc, "Reconnected");
else if (c)
else if (c) {
channel_cleanup_commands(c, "Reconnected");
channel_fail_reconnect(c, "Reconnected");
}
#if EXPERIMENTAL_FEATURES
else {
/* v2 has unsaved channels, not uncommitted_chans */
c = unsaved_channel_by_id(ld, &id);
if (c)
kill_unsaved_channel(c, "Reconnected");
channel_close_conn(c, "Reconnected");
}
#endif /* EXPERIMENTAL_FEATURES */
}
Expand Down
Loading