0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-12 11:19:08 -05:00

Merge bitcoin/bitcoin#28628: lint: Include test_utxo_snapshots in lint_shell, fix linter errors

348e79f7c6 lint: Include test_utxo_snapshots in lint_shell (Fabian Jahr)

Pull request description:

  jamesob excluded `test_utxo_snapshots.sh` from the shell linter with this explanation: "Add the script to the shellcheck exception list since the quoted variables rule needs to be violated in order to get bitcoind to pick up on $EARLY_IBD_FLAGS." However, macrofake pointed out that single lines can be excluded from linting.

  This fixes one fixable rule violation, excludes the rest of the offending lines from the linter and then removes the exclusion of the `test_utxo_snapshots.sh` file. Also adds documentation.

ACKs for top commit:
  Empact:
    ACK 348e79f7c6
  maflcko:
    lgtm ACK 348e79f7c6
  pablomartin4btc:
    tACK 348e79f7c6

Tree-SHA512: a904cc1cc3c94488dfbd39ea69a3ef17259f991708a797009001669448fef81eed086ecbce1ec433988d88baef293849698e2e0eb86a969b949cc7ef93af7b4b
This commit is contained in:
fanquake 2023-10-17 09:48:33 +01:00
commit 4caa10b580
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1
2 changed files with 11 additions and 2 deletions

View file

@ -11,13 +11,16 @@
# loaded. We see the background validation chainstate removed after validation # loaded. We see the background validation chainstate removed after validation
# completes. # completes.
# #
# The shellcheck rule SC2086 (quoted variables) disablements are necessary
# since this rule needs to be violated in order to get bitcoind to pick up on
# $EARLY_IBD_FLAGS for the script to work.
export LC_ALL=C export LC_ALL=C
set -e set -e
BASE_HEIGHT=${1:-30000} BASE_HEIGHT=${1:-30000}
INCREMENTAL_HEIGHT=20000 INCREMENTAL_HEIGHT=20000
FINAL_HEIGHT=$(($BASE_HEIGHT + $INCREMENTAL_HEIGHT)) FINAL_HEIGHT=$((BASE_HEIGHT + INCREMENTAL_HEIGHT))
SERVER_DATADIR="$(pwd)/utxodemo-data-server-$BASE_HEIGHT" SERVER_DATADIR="$(pwd)/utxodemo-data-server-$BASE_HEIGHT"
CLIENT_DATADIR="$(pwd)/utxodemo-data-client-$BASE_HEIGHT" CLIENT_DATADIR="$(pwd)/utxodemo-data-client-$BASE_HEIGHT"
@ -107,12 +110,14 @@ read -p "Press [enter] to continue" _
echo echo
echo "-- IBDing the blocks (height=$BASE_HEIGHT) required to the server node..." echo "-- IBDing the blocks (height=$BASE_HEIGHT) required to the server node..."
# shellcheck disable=SC2086
./src/bitcoind -logthreadnames=1 $SERVER_PORTS \ ./src/bitcoind -logthreadnames=1 $SERVER_PORTS \
-datadir="$SERVER_DATADIR" $EARLY_IBD_FLAGS -stopatheight="$BASE_HEIGHT" >/dev/null -datadir="$SERVER_DATADIR" $EARLY_IBD_FLAGS -stopatheight="$BASE_HEIGHT" >/dev/null
echo echo
echo "-- Creating snapshot at ~ height $BASE_HEIGHT ($UTXO_DAT_FILE)..." echo "-- Creating snapshot at ~ height $BASE_HEIGHT ($UTXO_DAT_FILE)..."
server_sleep_til_shutdown # wait for stopatheight to be hit server_sleep_til_shutdown # wait for stopatheight to be hit
# shellcheck disable=SC2086
./src/bitcoind -logthreadnames=1 $SERVER_PORTS \ ./src/bitcoind -logthreadnames=1 $SERVER_PORTS \
-datadir="$SERVER_DATADIR" $EARLY_IBD_FLAGS -connect=0 -listen=0 >/dev/null & -datadir="$SERVER_DATADIR" $EARLY_IBD_FLAGS -connect=0 -listen=0 >/dev/null &
SERVER_PID="$!" SERVER_PID="$!"
@ -137,11 +142,13 @@ echo " {${RPC_BASE_HEIGHT}, AssumeutxoHash{uint256S(\"0x${RPC_AU}\")}, ${RPC_N
echo echo
echo echo
echo "-- IBDing more blocks to the server node (height=$FINAL_HEIGHT) so there is a diff between snapshot and tip..." echo "-- IBDing more blocks to the server node (height=$FINAL_HEIGHT) so there is a diff between snapshot and tip..."
# shellcheck disable=SC2086
./src/bitcoind $SERVER_PORTS -logthreadnames=1 -datadir="$SERVER_DATADIR" \ ./src/bitcoind $SERVER_PORTS -logthreadnames=1 -datadir="$SERVER_DATADIR" \
$EARLY_IBD_FLAGS -stopatheight="$FINAL_HEIGHT" >/dev/null $EARLY_IBD_FLAGS -stopatheight="$FINAL_HEIGHT" >/dev/null
echo echo
echo "-- Starting the server node to provide blocks to the client node..." echo "-- Starting the server node to provide blocks to the client node..."
# shellcheck disable=SC2086
./src/bitcoind $SERVER_PORTS -logthreadnames=1 -debug=net -datadir="$SERVER_DATADIR" \ ./src/bitcoind $SERVER_PORTS -logthreadnames=1 -debug=net -datadir="$SERVER_DATADIR" \
$EARLY_IBD_FLAGS -connect=0 -listen=1 >/dev/null & $EARLY_IBD_FLAGS -connect=0 -listen=1 >/dev/null &
SERVER_PID="$!" SERVER_PID="$!"
@ -165,6 +172,7 @@ read -p "When you're ready for all this, hit [enter]" _
echo echo
echo "-- Starting the client node to get headers from the server, then load the snapshot..." echo "-- Starting the client node to get headers from the server, then load the snapshot..."
# shellcheck disable=SC2086
./src/bitcoind $CLIENT_PORTS $ALL_INDEXES -logthreadnames=1 -datadir="$CLIENT_DATADIR" \ ./src/bitcoind $CLIENT_PORTS $ALL_INDEXES -logthreadnames=1 -datadir="$CLIENT_DATADIR" \
-connect=0 -addnode=127.0.0.1:$SERVER_PORT -debug=net $EARLY_IBD_FLAGS >/dev/null & -connect=0 -addnode=127.0.0.1:$SERVER_PORT -debug=net $EARLY_IBD_FLAGS >/dev/null &
CLIENT_PID="$!" CLIENT_PID="$!"
@ -189,6 +197,7 @@ echo
read -p "Press [enter] to continue" read -p "Press [enter] to continue"
client_sleep_til_boot client_sleep_til_boot
# shellcheck disable=SC2086
./src/bitcoind $CLIENT_PORTS $ALL_INDEXES -logthreadnames=1 -datadir="$CLIENT_DATADIR" -connect=0 \ ./src/bitcoind $CLIENT_PORTS $ALL_INDEXES -logthreadnames=1 -datadir="$CLIENT_DATADIR" -connect=0 \
-addnode=127.0.0.1:$SERVER_PORT "$EARLY_IBD_FLAGS" >/dev/null & -addnode=127.0.0.1:$SERVER_PORT "$EARLY_IBD_FLAGS" >/dev/null &
CLIENT_PID="$!" CLIENT_PID="$!"

View file

@ -70,7 +70,7 @@ def main():
reg = re.compile(r'src/[leveldb,secp256k1,minisketch]') reg = re.compile(r'src/[leveldb,secp256k1,minisketch]')
def should_exclude(fname: str) -> bool: def should_exclude(fname: str) -> bool:
return bool(reg.match(fname)) or 'test_utxo_snapshots.sh' in fname return bool(reg.match(fname))
# remove everything that doesn't match this regex # remove everything that doesn't match this regex
files[:] = [file for file in files if not should_exclude(file)] files[:] = [file for file in files if not should_exclude(file)]