Browse Source

Make all internal message numbers unique.

We were sending a channeld message to onchaind, which was v. confusing
due to overlap.  We make all the numbers distinct, which means we can
also add an assert() that it's valid for that daemon, which catches
such errors immediately.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
72b215f6fe
  1. 46
      channeld/channel_wire.csv
  2. 8
      closingd/closing_wire.csv
  3. 48
      gossipd/gossip_wire.csv
  4. 22
      handshaked/handshake_wire.csv
  5. 1
      lightningd/subd.c
  6. 22
      onchaind/onchain_wire.csv
  7. 10
      openingd/opening_wire.csv

46
channeld/channel_wire.csv

@ -1,11 +1,11 @@
# Received and sent funding_locked
channel_normal_operation,1001
channel_normal_operation,11001
#include <common/cryptomsg.h>
#include <common/channel_config.h>
# Begin! (passes gossipd-client fd)
channel_init,1
channel_init,1000
channel_init,,chain_hash,struct sha256_double
channel_init,,funding_txid,struct sha256_double
channel_init,,funding_txout,2
@ -58,21 +58,21 @@ channel_init,,init_peer_pkt_len,u16
channel_init,,init_peer_pkt,init_peer_pkt_len*u8
# Tx is deep enough, go!
channel_funding_locked,2
channel_funding_locked,1002
channel_funding_locked,,short_channel_id,struct short_channel_id
# Tell the channel that we may announce the channel's existence
channel_funding_announce_depth,3
channel_funding_announce_depth,1003
# Tell channel to offer this htlc
channel_offer_htlc,4
channel_offer_htlc,1004
channel_offer_htlc,,amount_msat,8
channel_offer_htlc,,cltv_expiry,4
channel_offer_htlc,,payment_hash,32
channel_offer_htlc,,onion_routing_packet,1366*u8
# Reply; synchronous since IDs have to increment.
channel_offer_htlc_reply,104
channel_offer_htlc_reply,1104
channel_offer_htlc_reply,,id,8
# Zero failure code means success.
channel_offer_htlc_reply,,failure_code,2
@ -81,12 +81,12 @@ channel_offer_htlc_reply,,failurestr,failurestrlen*u8
# Main daemon found out the preimage for an htlc
#include <bitcoin/preimage.h>
channel_fulfill_htlc,5
channel_fulfill_htlc,1005
channel_fulfill_htlc,,id,8
channel_fulfill_htlc,,payment_preimage,struct preimage
# Main daemon says HTLC failed
channel_fail_htlc,6
channel_fail_htlc,1006
channel_fail_htlc,,id,8
# If malformed is non-zero, it's a BADONION code
channel_fail_htlc,,malformed,u16
@ -95,22 +95,22 @@ channel_fail_htlc,,len,2
channel_fail_htlc,,error_pkt,len*u8
# Ping/pong test.
channel_ping,11
channel_ping,1011
channel_ping,,num_pong_bytes,u16
channel_ping,,len,u16
channel_ping_reply,111
channel_ping_reply,1111
channel_ping_reply,,totlen,u16
# Channeld tells the master that the channel has been announced
channel_announced,12
channel_announced,1012
# When we receive funding_locked.
channel_got_funding_locked,19
channel_got_funding_locked,1019
channel_got_funding_locked,,next_per_commit_point,struct pubkey
# When we send a commitment_signed message, tell master.
channel_sending_commitsig,20
channel_sending_commitsig,1020
channel_sending_commitsig,,commitnum,u64
# SENT_ADD_COMMIT, SENT_REMOVE_ACK_COMMIT, SENT_ADD_ACK_COMMIT, SENT_REMOVE_COMMIT
channel_sending_commitsig,,num_changed,u16
@ -120,10 +120,10 @@ channel_sending_commitsig,,num_htlc_sigs,u16
channel_sending_commitsig,,htlc_sigs,num_htlc_sigs*secp256k1_ecdsa_signature
# Wait for reply, to make sure it's on disk before we send commit.
channel_sending_commitsig_reply,120
channel_sending_commitsig_reply,1120
# When we have a commitment_signed message, tell master to remember.
channel_got_commitsig,21
channel_got_commitsig,1021
channel_got_commitsig,,commitnum,u64
channel_got_commitsig,,signature,secp256k1_ecdsa_signature
channel_got_commitsig,,num_htlcs,u16
@ -143,11 +143,11 @@ channel_got_commitsig,,changed,num_changed*struct changed_htlc
channel_got_commitsig,,tx,struct bitcoin_tx
# Wait for reply, to make sure it's on disk before we send revocation.
channel_got_commitsig_reply,121
channel_got_commitsig_reply,1121
#include <common/htlc_wire.h>
channel_got_revoke,22
channel_got_revoke,1022
channel_got_revoke,,revokenum,u64
channel_got_revoke,,per_commitment_secret,struct sha256
channel_got_revoke,,next_per_commit_point,struct pubkey
@ -156,22 +156,22 @@ channel_got_revoke,,num_changed,u16
channel_got_revoke,,changed,num_changed*struct changed_htlc
# Wait for reply, to make sure it's on disk before we continue
# (eg. if we sent another commitment_signed, that would implicitly ack).
channel_got_revoke_reply,122
channel_got_revoke_reply,1122
# Tell peer that channel is shutting down
channel_send_shutdown,23
channel_send_shutdown,1023
channel_send_shutdown,,scriptpubkey_len,u16
channel_send_shutdown,,scriptpubkey,scriptpubkey_len*u8
# Peer told us that channel is shutting down
channel_got_shutdown,24
channel_got_shutdown,1024
channel_got_shutdown,,scriptpubkey_len,u16
channel_got_shutdown,,scriptpubkey,scriptpubkey_len*u8
# Shutdown is complete, ready for closing negotiation. + peer_fd & gossip_fd.
channel_shutdown_complete,25
channel_shutdown_complete,1025
channel_shutdown_complete,,crypto_state,struct crypto_state
# Re-enable commit timer.
channel_dev_reenable_commit,26
channel_dev_reenable_commit_reply,126
channel_dev_reenable_commit,1026
channel_dev_reenable_commit_reply,1126

Can't render this file because it has a wrong number of fields in line 2.

8
closingd/closing_wire.csv

@ -1,7 +1,7 @@
#include <common/cryptomsg.h>
#include <common/htlc_wire.h>
# Begin! (passes peer fd, gossipd-client fd)
closing_init,1
closing_init,2001
closing_init,,crypto_state,struct crypto_state
closing_init,,seed,struct privkey
closing_init,,funding_txid,struct sha256_double
@ -25,11 +25,11 @@ closing_init,,next_index_remote,u64
closing_init,,revocations_received,u64
# We received an offer, save signature.
closing_received_signature,2
closing_received_signature,2002
closing_received_signature,,signature,secp256k1_ecdsa_signature
closing_received_signature,,tx,struct bitcoin_tx
closing_received_signature_reply,102
closing_received_signature_reply,2102
# Negotiations complete, we're exiting.
closing_complete,4
closing_complete,2004

Can't render this file because it has a wrong number of fields in line 3.

48
gossipd/gossip_wire.csv

@ -1,11 +1,11 @@
# Peers can give a bad message, we close their fd, but no harm done.
gossipstatus_peer_bad_msg,1000
gossipstatus_peer_bad_msg,13000
gossipstatus_peer_bad_msg,,unique_id,8
gossipstatus_peer_bad_msg,,len,2
gossipstatus_peer_bad_msg,,err,len*u8
# Misc problems like opening control fd.
gossipstatus_peer_failed,1001
gossipstatus_peer_failed,13001
gossipstatus_peer_failed,,unique_id,8
gossipstatus_peer_failed,,len,2
gossipstatus_peer_failed,,err,len*u8
@ -13,29 +13,29 @@ gossipstatus_peer_failed,,err,len*u8
#include <common/cryptomsg.h>
# Initialize the gossip daemon
gossipctl_init,0
gossipctl_init,3000
gossipctl_init,,broadcast_interval,4
gossipctl_init,,chain_hash,struct sha256_double
# These take an fd, but have no response
# (if it is to move onto a channel, we get a status msg).
gossipctl_new_peer,1
gossipctl_new_peer,3001
gossipctl_new_peer,,unique_id,8
gossipctl_new_peer,,crypto_state,struct crypto_state
# Tell it to release a peer which has initialized.
gossipctl_release_peer,2
gossipctl_release_peer,3002
gossipctl_release_peer,,unique_id,8
# This releases the peer and returns the cryptostate (followed two fds: peer and gossip)
gossipctl_release_peer_reply,102
gossipctl_release_peer_reply,3102
gossipctl_release_peer_reply,,crypto_state,struct crypto_state
# This is if we couldn't find the peer.
gossipctl_release_peer_replyfail,202
gossipctl_release_peer_replyfail,3202
# This is where we save a peer's features.
#gossipstatus_peer_features,1
#gossipstatus_peer_features,3001
#gossipstatus_peer_features,,unique_id,8
#gossipstatus_peer_features,,gflen,2
#gossipstatus_peer_features,,globalfeatures,gflen
@ -43,72 +43,72 @@ gossipctl_release_peer_replyfail,202
#gossipstatus_peer_features,,localfeatures,lflen
# Peer can send non-gossip packet (usually an open_channel) (followed two fds: peer and gossip)
gossipstatus_peer_nongossip,4
gossipstatus_peer_nongossip,3004
gossipstatus_peer_nongossip,,unique_id,8
gossipstatus_peer_nongossip,,crypto_state,struct crypto_state
gossipstatus_peer_nongossip,,len,2
gossipstatus_peer_nongossip,,msg,len*u8
# Pass JSON-RPC getnodes call through
gossip_getnodes_request,5
gossip_getnodes_request,3005
#include <lightningd/gossip_msg.h>
gossip_getnodes_reply,105
gossip_getnodes_reply,3105
gossip_getnodes_reply,,num_nodes,u16
gossip_getnodes_reply,,nodes,num_nodes*struct gossip_getnodes_entry
# Pass JSON-RPC getroute call through
gossip_getroute_request,6
gossip_getroute_request,3006
gossip_getroute_request,,source,struct pubkey
gossip_getroute_request,,destination,struct pubkey
gossip_getroute_request,,msatoshi,u32
gossip_getroute_request,,riskfactor,u16
gossip_getroute_reply,106
gossip_getroute_reply,3106
gossip_getroute_reply,,num_hops,u16
gossip_getroute_reply,,hops,num_hops*struct route_hop
gossip_getchannels_request,7
gossip_getchannels_request,3007
gossip_getchannels_reply,107
gossip_getchannels_reply,3107
gossip_getchannels_reply,,num_channels,u16
gossip_getchannels_reply,,nodes,num_channels*struct gossip_getchannels_entry
# Ping/pong test.
gossip_ping,8
gossip_ping,3008
gossip_ping,,unique_id,u64
gossip_ping,,num_pong_bytes,u16
gossip_ping,,len,u16
gossip_ping_reply,108
gossip_ping_reply,3108
gossip_ping_reply,,totlen,u16
# Given a short_channel_id, return the endpoints
gossip_resolve_channel_request,9
gossip_resolve_channel_request,3009
gossip_resolve_channel_request,,channel_id,struct short_channel_id
gossip_resolve_channel_reply,109
gossip_resolve_channel_reply,3109
gossip_resolve_channel_reply,,num_keys,u16
gossip_resolve_channel_reply,,keys,num_keys*struct pubkey
# The main daemon forward some gossip message to gossipd, allows injecting
# arbitrary gossip messages.
gossip_forwarded_msg,10
gossip_forwarded_msg,3010
gossip_forwarded_msg,,msglen,2
gossip_forwarded_msg,,msg,msglen
# If peer is still connected, fail it (master does this for reconnect)
gossipctl_fail_peer,11
gossipctl_fail_peer,3011
gossipctl_fail_peer,,unique_id,8
# Get a gossip fd for this peer (it has reconnected)
gossipctl_get_peer_gossipfd,12
gossipctl_get_peer_gossipfd,3012
gossipctl_get_peer_gossipfd,,unique_id,u64
# Does it want a full dump of gossip?
gossipctl_get_peer_gossipfd,,sync,bool
# + fd.
gossipctl_get_peer_gossipfd_reply,112
gossipctl_get_peer_gossipfd_reply,3112
# Failure (can't make new socket)
gossipctl_get_peer_gossipfd_replyfail,212
gossipctl_get_peer_gossipfd_replyfail,3212

Can't render this file because it has a wrong number of fields in line 2.

22
handshaked/handshake_wire.csv

@ -1,17 +1,17 @@
#include <common/cryptomsg.h>
# FIXME: This is probably too finegrained.
initr_act_one,1001
initr_act_two,1002
initr_act_three,1003
respr_act_one,1011
respr_act_two,1012
respr_act_three,1013
success,0
initr_act_one,14001
initr_act_two,14002
initr_act_three,14003
respr_act_one,14011
respr_act_two,14012
respr_act_three,14013
success,4000
handshake_responder,1
handshake_responder,4001
handshake_responder,,my_id,33
handshake_responder_reply,101
handshake_responder_reply,4101
handshake_responder_reply,,initiator_id,33
handshake_responder_reply,,cs,struct crypto_state
handshake_responder_reply,,gflen,2
@ -19,11 +19,11 @@ handshake_responder_reply,,globalfeatures,gflen
handshake_responder_reply,,lflen,2
handshake_responder_reply,,localfeatures,lflen
handshake_initiator,2
handshake_initiator,4002
handshake_initiator,,my_id,33
handshake_initiator,,responder_id,33
handshake_initiator_reply,102
handshake_initiator_reply,4102
handshake_initiator_reply,,cs,struct crypto_state
handshake_initiator_reply,,gflen,2
handshake_initiator_reply,,globalfeatures,gflen

Can't render this file because it has a wrong number of fields in line 4.

1
lightningd/subd.c

@ -551,6 +551,7 @@ struct subd *new_subd(const tal_t *ctx,
void subd_send_msg(struct subd *sd, const u8 *msg_out)
{
assert(!strstarts(sd->msgname(fromwire_peektype(msg_out)), "INVALID"));
msg_enqueue(&sd->outq, msg_out);
}

22
onchaind/onchain_wire.csv

@ -1,6 +1,6 @@
#include <common/htlc_wire.h>
# Begin! Here's the onchain tx which spends funding tx, followed by all HTLCs.
onchain_init,1
onchain_init,5001
onchain_init,,seed,struct privkey
onchain_init,,shachain,struct shachain
onchain_init,,funding_amount_satoshi,u64
@ -33,48 +33,48 @@ onchain_init,,num_htlcs,u64
#include <onchaind/onchain_wire.h>
# This is all the HTLCs: one per message
onchain_htlc,2
onchain_htlc,5002
onchain_htlc,,htlc,struct htlc_stub
# If it's not in the commitment tx, tell us (immediately or htlc_missing_depth)
onchain_htlc,,tell_if_missing,bool
onchain_htlc,,tell_immediately,bool
# This sets what the state is, depending on tx.
onchain_init_reply,101
onchain_init_reply,5101
onchain_init_reply,,state,u8
# onchaind->master: Send out a tx.
onchain_broadcast_tx,3
onchain_broadcast_tx,5003
onchain_broadcast_tx,,tx,struct bitcoin_tx
# master->onchaind: Notifier that an output has been spent by input_num of tx.
onchain_spent,4
onchain_spent,5004
onchain_spent,,tx,struct bitcoin_tx
onchain_spent,,input_num,u32
onchain_spent,,blockheight,u32
# master->onchaind: We will receive more than one of these, as depth changes.
onchain_depth,5
onchain_depth,5005
onchain_depth,,txid,struct sha256_double
onchain_depth,,depth,u32
# onchaind->master: We don't want to watch this tx, or its outputs
onchain_unwatch_tx,6
onchain_unwatch_tx,5006
onchain_unwatch_tx,,txid,struct sha256_double
onchain_unwatch_tx,,num_outputs,u32
# master->onchaind: We know HTLC preimage
onchain_known_preimage,7
onchain_known_preimage,5007
onchain_known_preimage,,preimage,struct preimage
# onchaind->master: We discovered HTLC preimage
onchain_extracted_preimage,8
onchain_extracted_preimage,5008
onchain_extracted_preimage,,preimage,struct preimage
# onchaind->master: this HTLC was missing from commit tx.
onchain_missing_htlc_output,9
onchain_missing_htlc_output,5009
onchain_missing_htlc_output,,htlc,struct htlc_stub
# onchaind->master: this HTLC has timed out (after reasonable_depth)
onchain_htlc_timeout,10
onchain_htlc_timeout,5010
onchain_htlc_timeout,,htlc,struct htlc_stub

Can't render this file because it has a wrong number of fields in line 2.

10
openingd/opening_wire.csv

@ -1,6 +1,6 @@
#include <common/cryptomsg.h>
#include <common/channel_config.h>
opening_init,0
opening_init,6000
# Which network are we configured for (as index into the chainparams)?
opening_init,,network_index,4
# Base configuration we'll offer (channel reserve will vary with amount)
@ -15,7 +15,7 @@ opening_init,,seed,struct privkey
#include <common/bip32.h>
#include <common/htlc_wire.h>
# This means we offer the open.
opening_funder,1
opening_funder,6001
opening_funder,,funding_satoshis,8
opening_funder,,push_msat,8
opening_funder,,feerate_per_kw,4
@ -29,7 +29,7 @@ opening_funder,,inputs,num_inputs*struct utxo
opening_funder,,bip32,struct ext_key
# This gives their sig, means we can broadcast tx: we're done.
opening_funder_reply,101
opening_funder_reply,6101
opening_funder_reply,,their_config,struct channel_config
opening_funder_reply,,first_commit,struct bitcoin_tx
opening_funder_reply,,first_commit_sig,secp256k1_ecdsa_signature
@ -44,7 +44,7 @@ opening_funder_reply,,funding_txid,struct sha256_double
opening_funder_reply,,feerate_per_kw,4
# This means they offer the open (contains their offer packet)
opening_fundee,3
opening_fundee,6003
opening_fundee,,minimum_depth,4
opening_fundee,,min_feerate,4
opening_fundee,,max_feerate,4
@ -52,7 +52,7 @@ opening_fundee,,len,2
opening_fundee,,msg,len*u8
# This gives their txid and info, means we can send funding_signed: we're done.
opening_fundee_reply,103
opening_fundee_reply,6103
opening_fundee_reply,,their_config,struct channel_config
opening_fundee_reply,,first_commit,struct bitcoin_tx
opening_fundee_reply,,first_commit_sig,secp256k1_ecdsa_signature

Can't render this file because it has a wrong number of fields in line 3.
Loading…
Cancel
Save