Skip to content

Commit

Permalink
cryptopkt: revert ack split in authenticate_packet
Browse files Browse the repository at this point in the history
We need to remember the transmit order anyway, so a single counter works.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Aug 9, 2016
1 parent f00ee00 commit 8345bff
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 42 deletions.
17 changes: 7 additions & 10 deletions daemon/cryptopkt.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,19 +408,16 @@ static struct io_plan *check_proof(struct io_conn *conn, struct peer *peer)

/* BOLT #1:
*
* The receiver MUST NOT examine the `commits_seen` or
* The receiver MUST NOT examine the `ack` value until after the
* authentication fields have been successfully validated.
*
* `revocations_seen` values until after the authentication fields
* have been successfully validated. The `commits_seen` field MUST
* BE set to the number of `update_commit` and `open_commit_sig`
* messages received and processed if non-zero. The
* `revocations_seen` MUST BE set to the number of
* `update_revocation` messages received and processed.
* The `ack` field MUST BE set to the number of `update_commit`,
* `open_commit_sig` and `update_revocation` messages received and
* processed.
*/
/* FIXME: Handle reconnects. */
if (auth->commits_seen != 0 || auth->revocations_seen != 0) {
log_unusual(peer->log, "FIXME: non-zero seen %"PRIu64"/%"PRIu64,
auth->commits_seen, auth->revocations_seen);
if (auth->ack != 0) {
log_unusual(peer->log, "FIXME: non-zero ack %"PRIu64, auth->ack);
return io_close(conn);
}

Expand Down
32 changes: 9 additions & 23 deletions lightning.pb-c.c
Original file line number Diff line number Diff line change
Expand Up @@ -1464,9 +1464,8 @@ const ProtobufCMessageDescriptor funding__descriptor =
(ProtobufCMessageInit) funding__init,
NULL,NULL,NULL /* reserved[123] */
};
static const uint64_t authenticate__commits_seen__default_value = 0ull;
static const uint64_t authenticate__revocations_seen__default_value = 0ull;
static const ProtobufCFieldDescriptor authenticate__field_descriptors[4] =
static const uint64_t authenticate__ack__default_value = 0ull;
static const ProtobufCFieldDescriptor authenticate__field_descriptors[3] =
{
{
"node_id",
Expand All @@ -1493,40 +1492,27 @@ static const ProtobufCFieldDescriptor authenticate__field_descriptors[4] =
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"commits_seen",
"ack",
3,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_UINT64,
offsetof(Authenticate, has_commits_seen),
offsetof(Authenticate, commits_seen),
offsetof(Authenticate, has_ack),
offsetof(Authenticate, ack),
NULL,
&authenticate__commits_seen__default_value,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"revocations_seen",
4,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_UINT64,
offsetof(Authenticate, has_revocations_seen),
offsetof(Authenticate, revocations_seen),
NULL,
&authenticate__revocations_seen__default_value,
&authenticate__ack__default_value,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned authenticate__field_indices_by_name[] = {
2, /* field[2] = commits_seen */
2, /* field[2] = ack */
0, /* field[0] = node_id */
3, /* field[3] = revocations_seen */
1, /* field[1] = session_sig */
};
static const ProtobufCIntRange authenticate__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 4 }
{ 0, 3 }
};
const ProtobufCMessageDescriptor authenticate__descriptor =
{
Expand All @@ -1536,7 +1522,7 @@ const ProtobufCMessageDescriptor authenticate__descriptor =
"Authenticate",
"",
sizeof(Authenticate),
4,
3,
authenticate__field_descriptors,
authenticate__field_indices_by_name,
1, authenticate__number_ranges,
Expand Down
10 changes: 4 additions & 6 deletions lightning.pb-c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions lightning.proto
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ message authenticate {
required bitcoin_pubkey node_id = 1;
// Signature of your session key. */
required signature session_sig = 2;
// How many commitment/revocation messages we've already received
optional uint64 commits_seen = 3 [ default = 0 ];
optional uint64 revocations_seen = 4 [ default = 0 ];
// How many update_commit and update_revocation messages already received
optional uint64 ack = 3 [ default = 0 ];
};

// Set channel params.
Expand Down

0 comments on commit 8345bff

Please sign in to comment.