Skip to content

Commit 8d710d7

Browse files
authored
Merge pull request #3976 from ProvableHQ/release-mainnet-4.3.0
[Release] Mainnet 4.3.0
2 parents ede5692 + 8146e8a commit 8d710d7

114 files changed

Lines changed: 5804 additions & 2411 deletions

File tree

Some content is hidden

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

.cargo/audit.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ ignore = [
33
# As the rust community considers the paste crate 'done', we can safely ignore this warning.
44
# see https://users.rust-lang.org/t/paste-alternatives/126787/2
55
"RUSTSEC-2024-0436",
6+
# TODO find a suitable replacement for fxhash.
7+
"RUSTSEC-2025-0057",
68
]

.ci/bench_bft_sync.sh

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#!/bin/bash
2+
3+
#################################################################
4+
# Measures a validator syncing 1000 blocks from another validator
5+
#################################################################
6+
7+
set -eo pipefail # error on any command failure
8+
9+
network_id=1
10+
min_height=250
11+
12+
# The total number of validators in the beacon committee.
13+
# This must match the number of validators used when generating the snapshot.
14+
num_validators=40
15+
16+
# The number of validators that are syncing
17+
num_nodes=1
18+
19+
# Adjust this to show more/less log messages
20+
log_filter="info,snarkos_node_sync=trace,snarkos_node_bft::sync=trace,snarkos_node_bft::primary=warn,snarkos_node_rest=warn"
21+
22+
max_wait=1800 # Wait for up to 30 minutes
23+
poll_interval=1 # Check block heights every second
24+
25+
. ./.ci/utils.sh
26+
27+
branch_name=$(git rev-parse --abbrev-ref HEAD)
28+
echo "On branch: ${branch_name}"
29+
30+
network_name=$(get_network_name $network_id)
31+
echo "Using network: $network_name (ID: $network_id)"
32+
33+
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"
39+
40+
# Define a trap handler that cleans up all processes on exit.
41+
function exit_handler() {
42+
stop_nodes
43+
}
44+
trap exit_handler EXIT
45+
trap child_exit_handler CHLD
46+
47+
# 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
49+
50+
# Shared flags betwen all nodes
51+
common_flags=(
52+
--nobanner --noupdater --nodisplay \
53+
"--network=$network_id"
54+
--nocdn
55+
"--dev-num-validators=$num_validators"
56+
--no-dev-txs
57+
"--log-filter=$log_filter"
58+
)
59+
60+
# 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" &
63+
PIDS[0]=$!
64+
65+
# Stores the list of all validators.
66+
validators="127.0.0.1:5000"
67+
68+
# Spawn the clients that will sync the ledger
69+
for node_index in $(seq 1 "$num_nodes"); do
70+
name="validator-$node_index"
71+
72+
# Ensure there are no old ledger files and the node syncs from scratch
73+
snarkos clean "--dev=$node_index" "--network=$network_id" || true
74+
75+
$TASKSET2 snarkos start "--dev=$node_index" --validator \
76+
"${common_flags[@]}" "--validators=$validators" \
77+
"--logfile=$log_dir/$name.log" &
78+
PIDS[node_index]=$!
79+
80+
# Add the validators BFT address to the validators list.
81+
bft_port=$((5000 + node_index))
82+
validators="$validators,127.0.0.1:$bft_port"
83+
84+
# Add 1-second delay between starting nodes to avoid hitting rate limits
85+
sleep 1
86+
done
87+
88+
# Block until nodes are running and connected to each other.
89+
wait_for_nodes $((num_nodes+1)) 0
90+
91+
SECONDS=0
92+
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
99+
100+
connect_time=$SECONDS
101+
echo "ℹ️ Nodes are fully connected (took $connect_time secs). Starting block sync measurement."
102+
103+
# Check heights periodically with a timeout
104+
SECONDS=0
105+
while (( SECONDS < max_wait )); do
106+
# The last block cannot be fully applied to the ledger yet as there is no next block to confirm it.
107+
# However, we know that the sync height of a node is always at least one more than the ledger height.
108+
expected_height=$((min_height-1))
109+
110+
if check_heights 1 $((num_nodes+1)) $expected_height "$network_name" "$SECONDS"; then
111+
total_wait=$SECONDS
112+
throughput=$(compute_throughput "$min_height" "$total_wait")
113+
114+
echo "🎉 BFT sync benchmark done! Waited $total_wait seconds for $min_height blocks. Throughput was $throughput blocks/s."
115+
116+
# Append data to results file.
117+
printf "{ \"name\": \"bft-sync\", \"unit\": \"blocks/s\", \"value\": %.3f, \"extra\": \"total_wait=%is, target_height=%i, connect_time=%i, branch=%s, %s\" },\n" \
118+
"$throughput" "$total_wait" "$min_height" "$connect_time" "$branch_name" "$snapshot_info"| tee -a results.json
119+
exit 0
120+
fi
121+
122+
# Continue waiting
123+
sleep $poll_interval
124+
done
125+
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
134+
135+
exit 1

.ci/bench_cdn_sync.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
3+
####################################################
4+
# Measures a client syncing 1000 blocks from the CDN
5+
####################################################
6+
7+
set -eo pipefail # error on any command failure
8+
9+
network_id=0
10+
min_height=250
11+
12+
# Adjust this to show more/less log messages
13+
log_filter="info,snarkos_node_rest=warn,snarkos_node_cdn=debug"
14+
15+
max_wait=1800 # Wait for up to 30 minutes
16+
poll_interval=1 # Check block heights every second
17+
18+
. ./.ci/utils.sh
19+
20+
network_name=$(get_network_name $network_id)
21+
echo "Using network: $network_name (ID: $network_id)"
22+
23+
# Create log directory
24+
log_dir=".logs-$(date +"%Y%m%d%H%M%S")"
25+
mkdir -p "$log_dir"
26+
27+
# Define a trap handler that cleans up all processes on exit.
28+
function exit_handler() {
29+
stop_nodes
30+
}
31+
trap exit_handler EXIT
32+
trap child_exit_handler CHLD
33+
34+
# 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
36+
37+
# Ensure there are no old ledger files and the node syncs from scratch
38+
snarkos clean "--network=$network_id" || true
39+
40+
# Arguments to pass to the node
41+
args=(
42+
"--network=$network_id"
43+
--nobanner --noupdater --nodisplay # reduce clutter in the output and hide TUI
44+
--rest-rps=1000000 # ensure benchmarks don't fail due to rate limiting
45+
--log-filter=$log_filter # only show the logs we care about
46+
)
47+
48+
# Spawn the client that will sync the ledger.
49+
# Use the same CPU cores as in the other benchmarks, so the numbers are comparable.
50+
$TASKSET2 snarkos start --client "${args[@]}" &
51+
PIDS[0]=$!
52+
53+
wait_for_nodes 0 1
54+
55+
# Check heights periodically with a timeout
56+
SECONDS=0
57+
while (( SECONDS < max_wait )); do
58+
if check_heights 0 1 $min_height "$network_name" "$SECONDS"; then
59+
total_wait=$SECONDS
60+
throughput=$(compute_throughput "$min_height" "$total_wait")
61+
62+
echo "🎉 Benchmark done! Waited ${total_wait}s for $min_height blocks. Throughput was $throughput blocks/s."
63+
64+
# Append data to results file.
65+
printf "{ \"name\": \"cdn-sync\", \"unit\": \"blocks/s\", \"value\": %.3f, \"extra\": \"total_wait=%is, target_height=${min_height}\" }\n" \
66+
"$throughput" "$total_wait" | tee -a results.json
67+
exit 0
68+
fi
69+
70+
# Continue waiting
71+
sleep $poll_interval
72+
done
73+
74+
echo "❌ Benchmark failed! Client did not sync within 30 minutes."
75+
76+
exit 1

0 commit comments

Comments
 (0)