Skip to content

Commit 09137f2

Browse files
authored
Merge pull request #4144 from ProvableHQ/release-mainnet-4.5.0
Release mainnet 4.5.0
2 parents 10759d4 + 482f155 commit 09137f2

File tree

125 files changed

+8646
-3014
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+8646
-3014
lines changed

.cargo/audit.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,10 @@ ignore = [
77
"RUSTSEC-2025-0057",
88
# TODO remove once newer versions of tracing-sbuscriber support colored logs again.
99
"RUSTSEC-2025-0055",
10+
# TODO remove once `self_update` updates its dependency for `indicatif`.
11+
"RUSTSEC-2025-0119",
12+
# TODO remove once no longer lru 0.12.x is unsound via ratatui; upgrade ratatui when available
13+
"RUSTSEC-2026-0002",
14+
# TODO remove once we migrate away from bincode, or it becomes maintained again.
15+
"RUSTSEC-2025-0141",
1016
]

.ci/bench_bft_sync.sh

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,59 +22,62 @@ log_filter="info,snarkos_node_sync=trace,snarkos_node_bft::sync=trace,snarkos_no
2222
max_wait=1800 # Wait for up to 30 minutes
2323
poll_interval=1 # Check block heights every second
2424

25-
. ./.ci/utils.sh
25+
#shellcheck source=SCRIPTDIR/utils.sh
26+
. .ci/utils.sh
27+
28+
# Create log directory
29+
init_log_dir
2630

2731
branch_name=$(git rev-parse --abbrev-ref HEAD)
28-
echo "On branch: ${branch_name}"
32+
log "On branch: ${branch_name}"
2933

3034
network_name=$(get_network_name $network_id)
31-
echo "Using network: $network_name (ID: $network_id)"
35+
log "Using network: $network_name (ID: $network_id)"
3236

3337
snapshot_info=$(<info.txt)
34-
echo "Snapshot_info: ${snapshot_info}"
35-
36-
# Create log directory
37-
log_dir=".logs-$(date +"%Y%m%d%H%M%S")"
38-
mkdir -p "$log_dir"
38+
log "Snapshot_info: ${snapshot_info}"
3939

4040
# Define a trap handler that cleans up all processes on exit.
41+
# shellcheck disable=SC2329
4142
function exit_handler() {
4243
stop_nodes
4344
}
4445
trap exit_handler EXIT
45-
trap child_exit_handler CHLD
4646

4747
# Define a trap handler that prints a message when an error occurs
48-
trap 'echo "⛔️ Error in $BASH_SOURCE at line $LINENO: \"$BASH_COMMAND\" failed (exit $?)"' ERR
48+
trap 'log "⛔️ Error in $BASH_SOURCE at line $LINENO: \"$BASH_COMMAND\" failed (exit $?)"' ERR
4949

5050
# Shared flags betwen all nodes
5151
common_flags=(
5252
--nobanner --noupdater --nodisplay \
5353
"--network=$network_id"
5454
--nocdn
55+
"--dev-num-clients=0"
5556
"--dev-num-validators=$num_validators"
5657
--no-dev-txs
5758
"--log-filter=$log_filter"
5859
)
5960

6061
# The validator that has the ledger to by synced from.
61-
$TASKSET1 snarkos start --dev 0 --validator "${common_flags[@]}" \
62-
--logfile="$log_dir/validator-0.log" &
62+
# shellcheck disable=SC2086
63+
run_with_prefix "validator-0" $TASKSET1 snarkos start --dev 0 --validator "${common_flags[@]}" \
64+
--logfile="$log_dir/validator-0.log"
6365
PIDS[0]=$!
6466

6567
# Stores the list of all validators.
6668
validators="127.0.0.1:5000"
6769

68-
# Spawn the clients that will sync the ledger
70+
# Spawn the validators that will sync the ledger
6971
for node_index in $(seq 1 "$num_nodes"); do
7072
name="validator-$node_index"
7173

7274
# Ensure there are no old ledger files and the node syncs from scratch
7375
snarkos clean "--dev=$node_index" "--network=$network_id" || true
7476

75-
$TASKSET2 snarkos start "--dev=$node_index" --validator \
77+
# shellcheck disable=SC2086
78+
run_with_prefix "$name" $TASKSET2 snarkos start "--dev=$node_index" --validator \
7679
"${common_flags[@]}" "--validators=$validators" \
77-
"--logfile=$log_dir/$name.log" &
80+
"--logfile=$log_dir/$name.log"
7881
PIDS[node_index]=$!
7982

8083
# Add the validators BFT address to the validators list.
@@ -86,19 +89,19 @@ for node_index in $(seq 1 "$num_nodes"); do
8689
done
8790

8891
# Block until nodes are running and connected to each other.
89-
wait_for_nodes $((num_nodes+1)) 0
92+
wait_for_nodes $((num_nodes+1)) 0 "$network_name"
9093

9194
SECONDS=0
9295

93-
# TODO add API call for number of connected validators.
94-
#for ((node_index = 0; node_index < num_nodes+1; node_index++)); do
95-
# if ! (wait_for_peers "$node_index" $num_nodes); then
96-
# exit 1
97-
# fi
98-
#done
96+
# Wait for all validators to be connected to each other via the gateway.
97+
for ((node_index = 0; node_index < num_nodes+1; node_index++)); do
98+
if ! (wait_for_bft_connections "$node_index" $num_nodes "$network_name"); then
99+
exit 1
100+
fi
101+
done
99102

100103
connect_time=$SECONDS
101-
echo "ℹ️ Nodes are fully connected (took $connect_time secs). Starting block sync measurement."
104+
log "ℹ️ Nodes are fully connected (took $connect_time secs). Starting block sync measurement."
102105

103106
# Check heights periodically with a timeout
104107
SECONDS=0
@@ -111,7 +114,7 @@ while (( SECONDS < max_wait )); do
111114
total_wait=$SECONDS
112115
throughput=$(compute_throughput "$min_height" "$total_wait")
113116

114-
echo "🎉 BFT sync benchmark done! Waited $total_wait seconds for $min_height blocks. Throughput was $throughput blocks/s."
117+
log "🎉 BFT sync benchmark done! Waited $total_wait seconds for $min_height blocks. Throughput was $throughput blocks/s."
115118

116119
# Append data to results file.
117120
printf "{ \"name\": \"bft-sync\", \"unit\": \"blocks/s\", \"value\": %.3f, \"extra\": \"total_wait=%is, target_height=%i, connect_time=%i, branch=%s, %s\" },\n" \
@@ -123,13 +126,7 @@ while (( SECONDS < max_wait )); do
123126
sleep $poll_interval
124127
done
125128

126-
echo "❌ Benchmark failed! Validators did not sync within 30 minutes."
127-
128-
# Print logs for debugging
129-
echo "Last 20 lines of validators logs:"
130-
for ((node_index = 0; node_index <= num_nodes; node_index++)); do
131-
echo "=== Node $node_index logs ==="
132-
tail -n 20 "$log_dir/validator-$node_index.log"
133-
done
129+
log "❌ Benchmark failed! Validators did not sync within 30 minutes."
130+
print_validator_logs "$log_dir" "$num_validators" "$num_nodes"
134131

135132
exit 1

.ci/bench_cdn_sync.sh

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@ log_filter="info,snarkos_node_rest=warn,snarkos_node_cdn=debug"
1515
max_wait=1800 # Wait for up to 30 minutes
1616
poll_interval=1 # Check block heights every second
1717

18+
# shellcheck source=SCRIPTDIR/utils.sh
1819
. ./.ci/utils.sh
1920

20-
network_name=$(get_network_name $network_id)
21-
echo "Using network: $network_name (ID: $network_id)"
22-
2321
# Create log directory
24-
log_dir=".logs-$(date +"%Y%m%d%H%M%S")"
25-
mkdir -p "$log_dir"
22+
init_log_dir
23+
24+
network_name=$(get_network_name $network_id)
25+
log "Using network: $network_name (ID: $network_id)"
2626

2727
# Define a trap handler that cleans up all processes on exit.
28+
# shellcheck disable=SC2329
2829
function exit_handler() {
2930
stop_nodes
3031
}
3132
trap exit_handler EXIT
32-
trap child_exit_handler CHLD
3333

3434
# Define a trap handler that prints a message when an error occurs.
35-
trap 'echo "⛔️ Error in $BASH_SOURCE at line $LINENO: \"$BASH_COMMAND\" failed (exit $?)"' ERR
35+
trap 'log "⛔️ Error in $BASH_SOURCE at line $LINENO: \"$BASH_COMMAND\" failed (exit $?)"' ERR
3636

3737
# Ensure there are no old ledger files and the node syncs from scratch
3838
snarkos clean "--network=$network_id" || true
@@ -42,15 +42,16 @@ args=(
4242
"--network=$network_id"
4343
--nobanner --noupdater --nodisplay # reduce clutter in the output and hide TUI
4444
--rest-rps=1000000 # ensure benchmarks don't fail due to rate limiting
45-
--log-filter=$log_filter # only show the logs we care about
45+
"--log-filter=$log_filter" # only show the logs we care about
4646
)
4747

4848
# Spawn the client that will sync the ledger.
4949
# Use the same CPU cores as in the other benchmarks, so the numbers are comparable.
50-
$TASKSET2 snarkos start --client "${args[@]}" &
50+
# shellcheck disable=SC2086
51+
run_with_prefix "client-0" $TASKSET2 snarkos start --client "${args[@]}"
5152
PIDS[0]=$!
5253

53-
wait_for_nodes 0 1
54+
wait_for_nodes 0 1 "$network_name"
5455

5556
# Check heights periodically with a timeout
5657
SECONDS=0
@@ -59,7 +60,7 @@ while (( SECONDS < max_wait )); do
5960
total_wait=$SECONDS
6061
throughput=$(compute_throughput "$min_height" "$total_wait")
6162

62-
echo "🎉 Benchmark done! Waited ${total_wait}s for $min_height blocks. Throughput was $throughput blocks/s."
63+
log "🎉 Benchmark done! Waited ${total_wait}s for $min_height blocks. Throughput was $throughput blocks/s."
6364

6465
# Append data to results file.
6566
printf "{ \"name\": \"cdn-sync\", \"unit\": \"blocks/s\", \"value\": %.3f, \"extra\": \"total_wait=%is, target_height=${min_height}\" }\n" \
@@ -71,6 +72,6 @@ while (( SECONDS < max_wait )); do
7172
sleep $poll_interval
7273
done
7374

74-
echo "❌ Benchmark failed! Client did not sync within 30 minutes."
75+
log "❌ Benchmark failed! Client did not sync within 30 minutes."
7576

7677
exit 1

.ci/bench_p2p_sync.sh

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ min_height=250
1414
num_validators=40
1515

1616
# The number of clients that are syncing
17+
# Note: Because the first indexes 0-39 are resevered for validators, the first client will have index 40.
18+
# The script works around this by manually setting the storage, ports, and log files for the clients.
1719
num_clients=1
1820

1921
# Adjust this to show more/less log messages
@@ -22,8 +24,12 @@ log_filter="info,snarkos_node::client=trace,snarkos_node_sync=trace,snarkos_node
2224
max_wait=2400 # Wait for up to 40 minutes
2325
poll_interval=1 # Check block heights every second
2426

27+
# shellcheck source=SCRIPTDIR/utils.sh
2528
. ./.ci/utils.sh
2629

30+
# Create log directory
31+
init_log_dir
32+
2733
# Running sums for variance: use sum and sumsq for unbiased sample variance
2834
sum_speed=0
2935
sumsq_speed=0
@@ -45,13 +51,13 @@ function sample_sync_speeds() {
4551

4652
# Skip null or empty
4753
if [[ -z "$speed" ]] || [[ "$speed" == "null" ]]; then
48-
echo "Invalid speed value $speed"
54+
log "Invalid speed value $speed"
4955
continue
5056
fi
5157

5258
# Validate numeric (allow exponent)
5359
if ! (is_float "$speed"); then
54-
echo "Invalid speed value $speed"
60+
log "Invalid speed value $speed"
5561
continue
5662
fi
5763

@@ -73,24 +79,19 @@ function sample_sync_speeds() {
7379
}
7480

7581
branch_name=$(git rev-parse --abbrev-ref HEAD)
76-
echo "On branch: ${branch_name}"
82+
log "On branch: ${branch_name}"
7783

7884
network_name=$(get_network_name $network_id)
79-
echo "Using network: $network_name (ID: $network_id)"
85+
log "Using network: $network_name (ID: $network_id)"
8086

8187
snapshot_info=$(<info.txt)
82-
echo "Snapshot_info: ${snapshot_info}"
83-
84-
# Create log directory
85-
log_dir=".logs-$(date +"%Y%m%d%H%M%S")"
86-
mkdir -p "$log_dir"
88+
log "Snapshot_info: ${snapshot_info}"
8789

8890
# Define a trap handler that cleans up all processes on exit.
8991
trap stop_nodes EXIT
90-
trap child_exit_handler CHLD
9192

9293
# Define a trap handler that prints a message when an error occurs.
93-
trap 'echo "⛔️ Error in $BASH_SOURCE at line $LINENO: \"$BASH_COMMAND\" failed (exit $?)"' ERR
94+
trap 'log "⛔️ Error in $BASH_SOURCE at line $LINENO: \"$BASH_COMMAND\" failed (exit $?)"' ERR
9495

9596
# Shared flags between all nodes
9697
common_flags=(
@@ -104,41 +105,47 @@ common_flags=(
104105

105106
# The client that has the ledger
106107
# (runs on the first two cores)
107-
$TASKSET1 snarkos start --dev 0 --client "${common_flags[@]}" \
108-
--logfile="$log_dir/client-0.log" &
108+
# shellcheck disable=SC2086
109+
run_with_prefix "client-0" $TASKSET1 snarkos start "--dev=$num_validators" --client "${common_flags[@]}" \
110+
"--logfile=$log_dir/client-0.log" "--storage=.ledger-$network_id-0" \
111+
"--node=127.0.0.1:4130" "--rest=127.0.0.1:3030"
109112
PIDS[0]=$!
110113

111114
# Spawn the clients that will sync the ledger
112115
# (running on the other two cores)
113116
for client_index in $(seq 1 "$num_clients"); do
117+
node_index=$((num_validators + client_index))
114118
prev_port=$((4130+client_index-1))
119+
node_addr="127.0.0.1:$((4130+client_index))"
115120
name="client-$client_index"
116121

117122
# Ensure there are no old ledger files and the node syncs from scratch
118-
snarkos clean "--dev=$client_index" "--network=$network_id" || true
123+
snarkos clean "--dev=$node_index" "--network=$network_id" "--path=.ledger-$network_id-$client_index" || true
119124

120-
$TASKSET2 snarkos start "--dev=$client_index" --client \
121-
"${common_flags[@]}" "--peers=127.0.0.1:$prev_port" \
122-
"--logfile=$log_dir/$name.log" &
125+
# shellcheck disable=SC2086
126+
run_with_prefix "$name" $TASKSET2 snarkos start "--dev=$node_index" --client \
127+
"${common_flags[@]}" "--peers=127.0.0.1:$prev_port" "--node=$node_addr" \
128+
"--rest=127.0.0.1:$((3030+client_index))" \
129+
"--logfile=$log_dir/$name.log" "--storage=.ledger-$network_id-$client_index"
123130
PIDS[client_index]=$!
124131

125132
# Add 1-second delay between starting nodes to avoid hitting rate limits
126133
sleep 1
127134
done
128135

129136
# Block until nodes are running and connected to each other.
130-
wait_for_nodes 0 $((num_clients+1))
137+
wait_for_nodes $((num_clients+1)) 0 "$network_name"
131138

132139
# It takes about 30s for nodes to connect. Do not measure this time.
133140
SECONDS=0
134141
for node_index in $(seq 0 "$num_clients"); do
135-
if ! (wait_for_peers "$node_index" $num_clients); then
142+
if ! (wait_for_peers "$node_index" $num_clients "$network_name"); then
136143
exit 1
137144
fi
138145
done
139146

140147
connect_time=$SECONDS
141-
echo "ℹ️ Nodes are fully connected (took $connect_time secs). Starting block sync measurement."
148+
log "ℹ️ Nodes are fully connected (took $connect_time secs). Starting block sync measurement."
142149

143150
# Ensure the first node actually has the ledger snapshot.
144151
# This should succeed instantly in most cases
@@ -149,10 +156,12 @@ while (( SECONDS < 30 )); do
149156
has_blocks=true
150157
break
151158
fi
159+
160+
sleep $poll_interval
152161
done
153162

154163
if ! $has_blocks; then
155-
echo "Node #0 has not reached the expected height. Maybe the ledger snapshot is corrupted or outdated?"
164+
log "Node #0 has not reached the expected height. Maybe the ledger snapshot is corrupted or outdated?"
156165
exit 1
157166
fi
158167

@@ -178,7 +187,7 @@ while (( SECONDS < max_wait )); do
178187
variance=$(echo "scale=8; 0" | bc -l)
179188
fi
180189

181-
echo "🎉 P2P sync benchmark done! Waited $total_wait seconds for $min_height blocks. Throughput was $throughput blocks/s."
190+
log "🎉 P2P sync benchmark done! Waited $total_wait seconds for $min_height blocks. Throughput was $throughput blocks/s."
182191

183192
# Append data to results file.
184193
printf "{ \"name\": \"p2p-sync\", \"unit\": \"blocks/s\", \"value\": %.3f, \"extra\": \"total_wait=%is, target_height=%i, connect_time=%is, %s\" },\n" \
@@ -193,13 +202,9 @@ while (( SECONDS < max_wait )); do
193202
sleep $poll_interval
194203
done
195204

196-
echo "❌ Benchmark failed! Clients did not sync within 40 minutes."
205+
log "❌ Benchmark failed! Clients did not sync within 40 minutes."
197206

198207
# Print logs for debugging
199-
echo "Last 20 lines of client logs:"
200-
for ((client_index = 0; client_index < num_clients; client_index++)); do
201-
echo "=== Client $client_index logs ==="
202-
tail -n 20 "$log_dir/client-$client_index.log"
203-
done
208+
print_client_logs "$log_dir" "$num_validators" "$num_clients"
204209

205210
exit 1

0 commit comments

Comments
 (0)