Skip to content

Commit f513ee4

Browse files
committed
splice: Update commitment_signed_tlvs
As per eclair spec proposal. 1) A renaming to `funding_txid` 2) Adding of `batch_size` to indicate how many commitment_signed msgs are expected. Changelog-None
1 parent adf1d25 commit f513ee4

File tree

3 files changed

+37
-16
lines changed

3 files changed

+37
-16
lines changed

channeld/channeld.c

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,8 @@ static u8 *send_commit_part(const tal_t *ctx,
11351135
s64 remote_splice_amnt,
11361136
u64 remote_index,
11371137
const struct pubkey *remote_per_commit,
1138-
struct local_anchor_info **anchor)
1138+
struct local_anchor_info **anchor,
1139+
u16 batch_size)
11391140
{
11401141
u8 *msg;
11411142
struct bitcoin_signature commit_sig, *htlc_sigs;
@@ -1159,8 +1160,11 @@ static u8 *send_commit_part(const tal_t *ctx,
11591160
(int)splice_amnt, (int)remote_splice_amnt,
11601161
remote_index);
11611162

1162-
cs_tlv->splice_info = tal(cs_tlv, struct channel_id);
1163-
derive_channel_id(cs_tlv->splice_info, funding);
1163+
cs_tlv->splice_info = tal(cs_tlv,
1164+
struct tlv_commitment_signed_tlvs_splice_info);
1165+
1166+
cs_tlv->splice_info->batch_size = batch_size;
1167+
derive_channel_id(&cs_tlv->splice_info->funding_txid, funding);
11641168
}
11651169

11661170
txs = channel_txs(tmpctx, funding, funding_sats, &htlc_map,
@@ -1236,6 +1240,7 @@ static void send_commit(struct peer *peer)
12361240
u32 feerate_target;
12371241
u8 **msgs = tal_arr(tmpctx, u8*, 1);
12381242
u8 *msg;
1243+
u16 batch_size = tal_count(peer->splice_state->inflights) + 1;
12391244
struct local_anchor_info *local_anchor, *anchors_info;
12401245

12411246
if (peer->dev_disable_commit && !*peer->dev_disable_commit) {
@@ -1350,7 +1355,8 @@ static void send_commit(struct peer *peer)
13501355
msgs[0] = send_commit_part(msgs, peer, &peer->channel->funding,
13511356
peer->channel->funding_sats, changed_htlcs,
13521357
true, 0, 0, peer->next_index[REMOTE],
1353-
&peer->remote_per_commit, &local_anchor);
1358+
&peer->remote_per_commit, &local_anchor,
1359+
batch_size);
13541360
if (local_anchor)
13551361
tal_arr_expand(&anchors_info, *local_anchor);
13561362

@@ -1378,7 +1384,8 @@ static void send_commit(struct peer *peer)
13781384
remote_splice_amnt,
13791385
peer->next_index[REMOTE],
13801386
&peer->remote_per_commit,
1381-
&local_anchor));
1387+
&local_anchor,
1388+
batch_size);
13821389
if (local_anchor)
13831390
tal_arr_expand(&anchors_info, *local_anchor);
13841391
}
@@ -1877,10 +1884,12 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
18771884
derive_channel_id(&active_id, &peer->channel->funding);
18781885
if (peer->splice_state->await_commitment_succcess
18791886
&& !tal_count(peer->splice_state->inflights) && cs_tlv && cs_tlv->splice_info) {
1880-
if (!channel_id_eq(&active_id, cs_tlv->splice_info)) {
1887+
if (!channel_id_eq(&active_id,
1888+
&cs_tlv->splice_info->funding_txid)) {
18811889
status_info("Ignoring stale commit_sig for channel_id"
18821890
" %s, as %s is locked in now.",
1883-
fmt_channel_id(tmpctx, cs_tlv->splice_info),
1891+
fmt_channel_id(tmpctx,
1892+
&cs_tlv->splice_info->funding_txid),
18841893
fmt_channel_id(tmpctx, &active_id));
18851894
return NULL;
18861895
}
@@ -1983,7 +1992,7 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
19831992
fmt_channel_id(tmpctx, &active_id),
19841993
cs_tlv && cs_tlv->splice_info
19851994
? fmt_channel_id(tmpctx,
1986-
cs_tlv->splice_info)
1995+
&cs_tlv->splice_info->funding_txid)
19871996
: "N/A",
19881997
peer->splice_state->await_commitment_succcess ? "yes"
19891998
: "no",
@@ -2737,7 +2746,8 @@ static struct commitsig *interactive_send_commitments(struct peer *peer,
27372746
remote_splice_amnt,
27382747
next_index_remote - 1,
27392748
&peer->old_remote_per_commit,
2740-
&local_anchor));
2749+
&local_anchor,
2750+
1);
27412751
}
27422752

27432753
result = NULL;
@@ -2793,7 +2803,8 @@ static struct commitsig *interactive_send_commitments(struct peer *peer,
27932803
remote_splice_amnt,
27942804
next_index_remote - 1,
27952805
&peer->old_remote_per_commit,
2796-
&local_anchor));
2806+
&local_anchor,
2807+
1));
27972808
}
27982809

27992810
/* Sending and receiving splice commit should not increment commit
@@ -4559,6 +4570,7 @@ static void resend_commitment(struct peer *peer, struct changed_htlc *last)
45594570
u8 *msg;
45604571
u8 **msgs = tal_arr(tmpctx, u8*, 1);
45614572
struct local_anchor_info *local_anchor;
4573+
u16 batch_size = tal_count(peer->splice_state->inflights) + 1;
45624574

45634575
status_debug("Retransmitting commitment, feerate LOCAL=%u REMOTE=%u,"
45644576
" blockheight LOCAL=%u REMOTE=%u",
@@ -4653,7 +4665,7 @@ static void resend_commitment(struct peer *peer, struct changed_htlc *last)
46534665
peer->channel->funding_sats, NULL,
46544666
false, 0, 0, peer->next_index[REMOTE] - 1,
46554667
&peer->remote_per_commit,
4656-
&local_anchor);
4668+
&local_anchor, batch_size);
46574669

46584670
/* Loop over current inflights
46594671
* BOLT-0d8b701614b09c6ee4172b04da2203e73deec7e2 #2:
@@ -4679,7 +4691,7 @@ static void resend_commitment(struct peer *peer, struct changed_htlc *last)
46794691
remote_splice_amnt,
46804692
peer->next_index[REMOTE] - 1,
46814693
&peer->remote_per_commit,
4682-
&local_anchor));
4694+
&local_anchor, batch_size));
46834695
}
46844696

46854697
for(i = 0; i < tal_count(msgs); i++)

wire/peer_wire.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ msgdata,commitment_signed,num_htlcs,u16,
269269
msgdata,commitment_signed,htlc_signature,signature,num_htlcs
270270
msgdata,commitment_signed,splice_channel_id,commitment_signed_tlvs,
271271
tlvtype,commitment_signed_tlvs,splice_info,0
272-
tlvdata,commitment_signed_tlvs,splice_info,splice_channel_id,channel_id,
272+
tlvdata,commitment_signed_tlvs,splice_info,batch_size,u16,
273+
tlvdata,commitment_signed_tlvs,splice_info,funding_txid,channel_id,
273274
msgtype,revoke_and_ack,133
274275
msgdata,revoke_and_ack,channel_id,channel_id,
275276
msgdata,revoke_and_ack,per_commitment_secret,byte,32

wire/test/run-peer-wire.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,12 +792,19 @@ static bool update_fail_htlc_eq(const struct msg_update_fail_htlc *a,
792792
&& eq_var(a, b, reason);
793793
}
794794

795+
static bool tlv_splice_info_eq(const struct tlv_commitment_signed_tlvs_splice_info *a,
796+
const struct tlv_commitment_signed_tlvs_splice_info *b)
797+
{
798+
return eq_field(a, b, batch_size)
799+
&& eq_field(a, b, funding_txid);
800+
}
801+
795802
static bool commitment_signed_eq(const struct msg_commitment_signed *a,
796803
const struct msg_commitment_signed *b)
797804
{
798805
return eq_upto(a, b, htlc_signature)
799806
&& eq_var(a, b, htlc_signature)
800-
&& eq_tlv(a, b, splice_info, channel_id_eq);
807+
&& eq_tlv(a, b, splice_info, tlv_splice_info_eq);
801808
}
802809

803810
static bool funding_signed_eq(const struct msg_funding_signed *a,
@@ -1019,8 +1026,9 @@ int main(int argc, char *argv[])
10191026
cs.htlc_signature = tal_arr(ctx, secp256k1_ecdsa_signature, 2);
10201027
memset(cs.htlc_signature, 2, sizeof(secp256k1_ecdsa_signature)*2);
10211028
cs.tlvs = tlv_commitment_signed_tlvs_new(tmpctx);
1022-
cs.tlvs->splice_info = tal(ctx, struct channel_id);
1023-
set_cid(cs.tlvs->splice_info);
1029+
cs.tlvs->splice_info = tal(ctx, struct tlv_commitment_signed_tlvs_splice_info);
1030+
cs.tlvs->splice_info->batch_size = 1;
1031+
set_cid(&cs.tlvs->splice_info->funding_txid);
10241032

10251033
msg = towire_struct_commitment_signed(ctx, &cs);
10261034
cs2 = fromwire_struct_commitment_signed(ctx, msg);

0 commit comments

Comments
 (0)