Skip to content

test: add stale-first reorg proxy with reorg validation#123

Draft
l0rinc wants to merge 1 commit intomasterfrom
l0rinc/stale-reorg-proxy
Draft

test: add stale-first reorg proxy with reorg validation#123
l0rinc wants to merge 1 commit intomasterfrom
l0rinc/stale-reorg-proxy

Conversation

@l0rinc
Copy link
Copy Markdown
Owner

@l0rinc l0rinc commented Feb 21, 2026

Leaving a comment.

@l0rinc l0rinc force-pushed the l0rinc/stale-reorg-proxy branch from 8e1ce6b to 6d055d3 Compare February 21, 2026 19:52
Copy link
Copy Markdown
Owner Author

@l0rinc l0rinc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

submitting review

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.
@l0rinc l0rinc force-pushed the l0rinc/stale-reorg-proxy branch from 6d055d3 to 05adc33 Compare March 9, 2026 08:58
@l0rinc l0rinc closed this Mar 11, 2026
@l0rinc l0rinc reopened this Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant