mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-21 03:14:05 +02:00
Merge bitcoin/bitcoin#33477: Rollback for dumptxoutset without invalidating blocks
fc736013a5rpc: Add in_memory option to dumptxoutset with rollback (Fabian Jahr)d0fd718948test: Extend named pipe sqlite tool test to use rollback (Fabian Jahr)ab9463efactest: Add dumptxoutset fork test (Fabian Jahr)49d5e835a8rpc: Don't invalidate blocks in dumptxoutset (Fabian Jahr)fe58eb9850blockstorage: Add DeletePruneLock (Fabian Jahr) Pull request description: This is an alternative approach to implement `dumptxoutset` with rollback that was discussed a few times. It does not rely on `invalidateblock` and `reconsiderblock` and instead creates a temporary copy of the coins DB, modifies this copy by rolling back as many blocks as necessary and then creating the dump from this temp copy DB. See also https://github.com/bitcoin/bitcoin/pull/29553#issuecomment-1978480989, https://github.com/bitcoin/bitcoin/issues/32817#issuecomment-3012406102 and #29565 discussions. The nice side-effects of this are that forks can not interfere with the rollback and network activity does not have to be suspended. But there are also some downsides when comparing to the current approach: this does require some additional disk space for the copied coins DB and performance is slower (master took 3m 17s vs 9m 16s in my last test with the code here, rolling back ~1500 blocks). However, there is also not much code being added here, network can stay active throughout and performance would stay constant with this approach while it would impact master if there were forks that needed to be invalidated as well (see #33444 for the alternative approach), so this could still be considered a good trade-off. ACKs for top commit: stratospher: tested ACKfc73601. very nice! sedited: Re-ACKfc736013a5theStack: re-ACKfc736013a5Tree-SHA512: d3d674f68184ac3ada87d969d0fca7bc38203ee939853864adcd235ee3a954914c7e351b817800b885a495606e323392c27d88ba8d8e018eaf8567c098eb0e9c
This commit is contained in:
@@ -300,4 +300,26 @@ BOOST_AUTO_TEST_CASE(blockmanager_flush_block_file)
|
||||
BOOST_CHECK_EQUAL(read_block.nVersion, 2);
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(prune_lock_update_and_delete, TestingSetup)
|
||||
{
|
||||
LOCK(::cs_main);
|
||||
auto& chainman{*Assert(m_node.chainman)};
|
||||
auto& blockman{chainman.m_blockman};
|
||||
|
||||
// Create a prune lock
|
||||
blockman.UpdatePruneLock("test_lock", node::PruneLockInfo{.height_first = 100});
|
||||
|
||||
// Update it to a new height
|
||||
blockman.UpdatePruneLock("test_lock", node::PruneLockInfo{.height_first = 200});
|
||||
|
||||
// Delete existing prune lock
|
||||
BOOST_CHECK(blockman.DeletePruneLock("test_lock"));
|
||||
|
||||
// Verify deletion worked by trying to delete the same lock again
|
||||
BOOST_CHECK(!blockman.DeletePruneLock("test_lock"));
|
||||
|
||||
// Deleting a non-existent lock returns false
|
||||
BOOST_CHECK(!blockman.DeletePruneLock("nonexistent"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user