Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ jobs:
dgb_gentx_coinbase_test nmc_auxpow_merkle_test nmc_template_builder_test nmc_auxpow_wire_test nmc_reconstruct_won_block_test dgb_gentx_share_path_test dgb_other_tx_resolver_test \
dgb_other_tx_assembler_test dgb_reconstruct_won_block_test dgb_reconstruct_closure_test dgb_gentx_unpack_test dgb_work_source_test dgb_template_builder_test dgb_embedded_coin_node_test dgb_embedded_tx_select_test dgb_coinbase_value_parity_test \
rpc_request_test softfork_check_test genesis_check_test algo_select_test digishield_walk_test header_chain_test \
dgb_coin_node_seam_test dgb_block_broadcast_test dgb_won_block_dispatch_test dgb_forced_won_share_dualpath_test dgb_scrypt_pow_test dgb_nonce_grinder_test dgb_regrind_block_test \
v37_test \
dgb_coin_node_seam_test dgb_block_broadcast_test dgb_won_block_dispatch_test dgb_forced_won_share_dualpath_test dgb_scrypt_pow_test dgb_nonce_grinder_test dgb_regrind_block_test dgb_won_block_finalize_test v37_test \
-j$(nproc)

- name: Run tests
Expand Down Expand Up @@ -217,8 +216,7 @@ jobs:
dgb_gentx_coinbase_test nmc_auxpow_merkle_test nmc_template_builder_test nmc_auxpow_wire_test nmc_reconstruct_won_block_test dgb_gentx_share_path_test dgb_other_tx_resolver_test \
dgb_other_tx_assembler_test dgb_reconstruct_won_block_test dgb_reconstruct_closure_test dgb_gentx_unpack_test dgb_work_source_test dgb_template_builder_test dgb_embedded_coin_node_test dgb_embedded_tx_select_test dgb_coinbase_value_parity_test \
rpc_request_test softfork_check_test genesis_check_test algo_select_test digishield_walk_test header_chain_test \
dgb_coin_node_seam_test dgb_block_broadcast_test dgb_won_block_dispatch_test dgb_forced_won_share_dualpath_test dgb_scrypt_pow_test dgb_nonce_grinder_test dgb_regrind_block_test \
test_coin_broadcaster test_multiaddress_pplns test_pplns_stress \
dgb_coin_node_seam_test dgb_block_broadcast_test dgb_won_block_dispatch_test dgb_forced_won_share_dualpath_test dgb_scrypt_pow_test dgb_nonce_grinder_test dgb_regrind_block_test dgb_won_block_finalize_test test_coin_broadcaster test_multiaddress_pplns test_pplns_stress \
v37_test \
-j$(nproc)

Expand Down
65 changes: 55 additions & 10 deletions scripts/dgb_regtest_won_block_soak.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ provision "$DATADIR_B" "$RPCPORT_B"
wait_rpc() { local n=0; until "$@" getblockcount >/dev/null 2>&1; do n=$((n+1)); [ $n -gt 60 ] && die "rpc never came up: $*"; sleep 0.5; done; }
tip_b() { cli_b getblockcount; }

# pre-flight: a stale c2pool-dgb from a prior run holds the FIXED pool P2P
# listen port (5024, PREFIX-derived) -> ARM A aborts on "bind: Address already
# in use" and the gate FAILS as a phantom timeout. Free it before substrate up.
# DGB-only match; never touches other coins or the bitcoin-family regtest band.
kill_stale_c2pool() {
local pids; pids="$(pgrep -f 'c2pool-dgb .*--run' 2>/dev/null || true)"
[ -z "$pids" ] && return 0
log "pre-flight: freeing pool P2P port from stale c2pool-dgb: $pids"
kill $pids 2>/dev/null || true; sleep 2
pids="$(pgrep -f 'c2pool-dgb .*--run' 2>/dev/null || true)"
[ -n "$pids" ] && { kill -9 $pids 2>/dev/null || true; sleep 1; }
return 0
}
kill_stale_c2pool

# --- substrate: two peered regtest nodes --------------------------------------
log "starting node A (regtest RPC $RPCPORT_A / P2P $P2PPORT_A)"
"$DAEMON_BIN" -regtest -datadir="$DATADIR_A" -rpcport=$RPCPORT_A -port=$P2PPORT_A -daemon >/dev/null
Expand All @@ -105,13 +120,21 @@ cli_a createwallet "$PAYOUT_LABEL" >/dev/null 2>&1 || cli_a loadwallet "$PAYOUT_
ADDR_A="$(cli_a getnewaddress "$PAYOUT_LABEL")"
log "mining 101 maturity blocks to $ADDR_A"
cli_a generatetoaddress 101 "$ADDR_A" >/dev/null
# Wait for node B to FULLY IBD-sync node A's chain before baselining. Otherwise
# BASE_B captures B mid-sync (e.g. 96 < A=101) and the ARM A won-detector
# (tip_b > BASE_B) fires on B's normal sync catch-up rather than on a genuine
# c2pool-relayed won block -- a false positive that defeats the gate.
HEIGHT_A="$(cli_a getblockcount)"
n=0; until [ "$(tip_b)" -ge "$HEIGHT_A" ]; do
n=$((n+1)); [ $n -gt 120 ] && die "node B never synced to A height $HEIGHT_A (got $(tip_b))"; sleep 0.5
done
BASE_B="$(tip_b)"

# regtest magic + genesis are read from the running daemon's chainparams so the
# embedded backend's getheaders bootstrap matches node A exactly (no hand-typed
# consensus literal). DGB regtest magic is fixed in DigiByte Core chainparams.
DGB_REGTEST_GENESIS="$(cli_a getblockhash 0)"
: "${DGB_REGTEST_MAGIC:?set DGB_REGTEST_MAGIC to the DigiByte regtest pchMessageStart hex (from chainparams)}"
: "${DGB_REGTEST_MAGIC:=fabfb5da}" # DGB regtest pchMessageStart (DigiByte Core chainparams); override for a custom regtest
log "substrate OK: node A height $(cli_a getblockcount), peer B $BASE_B, genesis $DGB_REGTEST_GENESIS"

# --- ARM A (P2P PRIMARY): live UpdateTip won block relayed to node B ----------
Expand All @@ -121,7 +144,8 @@ log "ARM A: launching embedded c2pool-dgb against node A (regtest diff -> natura
--coin-rpc 127.0.0.1:$RPCPORT_A \
--coin-rpc-auth "$DATADIR_A/digibyte.conf" \
--coin-magic "$DGB_REGTEST_MAGIC" \
--coin-genesis "$DGB_REGTEST_GENESIS" >/tmp/c2pool-dgb-soak.log 2>&1 &
--coin-genesis "$DGB_REGTEST_GENESIS" --regtest --regtest-force-won-share \
--soak-regrind >/tmp/c2pool-dgb-soak.log 2>&1 &
C2POOL_PID=$!
log "c2pool-dgb PID $C2POOL_PID; waiting for a won share to relay a coinbase-only block to node B"
n=0
Expand All @@ -130,16 +154,37 @@ until [ "$(tip_b)" -gt "$BASE_B" ]; do
sleep 0.5
done
WON_HASH="$(cli_b getblockhash "$(tip_b)")"
NTX="$(cli_b getblock "$WON_HASH" | grep -o '"tx"[^]]*]' | grep -o '"[0-9a-f]\{64\}"' | wc -l)"
NTX="$(cli_b getblock "$WON_HASH" | tr -d '\n' | grep -o '"tx"[^]]*]' | grep -o '"[0-9a-f]\{64\}"' | wc -l)"
[ "$NTX" -eq 1 ] || die "ARM A: won block $WON_HASH has $NTX txs, expected 1 (coinbase-only, PROP 1)"
log "ARM A OK: P2P-relayed coinbase-only won block $WON_HASH accepted by peer node B (PROP 1 + ARM A)"
kill "$C2POOL_PID" >/dev/null 2>&1; C2POOL_PID=""

# --- ARM B (RPC FALLBACK): GATED on integrator isolation-mechanism decision ----
# No --no-p2p-relay flag exists; isolating the submitblock fallback from the P2P arm
# is an open design call (see header item 2). Until integrator picks the mechanism,
# ARM B is NOT asserted -- shipping a placeholder assert would be the silent-gap the
# gate exists to prevent.
log "ARM B: GATED -- submitblock-fallback isolation mechanism pending integrator decision (header item 2)"
# --- ARM B (RPC FALLBACK, ISOLATED): submitblock-only via --no-p2p-relay -------
# The --no-p2p-relay flag (main_dgb.cpp) suppresses the embedded P2P `block`
# relay sink, leaving the external-digibyted submitblock RPC fallback as the
# SOLE path to the network. A second forced won block reaching node B with the
# P2P arm muted proves ARM B reaches the network INDEPENDENTLY (header item 2,
# now resolved by the flag).
BASE_B2="$(tip_b)"
log "ARM B (isolated): relaunching c2pool-dgb with --no-p2p-relay (submitblock fallback only)"
"$C2POOL_DGB" --run \
--coin-daemon 127.0.0.1:$P2PPORT_A \
--coin-rpc 127.0.0.1:$RPCPORT_A \
--coin-rpc-auth "$DATADIR_A/digibyte.conf" \
--coin-magic "$DGB_REGTEST_MAGIC" \
--coin-genesis "$DGB_REGTEST_GENESIS" --regtest --regtest-force-won-share \
--soak-regrind --no-p2p-relay >/tmp/c2pool-dgb-soak-armb.log 2>&1 &
C2POOL_PID=$!
log "c2pool-dgb (ARM B) PID $C2POOL_PID; waiting for submitblock-only won block on node B"
n=0
until [ "$(tip_b)" -gt "$BASE_B2" ]; do
n=$((n+1)); [ $n -gt 240 ] && die "ARM B: no won block reached node B within 120s (submitblock RPC fallback)"
sleep 0.5
done
WON_HASH_B="$(cli_b getblockhash "$(tip_b)")"
NTX_B="$(cli_b getblock "$WON_HASH_B" | tr -d '\n' | grep -o '"tx"[^]]*]' | grep -o '"[0-9a-f]\{64\}"' | wc -l)"
[ "$NTX_B" -eq 1 ] || die "ARM B: won block $WON_HASH_B has $NTX_B txs, expected 1 (coinbase-only, PROP 1)"
log "ARM B OK: submitblock-RPC-only coinbase-only won block $WON_HASH_B accepted by peer node B (PROP 1 + ARM B, P2P arm suppressed)"
kill "$C2POOL_PID" >/dev/null 2>&1; C2POOL_PID=""

log "ARM A proven; ARM B + digibyted provisioning are the two remaining live-leg items for the #82 gate."
log "BOTH ARMS PROVEN: ARM A (P2P relay) block $WON_HASH + ARM B (submitblock isolated) block $WON_HASH_B each accepted by peer node B. #82 dual-path broadcaster gate satisfied (digibyted self-provisioned)."
Loading
Loading