Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions dsm_client/frontend/public/dsm_env_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,23 @@ mempool_api_url = "https://mempool.space"
# Path is relative to this config file's directory (resolved by SDK).
custom_ca_certs = ["ca.crt"]

# `name` IS THE MEMBER ID OF THE CANONICAL STORAGE SET, not a label. It is
# hashed (sorted, length-prefixed) into the storage_set_id a vault is born
# under, and it is what an acceptance is counted against: a member only counts
# toward quorum when the node echoes this exact string back as x-dsm-node-id.
#
# So each name MUST equal that node's own `[node] id`, which is also the CN of
# the TLS certificate it serves. A name that merely describes the node
# ("us-west-1a-1") makes the client compute a set id no node belongs to: every
# settlement-slot claim is refused as a foreign set.
[[nodes]]
name = "us-west-1a-1"
name = "dsm-node-1"
endpoint = "https://47.251.246.93:8080"

[[nodes]]
name = "us-west-1a-2"
name = "dsm-node-2"
endpoint = "https://47.251.250.159:8080"

[[nodes]]
name = "us-west-1a-3"
name = "dsm-node-3"
endpoint = "https://47.251.88.58:8080"
50 changes: 27 additions & 23 deletions scripts/push_env_override.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,24 @@ EOF
}

# --- Gather devices ---
serials=( $(adb devices | awk '/\tdevice$/{print $1}') )
if [[ ${#serials[@]} -eq 0 ]]; then
# Address devices by transport id, not serial: wireless (mDNS) serials contain
# spaces ("adb-XXXX-yyyy (2)._adb-tls-connect._tcp"), which word-splitting
# truncates into a serial `adb -s` cannot resolve. Transport ids are plain
# integers and unambiguous.
transports=( $(adb devices -l | awk '/ device /{for(i=1;i<=NF;i++) if($i ~ /^transport_id:/){sub("transport_id:","",$i); print $i}}') )
if [[ ${#transports[@]} -eq 0 ]]; then
echo "No connected adb devices in device state."
adb devices -l
exit 2
fi

echo "Detected devices: $serials"
echo "Detected device transports: $transports"

for d in $serials; do
echo "=== Processing $d ==="
for d in $transports; do
echo "=== Processing transport $d ==="

# Ensure app-private files dir exists
adb -s "$d" shell run-as "$APP_PKG" mkdir -p files || true
adb -t "$d" shell run-as "$APP_PKG" mkdir -p files || true

if [[ "$MODE" == "aws" || "$MODE" == "gcp" || "$MODE" == "alibaba" ]]; then
# --- Remote mode (AWS / GCP / Alibaba) ---
Expand All @@ -135,32 +139,32 @@ for d in $serials; do
# launch (FileOutputStream ... false), so a push there is clobbered. The override
# (dsm_env_config.override.toml) is checked first and wins.
echo "Pushing $MODE storage node config to $d (developer override)..."
adb -s "$d" push "$REMOTE_CONFIG" /data/local/tmp/dsm_env_config.override.toml
adb -s "$d" shell run-as "$APP_PKG" cp /data/local/tmp/dsm_env_config.override.toml files/dsm_env_config.override.toml
adb -t "$d" push "$REMOTE_CONFIG" /data/local/tmp/dsm_env_config.override.toml
adb -t "$d" shell run-as "$APP_PKG" cp /data/local/tmp/dsm_env_config.override.toml files/dsm_env_config.override.toml

echo "Pushing CA cert to $d..."
adb -s "$d" push "$CA_CERT" /data/local/tmp/ca.crt
adb -s "$d" shell run-as "$APP_PKG" cp /data/local/tmp/ca.crt files/ca.crt
adb -t "$d" push "$CA_CERT" /data/local/tmp/ca.crt
adb -t "$d" shell run-as "$APP_PKG" cp /data/local/tmp/ca.crt files/ca.crt

# Remove any stale adb reverse ports (not needed for remote)
for p in $PORTS 18443; do
adb -s "$d" reverse --remove tcp:$p 2>/dev/null || true
adb -t "$d" reverse --remove tcp:$p 2>/dev/null || true
done

echo "Config: $MODE storage nodes (HTTPS + custom CA, via override file)"
adb -s "$d" shell run-as "$APP_PKG" ls -l files/dsm_env_config.override.toml files/ca.crt
adb -t "$d" shell run-as "$APP_PKG" ls -l files/dsm_env_config.override.toml files/ca.crt

else
# --- Local mode ---
is_emulator=$(adb -s "$d" shell getprop ro.kernel.qemu | tr -d '\r' | tr -d '\n')
is_emulator=$(adb -t "$d" shell getprop ro.kernel.qemu | tr -d '\r' | tr -d '\n')
if [[ "$is_emulator" == "1" ]]; then
host="10.0.2.2"
echo "Device $d identified as emulator (ro.kernel.qemu=1). Using host=$host"
else
host="127.0.0.1"
echo "Device $d identified as physical. Using host=$host and setting reverse ports"
for p in $PORTS 18443; do
adb -s "$d" reverse tcp:$p tcp:$p || echo "reverse failed for $d:$p"
adb -t "$d" reverse tcp:$p tcp:$p || echo "reverse failed for $d:$p"
done
fi

Expand All @@ -171,31 +175,31 @@ for d in $serials; do
make_env_toml "$host" > "$tmpfile"
echo "Generated local dev config:"; head -10 "$tmpfile"

adb -s "$d" push "$tmpfile" /data/local/tmp/dsm_env_config.toml
adb -s "$d" shell run-as "$APP_PKG" cp /data/local/tmp/dsm_env_config.toml files/dsm_env_config.toml
adb -s "$d" shell run-as "$APP_PKG" ls -l files/dsm_env_config.toml
adb -t "$d" push "$tmpfile" /data/local/tmp/dsm_env_config.toml
adb -t "$d" shell run-as "$APP_PKG" cp /data/local/tmp/dsm_env_config.toml files/dsm_env_config.toml
adb -t "$d" shell run-as "$APP_PKG" ls -l files/dsm_env_config.toml
rm -f "$tmpfile"

echo "Config: 5 local dev nodes (HTTP via adb reverse)"
fi

# Uninstall/install APK if not present
pm_out=$(adb -s "$d" shell pm list packages | grep -c "$APP_PKG" || true)
pm_out=$(adb -t "$d" shell pm list packages | grep -c "$APP_PKG" || true)
if [[ "$pm_out" == "0" ]]; then
echo "App not installed on $d; installing APK..."
adb -s "$d" install -r "$APK_PATH" || echo "Install failed; continuing"
adb -t "$d" install -r "$APK_PATH" || echo "Install failed; continuing"
fi

echo "Restarting app on $d..."
adb -s "$d" shell am force-stop "$APP_PKG" || true
adb -s "$d" shell am start -n "$APP_PKG"/.ui.MainActivity || echo "Failed to start on $d"
adb -t "$d" shell am force-stop "$APP_PKG" || true
adb -t "$d" shell am start -n "$APP_PKG"/.ui.MainActivity || echo "Failed to start on $d"

echo "Verifying startup logs for $d..."
sleep 2
if [[ "$MODE" == "aws" || "$MODE" == "gcp" || "$MODE" == "alibaba" ]]; then
adb -s "$d" logcat -d | grep -iE "(storage node|ca cert|6 storage|appState changed to: wallet_ready)" | tail -15 || true
adb -t "$d" logcat -d | grep -iE "(storage node|ca cert|6 storage|appState changed to: wallet_ready)" | tail -15 || true
else
adb -s "$d" logcat -d | grep -E "(Using 5 storage nodes|appState changed to: wallet_ready|Genesis.*published)" | tail -15 || true
adb -t "$d" logcat -d | grep -E "(Using 5 storage nodes|appState changed to: wallet_ready|Genesis.*published)" | tail -15 || true
fi
echo "=== Done $d ==="
echo
Expand Down
Loading