gossipd: don't try to upgrade ancient gossip_store.

If they really upgrade directly from 0.9.2, it will simply delete the
store and re-fetch it.

We still update from v9 (which could be v0.11), since it's a noop.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2022-09-14 13:20:28 +09:30
parent 45cdfd2ff7
commit fe556d1ed9
3 changed files with 4 additions and 146 deletions

View File

@ -101,26 +101,10 @@ static bool append_msg(int fd, const u8 *msg, u32 timestamp,
return true;
}
#ifdef COMPAT_V082
static u8 *mk_private_channelmsg(const tal_t *ctx,
struct routing_state *rstate,
const struct short_channel_id *scid,
const struct node_id *remote_node_id,
struct amount_sat sat,
const u8 *features)
{
const u8 *ann = private_channel_announcement(tmpctx, scid,
&rstate->local_id,
remote_node_id,
features);
return towire_gossip_store_private_channel(ctx, sat, ann);
}
/* The upgrade from version 7 is trivial */
/* The upgrade from version 9 is a noop: we added the spam flag. */
static bool can_upgrade(u8 oldversion)
{
return oldversion == 7 || oldversion == 8 || oldversion == 9;
return oldversion == 9;
}
static bool upgrade_field(u8 oldversion,
@ -128,52 +112,8 @@ static bool upgrade_field(u8 oldversion,
u8 **msg)
{
assert(can_upgrade(oldversion));
if (fromwire_peektype(*msg) == WIRE_GOSSIPD_LOCAL_ADD_CHANNEL_OBS
&& oldversion == 7) {
/* Append two 0 bytes, for (empty) feature bits */
tal_resizez(msg, tal_bytelen(*msg) + 2);
}
/* We turn these (v8) into a WIRE_GOSSIP_STORE_PRIVATE_CHANNEL */
if (fromwire_peektype(*msg) == WIRE_GOSSIPD_LOCAL_ADD_CHANNEL_OBS) {
struct short_channel_id scid;
struct node_id remote_node_id;
struct amount_sat satoshis;
u8 *features;
u8 *storemsg;
if (!fromwire_gossipd_local_add_channel_obs(tmpctx, *msg,
&scid,
&remote_node_id,
&satoshis,
&features))
return false;
storemsg = mk_private_channelmsg(tal_parent(*msg),
rstate,
&scid,
&remote_node_id,
satoshis,
features);
tal_free(*msg);
*msg = storemsg;
}
return true;
}
#else
static bool can_upgrade(u8 oldversion)
{
return false;
}
static bool upgrade_field(u8 oldversion,
struct routing_state *rstate,
u8 **msg)
{
abort();
}
#endif /* !COMPAT_V082 */
/* Read gossip store entries, copy non-deleted ones. This code is written
* as simply and robustly as possible! */
@ -771,7 +711,7 @@ u32 gossip_store_load(struct routing_state *rstate, struct gossip_store *gs)
}
if (checksum != crc32c(be32_to_cpu(hdr.timestamp), msg, msglen)) {
bad = "Checksum verification failed";
bad = tal_fmt(tmpctx, "Checksum verification failed: should be %08x", crc32c(be32_to_cpu(hdr.timestamp), msg, msglen));
goto badmsg;
}

View File

@ -23,12 +23,3 @@ msgdata,gossip_store_delete_chan,scid,short_channel_id,
msgtype,gossip_store_ended,4105
msgdata,gossip_store_ended,equivalent_offset,u64,
# FIXME: Here for COMPAT with v0.9.0 and before only.
msgtype,gossipd_local_add_channel_obs,3503
msgdata,gossipd_local_add_channel_obs,short_channel_id,short_channel_id,
msgdata,gossipd_local_add_channel_obs,remote_node_id,node_id,
msgdata,gossipd_local_add_channel_obs,satoshis,amount_sat,
msgdata,gossipd_local_add_channel_obs,flen,u16,
msgdata,gossipd_local_add_channel_obs,features,u8,flen

1 # gossip_store messages: messages persisted in the gossip_store
23
24
25
msgdata,gossipd_local_add_channel_obs,flen,u16,
msgdata,gossipd_local_add_channel_obs,features,u8,flen

View File

@ -5,7 +5,7 @@ from fixtures import TEST_NETWORK
from pyln.client import RpcError, Millisatoshi
from utils import (
DEVELOPER, wait_for, TIMEOUT, only_one, sync_blockheight,
expected_node_features, COMPAT,
expected_node_features,
mine_funding_to_announce, default_ln_port
)
@ -2001,79 +2001,6 @@ def test_torport_onions(node_factory):
assert l2.daemon.is_in_log('x2y4zvh4fn5q3eouuh7nxnc7zeawrqoutljrup2xjtiyxgx3emgkemad.onion:45321,127.0.0.1:{}'.format(l2.port))
@unittest.skipIf(not COMPAT, "needs COMPAT to convert obsolete gossip_store")
def test_gossip_store_upgrade_v7_v8(node_factory):
"""Version 8 added feature bits to local channel announcements"""
# We get BROKEN logs because gossipd talks about non-existent channels to
# lightningd ("**BROKEN** lightningd: Local update for bad scid 103x1x1").
l1 = node_factory.get_node(start=False,
allow_broken_log=True)
# 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("07000000428ce4d2d8000000000daf00"
"00670000010001022d223620a359a47f"
"f7f7ac447c85c46c923da53389221a00"
"54c11c1e3ca31d5900000000000f4240"
"000d8000000000000000000000000000"
"00008e3af3badf000000001006008a01"
"02005a9911d425effd461f803a380f05"
"e72d3332eb6e9a7c6c58405ae61eacde"
"4e2da18240ffb3d5c595f85e4f78b594"
"c59e4d01c0470edd4f5afe645026515e"
"fe06226e46111a0b59caaf126043eb5b"
"bf28c34f3a5e332a1fc7b2b73cf18891"
"0f00006700000100015eaa5eb0010100"
"06000000000000000000000001000000"
"0a000000003b0233800000008e074a6e"
"0f000000001006008a0102463de636b2"
"f46ccd6c23259787fc39dc4fdb983510"
"1651879325b18cf1bb26330127e51ce8"
"7a111b05ef92fe00a9a089979dc49178"
"200f49139a541e7078cdc506226e4611"
"1a0b59caaf126043eb5bbf28c34f3a5e"
"332a1fc7b2b73cf188910f0000670000"
"0100015eaa5eb0010000060000000000"
"000000000000010000000a000000003b"
"023380"))
l1.start()
assert l1.rpc.listchannels()['channels'] == [
{'source': '022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59',
'destination': '0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518',
'short_channel_id': '103x1x1',
'public': False,
'amount_msat': Millisatoshi(1000000000),
'message_flags': 1,
'channel_flags': 0,
'active': False,
'last_update': 1588223664,
'base_fee_millisatoshi': 1,
'fee_per_millionth': 10,
'delay': 6,
'htlc_minimum_msat': Millisatoshi(0),
'htlc_maximum_msat': Millisatoshi(990000000),
# This store was created on an experimental branch (OPT_ONION_MESSAGES)
'features': '80000000000000000000000000'},
{'source': '0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518',
'destination': '022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59',
'short_channel_id': '103x1x1',
'public': False,
'amount_msat': Millisatoshi(1000000000),
'message_flags': 1,
'channel_flags': 1,
'active': False,
'last_update': 1588223664,
'base_fee_millisatoshi': 1,
'fee_per_millionth': 10,
'delay': 6,
'htlc_minimum_msat': Millisatoshi(0),
'htlc_maximum_msat': Millisatoshi(990000000),
'features': '80000000000000000000000000'}]
@pytest.mark.developer("devtools are for devs anyway")
def test_routetool(node_factory):
"""Test that route tool can see unpublished channels"""