integrate fast sync to start wizard#280
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughChangesFast-sync support
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant start-wizard.sh
participant PivotScript
participant RPC
participant NodeStartup
start-wizard.sh->>PivotScript: calculate FASTSYNC_PIVOT_* values
PivotScript->>RPC: query epoch, block, and state-root data
RPC-->>PivotScript: return pivot data
PivotScript-->>start-wizard.sh: return validated variables
start-wizard.sh->>NodeStartup: write sync configuration
NodeStartup->>NodeStartup: append pivot arguments for fast sync
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tools/get_pivot_more.sh`:
- Around line 6-13: Add --max-time 30 to all three curl invocations in the
script, including the calls assigned to epoch_response and the other RPC
requests, so each request terminates instead of hanging indefinitely.
- Line 67: Redirect the debug output in get_pivot_more.sh from stdout to stderr
by appending >&2 to the echo "current_epoch: $current_epoch" statement, matching
get_pivot.sh and preserving sourceable stdout.
In `@tools/get_pivot.sh`:
- Around line 6-13: Add --max-time 30 to all three curl invocations in
get_pivot.sh, including the calls used for epoch_response and the requests
around the other RPC lookups, so each request terminates instead of hanging
indefinitely.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c269de69-d975-4963-a00f-a5908f419d9c
📒 Files selected for processing (8)
mainnet/env.examplemainnet/start-node.shstart-wizard.shtestnet/env.exampletestnet/start-apothem.shtools/README.mdtools/get_pivot.shtools/get_pivot_more.sh
| epoch_response=$(curl -s -X POST "$RPC_URL" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{ | ||
| "jsonrpc": "2.0", | ||
| "method": "XDPoS_getMasternodesByNumber", | ||
| "params": ["latest"], | ||
| "id": 1 | ||
| }') |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Add --max-time to all curl calls to prevent indefinite hangs.
Same issue as tools/get_pivot.sh — the three curl invocations (lines 6, 70, 91) have no timeout. A non-responsive RPC endpoint will hang the script and, when invoked from the wizard, hang the entire setup with no user-visible feedback.
🔒 Proposed fix — add `--max-time 30` to each curl call
-epoch_response=$(curl -s -X POST "$RPC_URL" \
+epoch_response=$(curl -s --max-time 30 -X POST "$RPC_URL" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "XDPoS_getMasternodesByNumber",
"params": ["latest"],
"id": 1
}')-block_info_response=$(curl -s -X POST "$RPC_URL" \
+block_info_response=$(curl -s --max-time 30 -X POST "$RPC_URL" \
-H "Content-Type: application/json" \
-d "{
\"jsonrpc\": \"2.0\",
\"method\": \"XDPoS_getBlockInfoByEpochNum\",
\"params\": [$current_epoch],
\"id\": 1
}")-block_details=$(curl -s -X POST "$RPC_URL" \
+block_details=$(curl -s --max-time 30 -X POST "$RPC_URL" \
-H "Content-Type: application/json" \
-d "{
\"jsonrpc\": \"2.0\",
\"method\": \"eth_getBlockByHash\",
\"params\": [\"$block_hash\", false],
\"id\": 1
}")Also applies to: 70-77, 91-98
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tools/get_pivot_more.sh` around lines 6 - 13, Add --max-time 30 to all three
curl invocations in the script, including the calls assigned to epoch_response
and the other RPC requests, so each request terminates instead of hanging
indefinitely.
| --arg switch "$switchEpoch" \ | ||
| '(($round | tonumber) / ($epoch | tonumber) | floor) + ($switch | tonumber)') | ||
|
|
||
| echo "current_epoch: $current_epoch" |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Redirect debug output to stderr for consistency with get_pivot.sh.
get_pivot.sh sends echo "Current epoch: …" >&2 (line 37), but this script prints echo "current_epoch: …" to stdout. The README states the output "can be sourced directly" — this line will break source <(./get_pivot_more.sh) with a command not found error. The wizard's grep-based parsing handles it, but direct usage is affected.
🛡️ Proposed fix
-echo "current_epoch: $current_epoch"
+echo "current_epoch: $current_epoch" >&2📝 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.
| echo "current_epoch: $current_epoch" | |
| echo "current_epoch: $current_epoch" >&2 |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tools/get_pivot_more.sh` at line 67, Redirect the debug output in
get_pivot_more.sh from stdout to stderr by appending >&2 to the echo
"current_epoch: $current_epoch" statement, matching get_pivot.sh and preserving
sourceable stdout.
| epoch_response=$(curl -s -X POST "$RPC_URL" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{ | ||
| "jsonrpc": "2.0", | ||
| "method": "XDPoS_getMasternodesByNumber", | ||
| "params": ["latest"], | ||
| "id": 1 | ||
| }') |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Add --max-time to all curl calls to prevent indefinite hangs.
None of the three curl invocations (lines 6, 40, 61) specify a timeout. If the RPC endpoint accepts the connection but never responds, the script blocks indefinitely. In the wizard context (start-wizard.sh captures stdout and discards stderr with 2>/dev/null), the user gets no feedback and the full-sync fallback never triggers.
🔒 Proposed fix — add `--max-time 30` to each curl call
-epoch_response=$(curl -s -X POST "$RPC_URL" \
+epoch_response=$(curl -s --max-time 30 -X POST "$RPC_URL" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "XDPoS_getMasternodesByNumber",
"params": ["latest"],
"id": 1
}')-block_info_response=$(curl -s -X POST "$RPC_URL" \
+block_info_response=$(curl -s --max-time 30 -X POST "$RPC_URL" \
-H "Content-Type: application/json" \
-d "{
\"jsonrpc\": \"2.0\",
\"method\": \"XDPoS_getBlockInfoByV2EpochNum\",
\"params\": [$current_epoch],
\"id\": 1
}")-block_details=$(curl -s -X POST "$RPC_URL" \
+block_details=$(curl -s --max-time 30 -X POST "$RPC_URL" \
-H "Content-Type: application/json" \
-d "{
\"jsonrpc\": \"2.0\",
\"method\": \"eth_getBlockByHash\",
\"params\": [\"$block_hash\", false],
\"id\": 1
}")Also applies to: 40-47, 61-68
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tools/get_pivot.sh` around lines 6 - 13, Add --max-time 30 to all three curl
invocations in get_pivot.sh, including the calls used for epoch_response and the
requests around the other RPC lookups, so each request terminates instead of
hanging indefinitely.
Summary by CodeRabbit
full|fastsync mode and fast-sync pivot variables.