Skip to content

Commit 7b1e36d

Browse files
rustyrussellendothermicdev
authored andcommitted
wallet: remove migration code for old commando runes.
This migration was introduced in dccbccf (pre 23.08), so the only way they would need this is if they migration straight from 23.05 to 25.02. And then the solution is to migration to a prior one first, but I'll bet good money we never, ever see this message: Commando runes still present? Migration removed in v25.02: call Rusty! Signed-off-by: Rusty Russell <[email protected]>
1 parent 8151c03 commit 7b1e36d

File tree

2 files changed

+4
-97
lines changed

2 files changed

+4
-97
lines changed

tests/test_runes.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -509,50 +509,6 @@ def test_rune_pay_amount(node_factory):
509509
assert res['valid'] is True
510510

511511

512-
@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "Depends on canned sqlite3 db")
513-
@unittest.skipIf(TEST_NETWORK != 'regtest', 'canned sqlite3 db is regtest')
514-
def test_commando_rune_migration(node_factory):
515-
"""Test migration from commando's datastore using db from test_commando_listrunes"""
516-
l1 = node_factory.get_node(dbfile='commando_listrunes.sqlite3.xz',
517-
options={'database-upgrade': True})
518-
519-
# This happens really early in logs!
520-
l1.daemon.logsearch_start = 0
521-
l1.daemon.wait_for_logs(['Transferring commando rune to db: '] * 2)
522-
523-
# datastore should be empty:
524-
assert l1.rpc.listdatastore(['commando']) == {'datastore': []}
525-
526-
# Should match commando results!
527-
assert l1.rpc.showrunes() == {'runes': [{'rune':
528-
'OSqc7ixY6F-gjcigBfxtzKUI54uzgFSA6YfBQoWGDV89MA==',
529-
'unique_id': '0', 'restrictions':
530-
[], 'restrictions_as_english': ''},
531-
{'rune':
532-
'geZmO6U7yqpHn-moaX93FVMVWrDRfSNY4AXx9ypLcqg9MQ==',
533-
'unique_id': '1', 'restrictions':
534-
[], 'restrictions_as_english': ''}]}
535-
536-
537-
@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "Depends on canned sqlite3 db")
538-
@unittest.skipIf(TEST_NETWORK != 'regtest', 'canned sqlite3 db is regtest')
539-
def test_commando_blacklist_migration(node_factory):
540-
"""Test migration from commando's datastore using db from test_commando_blacklist"""
541-
l1 = node_factory.get_node(dbfile='commando_blacklist.sqlite3.xz',
542-
options={'database-upgrade': True})
543-
544-
# This happens really early in logs!
545-
l1.daemon.logsearch_start = 0
546-
l1.daemon.wait_for_logs(['Transferring commando blacklist to db: '] * 2)
547-
548-
# datastore should be empty:
549-
assert l1.rpc.listdatastore(['commando']) == {'datastore': []}
550-
551-
# Should match commando results!
552-
assert l1.rpc.blacklistrune() == {'blacklist': [{'start': 0, 'end': 6},
553-
{'start': 9, 'end': 9}]}
554-
555-
556512
def test_missing_method_or_nodeid(node_factory):
557513
"""For v23.11 we realized that nodeid should not be required for checkrune, which means method (which followed it) could not be require either"""
558514
l1 = node_factory.get_node()

wallet/wallet.c

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6269,65 +6269,16 @@ void wallet_delete_blacklist(struct wallet *wallet, const struct rune_blacklist
62696269

62706270
void migrate_datastore_commando_runes(struct lightningd *ld, struct db *db)
62716271
{
6272-
struct db_stmt *stmt;
6273-
const char **startkey, **k;
6274-
const u8 *data;
6275-
size_t max;
6272+
const char **startkey;
62766273

62776274
/* datastore routines expect a tal_arr */
62786275
startkey = tal_arr(tmpctx, const char *, 2);
6279-
startkey[0] = "commando";
6280-
startkey[1] = "runes";
6281-
6282-
for (stmt = db_datastore_first(tmpctx, db, startkey, &k, &data, NULL);
6283-
stmt;
6284-
stmt = db_datastore_next(tmpctx, stmt, startkey, &k, &data, NULL)) {
6285-
const char *err, *str;
6286-
struct rune *r;
6287-
6288-
str = db_col_strdup(tmpctx, stmt, "data");
6289-
r = rune_from_base64(tmpctx, str);
6290-
if (!r)
6291-
db_fatal(db, "Invalid commando rune %s", str);
6292-
err = rune_is_ours(ld, r);
6293-
if (err) {
6294-
log_unusual(ld->log,
6295-
"Warning: removing commando"
6296-
" rune %s (uid %s): %s",
6297-
str, r->unique_id, err);
6298-
} else {
6299-
log_debug(ld->log, "Transferring commando rune to db: %s",
6300-
str);
6301-
db_rune_insert(db, r);
6302-
}
6303-
db_datastore_remove(db, k);
6304-
}
6305-
6306-
/* Now convert blacklist */
6307-
startkey[0] = "commando";
6308-
startkey[1] = "blacklist";
6309-
6310-
data = db_datastore_get(tmpctx, db, startkey, NULL);
6311-
max = tal_bytelen(data);
6312-
while (max) {
6313-
struct rune_blacklist b;
6314-
6315-
b.start = fromwire_u64(&data, &max);
6316-
b.end = fromwire_u64(&data, &max);
6317-
6318-
if (!data)
6319-
db_fatal(db, "Invalid commando blacklist?");
6320-
log_debug(ld->log, "Transferring commando blacklist to db: %"PRIu64"-%"PRIu64,
6321-
b.start, b.end);
6322-
db_insert_blacklist(db, &b);
6323-
}
6324-
db_datastore_remove(db, startkey);
63256276

6326-
/* Might as well clean up "rune_counter" while we're here, so
6327-
* commando datastore is completely clean. */
6277+
/* We deleted this from the datastore on migration. */
63286278
startkey[0] = "commando";
63296279
startkey[1] = "rune_counter";
6330-
db_datastore_remove(db, startkey);
6280+
if (db_datastore_get(tmpctx, db, startkey, NULL))
6281+
db_fatal(db, "Commando runes still present? Migration removed in v25.02: call Rusty!");
63316282
}
63326283

63336284
void migrate_runes_idfix(struct lightningd *ld, struct db *db)

0 commit comments

Comments
 (0)