diff --git a/channeld/channeld.c b/channeld/channeld.c index b9a660524dc0..2cccbfefb32c 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -45,9 +46,9 @@ #include #include -/* stdin == requests, 3 == peer, 4 = gossip, 5 = gossip_store, 6 = HSM */ +/* stdin == requests, 3 == peer, 4 = gossip, 5 = HSM */ #define MASTER_FD STDIN_FILENO -#define HSM_FD 6 +#define HSM_FD 5 enum pong_expect_type { /* We weren't expecting a ping reply */ @@ -160,6 +161,9 @@ struct peer { #if DEVELOPER /* If set, don't fire commit counter when this hits 0 */ u32 *dev_disable_commit; + + /* If set, send channel_announcement after 1 second, not 30 */ + bool dev_fast_gossip; #endif /* Information used for reestablishment. */ bool last_was_revoke; @@ -638,7 +642,7 @@ static void channel_announcement_negotiate(struct peer *peer) /* Give other nodes time to notice new block. */ notleak(new_reltimer(&peer->timers, peer, - time_from_sec(GOSSIP_ANNOUNCE_DELAY(dev_fast_gossip)), + time_from_sec(GOSSIP_ANNOUNCE_DELAY(peer->dev_fast_gossip)), announce_channel, peer)); } } @@ -980,7 +984,7 @@ static void send_shutdown_complete(struct peer *peer) { /* Now we can tell master shutdown is complete. */ wire_sync_write(MASTER_FD, - take(towire_channeld_shutdown_complete(NULL, peer->pps))); + take(towire_channeld_shutdown_complete(NULL))); per_peer_state_fdpass_send(MASTER_FD, peer->pps); close(MASTER_FD); } @@ -3839,6 +3843,7 @@ static void init_channel(struct peer *peer) u8 *reestablish_only; struct channel_type *channel_type; u32 *dev_disable_commit; /* Always NULL */ + bool dev_fast_gossip; #if !DEVELOPER bool dev_fail_process_onionpacket; /* Ignored */ #endif @@ -3862,7 +3867,6 @@ static void init_channel(struct peer *peer) &peer->feerate_max, &peer->feerate_penalty, &peer->their_commit_sig, - &peer->pps, &funding_pubkey[REMOTE], &points[REMOTE], &peer->remote_per_commit, @@ -3910,6 +3914,7 @@ static void init_channel(struct peer *peer) #if DEVELOPER peer->dev_disable_commit = dev_disable_commit; + peer->dev_fast_gossip = dev_fast_gossip; #endif status_debug("option_static_remotekey = %u, option_anchor_outputs = %u", @@ -3924,8 +3929,9 @@ static void init_channel(struct peer *peer) tal_dup(peer, struct penalty_base, &pbases[i])); tal_free(pbases); - /* stdin == requests, 3 == peer, 4 = gossip, 5 = gossip_store, 6 = HSM */ - per_peer_state_set_fds(peer->pps, 3, 4, 5); + /* stdin == requests, 3 == peer, 4 = gossip */ + peer->pps = new_per_peer_state(peer); + per_peer_state_set_fds(peer->pps, 3, 4); status_debug("init %s: remote_per_commit = %s, old_remote_per_commit = %s" " next_idx_local = %"PRIu64 @@ -4019,14 +4025,6 @@ static void init_channel(struct peer *peer) billboard_update(peer); } -static void try_read_gossip_store(struct peer *peer) -{ - u8 *msg = gossip_store_next(tmpctx, peer->pps); - - if (msg) - peer_write(peer->pps, take(msg)); -} - int main(int argc, char *argv[]) { setup_locale(); @@ -4088,7 +4086,6 @@ int main(int argc, char *argv[]) struct timeval timeout, *tptr; struct timer *expired; const u8 *msg; - struct timerel trel; struct timemono now = time_mono(); /* Free any temporary allocations */ @@ -4120,13 +4117,6 @@ int main(int argc, char *argv[]) tptr = &timeout; } - /* If timer to next gossip is sooner, use that instead. */ - if (time_to_next_gossip(peer->pps, &trel) - && (!tptr || time_less(trel, timeval_to_timerel(*tptr)))) { - timeout = timerel_to_timeval(trel); - tptr = &timeout; - } - if (select(nfds, &rfds, NULL, NULL, tptr) < 0) { /* Signals OK, eg. SIGUSR1 */ if (errno == EINTR) @@ -4154,8 +4144,7 @@ int main(int argc, char *argv[]) if (!msg) peer_failed_connection_lost(); handle_gossip_msg(peer->pps, take(msg)); - } else /* Lowest priority: stream from store. */ - try_read_gossip_store(peer); + } } /* We only exit when shutdown is complete. */ diff --git a/channeld/channeld_wire.csv b/channeld/channeld_wire.csv index f2eca498d7bb..f095b3cb5f61 100644 --- a/channeld/channeld_wire.csv +++ b/channeld/channeld_wire.csv @@ -8,7 +8,6 @@ #include #include #include -#include # Begin! (passes gossipd-client fd) msgtype,channeld_init,1000 @@ -28,7 +27,6 @@ msgdata,channeld_init,feerate_min,u32, msgdata,channeld_init,feerate_max,u32, msgdata,channeld_init,feerate_penalty,u32, msgdata,channeld_init,first_commit_sig,bitcoin_signature, -msgdata,channeld_init,per_peer_state,per_peer_state, msgdata,channeld_init,remote_fundingkey,pubkey, msgdata,channeld_init,remote_basepoints,basepoints, msgdata,channeld_init,remote_per_commit,pubkey, @@ -187,7 +185,6 @@ msgdata,channeld_got_shutdown,wrong_funding,?bitcoin_outpoint, # Shutdown is complete, ready for closing negotiation. + peer_fd & gossip_fd. msgtype,channeld_shutdown_complete,1025 -msgdata,channeld_shutdown_complete,per_peer_state,per_peer_state, # Re-enable commit timer. msgtype,channeld_dev_reenable_commit,1026 diff --git a/closingd/closingd.c b/closingd/closingd.c index 84dc438b5d8b..9fb74e4ba899 100644 --- a/closingd/closingd.c +++ b/closingd/closingd.c @@ -31,9 +31,9 @@ #include #include -/* stdin == requests, 3 == peer, 4 = gossip, 5 = gossip_store, 6 = hsmd */ +/* stdin == requests, 3 == peer, 4 = gossip, 5 = hsmd */ #define REQ_FD STDIN_FILENO -#define HSM_FD 6 +#define HSM_FD 5 static void notify(enum log_level level, const char *fmt, ...) { @@ -897,7 +897,6 @@ int main(int argc, char *argv[]) msg = wire_sync_read(tmpctx, REQ_FD); if (!fromwire_closingd_init(ctx, msg, &chainparams, - &pps, &channel_id, &funding, &funding_sats, @@ -914,12 +913,12 @@ int main(int argc, char *argv[]) &fee_negotiation_step, &fee_negotiation_step_unit, &use_quickclose, - &dev_fast_gossip, &wrong_funding)) master_badmsg(WIRE_CLOSINGD_INIT, msg); - /* stdin == requests, 3 == peer, 4 = gossip, 5 = gossip_store, 6 = hsmd */ - per_peer_state_set_fds(notleak(pps), 3, 4, 5); + /* stdin == requests, 3 == peer, 4 = gossip, 5 = hsmd */ + pps = notleak(new_per_peer_state(ctx)); + per_peer_state_set_fds(pps, 3, 4); funding_wscript = bitcoin_redeem_2of2(ctx, &funding_pubkey[LOCAL], diff --git a/closingd/closingd_wire.csv b/closingd/closingd_wire.csv index a6b066d739a3..94ab71c757e0 100644 --- a/closingd/closingd_wire.csv +++ b/closingd/closingd_wire.csv @@ -2,12 +2,10 @@ #include #include #include -#include #include # Begin! (passes peer fd, gossipd-client fd) msgtype,closingd_init,2001 msgdata,closingd_init,chainparams,chainparams, -msgdata,closingd_init,pps,per_peer_state, msgdata,closingd_init,channel_id,channel_id, msgdata,closingd_init,funding,bitcoin_outpoint, msgdata,closingd_init,funding_satoshi,amount_sat, @@ -28,7 +26,6 @@ msgdata,closingd_init,remote_scriptpubkey,u8,remote_scriptpubkey_len msgdata,closingd_init,fee_negotiation_step,u64, msgdata,closingd_init,fee_negotiation_step_unit,u8, msgdata,closingd_init,use_quickclose,bool, -msgdata,closingd_init,dev_fast_gossip,bool, msgdata,closingd_init,shutdown_wrong_funding,?bitcoin_outpoint, # Message for any commands waiting. diff --git a/common/gossip_store.c b/common/gossip_store.c index 1ab501044004..3456a483e003 100644 --- a/common/gossip_store.c +++ b/common/gossip_store.c @@ -11,39 +11,6 @@ #include #include -void gossip_setup_timestamp_filter(struct per_peer_state *pps, - u32 first_timestamp, - u32 timestamp_range) -{ - /* If this is the first filter, we gossip sync immediately. */ - if (!pps->gs) { - pps->gs = tal(pps, struct gossip_state); - pps->gs->next_gossip = time_mono(); - } - - pps->gs->timestamp_min = first_timestamp; - pps->gs->timestamp_max = first_timestamp + timestamp_range - 1; - /* Make sure we never leave it on an impossible value. */ - if (pps->gs->timestamp_max < pps->gs->timestamp_min) - pps->gs->timestamp_max = UINT32_MAX; - - /* BOLT #7: - * - * The receiver: - * - SHOULD send all gossip messages whose `timestamp` is greater or - * equal to `first_timestamp`, and less than `first_timestamp` plus - * `timestamp_range`. - * - MAY wait for the next outgoing gossip flush to send these. - * ... - * - SHOULD restrict future gossip messages to those whose `timestamp` - * is greater or equal to `first_timestamp`, and less than - * `first_timestamp` plus `timestamp_range`. - */ - - /* Restart just after header. */ - lseek(pps->gossip_store_fd, 1, SEEK_SET); -} - static bool timestamp_filter(const struct gossip_state *gs, u32 timestamp) { /* BOLT #7: @@ -182,24 +149,6 @@ u8 *gossip_store_iter(const tal_t *ctx, return msg; } -u8 *gossip_store_next(const tal_t *ctx, struct per_peer_state *pps) -{ - u8 *msg; - - /* Don't read until we're initialized. */ - if (!pps->gs) - return NULL; - - /* FIXME: We are only caller using off == NULL */ - msg = gossip_store_iter(ctx, &pps->gossip_store_fd, - pps->gs, pps->grf, NULL); - - if (!msg) - per_peer_state_reset_gossip_timer(pps); - - return msg; -} - size_t find_gossip_store_end(int gossip_store_fd, size_t off) { /* We cheat and read first two bytes of message too. */ diff --git a/common/gossip_store.h b/common/gossip_store.h index c109c8625817..e1d760860ae6 100644 --- a/common/gossip_store.h +++ b/common/gossip_store.h @@ -5,7 +5,6 @@ #include #include -struct per_peer_state; struct gossip_state; struct gossip_rcvd_filter; @@ -37,14 +36,6 @@ struct gossip_hdr { beint32_t timestamp; /* timestamp of msg. */ }; -/** - * Direct store accessor: loads gossip msg from store. - * - * Returns NULL and resets time_to_next_gossip(pps) if there are no - * more gossip msgs. - */ -u8 *gossip_store_next(const tal_t *ctx, struct per_peer_state *pps); - /** * Direct store accessor: loads gossip msg from store. * @@ -56,13 +47,6 @@ u8 *gossip_store_iter(const tal_t *ctx, struct gossip_rcvd_filter *grf, size_t *off); -/** - * Sets up the tiemstamp filter once they told us to set it.( - */ -void gossip_setup_timestamp_filter(struct per_peer_state *pps, - u32 first_timestamp, - u32 timestamp_range); - /** * Gossipd will be writing to this, and it's not atomic! Safest * way to find the "end" is to walk through. diff --git a/common/peer_failed.c b/common/peer_failed.c index 909161b650c3..e9f5487dafdc 100644 --- a/common/peer_failed.c +++ b/common/peer_failed.c @@ -20,7 +20,6 @@ peer_fatal_continue(const u8 *msg TAKES, const struct per_peer_state *pps) status_send_fd(pps->peer_fd); status_send_fd(pps->gossip_fd); - status_send_fd(pps->gossip_store_fd); exit(0x80 | (reason & 0xFF)); } @@ -44,7 +43,6 @@ peer_failed(struct per_peer_state *pps, msg = towire_status_peer_error(NULL, channel_id, desc, warn, - pps, msg); peer_billboard(true, desc); peer_fatal_continue(take(msg), pps); @@ -87,7 +85,7 @@ void peer_failed_received_errmsg(struct per_peer_state *pps, { u8 *msg; - msg = towire_status_peer_error(NULL, channel_id, desc, warning, pps, + msg = towire_status_peer_error(NULL, channel_id, desc, warning, NULL); peer_billboard(true, "Received %s", desc); peer_fatal_continue(take(msg), pps); diff --git a/common/peer_status_wire.csv b/common/peer_status_wire.csv index 8162443e2ffb..1fedb7ccc678 100644 --- a/common/peer_status_wire.csv +++ b/common/peer_status_wire.csv @@ -8,6 +8,5 @@ msgdata,status_peer_error,channel,channel_id, msgdata,status_peer_error,desc,wirestring, # Take a deep breath, then try reconnecting to the precious little snowflake. msgdata,status_peer_error,warning,bool, -msgdata,status_peer_error,pps,per_peer_state, msgdata,status_peer_error,len,u16, msgdata,status_peer_error,error_for_them,u8,len diff --git a/common/per_peer_state.c b/common/per_peer_state.c index de11384e272e..b33305538d27 100644 --- a/common/per_peer_state.c +++ b/common/per_peer_state.c @@ -2,7 +2,6 @@ #include #include #include -#include #include #include #include @@ -15,121 +14,37 @@ static void destroy_per_peer_state(struct per_peer_state *pps) close(pps->peer_fd); if (pps->gossip_fd != -1) close(pps->gossip_fd); - if (pps->gossip_store_fd != -1) - close(pps->gossip_store_fd); } struct per_peer_state *new_per_peer_state(const tal_t *ctx) { struct per_peer_state *pps = tal(ctx, struct per_peer_state); - pps->gs = NULL; - pps->peer_fd = pps->gossip_fd = pps->gossip_store_fd = -1; - pps->grf = new_gossip_rcvd_filter(pps); + pps->peer_fd = pps->gossip_fd = -1; tal_add_destructor(pps, destroy_per_peer_state); return pps; } void per_peer_state_set_fds(struct per_peer_state *pps, - int peer_fd, int gossip_fd, int gossip_store_fd) + int peer_fd, int gossip_fd) { assert(pps->peer_fd == -1); assert(pps->gossip_fd == -1); - assert(pps->gossip_store_fd == -1); pps->peer_fd = peer_fd; pps->gossip_fd = gossip_fd; - pps->gossip_store_fd = gossip_store_fd; } void per_peer_state_set_fds_arr(struct per_peer_state *pps, const int *fds) { - /* We expect 3 fds. */ - assert(tal_count(fds) == 3); - per_peer_state_set_fds(pps, fds[0], fds[1], fds[2]); -} - -void towire_gossip_state(u8 **pptr, const struct gossip_state *gs) -{ - towire_u64(pptr, gs->next_gossip.ts.tv_sec); - towire_u64(pptr, gs->next_gossip.ts.tv_nsec); - towire_u32(pptr, gs->timestamp_min); - towire_u32(pptr, gs->timestamp_max); -} - -void fromwire_gossip_state(const u8 **cursor, size_t *max, - struct gossip_state *gs) -{ - gs->next_gossip.ts.tv_sec = fromwire_u64(cursor, max); - gs->next_gossip.ts.tv_nsec = fromwire_u64(cursor, max); - gs->timestamp_min = fromwire_u32(cursor, max); - gs->timestamp_max = fromwire_u32(cursor, max); -} - -void towire_per_peer_state(u8 **pptr, const struct per_peer_state *pps) -{ - towire_bool(pptr, pps->gs != NULL); - if (pps->gs) - towire_gossip_state(pptr, pps->gs); - /* We don't pass the gossip_rcvd_filter: it's merely an optimization */ + /* We expect 2 fds. */ + assert(tal_count(fds) == 2); + per_peer_state_set_fds(pps, fds[0], fds[1]); } void per_peer_state_fdpass_send(int fd, const struct per_peer_state *pps) { assert(pps->peer_fd != -1); assert(pps->gossip_fd != -1); - assert(pps->gossip_store_fd != -1); fdpass_send(fd, pps->peer_fd); fdpass_send(fd, pps->gossip_fd); - fdpass_send(fd, pps->gossip_store_fd); -} - -struct per_peer_state *fromwire_per_peer_state(const tal_t *ctx, - const u8 **cursor, size_t *max) -{ - struct per_peer_state *pps; - - pps = new_per_peer_state(ctx); - if (fromwire_bool(cursor, max)) { - pps->gs = tal(pps, struct gossip_state); - fromwire_gossip_state(cursor, max, pps->gs); - } - return pps; -} - -/* FIXME: Put in ccan/time */ -/* Is a after b? */ -static inline bool timemono_after(struct timemono a, struct timemono b) -{ - return time_greater_(a.ts, b.ts); -} - -bool time_to_next_gossip(const struct per_peer_state *pps, - struct timerel *t) -{ - if (!pps->gs) - return false; - - struct timemono now = time_mono(); - if (timemono_after(now, pps->gs->next_gossip)) - *t = time_from_sec(0); - else - *t = timemono_between(pps->gs->next_gossip, now); - return true; -} - -/* BOLT #7: - * - * A node: - *... - * - SHOULD flush outgoing gossip messages once every 60 seconds, - * independently of the arrival times of the messages. - * - Note: this results in staggered announcements that are unique - * (not duplicated). - */ -void per_peer_state_reset_gossip_timer(struct per_peer_state *pps) -{ - struct timerel t = time_from_sec(GOSSIP_FLUSH_INTERVAL(dev_fast_gossip)); - - pps->gs->next_gossip = timemono_add(time_mono(), t); - gossip_rcvd_filter_age(pps->grf); } diff --git a/common/per_peer_state.h b/common/per_peer_state.h index e5e3b914cb6f..a81360ab3485 100644 --- a/common/per_peer_state.h +++ b/common/per_peer_state.h @@ -15,45 +15,21 @@ struct gossip_state { /* Things we hand between daemons to talk to peers. */ struct per_peer_state { - /* NULL if it's not initialized yet */ - struct gossip_state *gs; - /* Cache of msgs we have received, to avoid re-xmitting from store */ - struct gossip_rcvd_filter *grf; /* If not -1, closed on freeing */ - int peer_fd, gossip_fd, gossip_store_fd; + int peer_fd, gossip_fd; }; /* Allocate a new per-peer state and add destructor to close fds if set; - * sets fds to -1 and ->gs to NULL.. */ + * sets fds to -1. */ struct per_peer_state *new_per_peer_state(const tal_t *ctx); /* Initialize the fds (must be -1 previous) */ void per_peer_state_set_fds(struct per_peer_state *pps, - int peer_fd, int gossip_fd, int gossip_store_fd); + int peer_fd, int gossip_fd); -/* Array version of above: tal_count(fds) must be 3 */ +/* Array version of above: tal_count(fds) must be 2 */ void per_peer_state_set_fds_arr(struct per_peer_state *pps, const int *fds); -/* These routines do *part* of the work: you need to per_peer_state_fdpass_send - * or receive the three fds afterwards! */ -void towire_per_peer_state(u8 **pptr, const struct per_peer_state *pps); void per_peer_state_fdpass_send(int fd, const struct per_peer_state *pps); -struct per_peer_state *fromwire_per_peer_state(const tal_t *ctx, - const u8 **cursor, size_t *max); - -void towire_gossip_state(u8 **pptr, const struct gossip_state *gs); -void fromwire_gossip_state(const u8 **cursor, size_t *max, - struct gossip_state *gs); - -/* How long until we have to check gossip store, if any? */ -bool time_to_next_gossip(const struct per_peer_state *pps, - struct timerel *t); - -/* Reset pps->next_gossip now we've drained gossip_store */ -void per_peer_state_reset_gossip_timer(struct per_peer_state *pps); - -/* Used to speed up gossip iff DEVELOPER*/ -extern bool dev_fast_gossip; - #endif /* LIGHTNING_COMMON_PER_PEER_STATE_H */ diff --git a/common/read_peer_msg.c b/common/read_peer_msg.c index a1c0405e49a4..fe841108c6c4 100644 --- a/common/read_peer_msg.c +++ b/common/read_peer_msg.c @@ -1,8 +1,6 @@ #include "config.h" #include #include -#include -#include #include #include #include @@ -21,31 +19,15 @@ u8 *peer_or_gossip_sync_read(const tal_t *ctx, fd_set readfds; u8 *msg; - for (;;) { - struct timeval tv, *tptr; - struct timerel trel; - - if (time_to_next_gossip(pps, &trel)) { - tv = timerel_to_timeval(trel); - tptr = &tv; - } else - tptr = NULL; - - FD_ZERO(&readfds); - FD_SET(pps->peer_fd, &readfds); - FD_SET(pps->gossip_fd, &readfds); - - if (select(pps->peer_fd > pps->gossip_fd - ? pps->peer_fd + 1 : pps->gossip_fd + 1, - &readfds, NULL, NULL, tptr) != 0) - break; - - /* We timed out; look in gossip_store. Failure resets timer. */ - msg = gossip_store_next(tmpctx, pps); - if (msg) { - *from_gossipd = true; - return msg; - } + FD_ZERO(&readfds); + FD_SET(pps->peer_fd, &readfds); + FD_SET(pps->gossip_fd, &readfds); + + if (select(pps->peer_fd > pps->gossip_fd + ? pps->peer_fd + 1 : pps->gossip_fd + 1, + &readfds, NULL, NULL, NULL) <= 0) { + status_failed(STATUS_FAIL_GOSSIP_IO, + "select failed?: %s", strerror(errno)); } if (FD_ISSET(pps->peer_fd, &readfds)) { @@ -128,31 +110,6 @@ void handle_gossip_msg(struct per_peer_state *pps, const u8 *msg TAKES) } } -/* takes iff returns true */ -bool handle_timestamp_filter(struct per_peer_state *pps, const u8 *msg TAKES) -{ - struct bitcoin_blkid chain_hash; - u32 first_timestamp, timestamp_range; - - if (!fromwire_gossip_timestamp_filter(msg, &chain_hash, - &first_timestamp, - ×tamp_range)) { - return false; - } - - if (!bitcoin_blkid_eq(&chainparams->genesis_blockhash, &chain_hash)) { - peer_write(pps, - take(towire_warningfmt(NULL, NULL, - "gossip_timestamp_filter" - " for bad chain: %s", - tal_hex(tmpctx, take(msg))))); - return true; - } - - gossip_setup_timestamp_filter(pps, first_timestamp, timestamp_range); - return true; -} - bool handle_peer_gossip_or_error(struct per_peer_state *pps, const struct channel_id *channel_id, bool soft_error, @@ -177,15 +134,11 @@ bool handle_peer_gossip_or_error(struct per_peer_state *pps, goto handled; #endif - if (handle_timestamp_filter(pps, msg)) - return true; - else if (check_ping_make_pong(NULL, msg, &pong)) { + if (check_ping_make_pong(NULL, msg, &pong)) { if (pong) peer_write(pps, take(pong)); return true; } else if (is_msg_for_gossipd(msg)) { - if (is_msg_gossip_broadcast(msg)) - gossip_rcvd_filter_add(pps->grf, msg); wire_sync_write(pps->gossip_fd, msg); /* wire_sync_write takes, so don't take again. */ return true; diff --git a/connectd/connectd.c b/connectd/connectd.c index f22f21d9937c..a3c939acbbcd 100644 --- a/connectd/connectd.c +++ b/connectd/connectd.c @@ -223,7 +223,7 @@ static bool get_gossipfds(struct daemon *daemon, const u8 *their_features, struct per_peer_state *pps) { - bool gossip_queries_feature, initial_routing_sync, success; + bool gossip_queries_feature, success; u8 *msg; /*~ The way features generally work is that both sides need to offer it; @@ -232,23 +232,16 @@ static bool get_gossipfds(struct daemon *daemon, = feature_negotiated(daemon->our_features, their_features, OPT_GOSSIP_QUERIES); - /*~ `initial_routing_sync` is supported by every node, since it was in - * the initial lightning specification: it means the peer wants the - * backlog of existing gossip. */ - initial_routing_sync - = feature_offered(their_features, OPT_INITIAL_ROUTING_SYNC); - /*~ We do this communication sync, since gossipd is our friend and * it's easier. If gossipd fails, we fail. */ - msg = towire_gossipd_new_peer(NULL, id, gossip_queries_feature, - initial_routing_sync); + msg = towire_gossipd_new_peer(NULL, id, gossip_queries_feature); if (!wire_sync_write(GOSSIPCTL_FD, take(msg))) status_failed(STATUS_FAIL_INTERNAL_ERROR, "Failed writing to gossipctl: %s", strerror(errno)); msg = wire_sync_read(tmpctx, GOSSIPCTL_FD); - if (!fromwire_gossipd_new_peer_reply(pps, msg, &success, &pps->gs)) + if (!fromwire_gossipd_new_peer_reply(msg, &success)) status_failed(STATUS_FAIL_INTERNAL_ERROR, "Failed parsing msg gossipctl: %s", tal_hex(tmpctx, msg)); @@ -261,10 +254,9 @@ static bool get_gossipfds(struct daemon *daemon, return false; } - /* Otherwise, the next thing in the socket will be the file descriptors + /* Otherwise, the next thing in the socket will be the file descriptor * for the per-peer daemon. */ pps->gossip_fd = fdpass_recv(GOSSIPCTL_FD); - pps->gossip_store_fd = fdpass_recv(GOSSIPCTL_FD); return true; } @@ -454,6 +446,7 @@ struct io_plan *peer_connected(struct io_conn *conn, if (!peer) return io_close(conn); + /* FIXME: Remove pps abstraction! */ pps = new_per_peer_state(tmpctx); /* If gossipd can't give us a file descriptor, we give up connecting. */ @@ -467,7 +460,7 @@ struct io_plan *peer_connected(struct io_conn *conn, /* Create message to tell master peer has connected. */ msg = towire_connectd_peer_connected(NULL, id, addr, incoming, - pps, their_features); + their_features); /*~ daemon_conn is a message queue for inter-daemon communication: we * queue up the `connect_peer_connected` message to tell lightningd @@ -475,10 +468,9 @@ struct io_plan *peer_connected(struct io_conn *conn, daemon_conn_send(daemon->master, take(msg)); daemon_conn_send_fd(daemon->master, subd_fd); daemon_conn_send_fd(daemon->master, pps->gossip_fd); - daemon_conn_send_fd(daemon->master, pps->gossip_store_fd); - /* Don't try to close these on freeing. */ - pps->gossip_store_fd = pps->gossip_fd = -1; + /* Don't try to close this on freeing. */ + pps->gossip_fd = -1; /*~ Now we set up this connection to read/write from subd */ return multiplex_peer_setup(conn, peer); @@ -1892,10 +1884,9 @@ static void peer_final_msg(struct io_conn *conn, struct per_peer_state *pps; struct node_id id; u8 *finalmsg; - int fds[3]; + int fds[2]; - /* pps is allocated off f, so fds are closed when f freed. */ - if (!fromwire_connectd_peer_final_msg(tmpctx, msg, &id, &pps, &finalmsg)) + if (!fromwire_connectd_peer_final_msg(tmpctx, msg, &id, &finalmsg)) master_badmsg(WIRE_CONNECTD_PEER_FINAL_MSG, msg); /* Get the fds for this peer. */ @@ -1912,8 +1903,9 @@ static void peer_final_msg(struct io_conn *conn, /* Close fd to ourselves. */ close(fds[0]); - /* We put peer fd into conn, but pps needs to free the rest */ - per_peer_state_set_fds(pps, -1, fds[1], fds[2]); + /* We put peer fd into conn, but pps needs to free the gossip_fd */ + pps = new_per_peer_state(tmpctx); + per_peer_state_set_fds(pps, -1, fds[1]); /* This can happen if peer hung up on us. */ peer = peer_htable_get(&daemon->peers, &id); diff --git a/connectd/connectd_gossipd_wire.csv b/connectd/connectd_gossipd_wire.csv index c0d9152c9957..11133197442f 100644 --- a/connectd/connectd_gossipd_wire.csv +++ b/connectd/connectd_gossipd_wire.csv @@ -5,15 +5,12 @@ # Communication between gossipd and connectd. msgtype,gossipd_new_peer,4000 msgdata,gossipd_new_peer,id,node_id, -# Did we negotiate LOCAL_GOSSIP_QUERIES? +# Did we negotiate OPT_GOSSIP_QUERIES? msgdata,gossipd_new_peer,gossip_queries_feature,bool, -# Did they offer LOCAL_INITIAL_ROUTING_SYNC? -msgdata,gossipd_new_peer,initial_routing_sync,bool, -# if success: + gossip fd and gossip_store fd +# if success: + gossip fd msgtype,gossipd_new_peer_reply,4100 msgdata,gossipd_new_peer_reply,success,bool, -msgdata,gossipd_new_peer_reply,gs,?gossip_state, # Connectd asks gossipd for any known addresses for that node. msgtype,gossipd_get_addrs,4001 diff --git a/connectd/connectd_wire.csv b/connectd/connectd_wire.csv index bb5d0296f78e..960f74f9f90a 100644 --- a/connectd/connectd_wire.csv +++ b/connectd/connectd_wire.csv @@ -2,7 +2,6 @@ #include #include #include -#include #include msgtype,connectd_init,2000 @@ -63,7 +62,6 @@ msgtype,connectd_peer_connected,2002 msgdata,connectd_peer_connected,id,node_id, msgdata,connectd_peer_connected,addr,wireaddr_internal, msgdata,connectd_peer_connected,incoming,bool, -msgdata,connectd_peer_connected,pps,per_peer_state, msgdata,connectd_peer_connected,flen,u16, msgdata,connectd_peer_connected,features,u8,flen @@ -74,7 +72,6 @@ msgdata,connectd_peer_disconnected,id,node_id, # master -> connectd: give message to peer and disconnect. Three fds: peer, gossip and gossip_store msgtype,connectd_peer_final_msg,2003 msgdata,connectd_peer_final_msg,id,node_id, -msgdata,connectd_peer_final_msg,pps,per_peer_state, msgdata,connectd_peer_final_msg,len,u16, msgdata,connectd_peer_final_msg,msg,u8,len diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index 0b723508606a..9cfee53f4e6c 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -831,37 +831,21 @@ static struct io_plan *connectd_new_peer(struct io_conn *conn, struct peer *peer = tal(conn, struct peer); struct node *node; int fds[2]; - int gossip_store_fd; - struct gossip_state *gs; if (!fromwire_gossipd_new_peer(msg, &peer->id, - &peer->gossip_queries_feature, - &peer->initial_routing_sync_feature)) { + &peer->gossip_queries_feature)) { status_broken("Bad new_peer msg from connectd: %s", tal_hex(tmpctx, msg)); return io_close(conn); } - gossip_store_fd = gossip_store_readonly_fd(daemon->rstate->gs);; - if (gossip_store_fd < 0) { - status_broken("Failed to get readonly store fd: %s", - strerror(errno)); - daemon_conn_send(daemon->connectd, - take(towire_gossipd_new_peer_reply(NULL, - false, - NULL))); - goto done; - } - /* This can happen: we handle it gracefully, returning a `failed` msg. */ if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) != 0) { status_broken("Failed to create socketpair: %s", strerror(errno)); - close(gossip_store_fd); daemon_conn_send(daemon->connectd, take(towire_gossipd_new_peer_reply(NULL, - false, - NULL))); + false))); goto done; } @@ -898,43 +882,10 @@ static struct io_plan *connectd_new_peer(struct io_conn *conn, /* This sends the initial timestamp filter. */ seeker_setup_peer_gossip(daemon->seeker, peer); - /* BOLT #7: - * - * A node: - * - if the `gossip_queries` feature is negotiated: - * - MUST NOT relay any gossip messages it did not generate itself, - * unless explicitly requested. - */ - if (peer->gossip_queries_feature) { - gs = NULL; - } else { - /* BOLT #7: - * - * - upon receiving an `init` message with the - * `initial_routing_sync` flag set to 1: - * - SHOULD send gossip messages for all known channels and - * nodes, as if they were just received. - * - if the `initial_routing_sync` flag is set to 0, OR if the - * initial sync was completed: - * - SHOULD resume normal operation, as specified in the - * following [Rebroadcasting](#rebroadcasting) section. - */ - gs = tal(tmpctx, struct gossip_state); - gs->timestamp_min = 0; - gs->timestamp_max = UINT32_MAX; - - /* If they don't want initial sync, start at end of store */ - if (!peer->initial_routing_sync_feature) - lseek(gossip_store_fd, 0, SEEK_END); - - gs->next_gossip = time_mono(); - } - /* Reply with success, and the new fd and gossip_state. */ daemon_conn_send(daemon->connectd, - take(towire_gossipd_new_peer_reply(NULL, true, gs))); + take(towire_gossipd_new_peer_reply(NULL, true))); daemon_conn_send_fd(daemon->connectd, fds[1]); - daemon_conn_send_fd(daemon->connectd, gossip_store_fd); done: return daemon_conn_read_next(conn, daemon->connectd); diff --git a/gossipd/test/run-onion_message.c b/gossipd/test/run-onion_message.c index b306112c4392..66bad4d6941b 100644 --- a/gossipd/test/run-onion_message.c +++ b/gossipd/test/run-onion_message.c @@ -110,7 +110,7 @@ bool fromwire_gossipd_new_blockheight(const void *p UNNEEDED, u32 *blockheight U bool fromwire_gossipd_new_lease_rates(const void *p UNNEEDED, struct lease_rates *rates UNNEEDED) { fprintf(stderr, "fromwire_gossipd_new_lease_rates called!\n"); abort(); } /* Generated stub for fromwire_gossipd_new_peer */ -bool fromwire_gossipd_new_peer(const void *p UNNEEDED, struct node_id *id UNNEEDED, bool *gossip_queries_feature UNNEEDED, bool *initial_routing_sync UNNEEDED) +bool fromwire_gossipd_new_peer(const void *p UNNEEDED, struct node_id *id UNNEEDED, bool *gossip_queries_feature UNNEEDED) { fprintf(stderr, "fromwire_gossipd_new_peer called!\n"); abort(); } /* Generated stub for fromwire_gossipd_outpoint_spent */ bool fromwire_gossipd_outpoint_spent(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED) @@ -136,9 +136,6 @@ const u8 *gossip_store_get(const tal_t *ctx UNNEEDED, /* Generated stub for gossip_store_load */ u32 gossip_store_load(struct routing_state *rstate UNNEEDED, struct gossip_store *gs UNNEEDED) { fprintf(stderr, "gossip_store_load called!\n"); abort(); } -/* Generated stub for gossip_store_readonly_fd */ -int gossip_store_readonly_fd(struct gossip_store *gs UNNEEDED) -{ fprintf(stderr, "gossip_store_readonly_fd called!\n"); abort(); } /* Generated stub for gossip_time_now */ struct timeabs gossip_time_now(const struct routing_state *rstate UNNEEDED) { fprintf(stderr, "gossip_time_now called!\n"); abort(); } @@ -342,7 +339,7 @@ u8 *towire_gossipd_init_reply(const tal_t *ctx UNNEEDED) u8 *towire_gossipd_new_blockheight_reply(const tal_t *ctx UNNEEDED) { fprintf(stderr, "towire_gossipd_new_blockheight_reply called!\n"); abort(); } /* Generated stub for towire_gossipd_new_peer_reply */ -u8 *towire_gossipd_new_peer_reply(const tal_t *ctx UNNEEDED, bool success UNNEEDED, const struct gossip_state *gs UNNEEDED) +u8 *towire_gossipd_new_peer_reply(const tal_t *ctx UNNEEDED, bool success UNNEEDED) { fprintf(stderr, "towire_gossipd_new_peer_reply called!\n"); abort(); } /* Generated stub for towire_warningfmt */ u8 *towire_warningfmt(const tal_t *ctx UNNEEDED, diff --git a/hsmd/hsmd.c b/hsmd/hsmd.c index 77a09622341d..a7342a2e1a0e 100644 --- a/hsmd/hsmd.c +++ b/hsmd/hsmd.c @@ -614,6 +614,9 @@ static struct io_plan *handle_client(struct io_conn *conn, struct client *c) { enum hsmd_wire t = fromwire_peektype(c->msg_in); + if (!is_lightningd(c)) + status_peer_debug(&c->id, "Got %s", hsmd_wire_name(t)); + /* Before we do anything else, is this client allowed to do * what he asks for? */ if (!hsmd_check_client_capabilities(c->hsmd_client, t)) diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c index 9092970236d7..fc2de4ee43dd 100644 --- a/lightningd/channel_control.c +++ b/lightningd/channel_control.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -357,11 +358,12 @@ static void peer_start_closingd_after_shutdown(struct channel *channel, { struct per_peer_state *pps; - if (!fromwire_channeld_shutdown_complete(tmpctx, msg, &pps)) { + if (!fromwire_channeld_shutdown_complete(msg)) { channel_internal_error(channel, "bad shutdown_complete: %s", tal_hex(msg, msg)); return; } + pps = new_per_peer_state(msg); per_peer_state_set_fds_arr(pps, fds); /* This sets channel->owner, closes down channeld. */ @@ -489,9 +491,9 @@ static unsigned channel_msg(struct subd *sd, const u8 *msg, const int *fds) peer_got_shutdown(sd->channel, msg); break; case WIRE_CHANNELD_SHUTDOWN_COMPLETE: - /* We expect 3 fds. */ + /* We expect 2 fds. */ if (!fds) - return 3; + return 2; peer_start_closingd_after_shutdown(sd->channel, msg, fds); break; case WIRE_CHANNELD_FAIL_FALLEN_BEHIND: @@ -586,7 +588,6 @@ void peer_start_channeld(struct channel *channel, channel_set_billboard, take(&pps->peer_fd), take(&pps->gossip_fd), - take(&pps->gossip_store_fd), take(&hsmfd), NULL)); if (!channel->owner) { @@ -669,7 +670,6 @@ void peer_start_channeld(struct channel *channel, feerate_max(ld, NULL), try_get_feerate(ld->topology, FEERATE_PENALTY), &channel->last_sig, - pps, &channel->channel_info.remote_fundingkey, &channel->channel_info.theirbase, &channel->channel_info.remote_per_commit, diff --git a/lightningd/closing_control.c b/lightningd/closing_control.c index 96f600c7889a..4a42e1fea76f 100644 --- a/lightningd/closing_control.c +++ b/lightningd/closing_control.c @@ -380,7 +380,6 @@ void peer_start_closingd(struct channel *channel, channel_set_billboard, take(&pps->peer_fd), take(&pps->gossip_fd), - take(&pps->gossip_store_fd), take(&hsmfd), NULL)); @@ -455,7 +454,6 @@ void peer_start_closingd(struct channel *channel, initmsg = towire_closingd_init(tmpctx, chainparams, - pps, &channel->cid, &channel->funding, channel->funding_sats, @@ -476,7 +474,6 @@ void peer_start_closingd(struct channel *channel, && channel->closing_fee_negotiation_step_unit == CLOSING_FEE_NEGOTIATION_STEP_UNIT_PERCENTAGE) /* Always use quickclose with anchors */ || option_anchor_outputs, - IFDEV(ld->dev_fast_gossip, false), channel->shutdown_wrong_funding); /* We don't expect a response: it will give us feedback on diff --git a/lightningd/connect_control.c b/lightningd/connect_control.c index a1db898c4d52..16940f44c0dd 100644 --- a/lightningd/connect_control.c +++ b/lightningd/connect_control.c @@ -312,9 +312,9 @@ static unsigned connectd_msg(struct subd *connectd, const u8 *msg, const int *fd break; case WIRE_CONNECTD_PEER_CONNECTED: - if (tal_count(fds) != 3) - return 3; - peer_connected(connectd->ld, msg, fds[0], fds[1], fds[2]); + if (tal_count(fds) != 2) + return 2; + peer_connected(connectd->ld, msg, fds[0], fds[1]); break; case WIRE_CONNECTD_CONNECT_FAILED: diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c index badaaf6f8df7..22051750e548 100644 --- a/lightningd/dual_open_control.c +++ b/lightningd/dual_open_control.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -1348,16 +1349,16 @@ static void handle_channel_closed(struct subd *dualopend, struct per_peer_state *pps; struct channel *channel = dualopend->channel; - if (!fromwire_dualopend_shutdown_complete(tmpctx, msg, &pps)) { + if (!fromwire_dualopend_shutdown_complete(msg)) { channel_internal_error(dualopend->channel, "Bad DUALOPEND_SHUTDOWN_COMPLETE: %s", tal_hex(msg, msg)); close(fds[0]); close(fds[1]); - close(fds[2]); return; } + pps = new_per_peer_state(tmpctx); per_peer_state_set_fds_arr(pps, fds); peer_start_closingd(channel, pps); @@ -1630,12 +1631,13 @@ static void handle_channel_locked(struct subd *dualopend, struct channel *channel = dualopend->channel; struct per_peer_state *pps; - if (!fromwire_dualopend_channel_locked(tmpctx, msg, &pps)) { + if (!fromwire_dualopend_channel_locked(msg)) { channel_internal_error(channel, "Bad WIRE_DUALOPEND_CHANNEL_LOCKED: %s", tal_hex(msg, msg)); return; } + pps = new_per_peer_state(tmpctx); per_peer_state_set_fds_arr(pps, fds); assert(channel->scid); @@ -2976,16 +2978,16 @@ static unsigned int dual_opend_msg(struct subd *dualopend, handle_dry_run_finished(dualopend, msg); return 0; case WIRE_DUALOPEND_CHANNEL_LOCKED: - if (tal_count(fds) != 3) - return 3; + if (tal_count(fds) != 2) + return 2; handle_channel_locked(dualopend, fds, msg); return 0; case WIRE_DUALOPEND_GOT_SHUTDOWN: handle_peer_wants_to_close(dualopend, msg); return 0; case WIRE_DUALOPEND_SHUTDOWN_COMPLETE: - if (tal_count(fds) != 3) - return 3; + if (tal_count(fds) != 2) + return 2; handle_channel_closed(dualopend, fds, msg); return 0; case WIRE_DUALOPEND_FAIL_FALLEN_BEHIND: @@ -3220,7 +3222,6 @@ static void start_fresh_dualopend(struct peer *peer, channel_set_billboard, take(&pps->peer_fd), take(&pps->gossip_fd), - take(&pps->gossip_store_fd), take(&hsmfd), NULL); if (!channel->owner) { @@ -3249,7 +3250,7 @@ static void start_fresh_dualopend(struct peer *peer, &channel->our_config, max_to_self_delay, min_effective_htlc_capacity, - pps, &channel->local_basepoints, + &channel->local_basepoints, &channel->local_funding_pubkey, channel->minimum_depth); subd_send_msg(channel->owner, take(msg)); @@ -3288,7 +3289,6 @@ void peer_restart_dualopend(struct peer *peer, channel_set_billboard, take(&pps->peer_fd), take(&pps->gossip_fd), - take(&pps->gossip_store_fd), take(&hsmfd), NULL)); if (!channel->owner) { log_broken(channel->log, "Could not subdaemon channel: %s", @@ -3330,7 +3330,6 @@ void peer_restart_dualopend(struct peer *peer, &channel->cid, max_to_self_delay, min_effective_htlc_capacity, - pps, &channel->local_basepoints, &channel->local_funding_pubkey, &channel->channel_info.remote_fundingkey, diff --git a/lightningd/opening_common.c b/lightningd/opening_common.c index 0b02b41d5de7..bcf6ba210719 100644 --- a/lightningd/opening_common.c +++ b/lightningd/opening_common.c @@ -1,6 +1,7 @@ #include "config.h" #include #include +#include #include #include #include @@ -192,14 +193,12 @@ void handle_reestablish(struct lightningd *ld, type_to_string(tmpctx, struct channel_id, channel_id)); subd_send_msg(ld->connectd, take(towire_connectd_peer_final_msg(NULL, peer_id, - pps, err))); + err))); subd_send_fd(ld->connectd, pps->peer_fd); subd_send_fd(ld->connectd, pps->gossip_fd); - subd_send_fd(ld->connectd, pps->gossip_store_fd); /* Don't close those fds! */ pps->peer_fd = pps->gossip_fd - = pps->gossip_store_fd = -1; } } diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index 9e78a6963766..4cb58766e95f 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -348,7 +349,6 @@ static void opening_funder_finished(struct subd *openingd, const u8 *resp, &remote_commit, &pbase, &remote_commit_sig, - &pps, &channel_info.theirbase.revocation, &channel_info.theirbase.payment, &channel_info.theirbase.htlc, @@ -370,6 +370,8 @@ static void opening_funder_finished(struct subd *openingd, const u8 *resp, goto cleanup; } remote_commit->chainparams = chainparams; + + pps = new_per_peer_state(resp); per_peer_state_set_fds_arr(pps, fds); log_debug(ld->log, @@ -448,7 +450,6 @@ static void opening_fundee_finished(struct subd *openingd, &remote_commit, &pbase, &remote_commit_sig, - &pps, &channel_info.theirbase.revocation, &channel_info.theirbase.payment, &channel_info.theirbase.htlc, @@ -473,6 +474,7 @@ static void opening_fundee_finished(struct subd *openingd, } remote_commit->chainparams = chainparams; + pps = new_per_peer_state(tmpctx); per_peer_state_set_fds_arr(pps, fds); /* openingd should never accept them funding channel in this case. */ @@ -530,7 +532,6 @@ static void opening_fundee_finished(struct subd *openingd, failed: close(fds[0]); close(fds[1]); - close(fds[3]); tal_free(uc); } @@ -803,7 +804,7 @@ static void opening_got_offer(struct subd *openingd, } static void opening_got_reestablish(struct subd *openingd, const u8 *msg, - const int fds[3], + const int fds[2], struct uncommitted_channel *uc) { struct lightningd *ld = openingd->ld; @@ -813,12 +814,13 @@ static void opening_got_reestablish(struct subd *openingd, const u8 *msg, struct per_peer_state *pps; if (!fromwire_openingd_got_reestablish(tmpctx, msg, &channel_id, - &reestablish, &pps)) { + &reestablish)) { log_broken(openingd->log, "Malformed opening_got_reestablish %s", tal_hex(tmpctx, msg)); tal_free(openingd); return; } + pps = new_per_peer_state(tmpctx); per_peer_state_set_fds_arr(pps, fds); /* This could free peer */ @@ -841,8 +843,8 @@ static unsigned int openingd_msg(struct subd *openingd, tal_free(openingd); return 0; } - if (tal_count(fds) != 3) - return 3; + if (tal_count(fds) != 2) + return 2; opening_funder_finished(openingd, msg, fds, uc->fc); return 0; case WIRE_OPENINGD_FUNDER_START_REPLY: @@ -865,8 +867,8 @@ static unsigned int openingd_msg(struct subd *openingd, return 0; case WIRE_OPENINGD_FUNDEE: - if (tal_count(fds) != 3) - return 3; + if (tal_count(fds) != 2) + return 2; opening_fundee_finished(openingd, msg, fds, uc); return 0; @@ -875,8 +877,8 @@ static unsigned int openingd_msg(struct subd *openingd, return 0; case WIRE_OPENINGD_GOT_REESTABLISH: - if (tal_count(fds) != 3) - return 3; + if (tal_count(fds) != 2) + return 2; opening_got_reestablish(openingd, msg, fds, uc); return 0; @@ -932,7 +934,6 @@ void peer_start_openingd(struct peer *peer, struct per_peer_state *pps) opend_channel_set_billboard, take(&pps->peer_fd), take(&pps->gossip_fd), - take(&pps->gossip_store_fd), take(&hsmfd), NULL); if (!uc->open_daemon) { uncommitted_channel_disconnect(uc, LOG_BROKEN, @@ -962,13 +963,12 @@ void peer_start_openingd(struct peer *peer, struct per_peer_state *pps) &uc->our_config, max_to_self_delay, min_effective_htlc_capacity, - pps, &uc->local_basepoints, + &uc->local_basepoints, &uc->local_funding_pubkey, uc->minimum_depth, feerate_min(peer->ld, NULL), feerate_max(peer->ld, NULL), - IFDEV(peer->ld->dev_force_tmp_channel_id, NULL), - IFDEV(peer->ld->dev_fast_gossip, false)); + IFDEV(peer->ld->dev_force_tmp_channel_id, NULL)); subd_send_msg(uc->open_daemon, take(msg)); } diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 1df75a738a1c..2b3a1b3972b5 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -1052,14 +1052,12 @@ static void peer_connected_hook_final(struct peer_connected_hook_payload *payloa /* Get connectd to send error and close. */ subd_send_msg(ld->connectd, take(towire_connectd_peer_final_msg(NULL, &peer->id, - payload->pps, error))); + error))); subd_send_fd(ld->connectd, payload->pps->peer_fd); subd_send_fd(ld->connectd, payload->pps->gossip_fd); - subd_send_fd(ld->connectd, payload->pps->gossip_store_fd); /* Don't close those fds! */ payload->pps->peer_fd = payload->pps->gossip_fd - = payload->pps->gossip_store_fd = -1; } @@ -1117,7 +1115,7 @@ REGISTER_PLUGIN_HOOK(peer_connected, /* Connectd tells us a peer has connected: it never hands us duplicates, since * it holds them until we say peer_died. */ void peer_connected(struct lightningd *ld, const u8 *msg, - int peer_fd, int gossip_fd, int gossip_store_fd) + int peer_fd, int gossip_fd) { struct node_id id; u8 *their_features; @@ -1130,13 +1128,12 @@ void peer_connected(struct lightningd *ld, const u8 *msg, if (!fromwire_connectd_peer_connected(hook_payload, msg, &id, &hook_payload->addr, &hook_payload->incoming, - &hook_payload->pps, &their_features)) fatal("Connectd gave bad CONNECT_PEER_CONNECTED message %s", tal_hex(msg, msg)); - per_peer_state_set_fds(hook_payload->pps, - peer_fd, gossip_fd, gossip_store_fd); + hook_payload->pps = new_per_peer_state(hook_payload); + per_peer_state_set_fds(hook_payload->pps, peer_fd, gossip_fd); /* If we're already dealing with this peer, hand off to correct * subdaemon. Otherwise, we'll hand to openingd to wait there. */ diff --git a/lightningd/peer_control.h b/lightningd/peer_control.h index 97d96753bad6..3ce98cd368bc 100644 --- a/lightningd/peer_control.h +++ b/lightningd/peer_control.h @@ -65,7 +65,7 @@ struct peer *peer_from_json(struct lightningd *ld, const jsmntok_t *peeridtok); void peer_connected(struct lightningd *ld, const u8 *msg, - int peer_fd, int gossip_fd, int gossip_store_fd); + int peer_fd, int gossip_fd); /* Could be configurable. */ #define OUR_CHANNEL_FLAGS CHANNEL_FLAGS_ANNOUNCE_CHANNEL diff --git a/lightningd/subd.c b/lightningd/subd.c index 1ef25e9191a0..530706cd8027 100644 --- a/lightningd/subd.c +++ b/lightningd/subd.c @@ -404,7 +404,7 @@ static bool log_status_fail(struct subd *sd, const u8 *msg) return true; } -static bool handle_peer_error(struct subd *sd, const u8 *msg, int fds[3]) +static bool handle_peer_error(struct subd *sd, const u8 *msg, int fds[2]) { void *channel = sd->channel; struct channel_id channel_id; @@ -415,9 +415,10 @@ static bool handle_peer_error(struct subd *sd, const u8 *msg, int fds[3]) if (!fromwire_status_peer_error(msg, msg, &channel_id, &desc, &warning, - &pps, &err_for_them)) + &err_for_them)) return false; + pps = new_per_peer_state(msg); per_peer_state_set_fds_arr(pps, fds); /* Don't free sd; we may be about to free channel. */ @@ -523,11 +524,11 @@ static struct io_plan *sd_msg_read(struct io_conn *conn, struct subd *sd) if (sd->channel) { switch ((enum peer_status_wire)type) { case WIRE_STATUS_PEER_ERROR: - /* We expect 3 fds after this */ + /* We expect 2 fds after this */ if (!sd->fds_in) { /* Don't free msg_in: we go around again. */ tal_steal(sd, sd->msg_in); - plan = sd_collect_fds(conn, sd, 3); + plan = sd_collect_fds(conn, sd, 2); goto out; } if (!handle_peer_error(sd, sd->msg_in, sd->fds_in)) diff --git a/lightningd/test/run-find_my_abspath.c b/lightningd/test/run-find_my_abspath.c index f64cd1d4f1a4..9baf90cbf066 100644 --- a/lightningd/test/run-find_my_abspath.c +++ b/lightningd/test/run-find_my_abspath.c @@ -86,7 +86,7 @@ bool fromwire_status_fail(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, enu bool fromwire_status_peer_billboard(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, bool *perm UNNEEDED, wirestring **happenings UNNEEDED) { fprintf(stderr, "fromwire_status_peer_billboard called!\n"); abort(); } /* Generated stub for fromwire_status_peer_error */ -bool fromwire_status_peer_error(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct channel_id *channel UNNEEDED, wirestring **desc UNNEEDED, bool *warning UNNEEDED, struct per_peer_state **pps UNNEEDED, u8 **error_for_them UNNEEDED) +bool fromwire_status_peer_error(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct channel_id *channel UNNEEDED, wirestring **desc UNNEEDED, bool *warning UNNEEDED, u8 **error_for_them UNNEEDED) { fprintf(stderr, "fromwire_status_peer_error called!\n"); abort(); } /* Generated stub for fromwire_status_version */ bool fromwire_status_version(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, wirestring **version UNNEEDED) @@ -167,6 +167,9 @@ struct log *new_log(const tal_t *ctx UNNEEDED, struct log_book *record UNNEEDED, /* Generated stub for new_log_book */ struct log_book *new_log_book(struct lightningd *ld UNNEEDED, size_t max_mem UNNEEDED) { fprintf(stderr, "new_log_book called!\n"); abort(); } +/* Generated stub for new_per_peer_state */ +struct per_peer_state *new_per_peer_state(const tal_t *ctx UNNEEDED) +{ fprintf(stderr, "new_per_peer_state called!\n"); abort(); } /* Generated stub for new_topology */ struct chain_topology *new_topology(struct lightningd *ld UNNEEDED, struct log *log UNNEEDED) { fprintf(stderr, "new_topology called!\n"); abort(); } diff --git a/lightningd/test/run-invoice-select-inchan.c b/lightningd/test/run-invoice-select-inchan.c index 020921cbd682..aaaf1eaecbae 100644 --- a/lightningd/test/run-invoice-select-inchan.c +++ b/lightningd/test/run-invoice-select-inchan.c @@ -210,7 +210,7 @@ bool fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, bool fromwire_channeld_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED) { fprintf(stderr, "fromwire_channeld_dev_memleak_reply called!\n"); abort(); } /* Generated stub for fromwire_connectd_peer_connected */ -bool fromwire_connectd_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, struct wireaddr_internal *addr UNNEEDED, bool *incoming UNNEEDED, struct per_peer_state **pps UNNEEDED, u8 **features UNNEEDED) +bool fromwire_connectd_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, struct wireaddr_internal *addr UNNEEDED, bool *incoming UNNEEDED, u8 **features UNNEEDED) { fprintf(stderr, "fromwire_connectd_peer_connected called!\n"); abort(); } /* Generated stub for fromwire_hsmd_sign_bolt12_reply */ bool fromwire_hsmd_sign_bolt12_reply(const void *p UNNEEDED, struct bip340sig *sig UNNEEDED) @@ -444,6 +444,9 @@ struct height_states *new_height_states(const tal_t *ctx UNNEEDED, enum side opener UNNEEDED, const u32 *blockheight UNNEEDED) { fprintf(stderr, "new_height_states called!\n"); abort(); } +/* Generated stub for new_per_peer_state */ +struct per_peer_state *new_per_peer_state(const tal_t *ctx UNNEEDED) +{ fprintf(stderr, "new_per_peer_state called!\n"); abort(); } /* Generated stub for new_reltimer_ */ struct oneshot *new_reltimer_(struct timers *timers UNNEEDED, const tal_t *ctx UNNEEDED, @@ -598,7 +601,7 @@ struct channel *peer_unsaved_channel(struct peer *peer UNNEEDED) { fprintf(stderr, "peer_unsaved_channel called!\n"); abort(); } /* Generated stub for per_peer_state_set_fds */ void per_peer_state_set_fds(struct per_peer_state *pps UNNEEDED, - int peer_fd UNNEEDED, int gossip_fd UNNEEDED, int gossip_store_fd UNNEEDED) + int peer_fd UNNEEDED, int gossip_fd UNNEEDED) { fprintf(stderr, "per_peer_state_set_fds called!\n"); abort(); } /* Generated stub for plugin_hook_call_ */ bool plugin_hook_call_(struct lightningd *ld UNNEEDED, const struct plugin_hook *hook UNNEEDED, @@ -645,7 +648,7 @@ u8 *towire_channeld_specific_feerates(const tal_t *ctx UNNEEDED, u32 feerate_bas u8 *towire_connectd_connect_to_peer(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, u32 seconds_waited UNNEEDED, const struct wireaddr_internal *addrhint UNNEEDED) { fprintf(stderr, "towire_connectd_connect_to_peer called!\n"); abort(); } /* Generated stub for towire_connectd_peer_final_msg */ -u8 *towire_connectd_peer_final_msg(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, const struct per_peer_state *pps UNNEEDED, const u8 *msg UNNEEDED) +u8 *towire_connectd_peer_final_msg(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, const u8 *msg UNNEEDED) { fprintf(stderr, "towire_connectd_peer_final_msg called!\n"); abort(); } /* Generated stub for towire_errorfmt */ u8 *towire_errorfmt(const tal_t *ctx UNNEEDED, diff --git a/lightningd/test/run-shuffle_fds.c b/lightningd/test/run-shuffle_fds.c index c2a00d667439..3d7fb6e524d0 100644 --- a/lightningd/test/run-shuffle_fds.c +++ b/lightningd/test/run-shuffle_fds.c @@ -70,7 +70,7 @@ bool fromwire_status_fail(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, enu bool fromwire_status_peer_billboard(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, bool *perm UNNEEDED, wirestring **happenings UNNEEDED) { fprintf(stderr, "fromwire_status_peer_billboard called!\n"); abort(); } /* Generated stub for fromwire_status_peer_error */ -bool fromwire_status_peer_error(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct channel_id *channel UNNEEDED, wirestring **desc UNNEEDED, bool *warning UNNEEDED, struct per_peer_state **pps UNNEEDED, u8 **error_for_them UNNEEDED) +bool fromwire_status_peer_error(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct channel_id *channel UNNEEDED, wirestring **desc UNNEEDED, bool *warning UNNEEDED, u8 **error_for_them UNNEEDED) { fprintf(stderr, "fromwire_status_peer_error called!\n"); abort(); } /* Generated stub for fromwire_status_version */ bool fromwire_status_version(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, wirestring **version UNNEEDED) @@ -108,6 +108,9 @@ struct log *new_log(const tal_t *ctx UNNEEDED, struct log_book *record UNNEEDED, const struct node_id *default_node_id UNNEEDED, const char *fmt UNNEEDED, ...) { fprintf(stderr, "new_log called!\n"); abort(); } +/* Generated stub for new_per_peer_state */ +struct per_peer_state *new_per_peer_state(const tal_t *ctx UNNEEDED) +{ fprintf(stderr, "new_per_peer_state called!\n"); abort(); } /* Generated stub for per_peer_state_set_fds_arr */ void per_peer_state_set_fds_arr(struct per_peer_state *pps UNNEEDED, const int *fds UNNEEDED) { fprintf(stderr, "per_peer_state_set_fds_arr called!\n"); abort(); } diff --git a/openingd/dualopend.c b/openingd/dualopend.c index ed2eb2872211..997525a853e2 100644 --- a/openingd/dualopend.c +++ b/openingd/dualopend.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -44,9 +45,9 @@ #include #include -/* stdin == lightningd, 3 == peer, 4 == gossipd, 5 = gossip_store, 6 = hsmd */ +/* stdin == lightningd, 3 == peer, 4 == gossipd, 5 = hsmd */ #define REQ_FD STDIN_FILENO -#define HSM_FD 6 +#define HSM_FD 5 /* tx_add_input, tx_add_output, tx_rm_input, tx_rm_output */ #define NUM_TX_MSGS (TX_RM_OUTPUT + 1) @@ -297,7 +298,7 @@ static u8 *psbt_changeset_get_next(const tal_t *ctx, static void shutdown(struct state *state) { - u8 *msg = towire_dualopend_shutdown_complete(state, state->pps); + u8 *msg = towire_dualopend_shutdown_complete(state); wire_sync_write(REQ_FD, msg); per_peer_state_fdpass_send(REQ_FD, state->pps); @@ -1162,7 +1163,7 @@ static u8 *handle_funding_locked(struct state *state, u8 *msg) billboard_update(state); if (state->funding_locked[LOCAL]) - return towire_dualopend_channel_locked(state, state->pps); + return towire_dualopend_channel_locked(state); return NULL; } @@ -1197,7 +1198,6 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state) /* Some messages go straight to gossipd. */ if (is_msg_for_gossipd(msg)) { - gossip_rcvd_filter_add(state->pps->grf, msg); wire_sync_write(state->pps->gossip_fd, take(msg)); continue; } @@ -1211,10 +1211,6 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state) if (is_unknown_msg_discardable(msg)) continue; - /* Might be a timestamp filter request: handle. */ - if (handle_timestamp_filter(state->pps, msg)) - continue; - /* A helper which decodes an error. */ if (is_peer_error(tmpctx, msg, &state->channel_id, &err, &warning)) { @@ -3416,8 +3412,7 @@ static u8 *handle_funding_depth(struct state *state, u8 *msg) send_funding_locked(state); if (state->funding_locked[REMOTE]) - return towire_dualopend_channel_locked(state, - state->pps); + return towire_dualopend_channel_locked(state); return NULL; } @@ -3435,14 +3430,6 @@ static void handle_gossip_in(struct state *state) handle_gossip_msg(state->pps, take(msg)); } -static void try_read_gossip_store(struct state *state) -{ - u8 *msg = gossip_store_next(tmpctx, state->pps); - - if (msg) - peer_write(state->pps, take(msg)); -} - /* Try to handle a custommsg Returns true if it was a custom message and has * been handled, false if the message was not handled. */ @@ -3832,7 +3819,6 @@ int main(int argc, char *argv[]) &state->tx_state->localconf, &state->max_to_self_delay, &state->min_effective_htlc_capacity, - &state->pps, &state->our_points, &state->our_funding_pubkey, &state->minimum_depth)) { @@ -3864,7 +3850,6 @@ int main(int argc, char *argv[]) &state->channel_id, &state->max_to_self_delay, &state->min_effective_htlc_capacity, - &state->pps, &state->our_points, &state->our_funding_pubkey, &state->their_funding_pubkey, @@ -3932,8 +3917,9 @@ int main(int argc, char *argv[]) - /* 3 == peer, 4 == gossipd, 5 = gossip_store, 6 = hsmd */ - per_peer_state_set_fds(state->pps, 3, 4, 5); + /* 3 == peer, 4 == gossipd, 5 = hsmd */ + state->pps = new_per_peer_state(state); + per_peer_state_set_fds(state->pps, 3, 4); /*~ We need an initial per-commitment point whether we're funding or * they are, and lightningd has reserved a unique dbid for us already, @@ -3972,19 +3958,13 @@ int main(int argc, char *argv[]) * opening_funder_reply or opening_fundee. */ msg = NULL; while (!msg) { - int t; - struct timerel trel; - if (time_to_next_gossip(state->pps, &trel)) - t = time_to_msec(trel); - else - t = -1; /*~ If we get a signal which aborts the poll() call, valgrind * complains about revents being uninitialized. I'm not sure * that's correct, but it's easy to be sure. */ pollfd[0].revents = pollfd[1].revents = pollfd[2].revents = 0; - poll(pollfd, ARRAY_SIZE(pollfd), t); + poll(pollfd, ARRAY_SIZE(pollfd), -1); /* Subtle: handle_master_in can do its own poll loop, so * don't try to service more than one fd per loop. */ /* First priority: messages from lightningd. */ @@ -3996,13 +3976,10 @@ int main(int argc, char *argv[]) /* Last priority: chit-chat from gossipd. */ else if (pollfd[1].revents & POLLIN) handle_gossip_in(state); - else - try_read_gossip_store(state); /* If we've shutdown, we're done */ if (shutdown_complete(state)) - msg = towire_dualopend_shutdown_complete(state, - state->pps); + msg = towire_dualopend_shutdown_complete(state); /* Since we're the top-level event loop, we clean up */ clean_tmpctx(); } diff --git a/openingd/dualopend_wire.csv b/openingd/dualopend_wire.csv index 48177925bcc7..c87fbef2a30d 100644 --- a/openingd/dualopend_wire.csv +++ b/openingd/dualopend_wire.csv @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -23,7 +22,6 @@ msgdata,dualopend_init,our_config,channel_config, # Minimum/maximum configuration values we'll accept msgdata,dualopend_init,max_to_self_delay,u32, msgdata,dualopend_init,min_effective_htlc_capacity_msat,amount_msat, -msgdata,dualopend_init,pps,per_peer_state, msgdata,dualopend_init,our_basepoints,basepoints, msgdata,dualopend_init,our_funding_pubkey,pubkey, # Constraints in case the other end tries to open a channel. @@ -40,7 +38,6 @@ msgdata,dualopend_reinit,their_config,channel_config, msgdata,dualopend_reinit,channel_id,channel_id, msgdata,dualopend_reinit,max_to_self_delay,u32, msgdata,dualopend_reinit,min_effective_htlc_capacity_msat,amount_msat, -msgdata,dualopend_reinit,pps,per_peer_state, msgdata,dualopend_reinit,our_basepoints,basepoints, msgdata,dualopend_reinit,our_funding_pubkey,pubkey, msgdata,dualopend_reinit,their_funding_pubkey,pubkey, @@ -202,7 +199,6 @@ msgdata,dualopend_peer_locked,remote_per_commit,pubkey, # dualopend->master this channel has been locked msgtype,dualopend_channel_locked,7019 -msgdata,dualopend_channel_locked,pps,per_peer_state, # master->dualopend funding reached depth; tell peer msgtype,dualopend_depth_reached,7020 @@ -223,7 +219,6 @@ msgtype,dualopend_fail_fallen_behind,1028 # Shutdown is complete, ready for closing negotiation. + peer_fd & gossip_fd. msgtype,dualopend_shutdown_complete,7025 -msgdata,dualopend_shutdown_complete,per_peer_state,per_peer_state, # dualopend -> master: this was a dry run, here's some info about this open msgtype,dualopend_dry_run,7026 diff --git a/openingd/openingd.c b/openingd/openingd.c index 72471da3f6c5..e94c31f74437 100644 --- a/openingd/openingd.c +++ b/openingd/openingd.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -35,9 +36,9 @@ #include #include -/* stdin == lightningd, 3 == peer, 4 == gossipd, 5 = gossip_store, 6 = hsmd */ +/* stdin == lightningd, 3 == peer, 4 == gossipd, 5 = hsmd */ #define REQ_FD STDIN_FILENO -#define HSM_FD 6 +#define HSM_FD 5 #if DEVELOPER /* If --dev-force-tmp-channel-id is set, it ends up here */ @@ -205,7 +206,6 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state, /* Some messages go straight to gossipd. */ if (is_msg_for_gossipd(msg)) { - gossip_rcvd_filter_add(state->pps->grf, msg); wire_sync_write(state->pps->gossip_fd, take(msg)); continue; } @@ -219,10 +219,6 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state, if (is_unknown_msg_discardable(msg)) continue; - /* Might be a timestamp filter request: handle. */ - if (handle_timestamp_filter(state->pps, msg)) - continue; - /* A helper which decodes an error. */ if (is_peer_error(tmpctx, msg, &state->channel_id, &err, &warning)) { @@ -774,7 +770,6 @@ static u8 *funder_channel_complete(struct state *state) tx, pbase, &sig, - state->pps, &state->their_points.revocation, &state->their_points.payment, &state->their_points.htlc, @@ -1234,7 +1229,6 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg) local_commit, pbase, &theirsig, - state->pps, &theirs.revocation, &theirs.payment, &theirs.htlc, @@ -1286,8 +1280,7 @@ static u8 *handle_peer_in(struct state *state) /* Reestablish on some now-closed channel? Be nice. */ if (extracted && fromwire_peektype(msg) == WIRE_CHANNEL_REESTABLISH) { return towire_openingd_got_reestablish(NULL, - &channel_id, msg, - state->pps); + &channel_id, msg); } peer_write(state->pps, take(towire_warningfmt(NULL, @@ -1427,14 +1420,6 @@ static u8 *handle_master_in(struct state *state) "Unknown msg %s", tal_hex(tmpctx, msg)); } -static void try_read_gossip_store(struct state *state) -{ - u8 *msg = gossip_store_next(tmpctx, state->pps); - - if (msg) - peer_write(state->pps, take(msg)); -} - int main(int argc, char *argv[]) { setup_locale(); @@ -1460,21 +1445,20 @@ int main(int argc, char *argv[]) &state->localconf, &state->max_to_self_delay, &state->min_effective_htlc_capacity, - &state->pps, &state->our_points, &state->our_funding_pubkey, &state->minimum_depth, &state->min_feerate, &state->max_feerate, - &force_tmp_channel_id, - &dev_fast_gossip)) + &force_tmp_channel_id)) master_badmsg(WIRE_OPENINGD_INIT, msg); #if DEVELOPER dev_force_tmp_channel_id = force_tmp_channel_id; #endif - /* 3 == peer, 4 == gossipd, 5 = gossip_store, 6 = hsmd */ - per_peer_state_set_fds(state->pps, 3, 4, 5); + /* 3 == peer, 4 == gossipd, 5 = hsmd */ + state->pps = new_per_peer_state(state); + per_peer_state_set_fds(state->pps, 3, 4); /*~ Initially we're not associated with a channel, but * handle_peer_gossip_or_error compares this. */ @@ -1520,19 +1504,12 @@ int main(int argc, char *argv[]) * opening_funder_reply or opening_fundee. */ msg = NULL; while (!msg) { - int t; - struct timerel trel; - if (time_to_next_gossip(state->pps, &trel)) - t = time_to_msec(trel); - else - t = -1; - /*~ If we get a signal which aborts the poll() call, valgrind * complains about revents being uninitialized. I'm not sure * that's correct, but it's easy to be sure. */ pollfd[0].revents = pollfd[1].revents = pollfd[2].revents = 0; - poll(pollfd, ARRAY_SIZE(pollfd), t); + poll(pollfd, ARRAY_SIZE(pollfd), -1); /* Subtle: handle_master_in can do its own poll loop, so * don't try to service more than one fd per loop. */ /* First priority: messages from lightningd. */ @@ -1544,8 +1521,6 @@ int main(int argc, char *argv[]) /* Last priority: chit-chat from gossipd. */ else if (pollfd[1].revents & POLLIN) handle_gossip_in(state); - else - try_read_gossip_store(state); /* Since we're the top-level event loop, we clean up */ clean_tmpctx(); diff --git a/openingd/openingd_wire.csv b/openingd/openingd_wire.csv index 7a688c7f692f..b8f0fc5b9d6f 100644 --- a/openingd/openingd_wire.csv +++ b/openingd/openingd_wire.csv @@ -5,7 +5,6 @@ #include #include #include -#include msgtype,openingd_init,6000 # Which network are we configured for? @@ -18,7 +17,6 @@ msgdata,openingd_init,our_config,channel_config, # Minimum/maximum configuration values we'll accept msgdata,openingd_init,max_to_self_delay,u32, msgdata,openingd_init,min_effective_htlc_capacity_msat,amount_msat, -msgdata,openingd_init,pps,per_peer_state, msgdata,openingd_init,our_basepoints,basepoints, msgdata,openingd_init,our_funding_pubkey,pubkey, # Constraints in case the other end tries to open a channel. @@ -26,14 +24,12 @@ msgdata,openingd_init,minimum_depth,u32, msgdata,openingd_init,min_feerate,u32, msgdata,openingd_init,max_feerate,u32, msgdata,openingd_init,dev_temporary_channel_id,?byte,32 -msgdata,openingd_init,dev_fast_gossip,bool, # Openingd->master: they tried to reestablish a channel. msgtype,openingd_got_reestablish,6001 msgdata,openingd_got_reestablish,channel_id,channel_id, msgdata,openingd_got_reestablish,len,u16, msgdata,openingd_got_reestablish,msg,u8,len -msgdata,openingd_got_reestablish,pps,per_peer_state, # Openingd->master: they offered channel, should we continue? msgtype,openingd_got_offer,6005 @@ -65,7 +61,6 @@ msgdata,openingd_funder_reply,their_config,channel_config, msgdata,openingd_funder_reply,first_commit,bitcoin_tx, msgdata,openingd_funder_reply,pbase,?penalty_base, msgdata,openingd_funder_reply,first_commit_sig,bitcoin_signature, -msgdata,openingd_funder_reply,pps,per_peer_state, msgdata,openingd_funder_reply,revocation_basepoint,pubkey, msgdata,openingd_funder_reply,payment_basepoint,pubkey, msgdata,openingd_funder_reply,htlc_basepoint,pubkey, @@ -119,7 +114,6 @@ msgdata,openingd_fundee,their_config,channel_config, msgdata,openingd_fundee,first_commit,bitcoin_tx, msgdata,openingd_fundee,pbase,?penalty_base, msgdata,openingd_fundee,first_commit_sig,bitcoin_signature, -msgdata,openingd_fundee,pps,per_peer_state, msgdata,openingd_fundee,revocation_basepoint,pubkey, msgdata,openingd_fundee,payment_basepoint,pubkey, msgdata,openingd_fundee,htlc_basepoint,pubkey, diff --git a/tests/test_gossip.py b/tests/test_gossip.py index 75879bf95b5b..af6f9858d223 100644 --- a/tests/test_gossip.py +++ b/tests/test_gossip.py @@ -1335,8 +1335,7 @@ def test_gossipwith(node_factory): num_msgs += 1 # one channel announcement, two channel_updates, two node announcements. - # FIXME: Currently gets double gossip! - assert num_msgs == 5 * 2 + assert num_msgs == 5 def test_gossip_notices_close(node_factory, bitcoind): diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index e452202ee457..f137766a802f 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -130,7 +130,7 @@ bool fromwire_channeld_offer_htlc_reply(const tal_t *ctx UNNEEDED, const void *p bool fromwire_channeld_sending_commitsig(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u64 *commitnum UNNEEDED, struct penalty_base **pbase UNNEEDED, struct fee_states **fee_states UNNEEDED, struct height_states **blockheight_states UNNEEDED, struct changed_htlc **changed UNNEEDED, struct bitcoin_signature *commit_sig UNNEEDED, struct bitcoin_signature **htlc_sigs UNNEEDED) { fprintf(stderr, "fromwire_channeld_sending_commitsig called!\n"); abort(); } /* Generated stub for fromwire_connectd_peer_connected */ -bool fromwire_connectd_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, struct wireaddr_internal *addr UNNEEDED, bool *incoming UNNEEDED, struct per_peer_state **pps UNNEEDED, u8 **features UNNEEDED) +bool fromwire_connectd_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, struct wireaddr_internal *addr UNNEEDED, bool *incoming UNNEEDED, u8 **features UNNEEDED) { fprintf(stderr, "fromwire_connectd_peer_connected called!\n"); abort(); } /* Generated stub for fromwire_custommsg_in */ bool fromwire_custommsg_in(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **msg UNNEEDED) @@ -448,6 +448,9 @@ struct chain_coin_mvt *new_coin_wallet_deposit(const tal_t *ctx UNNEEDED, enum mvt_tag tag) { fprintf(stderr, "new_coin_wallet_deposit called!\n"); abort(); } +/* Generated stub for new_per_peer_state */ +struct per_peer_state *new_per_peer_state(const tal_t *ctx UNNEEDED) +{ fprintf(stderr, "new_per_peer_state called!\n"); abort(); } /* Generated stub for notify_chain_mvt */ void notify_chain_mvt(struct lightningd *ld UNNEEDED, const struct chain_coin_mvt *mvt UNNEEDED) { fprintf(stderr, "notify_chain_mvt called!\n"); abort(); } @@ -628,7 +631,7 @@ const char *peer_wire_name(int e UNNEEDED) { fprintf(stderr, "peer_wire_name called!\n"); abort(); } /* Generated stub for per_peer_state_set_fds */ void per_peer_state_set_fds(struct per_peer_state *pps UNNEEDED, - int peer_fd UNNEEDED, int gossip_fd UNNEEDED, int gossip_store_fd UNNEEDED) + int peer_fd UNNEEDED, int gossip_fd UNNEEDED) { fprintf(stderr, "per_peer_state_set_fds called!\n"); abort(); } /* Generated stub for plugin_hook_call_ */ bool plugin_hook_call_(struct lightningd *ld UNNEEDED, const struct plugin_hook *hook UNNEEDED, @@ -719,7 +722,7 @@ u8 *towire_connectd_connect_to_peer(const tal_t *ctx UNNEEDED, const struct node u8 *towire_connectd_peer_disconnected(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED) { fprintf(stderr, "towire_connectd_peer_disconnected called!\n"); abort(); } /* Generated stub for towire_connectd_peer_final_msg */ -u8 *towire_connectd_peer_final_msg(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, const struct per_peer_state *pps UNNEEDED, const u8 *msg UNNEEDED) +u8 *towire_connectd_peer_final_msg(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, const u8 *msg UNNEEDED) { fprintf(stderr, "towire_connectd_peer_final_msg called!\n"); abort(); } /* Generated stub for towire_custommsg_out */ u8 *towire_custommsg_out(const tal_t *ctx UNNEEDED, const u8 *msg UNNEEDED)