test: add stale-first reorg proxy with reorg validation#123
Draft
test: add stale-first reorg proxy with reorg validation#123
Conversation
8e1ce6b to
6d055d3
Compare
l0rinc
commented
Mar 3, 2026
Add a stale-first historical reorg proxy and functional coverage: - add test framework helper to serve stale blocks before canonical blocks - add p2p_historical_reorg_proxy functional test - add contrib/historical_reorg_proxy.py runner for local/real-node replay - add debug.log reorg validation summary in the contrib runner - add docs and register test in test_runner.py Reproducer (local, stop at height 300000): BASE_DIR="/mnt/my_storage" SRC_DIR="/bitcoin" SRC_DATA_DIR="/BitcoinData" TGT_DATA_DIR="/ShallowBitcoinData" LOG_DIR="/logs" STALE_DIR="/data/my_storage/stale-blocks/blocks" # Terminal 1: upstream node (RPC required; cookie auth, no rpcuser/rpcpassword) "/build/bin/bitcoind" \ -datadir="" \ -server=1 \ -rpcbind=127.0.0.1 \ -rpcallowip=127.0.0.1 \ -rpcport=19443 \ -stopatheight=300000 \ -debuglogfile="/upstream-300k.log" # Terminal 2: stale-first proxy "/contrib/historical_reorg_proxy.py" \ --upstream-rpc=http://127.0.0.1:19443 \ --upstream-cookie-file="/.cookie" \ --stale-blocks-dir="" \ --target-debug-log="/shallow-300k.log" \ --listen-host=127.0.0.1 \ --listen-port=8338 \ --network=mainnet # Terminal 3: target node under test (no -server=1) "/build/bin/bitcoind" \ -datadir="" \ -prune=550 \ -noconnect \ -addnode=127.0.0.1:8338 \ -listen=0 \ -dnsseed=0 \ -fixedseeds=0 \ -discover=0 \ -stopatheight=300000 \ -debuglogfile="/shallow-300k.log" After the target exits at 300000, stop the proxy with Ctrl-C to print the reorg validation summary from debug.log. ---- Reproducer (local, stop at height 300000): BASE_DIR="/mnt/my_storage" SRC_DIR="$BASE_DIR/bitcoin" SRC_DATA_DIR="$BASE_DIR/BitcoinData" TGT_DATA_DIR="$BASE_DIR/ShallowBitcoinData" LOG_DIR="$BASE_DIR/logs" STALE_DIR="/data/my_storage/stale-blocks/blocks" # Terminal 1: upstream node (RPC required; cookie auth, no rpcuser/rpcpassword) "$SRC_DIR/build/bin/bitcoind" \ -datadir="$SRC_DATA_DIR" \ -server=1 \ -rpcbind=127.0.0.1 \ -rpcallowip=127.0.0.1 \ -rpcport=19443 \ -stopatheight=300000 \ -debuglogfile="$LOG_DIR/upstream-300k.log" # Terminal 2: stale-first proxy "$SRC_DIR/contrib/historical_reorg_proxy.py" \ --upstream-rpc=http://127.0.0.1:19443 \ --upstream-cookie-file="$SRC_DATA_DIR/.cookie" \ --stale-blocks-dir="$STALE_DIR" \ --target-debug-log="$LOG_DIR/shallow-300k.log" \ --listen-host=127.0.0.1 \ --listen-port=8338 \ --network=mainnet # Terminal 3: target node under test (no -server=1) "$SRC_DIR/build/bin/bitcoind" \ -datadir="$TGT_DATA_DIR" \ -prune=550 \ -noconnect \ -addnode=127.0.0.1:8338 \ -listen=0 \ -dnsseed=0 \ -fixedseeds=0 \ -discover=0 \ -stopatheight=300000 \ -debuglogfile="$LOG_DIR/shallow-300k.log" After the target exits at 300000, stop the proxy with Ctrl-C to print the reorg validation summary from debug.log.
6d055d3 to
05adc33
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Leaving a comment.