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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2016-08-09 13:11:11 +09:30
parent f00ee00fd8
commit 8345bff825
4 changed files with 22 additions and 42 deletions

View File

@ -408,19 +408,16 @@ static struct io_plan *check_proof(struct io_conn *conn, struct peer *peer)
/* BOLT #1: /* 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 * The `ack` field MUST BE set to the number of `update_commit`,
* have been successfully validated. The `commits_seen` field MUST * `open_commit_sig` and `update_revocation` messages received and
* BE set to the number of `update_commit` and `open_commit_sig` * processed.
* messages received and processed if non-zero. The
* `revocations_seen` MUST BE set to the number of
* `update_revocation` messages received and processed.
*/ */
/* FIXME: Handle reconnects. */ /* FIXME: Handle reconnects. */
if (auth->commits_seen != 0 || auth->revocations_seen != 0) { if (auth->ack != 0) {
log_unusual(peer->log, "FIXME: non-zero seen %"PRIu64"/%"PRIu64, log_unusual(peer->log, "FIXME: non-zero ack %"PRIu64, auth->ack);
auth->commits_seen, auth->revocations_seen);
return io_close(conn); return io_close(conn);
} }

View File

@ -1464,9 +1464,8 @@ const ProtobufCMessageDescriptor funding__descriptor =
(ProtobufCMessageInit) funding__init, (ProtobufCMessageInit) funding__init,
NULL,NULL,NULL /* reserved[123] */ NULL,NULL,NULL /* reserved[123] */
}; };
static const uint64_t authenticate__commits_seen__default_value = 0ull; static const uint64_t authenticate__ack__default_value = 0ull;
static const uint64_t authenticate__revocations_seen__default_value = 0ull; static const ProtobufCFieldDescriptor authenticate__field_descriptors[3] =
static const ProtobufCFieldDescriptor authenticate__field_descriptors[4] =
{ {
{ {
"node_id", "node_id",
@ -1493,40 +1492,27 @@ static const ProtobufCFieldDescriptor authenticate__field_descriptors[4] =
0,NULL,NULL /* reserved1,reserved2, etc */ 0,NULL,NULL /* reserved1,reserved2, etc */
}, },
{ {
"commits_seen", "ack",
3, 3,
PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_UINT64, PROTOBUF_C_TYPE_UINT64,
offsetof(Authenticate, has_commits_seen), offsetof(Authenticate, has_ack),
offsetof(Authenticate, commits_seen), offsetof(Authenticate, ack),
NULL, NULL,
&authenticate__commits_seen__default_value, &authenticate__ack__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,
0, /* flags */ 0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */ 0,NULL,NULL /* reserved1,reserved2, etc */
}, },
}; };
static const unsigned authenticate__field_indices_by_name[] = { static const unsigned authenticate__field_indices_by_name[] = {
2, /* field[2] = commits_seen */ 2, /* field[2] = ack */
0, /* field[0] = node_id */ 0, /* field[0] = node_id */
3, /* field[3] = revocations_seen */
1, /* field[1] = session_sig */ 1, /* field[1] = session_sig */
}; };
static const ProtobufCIntRange authenticate__number_ranges[1 + 1] = static const ProtobufCIntRange authenticate__number_ranges[1 + 1] =
{ {
{ 1, 0 }, { 1, 0 },
{ 0, 4 } { 0, 3 }
}; };
const ProtobufCMessageDescriptor authenticate__descriptor = const ProtobufCMessageDescriptor authenticate__descriptor =
{ {
@ -1536,7 +1522,7 @@ const ProtobufCMessageDescriptor authenticate__descriptor =
"Authenticate", "Authenticate",
"", "",
sizeof(Authenticate), sizeof(Authenticate),
4, 3,
authenticate__field_descriptors, authenticate__field_descriptors,
authenticate__field_indices_by_name, authenticate__field_indices_by_name,
1, authenticate__number_ranges, 1, authenticate__number_ranges,

View File

@ -176,16 +176,14 @@ struct _Authenticate
*/ */
Signature *session_sig; 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; protobuf_c_boolean has_ack;
uint64_t commits_seen; uint64_t ack;
protobuf_c_boolean has_revocations_seen;
uint64_t revocations_seen;
}; };
#define AUTHENTICATE__INIT \ #define AUTHENTICATE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&authenticate__descriptor) \ { PROTOBUF_C_MESSAGE_INIT (&authenticate__descriptor) \
, NULL, NULL, 0,0ull, 0,0ull } , NULL, NULL, 0,0ull }
/* /*

View File

@ -64,9 +64,8 @@ message authenticate {
required bitcoin_pubkey node_id = 1; required bitcoin_pubkey node_id = 1;
// Signature of your session key. */ // Signature of your session key. */
required signature session_sig = 2; required signature session_sig = 2;
// How many commitment/revocation messages we've already received // How many update_commit and update_revocation messages already received
optional uint64 commits_seen = 3 [ default = 0 ]; optional uint64 ack = 3 [ default = 0 ];
optional uint64 revocations_seen = 4 [ default = 0 ];
}; };
// Set channel params. // Set channel params.