Skip to content

Commit 2c8ea28

Browse files
committed
Updating validation script
- fixed issue with retrieving awk element for total blocks - moved initial setup to create logs/tmux session separately
1 parent 6c76d35 commit 2c8ea28

File tree

1 file changed

+34
-29
lines changed

1 file changed

+34
-29
lines changed

contrib/tools/block-validation.sh

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -129,35 +129,39 @@ configure_validation_slices() {
129129
}
130130

131131
## setup the tmux sessions and create the logdir for storing output
132-
setup_validation() {
133-
## if there is an existing folder, rm it
134-
if [ -d "${LOG_DIR}" ];then
135-
echo "Removing logdir ${LOG_DIR}"
136-
rm -rf "${LOG_DIR}"
137-
fi
138-
## create LOG_DIR to store output files
139-
if [ ! -d "${LOG_DIR}" ]; then
140-
echo "Creating logdir ${LOG_DIR}"
141-
mkdir -p "${LOG_DIR}"
142-
fi
143-
## if tmux session "${TMUX_SESSION}" exists, kill it and start anew
144-
if eval "tmux list-windows -t ${TMUX_SESSION} &> /dev/null"; then
145-
echo "Killing existing tmux session: ${TMUX_SESSION}"
146-
eval "tmux kill-session -t ${TMUX_SESSION} &> /dev/null"
147-
fi
148-
local slice_counter=0
132+
setup_logs() {
133+
## if there is an existing folder, rm it
134+
if [ -d "${LOG_DIR}" ];then
135+
echo "Removing logdir ${LOG_DIR}"
136+
rm -rf "${LOG_DIR}"
137+
fi
138+
## create LOG_DIR to store output files
139+
if [ ! -d "${LOG_DIR}" ]; then
140+
echo "Creating logdir ${LOG_DIR}"
141+
mkdir -p "${LOG_DIR}"
142+
fi
149143

150-
## create tmux session named ${TMUX_SESSION} with a window named slice0
151-
tmux new-session -d -s ${TMUX_SESSION} -n slice${slice_counter} || {
152-
echo "${COLRED}Error${COLRESET} creating tmux session ${COLYELLOW}${TMUX_SESSION}${COLRESET}"
153-
exit 1
154-
}
144+
}
155145

156-
if [ ! -f "${SLICE_DIR}0/chainstate/vm/index.sqlite" ]; then
157-
echo "${COLRED}Error${COLRESET}: chainstate db not found (${SLICE_DIR}0/chainstate/vm/index.sqlite)"
158-
exit 1
159-
fi
160-
return 0
146+
setup_tmux() {
147+
## if tmux session "$TMUX_SESSION" exists, kill it and start anew
148+
if eval "tmux list-windows -t ${TMUX_SESSION} &> /dev/null"; then
149+
echo "Killing existing tmux session: ${TMUX_SESSION}"
150+
eval "tmux kill-session -t ${TMUX_SESSION} &> /dev/null"
151+
fi
152+
local slice_counter=0
153+
154+
## create tmux session named ${TMUX_SESSION} with a window named slice0
155+
tmux new-session -d -s ${TMUX_SESSION} -n slice${slice_counter} || {
156+
echo "${COLRED}Error${COLRESET} creating tmux session ${COLYELLOW}${TMUX_SESSION}${COLRESET}"
157+
exit 1
158+
}
159+
160+
if [ ! -f "${SLICE_DIR}0/chainstate/vm/index.sqlite" ]; then
161+
echo "${COLRED}Error${COLRESET}: chainstate db not found (${SLICE_DIR}0/chainstate/vm/index.sqlite)"
162+
exit 1
163+
fi
164+
return 0
161165
}
162166

163167
## run the block validation
@@ -203,7 +207,7 @@ start_validation() {
203207
echo "${COLRED}Error${COLRESET} retrieving total number of blocks from chainstate"
204208
exit 1
205209
fi
206-
total_blocks=$(printf '%s\n' "${count_output}" | awk '/Total available entries: / {print $5}')
210+
total_blocks=$(printf '%s\n' "${count_output}" | awk '/Total available entries: / {print $4}')
207211
if [ -z "${total_blocks}" ]; then
208212
echo "${COLRED}Error${COLRESET} parsing block count from stacks-inspect output"
209213
exit 1
@@ -528,7 +532,8 @@ tput reset
528532
echo "Validation Started: ${COLYELLOW}$(date)${COLRESET}"
529533
build_stacks_inspect ## comment if using an existing chainstate/slice dir (ex: validation was performed already, and a second run is desired)
530534
configure_validation_slices ## comment if using an existing chainstate/slice dir (ex: validation was performed already, and a second run is desired)
531-
setup_validation ## configure logdir and tmux sessions
535+
setup_logs ## configure logdir
536+
setup_tmux ## configure tmux sessions
532537
start_validation ## validate pre-nakamoto blocks (2.x)
533538
start_validation nakamoto ## validate nakamoto blocks
534539
store_results ## store aggregated results of validation

0 commit comments

Comments
 (0)