-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add local testnet guide #1815
base: main
Are you sure you want to change the base?
Conversation
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes in this pull request introduce a new sidebar item titled "Set up a local testnet" in the VitePress configuration file, linking to a new guide. This guide, located in Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 10
🧹 Outside diff range and nitpick comments (7)
how-to-guides/local-testnet.md (5)
41-44
: Add note about example dataThe example genesis hash should be clearly marked as example data that will differ for each setup.
🧰 Tools
🪛 Markdownlint (0.35.0)
42-42: null
Fenced code blocks should have a language specified(MD040, fenced-code-language)
48-50
: Address environment variable persistenceConsider adding instructions for:
- Making the environment variable persistent across sessions
- Verifying the variable is set correctly
124-124
: Document port selectionAdd a note explaining:
- Why port 42069 was chosen
- That users can choose a different available port
- How to verify port availability
153-156
: Enhance blob submission documentationConsider adding:
- Explanation of the blob data format (0x4772756763686174)
- Expected success response
- How to verify the blob was submitted successfully
42-44
: Add language specification to code blockAdd a language identifier to the fenced code block for proper syntax highlighting.
-``` +```text 1D53B32ACB02563E425BA1F8B5178B06A748E0F7B9748A8B1D07C34B454AF595<details> <summary>🧰 Tools</summary> <details> <summary>🪛 Markdownlint (0.35.0)</summary> 42-42: null Fenced code blocks should have a language specified (MD040, fenced-code-language) </details> </details> </blockquote></details> <details> <summary>public/start-local.sh (2)</summary><blockquote> `3-10`: **Enhance the warning message with specific details** While the warning is good practice, it could be more specific about which data will be deleted and the potential impact. ```diff -echo "WARNING: This script will DELETE your existing .celestia-app directory and start a new local testnet." -echo "Make sure you have backed up any important data from .celestia-app" +echo "WARNING: This script will DELETE the following directories:" +echo " - $HOME/.celestia-app" +echo " - $HOME/.celestia-custom-bridge" +echo " - $HOME/.celestia-custom-light" +echo "This will remove all existing chain data, keys, and configurations." +echo "Please ensure you have backed up any important data before proceeding."
1-139
: Consider improving script documentation and modularityWhile the script is functional, consider the following architectural improvements:
- Add a comprehensive help/usage section with command-line arguments for customization
- Break down the script into modules for better maintainability
- Add logging levels and verbose mode for debugging
- Consider creating a configuration file for customizable parameters
Example help section to add at the beginning:
#!/bin/bash show_help() { cat << EOF Usage: $(basename "$0") [OPTIONS] Sets up a local Celestia testnet with validator, bridge, and light nodes. Options: -h, --help Show this help message -v, --verbose Enable verbose logging --no-cleanup Skip cleanup on exit --timeout SECONDS Service startup timeout (default: 60) --stabilization SECONDS Post-startup stabilization delay (default: 5) Example: $(basename "$0") --verbose --timeout 120 For more information, visit: https://docs.celestia.org/nodes/local-testnet EOF exit 0 } # Parse command line arguments while [[ $# -gt 0 ]]; do case $1 in -h|--help) show_help ;; -v|--verbose) VERBOSE=1 ;; --no-cleanup) NO_CLEANUP=1 ;; --timeout) TIMEOUT="$2"; shift ;; --stabilization) STABILIZATION="$2"; shift ;; *) echo "Unknown option: $1"; show_help ;; esac shift done
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
.vitepress/config.ts
(1 hunks)how-to-guides/local-testnet.md
(1 hunks)public/start-local.sh
(1 hunks)
🧰 Additional context used
🪛 Markdownlint (0.35.0)
how-to-guides/local-testnet.md
42-42: null
Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🔇 Additional comments (2)
how-to-guides/local-testnet.md (1)
7-10
: Consider enhancing the prerequisites section
While the prerequisites are clearly listed, consider:
- Specifying minimum required versions for each tool
- Adding installation instructions or links for
jq
andnc
Let's verify the relative link to compatible versions:
.vitepress/config.ts (1)
391-394
: LGTM! The sidebar item is well-placed and properly structured.
The new "Set up a local testnet" item is appropriately placed under the "Getting started" section, following the existing pattern and hierarchy. The link path follows the documentation's convention.
```bash | ||
cd celestia-app/scripts | ||
bash single-node.sh | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add validation steps for successful node startup
Consider adding:
- Expected output or success indicators
- Commands to verify the validator node is running correctly
- Troubleshooting steps for common issues
Send funds to the light node: | ||
|
||
```bash | ||
celestia-appd tx bank send validator celestia1p8yx4yveuu6ushyccepsuknaqpqn9ppq07m4n3 10000000utia \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Document address usage
Replace the hardcoded address with a placeholder and explain:
- How to obtain the correct address
- The expected address format
# Get addresses and fund light node | ||
echo "Getting node addresses..." | ||
BRIDGE_ADDRESS=$(celestia state account-address --node.store "$HOME/.celestia-custom-bridge" | jq -r '.result') | ||
LIGHT_ADDRESS=$(celestia state account-address --node.store "$HOME/.celestia-custom-light" --url http://localhost:42069 | jq -r '.result') | ||
echo "Funding light node..." | ||
celestia-appd tx bank send validator "$LIGHT_ADDRESS" 10000000utia \ | ||
--chain-id test \ | ||
--keyring-backend test \ | ||
--fees 500utia -y | ||
echo "Waiting for funding transaction to be included in a block..." | ||
sleep 5 | ||
echo "Testing blob submission..." | ||
celestia blob submit 0x4772756763686174 '"Simplicity is the ultimate sophistication." -Leonardo da Vinci' \ | ||
--node.store "$HOME/.celestia-custom-light" \ | ||
--url http://localhost:42069 | ||
echo "Setup complete!" | ||
echo "Bridge node address: $BRIDGE_ADDRESS" | ||
echo "Light node address: $LIGHT_ADDRESS" | ||
echo "Custom network: $CELESTIA_CUSTOM" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Improve final setup reliability and add cleanup
The current implementation needs better transaction validation and cleanup handling.
+# Trap for cleanup on script exit
+cleanup() {
+ echo "Cleaning up..."
+ stop_process "celestia-appd"
+ stop_process "celestia"
+ rm -f light.log bridge.log
+}
+trap cleanup EXIT
+
# Get addresses and fund light node
echo "Getting node addresses..."
-BRIDGE_ADDRESS=$(celestia state account-address --node.store "$HOME/.celestia-custom-bridge" | jq -r '.result')
-LIGHT_ADDRESS=$(celestia state account-address --node.store "$HOME/.celestia-custom-light" --url http://localhost:42069 | jq -r '.result')
+BRIDGE_ADDRESS=$(celestia state account-address --node.store "$HOME/.celestia-custom-bridge" | jq -r '.result') || {
+ echo "Error: Failed to get bridge address"
+ exit 1
+}
+LIGHT_ADDRESS=$(celestia state account-address --node.store "$HOME/.celestia-custom-light" --url http://localhost:42069 | jq -r '.result') || {
+ echo "Error: Failed to get light address"
+ exit 1
+}
+
echo "Funding light node..."
-celestia-appd tx bank send validator "$LIGHT_ADDRESS" 10000000utia \
+TX_HASH=$(celestia-appd tx bank send validator "$LIGHT_ADDRESS" 10000000utia \
--chain-id test \
--keyring-backend test \
- --fees 500utia -y
+ --fees 500utia -y | jq -r '.txhash') || {
+ echo "Error: Funding transaction failed"
+ exit 1
+}
+
echo "Waiting for funding transaction to be included in a block..."
-sleep 5
+for i in {1..30}; do
+ if celestia-appd query tx "$TX_HASH" 2>/dev/null; then
+ break
+ fi
+ if [ "$i" -eq 30 ]; then
+ echo "Error: Funding transaction not confirmed after 30 seconds"
+ exit 1
+ fi
+ sleep 1
+done
+
echo "Testing blob submission..."
celestia blob submit 0x4772756763686174 '"Simplicity is the ultimate sophistication." -Leonardo da Vinci' \
--node.store "$HOME/.celestia-custom-light" \
- --url http://localhost:42069
+ --url http://localhost:42069 || {
+ echo "Error: Blob submission failed"
+ exit 1
+}
+
echo "Setup complete!"
echo "Bridge node address: $BRIDGE_ADDRESS"
echo "Light node address: $LIGHT_ADDRESS"
echo "Custom network: $CELESTIA_CUSTOM"
+echo "Logs available at: bridge.log and light.log"
Committable suggestion skipped: line range outside the PR's diff.
wait_for_service() { | ||
local port=$1 | ||
local service=$2 | ||
echo "Waiting for $service to be ready..." | ||
while ! nc -z localhost "$port"; do | ||
sleep 1 | ||
done | ||
echo "$service is ready!" | ||
sleep 5 # Give it a little extra time to stabilize | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add timeout and configurable stabilization delay to wait_for_service
The current implementation has two potential issues:
- No timeout mechanism could lead to an infinite wait
- Fixed 5-second stabilization delay might not be sufficient for all services
wait_for_service() {
local port=$1
local service=$2
+ local timeout=${3:-60} # Default 60 seconds timeout
+ local stabilization_delay=${4:-5} # Default 5 seconds stabilization
+ local start_time=$(date +%s)
echo "Waiting for $service to be ready..."
while ! nc -z localhost "$port"; do
+ if [ $(($(date +%s) - start_time)) -gt "$timeout" ]; then
+ echo "Timeout waiting for $service after $timeout seconds"
+ exit 1
+ fi
sleep 1
done
echo "$service is ready!"
- sleep 5 # Give it a little extra time to stabilize
+ sleep "$stabilization_delay"
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
wait_for_service() { | |
local port=$1 | |
local service=$2 | |
echo "Waiting for $service to be ready..." | |
while ! nc -z localhost "$port"; do | |
sleep 1 | |
done | |
echo "$service is ready!" | |
sleep 5 # Give it a little extra time to stabilize | |
} | |
wait_for_service() { | |
local port=$1 | |
local service=$2 | |
local timeout=${3:-60} # Default 60 seconds timeout | |
local stabilization_delay=${4:-5} # Default 5 seconds stabilization | |
local start_time=$(date +%s) | |
echo "Waiting for $service to be ready..." | |
while ! nc -z localhost "$port"; do | |
if [ $(($(date +%s) - start_time)) -gt "$timeout" ]; then | |
echo "Timeout waiting for $service after $timeout seconds" | |
exit 1 | |
fi | |
sleep 1 | |
done | |
echo "$service is ready!" | |
sleep "$stabilization_delay" | |
} |
# Initialize and start light node | ||
echo "Initializing light node..." | ||
celestia light init \ | ||
--p2p.network test \ | ||
--core.ip localhost:26657 \ | ||
--node.store "$HOME/.celestia-custom-light/" | ||
|
||
# Construct the light node start command | ||
LIGHT_NODE_CMD="celestia light start \ | ||
--p2p.network test \ | ||
--core.ip localhost:26657 \ | ||
--node.store \"$HOME/.celestia-custom-light/\" \ | ||
--headers.trusted-peers \"$PEER_ADDR/p2p/$PEER_ID\" \ | ||
--rpc.port 42069" | ||
|
||
# Log the command | ||
echo "Starting light node with command:" | ||
echo "$LIGHT_NODE_CMD" | ||
|
||
# Execute the command | ||
eval "$LIGHT_NODE_CMD" & | ||
wait_for_service 42069 "light node" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve light node setup security and reliability
The current implementation uses eval and lacks proper error handling.
# Initialize and start light node
echo "Initializing light node..."
celestia light init \
--p2p.network test \
--core.ip localhost:26657 \
- --node.store "$HOME/.celestia-custom-light/"
+ --node.store "$HOME/.celestia-custom-light/" || {
+ echo "Error: Light node initialization failed"
+ exit 1
+ }
-# Construct the light node start command
-LIGHT_NODE_CMD="celestia light start \
- --p2p.network test \
- --core.ip localhost:26657 \
- --node.store \"$HOME/.celestia-custom-light/\" \
- --headers.trusted-peers \"$PEER_ADDR/p2p/$PEER_ID\" \
- --rpc.port 42069"
-
-# Log the command
-echo "Starting light node with command:"
-echo "$LIGHT_NODE_CMD"
-
-# Execute the command
-eval "$LIGHT_NODE_CMD" &
+# Start light node directly without eval
+echo "Starting light node..."
+celestia light start \
+ --p2p.network test \
+ --core.ip localhost:26657 \
+ --node.store "$HOME/.celestia-custom-light/" \
+ --headers.trusted-peers "$PEER_ADDR/p2p/$PEER_ID" \
+ --rpc.port 42069 > light.log 2>&1 &
+LIGHT_PID=$!
+
wait_for_service 42069 "light node"
+
+# Verify light node is still running
+if ! kill -0 $LIGHT_PID 2>/dev/null; then
+ echo "Error: Light node failed to start. Check light.log for details"
+ exit 1
+fi
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
# Initialize and start light node | |
echo "Initializing light node..." | |
celestia light init \ | |
--p2p.network test \ | |
--core.ip localhost:26657 \ | |
--node.store "$HOME/.celestia-custom-light/" | |
# Construct the light node start command | |
LIGHT_NODE_CMD="celestia light start \ | |
--p2p.network test \ | |
--core.ip localhost:26657 \ | |
--node.store \"$HOME/.celestia-custom-light/\" \ | |
--headers.trusted-peers \"$PEER_ADDR/p2p/$PEER_ID\" \ | |
--rpc.port 42069" | |
# Log the command | |
echo "Starting light node with command:" | |
echo "$LIGHT_NODE_CMD" | |
# Execute the command | |
eval "$LIGHT_NODE_CMD" & | |
wait_for_service 42069 "light node" | |
# Initialize and start light node | |
echo "Initializing light node..." | |
celestia light init \ | |
--p2p.network test \ | |
--core.ip localhost:26657 \ | |
--node.store "$HOME/.celestia-custom-light/" || { | |
echo "Error: Light node initialization failed" | |
exit 1 | |
} | |
# Start light node directly without eval | |
echo "Starting light node..." | |
celestia light start \ | |
--p2p.network test \ | |
--core.ip localhost:26657 \ | |
--node.store "$HOME/.celestia-custom-light/" \ | |
--headers.trusted-peers "$PEER_ADDR/p2p/$PEER_ID" \ | |
--rpc.port 42069 > light.log 2>&1 & | |
LIGHT_PID=$! | |
wait_for_service 42069 "light node" | |
# Verify light node is still running | |
if ! kill -0 $LIGHT_PID 2>/dev/null; then | |
echo "Error: Light node failed to start. Check light.log for details" | |
exit 1 | |
fi |
# Clean up existing directories | ||
rm -rf "$HOME/.celestia-custom-bridge" | ||
rm -rf "$HOME/.celestia-custom-light" | ||
|
||
# Create necessary directories | ||
mkdir -p "$HOME/.celestia-custom-bridge" | ||
mkdir -p "$HOME/.celestia-custom-light" | ||
|
||
# Kill any existing celestia processes | ||
pkill celestia-appd | ||
pkill celestia | ||
sleep 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Improve error handling and process cleanup
The current implementation could be enhanced with better error handling and cleaner process management.
+# Function to safely remove directory
+safe_remove_dir() {
+ if [ -d "$1" ]; then
+ rm -rf "$1" || {
+ echo "Error: Failed to remove directory $1"
+ exit 1
+ }
+ fi
+}
+
+# Function to safely stop process
+stop_process() {
+ if pgrep "$1" >/dev/null; then
+ pkill "$1"
+ sleep 2
+ if pgrep "$1" >/dev/null; then
+ pkill -9 "$1" # Force kill if still running
+ fi
+ fi
+}
+
# Clean up existing directories
-rm -rf "$HOME/.celestia-custom-bridge"
-rm -rf "$HOME/.celestia-custom-light"
+safe_remove_dir "$HOME/.celestia-custom-bridge"
+safe_remove_dir "$HOME/.celestia-custom-light"
# Kill any existing celestia processes
-pkill celestia-appd
-pkill celestia
-sleep 2
+stop_process "celestia-appd"
+stop_process "celestia"
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
# Clean up existing directories | |
rm -rf "$HOME/.celestia-custom-bridge" | |
rm -rf "$HOME/.celestia-custom-light" | |
# Create necessary directories | |
mkdir -p "$HOME/.celestia-custom-bridge" | |
mkdir -p "$HOME/.celestia-custom-light" | |
# Kill any existing celestia processes | |
pkill celestia-appd | |
pkill celestia | |
sleep 2 | |
# Function to safely remove directory | |
safe_remove_dir() { | |
if [ -d "$1" ]; then | |
rm -rf "$1" || { | |
echo "Error: Failed to remove directory $1" | |
exit 1 | |
} | |
fi | |
} | |
# Function to safely stop process | |
stop_process() { | |
if pgrep "$1" >/dev/null; then | |
pkill "$1" | |
sleep 2 | |
if pgrep "$1" >/dev/null; then | |
pkill -9 "$1" # Force kill if still running | |
fi | |
fi | |
} | |
# Clean up existing directories | |
safe_remove_dir "$HOME/.celestia-custom-bridge" | |
safe_remove_dir "$HOME/.celestia-custom-light" | |
# Create necessary directories | |
mkdir -p "$HOME/.celestia-custom-bridge" | |
mkdir -p "$HOME/.celestia-custom-light" | |
# Kill any existing celestia processes | |
stop_process "celestia-appd" | |
stop_process "celestia" |
# Start the validator node | ||
echo "Starting validator node..." | ||
cd "$HOME/celestia-app/scripts" || exit 1 | ||
|
||
# Automatically answer "y" to the prompt | ||
echo "y" | bash single-node.sh & | ||
wait_for_service 26657 "validator node" | ||
|
||
# Get the genesis block hash | ||
echo "Getting genesis block hash..." | ||
BLOCK_HASH=$(curl -s "localhost:26657/block?height=1" | jq -r '.result.block_id.hash') | ||
if [ -z "$BLOCK_HASH" ]; then | ||
echo "Error: Could not get block hash" | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve validator setup reliability
The current implementation has several potential points of failure that should be addressed.
# Start the validator node
echo "Starting validator node..."
-cd "$HOME/celestia-app/scripts" || exit 1
+SCRIPT_PATH="$HOME/celestia-app/scripts/single-node.sh"
+if [ ! -f "$SCRIPT_PATH" ]; then
+ echo "Error: single-node.sh not found at $SCRIPT_PATH"
+ exit 1
+fi
# Automatically answer "y" to the prompt
-echo "y" | bash single-node.sh &
+TMPFILE=$(mktemp)
+trap 'rm -f $TMPFILE' EXIT
+expect << EOF
+spawn bash $SCRIPT_PATH
+expect "Do you want to proceed? (y/n):"
+send "y\r"
+expect eof
+EOF
wait_for_service 26657 "validator node"
# Get the genesis block hash
echo "Getting genesis block hash..."
-BLOCK_HASH=$(curl -s "localhost:26657/block?height=1" | jq -r '.result.block_id.hash')
+BLOCK_HASH=$(curl -s --max-time 10 "localhost:26657/block?height=1" | jq -r '.result.block_id.hash')
if [ -z "$BLOCK_HASH" ]; then
echo "Error: Could not get block hash"
exit 1
fi
Note: This change requires the expect
utility. Please add it to the command check list:
check_command "celestia-appd"
check_command "celestia"
check_command "jq"
check_command "nc"
+check_command "expect"
Committable suggestion skipped: line range outside the PR's diff.
# Initialize and start bridge node | ||
echo "Initializing bridge node..." | ||
celestia bridge init \ | ||
--node.store "$HOME/.celestia-custom-bridge" \ | ||
--core.ip localhost \ | ||
--core.grpc.port 9090 \ | ||
--core.rpc.port 26657 \ | ||
--p2p.network test | ||
echo "Starting bridge node..." | ||
celestia bridge start \ | ||
--node.store "$HOME/.celestia-custom-bridge" \ | ||
--core.ip localhost \ | ||
--core.grpc.port 9090 \ | ||
--core.rpc.port 26657 \ | ||
--p2p.network test & | ||
wait_for_service 2121 "bridge node" | ||
|
||
# Get bridge node info | ||
echo "Getting bridge node peer info..." | ||
BRIDGE_INFO=$(celestia p2p info --node.store "$HOME/.celestia-custom-bridge") | ||
PEER_ID=$(echo "$BRIDGE_INFO" | jq -r '.result.id') | ||
PEER_ADDR=$(echo "$BRIDGE_INFO" | jq -r '.result.peer_addr[] | select(contains("/ip4/10.0.0.125") and contains("/udp/") and contains("/webrtc-direct/"))' | head -n 1) | ||
if [ -z "$PEER_ID" ] || [ -z "$PEER_ADDR" ]; then | ||
echo "Error: Could not get peer information" | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enhance bridge node setup reliability
The bridge node setup needs better error handling and more robust peer address selection.
+# Function to verify bridge node initialization
+verify_bridge_init() {
+ local store_path="$1"
+ if [ ! -d "$store_path/keys" ] || [ ! -f "$store_path/config.toml" ]; then
+ echo "Error: Bridge node initialization failed"
+ exit 1
+ fi
+}
+
# Initialize and start bridge node
echo "Initializing bridge node..."
celestia bridge init \
--node.store "$HOME/.celestia-custom-bridge" \
--core.ip localhost \
--core.grpc.port 9090 \
--core.rpc.port 26657 \
- --p2p.network test
+ --p2p.network test || exit 1
+
+verify_bridge_init "$HOME/.celestia-custom-bridge"
+
echo "Starting bridge node..."
celestia bridge start \
--node.store "$HOME/.celestia-custom-bridge" \
--core.ip localhost \
--core.grpc.port 9090 \
--core.rpc.port 26657 \
- --p2p.network test &
+ --p2p.network test > bridge.log 2>&1 &
+BRIDGE_PID=$!
+
wait_for_service 2121 "bridge node"
+# Verify bridge node is still running
+if ! kill -0 $BRIDGE_PID 2>/dev/null; then
+ echo "Error: Bridge node failed to start. Check bridge.log for details"
+ exit 1
+fi
+
# Get bridge node info
echo "Getting bridge node peer info..."
-BRIDGE_INFO=$(celestia p2p info --node.store "$HOME/.celestia-custom-bridge")
+BRIDGE_INFO=$(celestia p2p info --node.store "$HOME/.celestia-custom-bridge") || {
+ echo "Error: Failed to get bridge node info"
+ exit 1
+}
+
-PEER_ADDR=$(echo "$BRIDGE_INFO" | jq -r '.result.peer_addr[] | select(contains("/ip4/10.0.0.125") and contains("/udp/") and contains("/webrtc-direct/"))' | head -n 1)
+# More robust peer address selection
+PEER_ADDR=$(echo "$BRIDGE_INFO" | jq -r '.result.peer_addr[] |
+ select(contains("/ip4/") and (contains("/tcp/") or contains("/udp/")))' | head -n 1)
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
# Initialize and start bridge node | |
echo "Initializing bridge node..." | |
celestia bridge init \ | |
--node.store "$HOME/.celestia-custom-bridge" \ | |
--core.ip localhost \ | |
--core.grpc.port 9090 \ | |
--core.rpc.port 26657 \ | |
--p2p.network test | |
echo "Starting bridge node..." | |
celestia bridge start \ | |
--node.store "$HOME/.celestia-custom-bridge" \ | |
--core.ip localhost \ | |
--core.grpc.port 9090 \ | |
--core.rpc.port 26657 \ | |
--p2p.network test & | |
wait_for_service 2121 "bridge node" | |
# Get bridge node info | |
echo "Getting bridge node peer info..." | |
BRIDGE_INFO=$(celestia p2p info --node.store "$HOME/.celestia-custom-bridge") | |
PEER_ID=$(echo "$BRIDGE_INFO" | jq -r '.result.id') | |
PEER_ADDR=$(echo "$BRIDGE_INFO" | jq -r '.result.peer_addr[] | select(contains("/ip4/10.0.0.125") and contains("/udp/") and contains("/webrtc-direct/"))' | head -n 1) | |
if [ -z "$PEER_ID" ] || [ -z "$PEER_ADDR" ]; then | |
echo "Error: Could not get peer information" | |
exit 1 | |
fi | |
# Function to verify bridge node initialization | |
verify_bridge_init() { | |
local store_path="$1" | |
if [ ! -d "$store_path/keys" ] || [ ! -f "$store_path/config.toml" ]; then | |
echo "Error: Bridge node initialization failed" | |
exit 1 | |
fi | |
} | |
# Initialize and start bridge node | |
echo "Initializing bridge node..." | |
celestia bridge init \ | |
--node.store "$HOME/.celestia-custom-bridge" \ | |
--core.ip localhost \ | |
--core.grpc.port 9090 \ | |
--core.rpc.port 26657 \ | |
--p2p.network test || exit 1 | |
verify_bridge_init "$HOME/.celestia-custom-bridge" | |
echo "Starting bridge node..." | |
celestia bridge start \ | |
--node.store "$HOME/.celestia-custom-bridge" \ | |
--core.ip localhost \ | |
--core.grpc.port 9090 \ | |
--core.rpc.port 26657 \ | |
--p2p.network test > bridge.log 2>&1 & | |
BRIDGE_PID=$! | |
wait_for_service 2121 "bridge node" | |
# Verify bridge node is still running | |
if ! kill -0 $BRIDGE_PID 2>/dev/null; then | |
echo "Error: Bridge node failed to start. Check bridge.log for details" | |
exit 1 | |
fi | |
# Get bridge node info | |
echo "Getting bridge node peer info..." | |
BRIDGE_INFO=$(celestia p2p info --node.store "$HOME/.celestia-custom-bridge") || { | |
echo "Error: Failed to get bridge node info" | |
exit 1 | |
} | |
PEER_ID=$(echo "$BRIDGE_INFO" | jq -r '.result.id') | |
# More robust peer address selection | |
PEER_ADDR=$(echo "$BRIDGE_INFO" | jq -r '.result.peer_addr[] | | |
select(contains("/ip4/") and (contains("/tcp/") or contains("/udp/")))' | head -n 1) | |
if [ -z "$PEER_ID" ] || [ -z "$PEER_ADDR" ]; then | |
echo "Error: Could not get peer information" | |
exit 1 | |
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (4)
how-to-guides/local-testnet.md (4)
7-10
: Enhance prerequisites section with installation linksConsider adding links to installation guides for each prerequisite:
- Link to
jq
installation guide- Link to
nc
(netcat) installation guide- Add version requirements for
jq
andnc
48-50
: Improve environment variable handlingConsider adding:
- Instructions for persisting the environment variable in shell configuration files
- Verification step to confirm the variable is set correctly
- Troubleshooting steps if the genesis hash is incorrect
118-125
: Improve light node configuration clarityThe light node startup command needs improvements:
- Explain the choice of port 42069 and whether it can be customized
- Consider using environment variables for peer info to avoid long command lines
- Add validation steps to confirm successful connection to the bridge node
42-44
: Add language specification to code blockAdd a language specification to the fenced code block:
-``` +```text 1D53B32ACB02563E425BA1F8B5178B06A748E0F7B9748A8B1D07C34B454AF595<details> <summary>🧰 Tools</summary> <details> <summary>🪛 Markdownlint (0.35.0)</summary> 42-42: null Fenced code blocks should have a language specified (MD040, fenced-code-language) </details> </details> </blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used: CodeRabbit UI** **Review profile: CHILL** <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 4fc655299d579a2da38c2f21514d7fda186603f4 and 6b8a280f26550e932fd9b7e207f5eacc3f23d30b. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `how-to-guides/local-testnet.md` (1 hunks) </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>🪛 Markdownlint (0.35.0)</summary> <details> <summary>how-to-guides/local-testnet.md</summary> 42-42: null Fenced code blocks should have a language specified (MD040, fenced-code-language) </details> </details> </details> <details> <summary>🔇 Additional comments (3)</summary> <details> <summary>how-to-guides/local-testnet.md (3)</summary> `28-31`: **Add validation steps for successful node startup** The validator node setup instructions need more detail about success indicators. Previous review comment still applies regarding: 1. Expected output 2. Validation commands 3. Troubleshooting steps --- `16-18`: _:warning: Potential issue_ **Add security advisory for script execution** The current curl-to-bash execution method should include security precautions. Previous review comment still applies regarding: 1. Adding a warning to inspect scripts before execution 2. Providing SHA256 checksum verification 3. Adding direct link to view script content --- `144-144`: _:hammer_and_wrench: Refactor suggestion_ **Document address usage and parameters** The funding command uses hardcoded values that need documentation. Previous review comment still applies regarding: 1. Replacing hardcoded address with placeholder 2. Explaining address format 3. Adding instructions for obtaining correct addresses </details> </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
feat: add local testnet guide docs: add to sidebar feat: mvp of script for local testnet feat: mvp of script for local testnet docs: updates
6b8a280
to
b4bac15
Compare
Overview
PREVIEW
Resolves #1813
Tasks
Summary by CodeRabbit