mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 09:40:19 +01:00
channeld: tell gossipd what the features are for our local channels.
This msg is stored in the gossip_store, so it means a version bump. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
1f2740efe8
commit
78ffea61e1
10 changed files with 23 additions and 15 deletions
|
@ -349,12 +349,16 @@ static const u8 *get_local_channel_update(const tal_t *ctx, struct peer *peer)
|
|||
static void make_channel_local_active(struct peer *peer)
|
||||
{
|
||||
u8 *msg;
|
||||
const u8 *annfeatures = get_agreed_channelfeatures(tmpctx,
|
||||
peer->our_features,
|
||||
peer->their_features);
|
||||
|
||||
/* Tell gossipd about local channel. */
|
||||
msg = towire_gossipd_local_add_channel(NULL,
|
||||
&peer->short_channel_ids[LOCAL],
|
||||
&peer->node_ids[REMOTE],
|
||||
peer->channel->funding);
|
||||
peer->channel->funding,
|
||||
annfeatures);
|
||||
wire_sync_write(peer->pps->gossip_fd, take(msg));
|
||||
|
||||
/* Tell gossipd and the other side what parameters we expect should
|
||||
|
|
|
@ -10,7 +10,7 @@ struct per_peer_state;
|
|||
/**
|
||||
* gossip_store -- On-disk storage related information
|
||||
*/
|
||||
#define GOSSIP_STORE_VERSION 7
|
||||
#define GOSSIP_STORE_VERSION 8
|
||||
|
||||
/**
|
||||
* Bit of length we use to mark a deleted record.
|
||||
|
|
|
@ -16,6 +16,8 @@ msgtype,gossipd_local_add_channel,3503
|
|||
msgdata,gossipd_local_add_channel,short_channel_id,short_channel_id,
|
||||
msgdata,gossipd_local_add_channel,remote_node_id,node_id,
|
||||
msgdata,gossipd_local_add_channel,satoshis,amount_sat,
|
||||
msgdata,gossipd_local_add_channel,flen,u16,
|
||||
msgdata,gossipd_local_add_channel,features,u8,flen
|
||||
|
||||
# Send this channel_update.
|
||||
msgtype,gossipd_local_channel_update,3504
|
||||
|
|
|
|
@ -2904,9 +2904,10 @@ bool handle_local_add_channel(struct routing_state *rstate,
|
|||
struct node_id remote_node_id;
|
||||
struct amount_sat sat;
|
||||
struct chan *chan;
|
||||
u8 *features;
|
||||
|
||||
if (!fromwire_gossipd_local_add_channel(msg, &scid, &remote_node_id,
|
||||
&sat)) {
|
||||
if (!fromwire_gossipd_local_add_channel(msg, msg, &scid, &remote_node_id,
|
||||
&sat, &features)) {
|
||||
status_peer_broken(peer ? &peer->id : NULL,
|
||||
"Unable to parse local_add_channel message: %s",
|
||||
tal_hex(msg, msg));
|
||||
|
|
|
@ -44,7 +44,7 @@ bool fromwire_gossip_store_channel_amount(const void *p UNNEEDED, struct amount_
|
|||
bool fromwire_gossip_store_private_update(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **update UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_private_update called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossipd_local_add_channel */
|
||||
bool fromwire_gossipd_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
bool fromwire_gossipd_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **features UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossipd_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_wireaddr */
|
||||
bool fromwire_wireaddr(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct wireaddr *addr UNNEEDED)
|
||||
|
|
|
@ -31,7 +31,7 @@ bool fromwire_gossip_store_channel_amount(const void *p UNNEEDED, struct amount_
|
|||
bool fromwire_gossip_store_private_update(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **update UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_private_update called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossipd_local_add_channel */
|
||||
bool fromwire_gossipd_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
bool fromwire_gossipd_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **features UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossipd_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_wireaddr */
|
||||
bool fromwire_wireaddr(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct wireaddr *addr UNNEEDED)
|
||||
|
|
|
@ -31,7 +31,7 @@ bool fromwire_gossip_store_channel_amount(const void *p UNNEEDED, struct amount_
|
|||
bool fromwire_gossip_store_private_update(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **update UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_private_update called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossipd_local_add_channel */
|
||||
bool fromwire_gossipd_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
bool fromwire_gossipd_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **features UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossipd_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_wireaddr */
|
||||
bool fromwire_wireaddr(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct wireaddr *addr UNNEEDED)
|
||||
|
|
|
@ -31,7 +31,7 @@ bool fromwire_gossip_store_channel_amount(const void *p UNNEEDED, struct amount_
|
|||
bool fromwire_gossip_store_private_update(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **update UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossip_store_private_update called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossipd_local_add_channel */
|
||||
bool fromwire_gossipd_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
bool fromwire_gossipd_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **features UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossipd_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_wireaddr */
|
||||
bool fromwire_wireaddr(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct wireaddr *addr UNNEEDED)
|
||||
|
|
|
@ -13,7 +13,7 @@ bool cupdate_different(struct gossip_store *gs UNNEEDED,
|
|||
char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED)
|
||||
{ fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossipd_local_add_channel */
|
||||
bool fromwire_gossipd_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED)
|
||||
bool fromwire_gossipd_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **features UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_gossipd_local_add_channel called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_wireaddr */
|
||||
bool fromwire_wireaddr(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct wireaddr *addr UNNEEDED)
|
||||
|
|
|
@ -920,7 +920,7 @@ def test_gossip_store_load(node_factory):
|
|||
"""Make sure we can read canned gossip store"""
|
||||
l1 = node_factory.get_node(start=False)
|
||||
with open(os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, 'gossip_store'), 'wb') as f:
|
||||
f.write(bytearray.fromhex("07" # GOSSIP_STORE_VERSION
|
||||
f.write(bytearray.fromhex("08" # GOSSIP_STORE_VERSION
|
||||
"000001b0" # len
|
||||
"fea676e8" # csum
|
||||
"5b8d9b44" # timestamp
|
||||
|
@ -952,7 +952,7 @@ def test_gossip_store_load_announce_before_update(node_factory):
|
|||
"""Make sure we can read canned gossip store with node_announce before update. This happens when a channel_update gets replaced, leaving node_announce before it"""
|
||||
l1 = node_factory.get_node(start=False)
|
||||
with open(os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, 'gossip_store'), 'wb') as f:
|
||||
f.write(bytearray.fromhex("07" # GOSSIP_STORE_VERSION
|
||||
f.write(bytearray.fromhex("08" # GOSSIP_STORE_VERSION
|
||||
"000001b0" # len
|
||||
"fea676e8" # csum
|
||||
"5b8d9b44" # timestamp
|
||||
|
@ -995,7 +995,7 @@ def test_gossip_store_load_amount_truncated(node_factory):
|
|||
"""Make sure we can read canned gossip store with truncated amount"""
|
||||
l1 = node_factory.get_node(start=False, allow_broken_log=True)
|
||||
with open(os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, 'gossip_store'), 'wb') as f:
|
||||
f.write(bytearray.fromhex("07" # GOSSIP_STORE_VERSION
|
||||
f.write(bytearray.fromhex("08" # GOSSIP_STORE_VERSION
|
||||
"000001b0" # len
|
||||
"fea676e8" # csum
|
||||
"5b8d9b44" # timestamp
|
||||
|
@ -1419,7 +1419,7 @@ def test_gossip_store_load_no_channel_update(node_factory):
|
|||
|
||||
# A channel announcement with no channel_update.
|
||||
with open(os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, 'gossip_store'), 'wb') as f:
|
||||
f.write(bytearray.fromhex("07" # GOSSIP_STORE_VERSION
|
||||
f.write(bytearray.fromhex("08" # GOSSIP_STORE_VERSION
|
||||
"000001b0" # len
|
||||
"fea676e8" # csum
|
||||
"5b8d9b44" # timestamp
|
||||
|
@ -1446,7 +1446,7 @@ def test_gossip_store_load_no_channel_update(node_factory):
|
|||
l1.rpc.call('dev-compact-gossip-store')
|
||||
|
||||
with open(os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, 'gossip_store'), "rb") as f:
|
||||
assert bytearray(f.read()) == bytearray.fromhex("07")
|
||||
assert bytearray(f.read()) == bytearray.fromhex("08")
|
||||
|
||||
|
||||
@unittest.skipIf(not DEVELOPER, "gossip without DEVELOPER=1 is slow")
|
||||
|
@ -1456,7 +1456,8 @@ def test_gossip_store_compact_on_load(node_factory, bitcoind):
|
|||
l2.restart()
|
||||
|
||||
wait_for(lambda: l2.daemon.is_in_log(r'gossip_store_compact_offline: [5-8] deleted, 9 copied'))
|
||||
wait_for(lambda: l2.daemon.is_in_log(r'gossip_store: Read 1/4/2/0 cannounce/cupdate/nannounce/cdelete from store \(0 deleted\) in 1460 bytes'))
|
||||
|
||||
wait_for(lambda: l2.daemon.is_in_log(r'gossip_store: Read 1/4/2/0 cannounce/cupdate/nannounce/cdelete from store \(0 deleted\) in [0-9]* bytes'))
|
||||
|
||||
|
||||
def test_gossip_announce_invalid_block(node_factory, bitcoind):
|
||||
|
|
Loading…
Add table
Reference in a new issue