Closed sr-gi closed 1 year ago
I've tested this manually and it seems to run just fine.
In order to test this you'd need a tower that has a last known block at height n
and a node with a chain that has pruned that same block. I haven't been able to test this on regtest given pruning is based on how much block data we are holding (not how many blocks) and regtest blocks are mainly empty, so the threshold is never met. However, I've been able to test this using mainnet and an old tower state.
I may add some E2E testing for this if I manage to create a test where full blocks are created, so eviction can be triggered.
I'm confused about what the
chain_monitor
would do given it's being passed an old/pruned tip. Ispoll_best_tip()
gonna just skip the pruned blocks betweentip
and the best tip?
Yeah, you're right. I've come up with a better solution than this, will force push asap
This should make more sense now
I fixed suggestions and updated some of the logs since I didn't like them much.
I've also updated the PR description with guidelines for how to test this in regtest.
Nits should be fixed. I'd be nice to get a tACK
Nits should be fixed. I'd be nice to get a tACK
Yeah will work on that tonight.
Addressed comments
If a tower hasn't been running for a long time and the backend runs in pruned mode it could be the case that by the time the tower comes back online, the Last known block by the tower is not being known by the node anymore. In this situation, the tower cannot bootstrap normally, given the cache cannot be populated.
This commits adds a new argument to teosd (
--forceupdate
) that can be used to force a tower to update its last known block to the earliest known block by the backend under this situation. Notice that doing so may make the tower miss some of its state transitions (the ones triggered by missed blocks), so this must be done as a last resource.Fixes #209 Supersedes #212
Testing
This can be tested easily in regtest by running
bitcoind
with the (hidden, undocumented)-fastprune
modifier. That would make blocks smaller and easier to prune. After that, you can prune the chain usingbitcoin-cli pruneblockchain x
wherex
is your target prune height. The pruning is not likely to happen to the exact block you specified, given block files are pruned as a whole, so the chain would be pruned to the closest value that allows a bock file to be deleted.So the flow of testing should be:
teosd
and mine a few blocks so there is alast_known_block
known by the towerbitcoin-cli pruneblockchain x
and checked the returnedy
valuey - IRREVOCABLY_RESOLVED < last_known_block_height
, continue, otherwise go back to3.
teosd
again and test it with and without--forceupdate