Skip to content

Commit b027e15

Browse files
authored
Merge pull request #1571 from o1-labs/sanabriarusso/mina-rust-bps
Add block producer nodes validation to infrastructure tests and website
2 parents 8ecef5a + 0a3c80e commit b027e15

File tree

10 files changed

+389
-5
lines changed

10 files changed

+389
-5
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
# Test block producer node API capabilities
4+
# This corresponds to the test-docs-infrastructure.yaml workflow
5+
#
6+
# Usage:
7+
# ./test-block-producer-node-capabilities.sh
8+
#
9+
# This script tests API capabilities of o1Labs block producer nodes
10+
11+
echo "🔍 Testing block producer node API capabilities..."
12+
13+
# Read block producer nodes from file
14+
bp_nodes_file="website/docs/developers/scripts/infrastructure/block-producer-nodes.txt"
15+
bp_nodes=$(cat "$bp_nodes_file")
16+
17+
# Test with first available node
18+
for node_url in $bp_nodes; do
19+
graphql_url="${node_url}graphql"
20+
21+
echo "Testing API capabilities on: $graphql_url"
22+
23+
# Test network ID query using website script
24+
network_success=false
25+
if network_response=$(bash website/docs/developers/scripts/graphql-api/queries/curl/network-id.sh "$graphql_url" 2>&1); then
26+
if echo "$network_response" | jq -e '.data.networkID' > /dev/null 2>&1; then
27+
network_id=$(echo "$network_response" | jq -r '.data.networkID')
28+
echo "✅ Network ID query successful: $network_id"
29+
network_success=true
30+
else
31+
echo "⚠️ Network ID query failed or unexpected response"
32+
fi
33+
else
34+
echo "⚠️ Network ID query script failed"
35+
fi
36+
37+
# Test best chain query using website script
38+
chain_success=false
39+
if chain_response=$(bash website/docs/developers/scripts/graphql-api/queries/curl/best-chain.sh "$graphql_url" 2>&1); then
40+
if echo "$chain_response" | jq -e '.data.bestChain[0].stateHash' > /dev/null 2>&1; then
41+
state_hash=$(echo "$chain_response" | jq -r '.data.bestChain[0].stateHash')
42+
echo "✅ Best chain query successful: ${state_hash:0:16}..."
43+
chain_success=true
44+
else
45+
echo "⚠️ Best chain query failed or unexpected response"
46+
fi
47+
else
48+
echo "⚠️ Best chain query script failed"
49+
fi
50+
51+
# We only need to test one working node
52+
if [ "$network_success" = true ] && [ "$chain_success" = true ]; then
53+
echo "🎉 Block producer node API capabilities verified"
54+
break
55+
fi
56+
done
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
3+
# Test block producer node GraphQL endpoints
4+
# This corresponds to the test-docs-infrastructure.yaml workflow
5+
#
6+
# Usage:
7+
# ./test-block-producer-node-connectivity.sh
8+
#
9+
# This script tests GraphQL connectivity to o1Labs block producer nodes
10+
11+
echo "🔍 Testing block producer node GraphQL connectivity..."
12+
13+
# Read block producer nodes from file
14+
bp_nodes_file="website/docs/developers/scripts/infrastructure/block-producer-nodes.txt"
15+
16+
if [ ! -f "$bp_nodes_file" ]; then
17+
echo "❌ Block producer nodes file not found: $bp_nodes_file"
18+
exit 1
19+
fi
20+
21+
bp_nodes=$(cat "$bp_nodes_file")
22+
failed=0
23+
24+
for node_url in $bp_nodes; do
25+
echo "Testing GraphQL endpoint: $node_url"
26+
27+
# Test basic HTTP connectivity
28+
if curl -s --connect-timeout 10 --max-time 30 "$node_url" > /dev/null 2>&1; then
29+
echo "$node_url is reachable via HTTP"
30+
else
31+
echo "$node_url is not reachable via HTTP"
32+
failed=$((failed + 1))
33+
continue
34+
fi
35+
36+
# Test GraphQL endpoint using website scripts
37+
graphql_url="${node_url}graphql"
38+
39+
# Test daemon status query using the website script
40+
if response=$(bash website/docs/developers/scripts/graphql-api/queries/curl/daemon-status.sh "$graphql_url" 2>&1); then
41+
# Check if it's valid JSON
42+
if echo "$response" | jq . > /dev/null 2>&1; then
43+
# Check for GraphQL errors
44+
if echo "$response" | jq -e '.errors' > /dev/null 2>&1; then
45+
echo "⚠️ $graphql_url returned GraphQL error:"
46+
echo "$response" | jq '.errors'
47+
# Check for valid data
48+
elif echo "$response" | jq -e '.data.daemonStatus' > /dev/null 2>&1; then
49+
echo "$graphql_url GraphQL query successful"
50+
sync_status=$(echo "$response" | jq -r '.data.daemonStatus.syncStatus // "unknown"')
51+
chain_id=$(echo "$response" | jq -r '.data.daemonStatus.chainId // "unknown"')
52+
echo " Sync Status: $sync_status, Chain ID: ${chain_id:0:16}..."
53+
else
54+
echo "⚠️ $graphql_url unexpected response format"
55+
fi
56+
else
57+
echo "⚠️ $graphql_url did not return valid JSON: $(echo "$response" | head -c 100)..."
58+
fi
59+
else
60+
echo "$graphql_url GraphQL query failed"
61+
failed=$((failed + 1))
62+
fi
63+
64+
echo "---"
65+
done
66+
67+
if [ $failed -gt 0 ]; then
68+
echo "💥 $failed block producer node tests failed"
69+
echo "Infrastructure issues detected. Please check block producer node status."
70+
exit 1
71+
else
72+
echo "🎉 All block producer nodes are healthy and responding"
73+
fi

.github/workflows/test-docs-infrastructure.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ name: Test Documentation Scripts - Infrastructure
44
# This workflow validates:
55
# 1. Seed node connectivity and format verification
66
# 2. Plain node GraphQL endpoints and API capabilities
7-
# 3. Infrastructure script functionality
7+
# 3. Block producer node GraphQL endpoints and API capabilities
8+
# 4. Infrastructure script functionality
89
# Scripts can be run locally for development and debugging
910
on:
1011
schedule:
@@ -66,3 +67,21 @@ jobs:
6667
- name: Test infrastructure scripts
6768
run: ./.github/scripts/test-infrastructure-scripts.sh
6869

70+
test-block-producer-nodes:
71+
name: Test Block Producer Node Connectivity
72+
timeout-minutes: 2
73+
strategy:
74+
matrix:
75+
os: [ubuntu-latest, macos-latest]
76+
runs-on: ${{ matrix.os }}
77+
78+
steps:
79+
- name: Checkout repository
80+
uses: actions/checkout@v5
81+
82+
- name: Test block producer node GraphQL endpoints
83+
run: ./.github/scripts/test-block-producer-node-connectivity.sh
84+
85+
- name: Test block producer node API capabilities
86+
run: ./.github/scripts/test-block-producer-node-capabilities.sh
87+

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414

1515
### Added
1616

17+
- **CI**: Add validation workflows for block producer nodes infrastructure,
18+
including connectivity and API capability testing similar to plain nodes
19+
([#1571](https://github.com/o1-labs/mina-rust/pull/1571))
20+
- **Website**: Add block producer nodes documentation page with GraphQL query
21+
examples for latest canonical block and transaction information. Include note
22+
that block production functionality is under development
23+
([#1571](https://github.com/o1-labs/mina-rust/pull/1571))
1724
- **CLI**: add GraphQL introspection and execution commands under `mina
1825
internal graphql`. Three new commands enable dynamic endpoint discovery
1926
(`list`), detailed schema inspection (`inspect <endpoint>`), and arbitrary
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
https://mina-rust-bp-1.gcp.o1test.net/
2+
https://mina-rust-bp-2.gcp.o1test.net/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ bestChain(maxLength: 1) { stateHash protocolState { consensusState { blockHeight } } creator } }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ bestChain(maxLength: 1) { transactions { userCommands { amount fee from to } } } }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
# Usage: $0 GRAPHQL_ENDPOINT
3+
# GRAPHQL_ENDPOINT: GraphQL endpoint URL (required, must end with /graphql)
4+
# Example: https://mina-rust-bp-1.gcp.o1test.net/graphql
5+
6+
if [ -z "$1" ]; then
7+
echo "Error: GRAPHQL_ENDPOINT is required"
8+
echo "Usage: $0 GRAPHQL_ENDPOINT"
9+
exit 1
10+
fi
11+
12+
GRAPHQL_ENDPOINT="$1"
13+
14+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
15+
# Read the query and create JSON payload using jq for proper escaping
16+
QUERY=$(< "$SCRIPT_DIR/queries/best-chain-block.graphql")
17+
JSON_PAYLOAD=$(echo "{}" | jq --arg query "$QUERY" '.query = $query')
18+
curl -s -X POST "$GRAPHQL_ENDPOINT" \
19+
-H "Content-Type: application/json" \
20+
-d "$JSON_PAYLOAD"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
# Usage: $0 GRAPHQL_ENDPOINT
3+
# GRAPHQL_ENDPOINT: GraphQL endpoint URL (required, must end with /graphql)
4+
# Example: https://mina-rust-bp-1.gcp.o1test.net/graphql
5+
6+
if [ -z "$1" ]; then
7+
echo "Error: GRAPHQL_ENDPOINT is required"
8+
echo "Usage: $0 GRAPHQL_ENDPOINT"
9+
exit 1
10+
fi
11+
12+
GRAPHQL_ENDPOINT="$1"
13+
14+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
15+
# Read the query and create JSON payload using jq for proper escaping
16+
QUERY=$(< "$SCRIPT_DIR/queries/best-chain-transactions.graphql")
17+
JSON_PAYLOAD=$(echo "{}" | jq --arg query "$QUERY" '.query = $query')
18+
curl -s -X POST "$GRAPHQL_ENDPOINT" \
19+
-H "Content-Type: application/json" \
20+
-d "$JSON_PAYLOAD"

0 commit comments

Comments
 (0)