Skip to content

Commit 50a2ab0

Browse files
committed
Merge: combine update-binaries --compile local and deploy-binaries
1 parent 1f9fd89 commit 50a2ab0

2 files changed

Lines changed: 133 additions & 2 deletions

File tree

scripts/ipc-subnet-manager/ipc-subnet-manager.sh

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Commands:
4848
init --resume Continue init from where it left off (after deploy failure)
4949
update-config Update existing node configs without wiping data
5050
update-binaries Pull latest code, build, and install binaries on all validators
51+
deploy-binaries Copy existing binaries to validators (no build)
5152
check Comprehensive health check on all nodes
5253
diagnose [name] Detailed diagnostics for troubleshooting (all or one validator)
5354
restart Graceful restart of all nodes
@@ -95,6 +96,7 @@ Examples:
9596
$0 check # Run health checks
9697
$0 update-binaries --branch main # Update binaries from main branch
9798
$0 update-binaries -C local --branch main # Build locally, deploy to validators
99+
$0 deploy-binaries --path ./target/release # Copy binaries to all validators
98100
$0 watch-finality # Monitor parent finality progress
99101
$0 watch-blocks # Monitor block production
100102
$0 logs validator-1 # View logs from validator-1
@@ -486,6 +488,81 @@ EOF
486488
update_all_binaries "$branch" "$compile_mode"
487489
}
488490

491+
# Deploy binaries to validators (copy only, no build)
492+
cmd_deploy_binaries() {
493+
local binary_path=""
494+
local target_validator=""
495+
496+
# Parse options
497+
while [[ $# -gt 0 ]]; do
498+
case $1 in
499+
--path)
500+
binary_path="$2"
501+
shift 2
502+
;;
503+
--help|-h)
504+
cat << EOF
505+
Copy ipc-cli and fendermint binaries to validators (no build)
506+
507+
Usage: $0 deploy-binaries [options] [validator-name]
508+
509+
Options:
510+
--path DIR Path to directory containing ipc-cli and fendermint
511+
--help Show this help message
512+
513+
If --path is omitted, auto-detects from local IPC repo:
514+
- target/release/ (native build)
515+
- target/x86_64-unknown-linux-gnu/release/ (cross-compiled)
516+
517+
Examples:
518+
$0 deploy-binaries --path ./target/release
519+
$0 deploy-binaries --path ./target/x86_64-unknown-linux-gnu/release
520+
$0 deploy-binaries validator-2 # Deploy to single validator (uses auto-detect path)
521+
EOF
522+
exit 0
523+
;;
524+
-*)
525+
log_error "Unknown option: $1"
526+
exit 1
527+
;;
528+
*)
529+
target_validator="$1"
530+
shift
531+
;;
532+
esac
533+
done
534+
535+
load_config
536+
537+
# Auto-detect path if not specified
538+
if [ -z "$binary_path" ]; then
539+
local local_repo
540+
local_repo=$(get_config_value "paths.local_ipc_repo" 2>/dev/null || true)
541+
if [ -z "$local_repo" ] || [ "$local_repo" = "null" ]; then
542+
local_repo=$(cd "${SCRIPT_DIR}/../.." && pwd)
543+
fi
544+
if [ -f "$local_repo/target/release/ipc-cli" ]; then
545+
binary_path="$local_repo/target/release"
546+
elif [ -f "$local_repo/target/x86_64-unknown-linux-gnu/release/ipc-cli" ]; then
547+
binary_path="$local_repo/target/x86_64-unknown-linux-gnu/release"
548+
else
549+
log_error "Binaries not found. Specify --path or run from IPC repo with built binaries."
550+
log_info "Expected: target/release/ or target/x86_64-unknown-linux-gnu/release/"
551+
exit 1
552+
fi
553+
log_info "Using binaries from: $binary_path"
554+
fi
555+
556+
binary_path=$(cd "$binary_path" 2>/dev/null && pwd)
557+
if [ -z "$binary_path" ]; then
558+
log_error "Invalid path"
559+
exit 1
560+
fi
561+
562+
log_header "Deploying Binaries"
563+
deploy_binaries_only "$binary_path" "$target_validator"
564+
}
565+
489566
# Update existing node configs
490567
cmd_update_config() {
491568
log_header "Updating Node Configurations"
@@ -868,7 +945,7 @@ main() {
868945

869946
# Acquire lock for destructive operations
870947
case $command in
871-
init|restart|update-binaries)
948+
init|restart|update-binaries|deploy-binaries)
872949
acquire_lock
873950
;;
874951
esac
@@ -887,6 +964,9 @@ main() {
887964
update-binaries)
888965
cmd_update_binaries "$@"
889966
;;
967+
deploy-binaries)
968+
cmd_deploy_binaries "$@"
969+
;;
890970
check)
891971
cmd_check "$@"
892972
;;

scripts/ipc-subnet-manager/lib/health.sh

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1898,7 +1898,7 @@ build_ipc_locally() {
18981898
return 0
18991899
}
19001900

1901-
# Deploy locally-built binaries to a single validator
1901+
# Deploy binaries to a single validator (used by update-binaries --compile local and deploy-binaries)
19021902
deploy_binaries_to_validator() {
19031903
local validator_idx="$1"
19041904
local binary_dir="$2"
@@ -1929,6 +1929,57 @@ deploy_binaries_to_validator() {
19291929
return 0
19301930
}
19311931

1932+
# Deploy binaries to validators (copy only, no build)
1933+
# Usage: deploy_binaries_only <binary_dir> [validator_name]
1934+
deploy_binaries_only() {
1935+
local binary_dir="$1"
1936+
local target_validator="${2:-}"
1937+
1938+
if [ ! -f "$binary_dir/ipc-cli" ] || [ ! -f "$binary_dir/fendermint" ]; then
1939+
log_error "Binaries not found in $binary_dir (need ipc-cli and fendermint)"
1940+
return 1
1941+
fi
1942+
1943+
if [ -n "$target_validator" ]; then
1944+
local found=false
1945+
for name in "${VALIDATORS[@]}"; do
1946+
[ "$name" = "$target_validator" ] && found=true && break
1947+
done
1948+
if [ "$found" != true ]; then
1949+
log_error "Unknown validator: $target_validator"
1950+
log_info "Valid: ${VALIDATORS[*]}"
1951+
return 1
1952+
fi
1953+
fi
1954+
1955+
local all_success=true
1956+
local deployed=0
1957+
for idx in "${!VALIDATORS[@]}"; do
1958+
local name="${VALIDATORS[$idx]}"
1959+
if [ -n "$target_validator" ] && [ "$name" != "$target_validator" ]; then
1960+
continue
1961+
fi
1962+
deployed=1
1963+
if ! deploy_binaries_to_validator "$idx" "$binary_dir"; then
1964+
all_success=false
1965+
fi
1966+
done
1967+
1968+
if [ "$deployed" -eq 0 ]; then
1969+
log_error "No validators matched"
1970+
return 1
1971+
fi
1972+
1973+
if [ "$all_success" = true ]; then
1974+
log_success "✓ All binaries deployed successfully"
1975+
log_info "You may need to restart nodes: $0 restart"
1976+
return 0
1977+
else
1978+
log_error "✗ Some validators failed to receive binaries"
1979+
return 1
1980+
fi
1981+
}
1982+
19321983
# Update binaries on all validators
19331984
update_all_binaries() {
19341985
local branch="${1:-main}"

0 commit comments

Comments
 (0)