Repository navigation
feat(server): add read-only Soroban RPC ledger adapter - #86
Conversation
TOMOKI977
left a comment
There was a problem hiding this comment.
Buen adapter: los lectores de sc_val_json.dart fallan de forma explícita con LedgerUnavailable y la cobertura de casos de error es sólida. Dejo algunos ajustes antes de mergear:
StellarConfig(stellar_config.dart:41-56) usa valores de testnet cuando falta una variablePULS3_STELLAR_*. Un deploy a otra red con una variable olvidada verificaría pagos contra contratos de testnet sin ningún error. Sugiero fallar al iniciar (o al menos loguear la red activa) cuando falten variables fuera de desarrollo.networkPassphrasese lee pero nunca se usa. UngetNetworkal arrancar permitiría confirmar que el RPC sirve la red esperada.SorobanRpcClientno tiene reintentos ni backoff, y_resultdescarta el código y mensaje del error JSON-RPC. Con rate limiting del RPC público, el catálogo completo falla por una sola llamada (eagerError: true). Con un reintento simple para 429/5xx y conservar el error para los logs alcanza.- El criterio "las lecturas funcionan contra los contratos de testnet" solo está cubierto con fixtures. Un smoke test opcional (con tag) contra testnet cerraría ese criterio.
Nota general del stack: como este PR apunta a la rama de #84 y no a main, el CI nunca corrió aquí (#86 a #93). Conviene ir re-apuntando cada PR a main cuando se mergee el anterior, para que pasen gate y scan.
TOMOKI977
left a comment
There was a problem hiding this comment.
Approving. The adapter is solid and the failure-path coverage is good. None of the points from my earlier review block the Stellar Elite demo on testnet, so they can land as follow-ups:
StellarConfigsilently falls back to testnet values when aPULS3_STELLAR_*variable is missing. Before any non-testnet deploy, fail at startup instead, or at least log the active network.networkPassphraseis parsed but never used. AgetNetworkcheck at startup would confirm the RPC serves the expected network.SorobanRpcClienthas no retry or backoff, and_resultdrops the JSON-RPC error code and message. A simple retry on 429/5xx would make the catalog build more resilient on the public RPC.
Merge note: this PR targets the #84 branch, so CI hasn't run here yet. Once #84 merges, retarget this to main and let gate and scan pass before merging.
Closes #85
Stacked on #84 (base is that PR's branch; retarget to
mainafter #84 merges).Summary
Adds a read-only Soroban RPC adapter in
puls3_server/lib/src/ledger/that implements the domainLedgerPort(agentWallet,findPayment) and exposes registry reads (agentExists,agentUri) and the escrowget_jobread. It talks plain JSON-RPC over an injectedhttp.Client, builds unsigned invoke envelopes with a small in-repo XDR encoder, and decodesxdrFormat: "json"results. No signing, no broadcast, and it is not wired intoserver.dartyet.Acceptance criteria
simulateTransaction,getTransaction) implementingLedgerPort.get_jobagainst the deployed testnet contracts (recorded as fixtures).PULS3_STELLAR_*env vars with a testnet default, plus a drift test againstcontracts/deployments/testnet.json(contract ids).server.dart.Verification evidence
stellar contract invoke --send=no --build-only.simulateTransactionofagent_exists(7)returns{"bool":true}andgetTransactionfor the direct payment652a575b…31abreturns SUCCESS with the expected transfer event (to_muxed_id8, amount 5000000).Notes for reviewers
size:exception; the adapter is one self-contained unit and the commits are ordered for review.transfertopic, and the muxed id and amount ranges. Comparing wallet, amount and hire id against the hire happens in the domain (Payment.settles).LedgerUnavailableis thrown on transport/RPC errors and archived state;NOT_FOUNDreturnsnull. The RPC keeps transactions for about 7 days, so the hire flow must persist the verifiedPayment.pubspec.lockis untouched (httpis already locked transitively). A local Dart older than the lock's SDK rewrites it, so revert it before committing.