Skip to content

Commit 49b5918

Browse files
committed
feat: enable subnet deployment and activation in configuration
- Updated `ipc-subnet-config.yml` to set `deploy_subnet` and `activate_subnet` to true, allowing for automatic deployment and activation of subnet and gateway contracts during initialization. - Added preflight checks in `health.sh` to ensure necessary dependencies and binaries are available before starting storage services, improving robustness and user guidance for setup.
1 parent 9085661 commit 49b5918

2 files changed

Lines changed: 60 additions & 2 deletions

File tree

scripts/ipc-subnet-manager/ipc-subnet-config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ paths:
6464
# Initialization Settings
6565
init:
6666
# Deploy new subnet and gateway contracts (set true for fresh deployment)
67-
deploy_subnet: false
68-
activate_subnet: false
67+
deploy_subnet: true
68+
activate_subnet: true
6969
# node-topdown-mode passed to `ipc-cli subnet init` (legacy | f3 | auto)
7070
node_topdown_mode: "legacy"
7171
# Supply source (native or ERC20)

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

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,60 @@ storage_should_run_on_validator() {
227227
[ "$run_on" = "$validator_name" ]
228228
}
229229

230+
storage_preflight_checks() {
231+
local validator_idx="$1"
232+
local validator_name="$2"
233+
local eth_api_port="$3"
234+
local storage_node_bin="$4"
235+
local storage_gateway_bin="$5"
236+
local storage_actor_addr="0xff00000000000000000000000000000000000042"
237+
238+
if ! exec_on_host_simple "$validator_idx" "command -v yq >/dev/null 2>&1"; then
239+
log_error "$validator_name: missing required dependency 'yq'"
240+
log_info "Install it on $validator_name and retry:"
241+
log_info " sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 && sudo chmod +x /usr/local/bin/yq"
242+
return 1
243+
fi
244+
245+
if ! exec_on_host_simple "$validator_idx" "[ -x $storage_node_bin ]"; then
246+
log_error "$validator_name: storage node binary not found/executable: $storage_node_bin"
247+
log_info "Build and deploy storage binaries, then retry start-storage."
248+
return 1
249+
fi
250+
251+
if ! exec_on_host_simple "$validator_idx" "[ -x $storage_gateway_bin ]"; then
252+
log_error "$validator_name: storage gateway binary not found/executable: $storage_gateway_bin"
253+
log_info "Build and deploy storage binaries, then retry start-storage."
254+
return 1
255+
fi
256+
257+
local actor_probe
258+
actor_probe=$(exec_on_host "$validator_idx" \
259+
"resp=\$(curl -sS --max-time 8 -H 'Content-Type: application/json' --data '{\"jsonrpc\":\"2.0\",\"method\":\"eth_getCode\",\"params\":[\"$storage_actor_addr\",\"latest\"],\"id\":1}' http://127.0.0.1:$eth_api_port 2>/dev/null || true); \
260+
if echo \"\$resp\" | grep -q '\"result\":\"0x\"'; then echo MISSING; \
261+
elif echo \"\$resp\" | grep -q '\"result\":\"0x0\"'; then echo MISSING; \
262+
elif echo \"\$resp\" | grep -q '\"result\":\"0x'; then echo OK; \
263+
else echo UNKNOWN; fi")
264+
265+
if echo "$actor_probe" | grep -q "MISSING"; then
266+
log_error "$validator_name: storage actor (ID 66 / $storage_actor_addr) is not deployed on this subnet"
267+
log_info "Preflight failed to avoid starting storage against a chain without storage actors."
268+
log_info "Next steps:"
269+
log_info " 1) Keep init.deploy_subnet=true and init.activate_subnet=true in ipc-subnet-config.yml"
270+
log_info " 2) Re-run: ./ipc-manager init --yes"
271+
log_info " 3) After init succeeds, run: ./ipc-manager start-storage --register-operator --yes"
272+
return 1
273+
fi
274+
275+
if echo "$actor_probe" | grep -q "UNKNOWN"; then
276+
log_error "$validator_name: unable to verify storage actor deployment via http://127.0.0.1:$eth_api_port"
277+
log_info "Ensure the subnet node is up and the eth RPC endpoint is reachable, then retry."
278+
return 1
279+
fi
280+
281+
return 0
282+
}
283+
230284
start_storage_services() {
231285
local register_operator="${1:-false}"
232286
local started=0
@@ -280,6 +334,10 @@ start_storage_services() {
280334
local storage_node_bin="$ipc_repo/target/release/node"
281335
local storage_gateway_bin="$ipc_repo/target/release/gateway"
282336

337+
if ! storage_preflight_checks "$idx" "$name" "$eth_api_port" "$storage_node_bin" "$storage_gateway_bin"; then
338+
continue
339+
fi
340+
283341
exec_on_host_simple "$idx" "yq eval \".\\\"objects-listen-addr\\\" = \\\"$objects_listen_addr\\\"\" -i $storage_cfg_path"
284342
exec_on_host_simple "$idx" "yq eval \".\\\"node-rpc-bind-addr\\\" = \\\"$node_rpc_bind_addr\\\"\" -i $storage_cfg_path"
285343
exec_on_host_simple "$idx" "yq eval \".\\\"operator-rpc-url\\\" = \\\"$operator_rpc_url\\\"\" -i $storage_cfg_path"

0 commit comments

Comments
 (0)