Skip to content

Commit abf8ebe

Browse files
committed
feat: F9 on-testnet use-case demo — alerter watches a REAL on-chain state change (genesis funding tx on the hosted testnet) and notifies the owner over Logos Messaging; vault round-trip by the same testnet-funded agent; marketplace via the F8 integrated trace. Closes the 'use cases on LEZ testnet' gap
1 parent bc6a760 commit abf8ebe

1 file changed

Lines changed: 140 additions & 0 deletions

File tree

tests/demo-usecases-testnet.sh

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/usr/bin/env bash
2+
# tests/demo-usecases-testnet.sh — F9: illustrative use cases E2E with the agent DEPLOYED ON
3+
# THE LIVE HOSTED TESTNET (v0.2.0), RISC0_DEV_MODE=0.
4+
#
5+
# UC1 On-chain event alerter — the agent watches ITS OWN LEZ account on the hosted
6+
# testnet; the genesis funding tx (a real proof, getTransaction-confirmable) is the
7+
# on-chain state change; the agent notifies its owner over Logos Messaging.
8+
# UC2 Personal file vault — the SAME testnet-funded agent stores a document on Logos
9+
# Storage and retrieves it byte-exact by content address (storage is the Codex
10+
# network; the agent performing it is the testnet-deployed one).
11+
# UC3 Paid skill marketplace — see tests/demo-f8-testnet.sh (two agents, Waku discovery,
12+
# A2A task, gate hold, autonomous spend — F8_INTEGRATED_PASS on the live testnet).
13+
#
14+
# Env: LOGOSCORE_BIN, LEZ_BUILD, MODULES_DIR — same knobs as tests/demo-testnet.sh.
15+
set -u
16+
17+
HERE="$(cd "$(dirname "$0")" && pwd)"
18+
_first(){ for x in "$@"; do [ -e "$x" ] && { echo "$x"; return; }; done; }
19+
LOGOSCORE="${LOGOSCORE_BIN:-logoscore}"
20+
LEZ_BUILD="${LEZ_BUILD:-$(_first "$HERE/../logos-execution-zone" "$HOME/logos-execution-zone")}"
21+
MODULES_DIR="${MODULES_DIR:-$(_first "$HERE/../runtime-modules" "$HERE/../modules")}"
22+
WALLET="${LEZ_WALLET:-$LEZ_BUILD/target/release/wallet}"
23+
TESTNET="${TESTNET:-https://testnet.lez.logos.co/}"
24+
GEN="Public/6iArKUXxhUJqS7kCaPNhwMWt3ro71PDyBj7jwAyE2VQV"
25+
GENHEX="10a26a9aec7d34b82364eeae45c5294dbb0a764b000b94eeb9b58511dc487c4d"
26+
PW="${WALLET_PASSPHRASE:-demo-pass}"
27+
FUND_HOME="$(mktemp -d /tmp/lp0008-uc-fund.XXXXXX)"
28+
29+
G='\033[1;32m'; C='\033[1;36m'; D='\033[2m'; R='\033[1;31m'; N='\033[0m'
30+
say(){ printf "${C}| %s${N}\n" "$1"; }
31+
ok(){ printf "${G} ok %s${N}\n" "$1"; }
32+
die(){ printf "${R}x %s${N}\n" "$1" >&2; pkill -9 -f "logoscore -D" 2>/dev/null; exit 1; }
33+
34+
command -v "$LOGOSCORE" >/dev/null 2>&1 || [ -x "$LOGOSCORE" ] || die "logoscore not found"
35+
[ -x "$WALLET" ] || die "wallet not found at $WALLET"
36+
[ -d "$MODULES_DIR" ] || die "modules dir not found at $MODULES_DIR"
37+
38+
say "testnet reachable?"
39+
BLK=$(curl -s -m 15 -X POST "$TESTNET" -H 'content-type: application/json' \
40+
-d '{"jsonrpc":"2.0","method":"getLastBlockId","params":[],"id":1}' | grep -o '"result":[0-9]*' | grep -o '[0-9]*')
41+
[ -n "$BLK" ] || die "cannot reach $TESTNET"
42+
ok "live hosted testnet, block $BLK"
43+
44+
pkill -9 -f "logoscore -D" 2>/dev/null; sleep 2; rm -rf "$HOME/.logoscore" ~/uc-storage-data ~/uc-vault-out.txt
45+
46+
say "deploy the agent wired to the LIVE testnet (same boot as the primary demo)"
47+
RISC0_DEV_MODE=0 "$LOGOSCORE" -D -m "$MODULES_DIR" >/tmp/lp0008-uc-daemon.log 2>&1 & disown
48+
LOADED=""
49+
for i in $(seq 1 12); do
50+
sleep 8
51+
for m in storage_module lez_wallet_module agent_module; do "$LOGOSCORE" load-module "$m" >/dev/null 2>&1; done
52+
sleep 3
53+
LOADED=$("$LOGOSCORE" status 2>/dev/null | python3 -c "import sys,json;d=json.load(sys.stdin)['modules_summary'];print(d['loaded'],d['crashed'])" 2>/dev/null)
54+
echo "$LOADED" | grep -qE "^[3-9] 0$" && break
55+
done
56+
echo "$LOADED" | grep -qE "^[3-9] 0$" || die "modules did not load cleanly: $LOADED"
57+
ok "modules loaded (loaded crashed): $LOADED"
58+
59+
"$LOGOSCORE" call lez_wallet_module ensure_account >/dev/null 2>&1; sleep 2
60+
CFG=$(find "$HOME/.logoscore/data/lez_wallet_module" -name wallet_config.json | head -1)
61+
[ -n "$CFG" ] || die "module wallet config not created"
62+
echo "{\"sequencer_addr\":\"$TESTNET\",\"seq_poll_timeout\":\"60s\",\"seq_tx_poll_max_blocks\":80,\"seq_poll_max_retries\":40,\"seq_block_poll_max_amount\":200}" > "$CFG"
63+
pkill -9 -f "logoscore -D" 2>/dev/null; sleep 3
64+
RISC0_DEV_MODE=0 "$LOGOSCORE" -D -m "$MODULES_DIR" >/tmp/lp0008-uc-daemon2.log 2>&1 & disown
65+
for i in $(seq 1 12); do
66+
sleep 8
67+
for m in storage_module lez_wallet_module agent_module; do "$LOGOSCORE" load-module "$m" >/dev/null 2>&1; done
68+
sleep 3
69+
"$LOGOSCORE" status 2>/dev/null | python3 -c "import sys,json;d=json.load(sys.stdin)['modules_summary'];exit(0 if d['loaded']>=3 and d['crashed']==0 else 1)" 2>/dev/null && break
70+
done
71+
"$LOGOSCORE" call lez_wallet_module ensure_account >/dev/null 2>&1; sleep 2
72+
read -r ANPK AVPK < <("$LOGOSCORE" call agent_module agent_card 2>&1 | python3 -c "import sys,json
73+
d=json.load(sys.stdin); r=json.loads(d['result'])['result']; i=r.get('x-lez-identity',{})
74+
print(i.get('npk',''), i.get('vpk',''))")
75+
{ [ -n "$ANPK" ] && [ ${#AVPK} -gt 2000 ]; } || die "agent card did not expose npk + ML-KEM vpk"
76+
ok "agent identity on the testnet: npk ${ANPK:0:16}"
77+
78+
# owner identity for the alert leg (a chain-valid account, per the hard-won recipient rule)
79+
OWNERNPK=$(printf "%s\n%s\n" "$PW" "$PW" | LEE_WALLET_HOME_DIR="$(mktemp -d /tmp/lp0008-uc-owner.XXXXXX)" "$WALLET" account new private -l owner 2>&1 | grep -oE 'npk [0-9a-f]{64}' | awk '{print $2}')
80+
[ -n "$OWNERNPK" ] || die "owner account creation failed"
81+
"$LOGOSCORE" call agent_module meta_configure owner_address "$OWNERNPK" >/dev/null 2>&1
82+
83+
printf "\n${C}=== UC1 · on-chain event alerter — watch a LEZ account on the LIVE testnet ===${N}\n"
84+
BAL0=$("$LOGOSCORE" call lez_wallet_module balance 2>/dev/null | grep -oE '"result":"[0-9]+"' | grep -oE '[0-9]+' | head -1)
85+
say "alerter armed: the agent's watch loop reads its on-chain balance: ${BAL0:-0}"
86+
87+
say "an on-chain event happens: genesis funds the agent 100 LEZ (real RISC0 proof, watch the prover)"
88+
echo "$(printf '{"sequencer_addr":"%s","seq_poll_timeout":"60s","seq_tx_poll_max_blocks":80,"seq_poll_max_retries":40,"seq_block_poll_max_amount":200}' "$TESTNET")" > "$FUND_HOME/wallet_config.json"
89+
export LEE_WALLET_HOME_DIR="$FUND_HOME"
90+
printf "%s\n" "$PW" | "$WALLET" config get >/dev/null 2>&1
91+
printf "%s\n" "$PW" | "$WALLET" account import public --private-key "$GENHEX" >/dev/null 2>&1
92+
printf "%s\n" "$PW" | RISC0_DEV_MODE=0 RISC0_INFO=1 RUST_LOG=info,risc0_zkvm=info NO_COLOR=1 RUST_LOG_STYLE=never \
93+
"$WALLET" auth-transfer send --from "$GEN" --to-npk "$ANPK" --to-vpk "$AVPK" --amount 100 2>&1 | tee /tmp/lp0008-uc-fund.log | \
94+
grep --line-buffered -E "risc0_zkvm|segments|cycles|[Hh]ash is" | sed -u 's/^.*risc0_zkvm[^ ]* *//'
95+
TX=$(grep -oiE "hash is [0-9a-f]{64}" /tmp/lp0008-uc-fund.log | awk '{print $3}' | head -1)
96+
[ -n "$TX" ] || die "funding transfer did not return a tx hash"
97+
ok "on-chain event: funding tx $TX"
98+
99+
say "the agent's watch loop detects the state change (polling its balance through its own module)"
100+
NBAL=""
101+
for i in $(seq 1 60); do
102+
"$LOGOSCORE" call lez_wallet_module sync_private >/dev/null 2>&1
103+
NBAL=$("$LOGOSCORE" call lez_wallet_module balance 2>/dev/null | grep -oE '"result":"[0-9]+"' | grep -oE '[0-9]+' | head -1)
104+
[ -n "$NBAL" ] && [ "$NBAL" != "${BAL0:-0}" ] && break
105+
sleep 6
106+
done
107+
[ -n "$NBAL" ] && [ "$NBAL" != "${BAL0:-0}" ] || die "watch loop did not observe the state change"
108+
ok "state change observed on the LIVE testnet: balance ${BAL0:-0} -> $NBAL"
109+
110+
say "the agent alerts its owner over Logos Messaging"
111+
ALERT=$("$LOGOSCORE" call agent_module messaging_send "$OWNERNPK" "alert: LEZ account state change ${BAL0:-0} -> $NBAL (tx $TX, testnet block $BLK+)" 2>/dev/null | tail -1)
112+
echo "$ALERT" | grep -q '"status":"ok"' || die "owner alert failed: $ALERT"
113+
ok "UC1 complete: LEZ state watched on the hosted testnet, owner notified via Logos Messaging"
114+
115+
printf "\n${C}=== UC2 · personal file vault — by the SAME testnet-funded agent ===${N}\n"
116+
say "the agent runs an embedded Logos Storage node (content layer: Codex; the agent lives on the testnet)"
117+
"$LOGOSCORE" call storage_module init "{\"data-dir\":\"$HOME/uc-storage-data\",\"log-level\":\"INFO\",\"log-file\":\"$HOME/uc-storage-data/s.log\"}" >/dev/null 2>&1
118+
"$LOGOSCORE" call storage_module start >/dev/null 2>&1; sleep 12
119+
echo "owner's private note: recovery phrase + deed scan. $(date -u)" > ~/uc-vault-file.txt
120+
say "the owner hands the agent a file; the agent stores it and returns a content address"
121+
"$LOGOSCORE" call agent_module storage_upload "$HOME/uc-vault-file.txt" "owner-note" >/dev/null 2>&1
122+
sleep 3
123+
VCID=$("$LOGOSCORE" call agent_module storage_list 2>/dev/null | grep -oE 'zDv[A-Za-z0-9]+' | head -1)
124+
[ -n "$VCID" ] || die "vault upload returned no content address"
125+
ok "stored at content address: $VCID"
126+
say "retrieve by content address and byte-compare"
127+
"$LOGOSCORE" call agent_module storage_download "$VCID" "$HOME/uc-vault-out.txt" >/dev/null 2>&1; sleep 4
128+
cmp -s ~/uc-vault-file.txt ~/uc-vault-out.txt || die "retrieved bytes differ"
129+
ok "UC2 complete: byte-exact vault round-trip by the testnet-deployed agent"
130+
131+
printf "\n${C}=== UC3 · paid skill marketplace — see tests/demo-f8-testnet.sh ===${N}\n"
132+
say "two agents, Waku discovery, A2A task, gate hold, autonomous spend — F8_INTEGRATED_PASS on this same testnet"
133+
134+
printf "\n${G}PASS — F9: three illustrative use cases with the agent deployed on the LIVE v0.2.0 testnet:${N}\n"
135+
printf "${G} UC1 on-chain event alerter (state change = real funding tx %s, owner notified)${N}\n" "${TX:0:12}"
136+
printf "${G} UC2 personal file vault (CID %s, byte-exact)${N}\n" "$VCID"
137+
printf "${G} UC3 paid skill marketplace (demo-f8-testnet.sh, integrated pass)${N}\n"
138+
printf "${D} all proofs real: RISC0_DEV_MODE=0 · funding tx getTransaction-confirmable on %s${N}\n" "$TESTNET"
139+
pkill -9 -f "logoscore -D" 2>/dev/null
140+
exit 0

0 commit comments

Comments
 (0)