Skip to content

improve(server): replace Node sidecar with native Rust SDKs (ENG-1700)#134

Open
harrymove-ctrl wants to merge 4 commits intodevfrom
improve/ENG-1700-rust-walrus-seal
Open

improve(server): replace Node sidecar with native Rust SDKs (ENG-1700)#134
harrymove-ctrl wants to merge 4 commits intodevfrom
improve/ENG-1700-rust-walrus-seal

Conversation

@harrymove-ctrl
Copy link
Copy Markdown
Collaborator

Summary

  • Drops the Node.js sidecar (services/server/scripts/) the Rust server spawned at boot. SEAL / Walrus / Enoki now run in-process via Mysten Rust SDKs + thin reqwest clients.
  • Pure 1:1 behavioral migration. Same env contract (minus SIDECAR_*), same routes, same wire formats. Scope confirmed with @henry.nguyen on Linear.
  • Smaller deploy: single-stage Dockerfile, no Node runtime, no npm ci, faster boot (no 30s sidecar health-check loop)

Linear: ENG-1700

What's gone

  • services/server/scripts/sidecar-server.ts (1039 LOC) and the rest of scripts/.
  • SIDECAR_URL, SIDECAR_AUTH_TOKEN, SIDECAR_SCRIPTS_DIR config + spawn/health-check/shutdown plumbing in main.rs.
  • Node layer in the Docker image; Setup Node + Install sidecar deps steps in CI.
  • Dead apps/app/src/config.ts:sidecarUrl field (was never read by the FE).

What's new (Rust modules)

Module Purpose Replaces
seal.rs (rewritten) Native SEAL encrypt/decrypt/decrypt-batch via seal-sdk sidecar /seal/*
seal_keyserver.rs reqwest client for /v1/fetch_key + on-chain key-server resolution @mysten/seal SealClient HTTP layer
enoki.rs reqwest client for https://api.enoki.mystenlabs.com sidecar /sponsor + /sponsor/execute
walrus_publisher.rs PUT /v1/blobs?epochs=N&send_object_to=… @mysten/walrus upload step
walrus_onchain.rs metadata + transfer PTB (Enoki-sponsored or direct-signed) sidecar Walrus on-chain step

walrus.rs orchestrates the publisher + on-chain pieces; seal.rs / walrus.rs keep the same public function signatures so routes/main don't need ripple edits.

Security

Concern Status
Secret leakage in logs (API keys, private keys, signatures, session envelopes) Clean — audit shows zero tracing!() interpolation of secret material
ENOKI_API_KEY Bearer OK — only in Authorization header, never logged
/sponsor + /sponsor/execute rate limit + signature length validation Preserved unchanged
Upstream Enoki error body forwarded to client Masked via EnokiError::to_status() — generic strings only ("Sponsor service temporarily overloaded", "Sponsor request rejected"); full detail to server log
PTB privilege OK — seal_approve accepts only Input::Shared immutable for MemWalAccount; id bound to caller's owner address
Walrus publisher errors Mapped via map_publisher_errorAppError::Internal with deterministic generic message
seal_keyserver Request-Id (replay) Random uuid::Uuid::new_v4() per request

Test plan

  • cargo test --bin memwal-server — 164 passed, 1 #[ignore] (live testnet regression for Shared-input bug).
  • cargo clippy — no new warnings in migration files.
  • Playground happy path on testnet: remember (Step 2) → recall (Step 3) → add-delegate-key.
  • Verified Sponsored by 0x… field on suiscan for server-paid metadata+transfer txns.
  • Recall returns decrypted results (dropped_count: 0) — both x-seal-session and x-delegate-key paths.

hien-p added 2 commits May 5, 2026 22:20
benchmark-smoke.yml and benchmark-live.yml drove the now-deleted
services/server/scripts/bench-recall-latency.ts. Both fail at
actions/setup-node because services/server/scripts/package-lock.json
no longer exists.

The benchmark target itself is gone with the sidecar; restore in a
follow-up ticket once a Rust-native benchmark driver lands.

docs/relayer/benchmark-ci-setup.md still references these files but is
out of scope to rewrite here — flagged for the follow-up.
@ducnmm
Copy link
Copy Markdown
Collaborator

ducnmm commented May 6, 2026

Hi @harrymove-ctrl https://publisher.walrus-mainnet.walrus.space we are using upload relay to upload, your method will not work when on mainnet

hien-p added 2 commits May 6, 2026 11:01
Match the legacy Node sidecar's env contract (`sidecar-server.ts:65-69`)
so Railway's dev/staging/mainnet env values keep working without rename:

- Read `WALRUS_UPLOAD_RELAY_URL` (was: `WALRUS_PUBLISHER_URL`, a name we
  invented and that no env actually sets).
- Per-network defaults: `upload-relay.{testnet,mainnet}.walrus.space`.
- Same per-network Sui RPC fallback factored into one helper.

Known gap (ENG-1700 follow-up): the default `upload-relay.*` endpoint
speaks the multi-step register/upload/certify relay protocol used by
@mysten/walrus, while `walrus_publisher.rs` currently only speaks the
simpler `PUT /v1/blobs` public-publisher protocol. Until the relay
protocol is ported (Path A), `WALRUS_UPLOAD_RELAY_URL` must be set to a
`publisher.walrus-{net}.walrus.space` endpoint. Inline doc + helper
explain.
…k fallback (ENG-1700)

Reverts the env-name change from 33422e7. Railway sets `WALRUS_PUBLISHER_URL`
across dev/staging/mainnet (verified against the production Raw Editor):
e.g. `WALRUS_PUBLISHER_URL=https://publisher.walrus-mainnet.walrus.space`
on production. The previous commit renamed the read to
`WALRUS_UPLOAD_RELAY_URL` (sidecar's internal var name, NOT what Railway
exports), which made the server fall back to the per-network upload-relay
default — an endpoint that doesn't accept `PUT /v1/blobs` and returned 404
on every upload.

Also drops the speculative testnet/mainnet branching default added in
33422e7. The single-line read with one fallback (matching the original
pre-33422e7 code) is enough — Railway always sets the env var.
@ducnmm
Copy link
Copy Markdown
Collaborator

ducnmm commented May 6, 2026

Hi @harrymove-ctrl still use publisher

2026-05-06T06:22:24.088558Z ERROR memwal_server::types: Internal server error: Walrus publisher: publisher network error: error sending request for url (https://publisher.walrus-mainnet.walrus.space/v1/blobs?epochs=5&send_object_to=0x800ff2ea234bcab45e42f20bed8d539cc4c9bbf2da4a468ee29bc8d58a325942) trace_id=e37c62d0-575b-4d0e-9e8f-12d4fb8a0004

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants