diff --git a/contrib/pylightning/lightning/lightning.py b/contrib/pylightning/lightning/lightning.py index 776165fbc..f7e17dc78 100644 --- a/contrib/pylightning/lightning/lightning.py +++ b/contrib/pylightning/lightning/lightning.py @@ -433,16 +433,6 @@ class LightningRpc(UnixDomainSocketRpc): """ return self.call("dev-memleak") - def dev_query_scids(self, id, scids): - """ - Ask peer for a particular set of scids - """ - payload = { - "id": id, - "scids": scids - } - return self.call("dev-query-scids", payload) - def dev_reenable_commit(self, peer_id): """ Re-enable the commit timer on peer {id} diff --git a/gossipd/gossip_wire.csv b/gossipd/gossip_wire.csv index 97b4c7126..191279c5d 100644 --- a/gossipd/gossip_wire.csv +++ b/gossipd/gossip_wire.csv @@ -70,37 +70,6 @@ msgdata,gossip_ping_reply,sent,bool, # 0 == no pong expected msgdata,gossip_ping_reply,totlen,u16, -# Test of query_short_channel_ids. Master->gossipd -msgtype,gossip_query_scids,3031 -msgdata,gossip_query_scids,id,node_id, -msgdata,gossip_query_scids,num_ids,u16, -msgdata,gossip_query_scids,ids,short_channel_id,num_ids - -# Gossipd -> master -msgtype,gossip_scids_reply,3131 -msgdata,gossip_scids_reply,ok,bool, -msgdata,gossip_scids_reply,complete,bool, - -# Test gossip timestamp filtering. -msgtype,gossip_send_timestamp_filter,3028 -msgdata,gossip_send_timestamp_filter,id,node_id, -msgdata,gossip_send_timestamp_filter,first_timestamp,u32, -msgdata,gossip_send_timestamp_filter,timestamp_range,u32, - -# Test of query_channel_range. Master->gossipd -msgtype,gossip_query_channel_range,3029 -msgdata,gossip_query_channel_range,id,node_id, -msgdata,gossip_query_channel_range,first_blocknum,u32, -msgdata,gossip_query_channel_range,number_of_blocks,u32, - -# Gossipd -> master -msgtype,gossip_query_channel_range_reply,3129 -msgdata,gossip_query_channel_range_reply,final_first_block,u32, -msgdata,gossip_query_channel_range_reply,final_num_blocks,u32, -msgdata,gossip_query_channel_range_reply,final_complete,bool, -msgdata,gossip_query_channel_range_reply,num,u16, -msgdata,gossip_query_channel_range_reply,scids,short_channel_id,num - # Set artificial maximum reply_channel_range size. Master->gossipd msgtype,gossip_dev_set_max_scids_encode_size,3030 msgdata,gossip_dev_set_max_scids_encode_size,max,u32, diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index 5161f4d54..38a66d48f 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -1394,48 +1394,6 @@ static struct io_plan *new_blockheight(struct io_conn *conn, } #if DEVELOPER -/* BOLT #7: - * - * ### The `gossip_timestamp_filter` Message - *... - * This message allows a node to constrain future gossip messages to - * a specific range. A node which wants any gossip messages would have - * to send this, otherwise `gossip_queries` negotiation means no gossip - * messages would be received. - * - * Note that this filter replaces any previous one, so it can be used - * multiple times to change the gossip from a peer. */ -/* This is the entry point for dev_send_timestamp_filter testing. */ -static struct io_plan *send_timestamp_filter(struct io_conn *conn, - struct daemon *daemon, - const u8 *msg) -{ - struct node_id id; - u32 first, range; - struct peer *peer; - - if (!fromwire_gossip_send_timestamp_filter(msg, &id, &first, &range)) - master_badmsg(WIRE_GOSSIP_SEND_TIMESTAMP_FILTER, msg); - - peer = find_peer(daemon, &id); - if (!peer) { - status_broken("send_timestamp_filter: unknown peer %s", - type_to_string(tmpctx, struct node_id, &id)); - goto out; - } - - if (!peer->gossip_queries_feature) { - status_broken("send_timestamp_filter: no gossip_query support in peer %s", - type_to_string(tmpctx, struct node_id, &id)); - goto out; - } - - msg = towire_gossip_timestamp_filter(NULL, &daemon->chain_hash, - first, range); - queue_peer_msg(peer, take(msg)); -out: - return daemon_conn_read_next(conn, daemon->master); -} /* Another testing hack */ static struct io_plan *dev_gossip_suppress(struct io_conn *conn, struct daemon *daemon, @@ -1749,15 +1707,6 @@ static struct io_plan *recv_req(struct io_conn *conn, return new_blockheight(conn, daemon, msg); #if DEVELOPER - case WIRE_GOSSIP_QUERY_SCIDS: - return query_scids_req(conn, daemon, msg); - - case WIRE_GOSSIP_SEND_TIMESTAMP_FILTER: - return send_timestamp_filter(conn, daemon, msg); - - case WIRE_GOSSIP_QUERY_CHANNEL_RANGE: - return dev_query_channel_range(conn, daemon, msg); - case WIRE_GOSSIP_DEV_SET_MAX_SCIDS_ENCODE_SIZE: return dev_set_max_scids_encode_size(conn, daemon, msg); case WIRE_GOSSIP_DEV_SUPPRESS: @@ -1769,9 +1718,6 @@ static struct io_plan *recv_req(struct io_conn *conn, case WIRE_GOSSIP_DEV_SET_TIME: return dev_gossip_set_time(conn, daemon, msg); #else - case WIRE_GOSSIP_QUERY_SCIDS: - case WIRE_GOSSIP_SEND_TIMESTAMP_FILTER: - case WIRE_GOSSIP_QUERY_CHANNEL_RANGE: case WIRE_GOSSIP_DEV_SET_MAX_SCIDS_ENCODE_SIZE: case WIRE_GOSSIP_DEV_SUPPRESS: case WIRE_GOSSIP_DEV_MEMLEAK: @@ -1785,8 +1731,6 @@ static struct io_plan *recv_req(struct io_conn *conn, case WIRE_GOSSIP_GETROUTE_REPLY: case WIRE_GOSSIP_GETCHANNELS_REPLY: case WIRE_GOSSIP_PING_REPLY: - case WIRE_GOSSIP_SCIDS_REPLY: - case WIRE_GOSSIP_QUERY_CHANNEL_RANGE_REPLY: case WIRE_GOSSIP_GET_CHANNEL_PEER_REPLY: case WIRE_GOSSIP_GET_INCOMING_CHANNELS_REPLY: case WIRE_GOSSIP_GET_TXOUT: diff --git a/gossipd/queries.c b/gossipd/queries.c index c39712e24..cdb78246e 100644 --- a/gossipd/queries.c +++ b/gossipd/queries.c @@ -998,98 +998,6 @@ bool query_channel_range(struct daemon *daemon, } #if DEVELOPER -static void query_scids_done(struct peer *peer, bool complete) -{ - const u8 *msg = towire_gossip_scids_reply(NULL, true, complete); - daemon_conn_send(peer->daemon->master, take(msg)); -} - -struct io_plan *query_scids_req(struct io_conn *conn, - struct daemon *daemon, - const u8 *msg) -{ - struct node_id id; - struct short_channel_id *scids; - struct peer *peer; - - if (!fromwire_gossip_query_scids(msg, msg, &id, &scids)) - master_badmsg(WIRE_GOSSIP_QUERY_SCIDS, msg); - - peer = find_peer(daemon, &id); - if (!peer) { - status_broken("query_scids: unknown peer %s", - type_to_string(tmpctx, struct node_id, &id)); - daemon_conn_send(daemon->master, - take(towire_gossip_scids_reply(NULL, - false, false))); - } else if (!query_short_channel_ids(daemon, peer, scids, query_scids_done)) - daemon_conn_send(daemon->master, - take(towire_gossip_scids_reply(NULL, - false, false))); - return daemon_conn_read_next(conn, daemon->master); -} - -static void tell_master_scid_range(struct peer *peer, - u32 first_blocknum, u32 number_of_blocks, - const struct short_channel_id *scids, - bool complete) -{ - /* All done, send reply to lightningd. */ - u8 *msg = towire_gossip_query_channel_range_reply(NULL, - first_blocknum, - number_of_blocks, - complete, - scids); - daemon_conn_send(peer->daemon->master, take(msg)); -} - -struct io_plan *dev_query_channel_range(struct io_conn *conn, - struct daemon *daemon, - const u8 *msg) -{ - struct node_id id; - u32 first_blocknum, number_of_blocks; - struct peer *peer; - - if (!fromwire_gossip_query_channel_range(msg, &id, &first_blocknum, - &number_of_blocks)) - master_badmsg(WIRE_GOSSIP_QUERY_SCIDS, msg); - - peer = find_peer(daemon, &id); - if (!peer) { - status_broken("query_channel_range: unknown peer %s", - type_to_string(tmpctx, struct node_id, &id)); - goto fail; - } - - if (!peer->gossip_queries_feature) { - status_broken("query_channel_range: no gossip_query support in peer %s", - type_to_string(tmpctx, struct node_id, &id)); - goto fail; - } - - if (peer->query_channel_blocks) { - status_broken("query_channel_range: previous query active"); - goto fail; - } - - if (!query_channel_range(daemon, peer, - first_blocknum, number_of_blocks, - tell_master_scid_range)) - goto fail; - -out: - return daemon_conn_read_next(conn, daemon->master); - -fail: - daemon_conn_send(daemon->master, - take(towire_gossip_query_channel_range_reply(NULL, - 0, 0, - false, - NULL))); - goto out; -} - /* This is a testing hack to allow us to artificially lower the maximum bytes * of short_channel_ids we'll encode, using dev_set_max_scids_encode_size. */ struct io_plan *dev_set_max_scids_encode_size(struct io_conn *conn, diff --git a/gossipd/test/run-crc32_of_update.c b/gossipd/test/run-crc32_of_update.c index 035c2f8a1..7dda1436b 100644 --- a/gossipd/test/run-crc32_of_update.c +++ b/gossipd/test/run-crc32_of_update.c @@ -10,9 +10,6 @@ int unused_main(int argc, char *argv[]); struct io_plan *daemon_conn_read_next(struct io_conn *conn UNNEEDED, struct daemon_conn *dc UNNEEDED) { fprintf(stderr, "daemon_conn_read_next called!\n"); abort(); } -/* Generated stub for daemon_conn_send */ -void daemon_conn_send(struct daemon_conn *dc UNNEEDED, const u8 *msg UNNEEDED) -{ fprintf(stderr, "daemon_conn_send called!\n"); abort(); } /* Generated stub for daemon_conn_wake */ void daemon_conn_wake(struct daemon_conn *dc UNNEEDED) { fprintf(stderr, "daemon_conn_wake called!\n"); abort(); } @@ -32,12 +29,6 @@ bool fromwire_gossip_dev_set_max_scids_encode_size(const void *p UNNEEDED, u32 * /* Generated stub for fromwire_gossipd_local_channel_update */ bool fromwire_gossipd_local_channel_update(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, bool *disable UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, struct amount_msat *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED, struct amount_msat *htlc_maximum_msat UNNEEDED) { fprintf(stderr, "fromwire_gossipd_local_channel_update called!\n"); abort(); } -/* Generated stub for fromwire_gossip_query_channel_range */ -bool fromwire_gossip_query_channel_range(const void *p UNNEEDED, struct node_id *id UNNEEDED, u32 *first_blocknum UNNEEDED, u32 *number_of_blocks UNNEEDED) -{ fprintf(stderr, "fromwire_gossip_query_channel_range called!\n"); abort(); } -/* Generated stub for fromwire_gossip_query_scids */ -bool fromwire_gossip_query_scids(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, struct short_channel_id **ids UNNEEDED) -{ fprintf(stderr, "fromwire_gossip_query_scids called!\n"); abort(); } /* Generated stub for fromwire_hsm_cupdate_sig_reply */ bool fromwire_hsm_cupdate_sig_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **cu UNNEEDED) { fprintf(stderr, "fromwire_hsm_cupdate_sig_reply called!\n"); abort(); } @@ -96,12 +87,6 @@ u8 *towire_errorfmt(const tal_t *ctx UNNEEDED, const struct channel_id *channel UNNEEDED, const char *fmt UNNEEDED, ...) { fprintf(stderr, "towire_errorfmt called!\n"); abort(); } -/* Generated stub for towire_gossip_query_channel_range_reply */ -u8 *towire_gossip_query_channel_range_reply(const tal_t *ctx UNNEEDED, u32 final_first_block UNNEEDED, u32 final_num_blocks UNNEEDED, bool final_complete UNNEEDED, const struct short_channel_id *scids UNNEEDED) -{ fprintf(stderr, "towire_gossip_query_channel_range_reply called!\n"); abort(); } -/* Generated stub for towire_gossip_scids_reply */ -u8 *towire_gossip_scids_reply(const tal_t *ctx UNNEEDED, bool ok UNNEEDED, bool complete UNNEEDED) -{ fprintf(stderr, "towire_gossip_scids_reply called!\n"); abort(); } /* Generated stub for towire_hsm_cupdate_sig_req */ u8 *towire_hsm_cupdate_sig_req(const tal_t *ctx UNNEEDED, const u8 *cu UNNEEDED) { fprintf(stderr, "towire_hsm_cupdate_sig_req called!\n"); abort(); } diff --git a/gossipd/test/run-extended-info.c b/gossipd/test/run-extended-info.c index d5eef5e43..d125870a8 100644 --- a/gossipd/test/run-extended-info.c +++ b/gossipd/test/run-extended-info.c @@ -17,9 +17,6 @@ struct io_plan *daemon_conn_read_next(struct io_conn *conn UNNEEDED, struct daemon_conn *dc UNNEEDED) { fprintf(stderr, "daemon_conn_read_next called!\n"); abort(); } -/* Generated stub for daemon_conn_send */ -void daemon_conn_send(struct daemon_conn *dc UNNEEDED, const u8 *msg UNNEEDED) -{ fprintf(stderr, "daemon_conn_send called!\n"); abort(); } /* Generated stub for daemon_conn_wake */ void daemon_conn_wake(struct daemon_conn *dc UNNEEDED) { fprintf(stderr, "daemon_conn_wake called!\n"); abort(); } @@ -30,18 +27,9 @@ bigsize_t *decode_scid_query_flags(const tal_t *ctx UNNEEDED, /* Generated stub for decode_short_ids */ struct short_channel_id *decode_short_ids(const tal_t *ctx UNNEEDED, const u8 *encoded UNNEEDED) { fprintf(stderr, "decode_short_ids called!\n"); abort(); } -/* Generated stub for find_peer */ -struct peer *find_peer(struct daemon *daemon UNNEEDED, const struct node_id *id UNNEEDED) -{ fprintf(stderr, "find_peer called!\n"); abort(); } /* Generated stub for fromwire_gossip_dev_set_max_scids_encode_size */ bool fromwire_gossip_dev_set_max_scids_encode_size(const void *p UNNEEDED, u32 *max UNNEEDED) { fprintf(stderr, "fromwire_gossip_dev_set_max_scids_encode_size called!\n"); abort(); } -/* Generated stub for fromwire_gossip_query_channel_range */ -bool fromwire_gossip_query_channel_range(const void *p UNNEEDED, struct node_id *id UNNEEDED, u32 *first_blocknum UNNEEDED, u32 *number_of_blocks UNNEEDED) -{ fprintf(stderr, "fromwire_gossip_query_channel_range called!\n"); abort(); } -/* Generated stub for fromwire_gossip_query_scids */ -bool fromwire_gossip_query_scids(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, struct short_channel_id **ids UNNEEDED) -{ fprintf(stderr, "fromwire_gossip_query_scids called!\n"); abort(); } /* Generated stub for get_cupdate_parts */ void get_cupdate_parts(const u8 *channel_update UNNEEDED, const u8 *parts[2] UNNEEDED, @@ -71,12 +59,6 @@ u8 *towire_errorfmt(const tal_t *ctx UNNEEDED, const struct channel_id *channel UNNEEDED, const char *fmt UNNEEDED, ...) { fprintf(stderr, "towire_errorfmt called!\n"); abort(); } -/* Generated stub for towire_gossip_query_channel_range_reply */ -u8 *towire_gossip_query_channel_range_reply(const tal_t *ctx UNNEEDED, u32 final_first_block UNNEEDED, u32 final_num_blocks UNNEEDED, bool final_complete UNNEEDED, const struct short_channel_id *scids UNNEEDED) -{ fprintf(stderr, "towire_gossip_query_channel_range_reply called!\n"); abort(); } -/* Generated stub for towire_gossip_scids_reply */ -u8 *towire_gossip_scids_reply(const tal_t *ctx UNNEEDED, bool ok UNNEEDED, bool complete UNNEEDED) -{ fprintf(stderr, "towire_gossip_scids_reply called!\n"); abort(); } /* AUTOGENERATED MOCKS END */ /* Generated stub for status_fmt */ diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index 8c6b24c0c..ea7913956 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -142,9 +142,6 @@ static unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds) case WIRE_GOSSIP_GET_TXOUT_REPLY: case WIRE_GOSSIP_OUTPOINT_SPENT: case WIRE_GOSSIP_PAYMENT_FAILURE: - case WIRE_GOSSIP_QUERY_SCIDS: - case WIRE_GOSSIP_QUERY_CHANNEL_RANGE: - case WIRE_GOSSIP_SEND_TIMESTAMP_FILTER: case WIRE_GOSSIP_GET_INCOMING_CHANNELS: case WIRE_GOSSIP_DEV_SET_MAX_SCIDS_ENCODE_SIZE: case WIRE_GOSSIP_DEV_SUPPRESS: @@ -157,8 +154,6 @@ static unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds) case WIRE_GOSSIP_GETNODES_REPLY: case WIRE_GOSSIP_GETROUTE_REPLY: case WIRE_GOSSIP_GETCHANNELS_REPLY: - case WIRE_GOSSIP_SCIDS_REPLY: - case WIRE_GOSSIP_QUERY_CHANNEL_RANGE_REPLY: case WIRE_GOSSIP_GET_CHANNEL_PEER_REPLY: case WIRE_GOSSIP_GET_INCOMING_CHANNELS_REPLY: case WIRE_GOSSIP_DEV_MEMLEAK_REPLY: @@ -535,173 +530,6 @@ static const struct json_command listchannels_command = { AUTODATA(json_command, &listchannels_command); #if DEVELOPER -static void json_scids_reply(struct subd *gossip UNUSED, const u8 *reply, - const int *fds UNUSED, struct command *cmd) -{ - bool ok, complete; - struct json_stream *response; - - if (!fromwire_gossip_scids_reply(reply, &ok, &complete)) { - was_pending(command_fail(cmd, LIGHTNINGD, - "Gossip gave bad gossip_scids_reply")); - return; - } - - if (!ok) { - was_pending(command_fail(cmd, LIGHTNINGD, - "Gossip refused to query peer")); - return; - } - - response = json_stream_success(cmd); - json_add_bool(response, "complete", complete); - was_pending(command_success(cmd, response)); -} - -static struct command_result *json_dev_query_scids(struct command *cmd, - const char *buffer, - const jsmntok_t *obj UNNEEDED, - const jsmntok_t *params) -{ - u8 *msg; - const jsmntok_t *scidstok; - const jsmntok_t *t; - struct node_id *id; - struct short_channel_id *scids; - size_t i; - - if (!param(cmd, buffer, params, - p_req("id", param_node_id, &id), - p_req("scids", param_array, &scidstok), - NULL)) - return command_param_failed(); - - scids = tal_arr(cmd, struct short_channel_id, scidstok->size); - json_for_each_arr(i, t, scidstok) { - if (!json_to_short_channel_id(buffer, t, &scids[i])) { - return command_fail(cmd, JSONRPC2_INVALID_PARAMS, - "scid %zu '%.*s' is not an scid", - i, json_tok_full_len(t), - json_tok_full(buffer, t)); - } - } - - /* Tell gossipd, since this is a gossip query. */ - msg = towire_gossip_query_scids(cmd, id, scids); - subd_req(cmd->ld->gossip, cmd->ld->gossip, - take(msg), -1, 0, json_scids_reply, cmd); - return command_still_pending(cmd); -} - -static const struct json_command dev_query_scids_command = { - "dev-query-scids", - "developer", - json_dev_query_scids, - "Query peer {id} for [scids]" -}; -AUTODATA(json_command, &dev_query_scids_command); - -static struct command_result * -json_dev_send_timestamp_filter(struct command *cmd, - const char *buffer, - const jsmntok_t *obj UNNEEDED, - const jsmntok_t *params) -{ - u8 *msg; - struct node_id *id; - u32 *first, *range; - - if (!param(cmd, buffer, params, - p_req("id", param_node_id, &id), - p_req("first", param_number, &first), - p_req("range", param_number, &range), - NULL)) - return command_param_failed(); - - log_debug(cmd->ld->log, "Setting timestamp range %u+%u", *first, *range); - /* Tell gossipd, since this is a gossip query. */ - msg = towire_gossip_send_timestamp_filter(NULL, id, *first, *range); - subd_send_msg(cmd->ld->gossip, take(msg)); - - return command_success(cmd, json_stream_success(cmd)); -} - -static const struct json_command dev_send_timestamp_filter = { - "dev-send-timestamp-filter", - "developer", - json_dev_send_timestamp_filter, - "Send peer {id} the timestamp filter {first} {range}" -}; -AUTODATA(json_command, &dev_send_timestamp_filter); - -static void json_channel_range_reply(struct subd *gossip UNUSED, const u8 *reply, - const int *fds UNUSED, struct command *cmd) -{ - struct json_stream *response; - u32 final_first_block, final_num_blocks; - bool final_complete; - struct short_channel_id *scids; - - if (!fromwire_gossip_query_channel_range_reply(tmpctx, reply, - &final_first_block, - &final_num_blocks, - &final_complete, - &scids)) { - was_pending(command_fail(cmd, LIGHTNINGD, - "Gossip gave bad gossip_query_channel_range_reply")); - return; - } - - if (final_num_blocks == 0 && final_num_blocks == 0 && !final_complete) { - was_pending(command_fail(cmd, LIGHTNINGD, - "Gossip refused to query peer")); - return; - } - - response = json_stream_success(cmd); - /* As this is a dev interface, we don't bother saving and - * returning all the replies, just the final one. */ - json_add_num(response, "final_first_block", final_first_block); - json_add_num(response, "final_num_blocks", final_num_blocks); - json_add_bool(response, "final_complete", final_complete); - json_array_start(response, "short_channel_ids"); - for (size_t i = 0; i < tal_count(scids); i++) - json_add_short_channel_id(response, NULL, &scids[i]); - json_array_end(response); - was_pending(command_success(cmd, response)); -} - -static struct command_result *json_dev_query_channel_range(struct command *cmd, - const char *buffer, - const jsmntok_t *obj UNNEEDED, - const jsmntok_t *params) -{ - u8 *msg; - struct node_id *id; - u32 *first, *num; - - if (!param(cmd, buffer, params, - p_req("id", param_node_id, &id), - p_req("first", param_number, &first), - p_req("num", param_number, &num), - NULL)) - return command_param_failed(); - - /* Tell gossipd, since this is a gossip query. */ - msg = towire_gossip_query_channel_range(cmd, id, *first, *num); - subd_req(cmd->ld->gossip, cmd->ld->gossip, - take(msg), -1, 0, json_channel_range_reply, cmd); - return command_still_pending(cmd); -} - -static const struct json_command dev_query_channel_range_command = { - "dev-query-channel-range", - "developer", - json_dev_query_channel_range, - "Query peer {id} for short_channel_ids for {first} block + {num} blocks" -}; -AUTODATA(json_command, &dev_query_channel_range_command); - static struct command_result * json_dev_set_max_scids_encode_size(struct command *cmd, const char *buffer,