From 8345bff825da347e2c836b0ad2bb13bc03c270ab Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 9 Aug 2016 13:11:11 +0930 Subject: [PATCH] cryptopkt: revert ack split in authenticate_packet We need to remember the transmit order anyway, so a single counter works. Signed-off-by: Rusty Russell --- daemon/cryptopkt.c | 17 +++++++---------- lightning.pb-c.c | 32 +++++++++----------------------- lightning.pb-c.h | 10 ++++------ lightning.proto | 5 ++--- 4 files changed, 22 insertions(+), 42 deletions(-) diff --git a/daemon/cryptopkt.c b/daemon/cryptopkt.c index ed5e06513..e4d5865ff 100644 --- a/daemon/cryptopkt.c +++ b/daemon/cryptopkt.c @@ -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); } diff --git a/lightning.pb-c.c b/lightning.pb-c.c index b666ed274..d1a3ead3c 100644 --- a/lightning.pb-c.c +++ b/lightning.pb-c.c @@ -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", @@ -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 = { @@ -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, diff --git a/lightning.pb-c.h b/lightning.pb-c.h index 0d5f3c257..7fdf9aa40 100644 --- a/lightning.pb-c.h +++ b/lightning.pb-c.h @@ -176,16 +176,14 @@ struct _Authenticate */ Signature *session_sig; /* - * How many commitment/revocation messages we've already received + * How many update_commit and update_revocation messages already received */ - protobuf_c_boolean has_commits_seen; - uint64_t commits_seen; - protobuf_c_boolean has_revocations_seen; - uint64_t revocations_seen; + protobuf_c_boolean has_ack; + uint64_t ack; }; #define AUTHENTICATE__INIT \ { PROTOBUF_C_MESSAGE_INIT (&authenticate__descriptor) \ - , NULL, NULL, 0,0ull, 0,0ull } + , NULL, NULL, 0,0ull } /* diff --git a/lightning.proto b/lightning.proto index 0d9b6c574..ce951414e 100644 --- a/lightning.proto +++ b/lightning.proto @@ -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.