mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Merge 312f54278f into merged_master (Bitcoin PR bitcoin/bitcoin#29726)
This commit is contained in:
commit
33ab2ef7d2
2 changed files with 13 additions and 4 deletions
|
|
@ -6751,13 +6751,14 @@ bool ChainstateManager::DeleteSnapshotChainstate()
|
|||
Assert(m_snapshot_chainstate);
|
||||
Assert(m_ibd_chainstate);
|
||||
|
||||
fs::path snapshot_datadir = GetSnapshotCoinsDBPath(*m_snapshot_chainstate);
|
||||
fs::path snapshot_datadir = Assert(node::FindSnapshotChainstateDir(m_options.datadir)).value();
|
||||
if (!DeleteCoinsDBFromDisk(snapshot_datadir, /*is_snapshot=*/ true)) {
|
||||
LogPrintf("Deletion of %s failed. Please remove it manually to continue reindexing.\n",
|
||||
fs::PathToString(snapshot_datadir));
|
||||
return false;
|
||||
}
|
||||
m_active_chainstate = m_ibd_chainstate.get();
|
||||
m_active_chainstate->m_mempool = m_snapshot_chainstate->m_mempool;
|
||||
m_snapshot_chainstate.reset();
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,9 +11,6 @@ The assumeutxo value generated and used here is committed to in
|
|||
|
||||
## Possible test improvements
|
||||
|
||||
- TODO: test what happens with -reindex and -reindex-chainstate before the
|
||||
snapshot is validated, and make sure it's deleted successfully.
|
||||
|
||||
Interesting test cases could be loading an assumeutxo snapshot file with:
|
||||
|
||||
- TODO: Valid hash but invalid snapshot file (bad coin height or
|
||||
|
|
@ -380,6 +377,17 @@ class AssumeutxoTest(BitcoinTestFramework):
|
|||
assert_equal(loaded['coins_loaded'], SNAPSHOT_BASE_HEIGHT)
|
||||
assert_equal(loaded['base_height'], SNAPSHOT_BASE_HEIGHT)
|
||||
|
||||
for reindex_arg in ['-reindex=1', '-reindex-chainstate=1']:
|
||||
self.log.info(f"Check that restarting with {reindex_arg} will delete the snapshot chainstate")
|
||||
self.restart_node(2, extra_args=[reindex_arg, *self.extra_args[2]])
|
||||
assert_equal(1, len(n2.getchainstates()["chainstates"]))
|
||||
for i in range(1, 300):
|
||||
block = n0.getblock(n0.getblockhash(i), 0)
|
||||
n2.submitheader(block)
|
||||
loaded = n2.loadtxoutset(dump_output['path'])
|
||||
assert_equal(loaded['coins_loaded'], SNAPSHOT_BASE_HEIGHT)
|
||||
assert_equal(loaded['base_height'], SNAPSHOT_BASE_HEIGHT)
|
||||
|
||||
normal, snapshot = n2.getchainstates()['chainstates']
|
||||
assert_equal(normal['blocks'], START_HEIGHT)
|
||||
assert_equal(normal.get('snapshot_blockhash'), None)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue