Skip to content

bridgevm: close daemon-discovery RPC gap (info/supportedChains/chainConfig/signature)#5

Merged
hanzo-dev merged 1 commit into
mainfrom
feat/bridgevm-canonical
May 31, 2026
Merged

bridgevm: close daemon-discovery RPC gap (info/supportedChains/chainConfig/signature)#5
hanzo-dev merged 1 commit into
mainfrom
feat/bridgevm-canonical

Conversation

@hanzo-dev
Copy link
Copy Markdown
Member

Summary

  • Adds 4 read-only methods to BridgeVM RPC so the luxfi/bridge daemon's bchain client stops needing assumed/cached values for discovery + signature lookups.
  • All settlement decisions already live on B-Chain (quote engine + swap store landed in bridgevm: promote quote engine + swap store from cmd/bridge daemon #3ed623cb). This PR closes the discovery half so the daemon is a thin REST proxy end-to-end.

What's new

  • bridge_getInfo — version, nodeId, chainId, MPC readiness, threshold, supportedChains, aggregate totals.
  • bridge_getSupportedChains — slice of ChainConfig derived from vm.config.SupportedChains + MinConfirmations.
  • bridge_getChainConfig — single-chain lookup; case-insensitive match; explicit error names missing chain.
  • bridge_getSignature — reads from authoritative swap store; differentiates "not found" (swap missing) from "not yet available" (still signing) so daemons can poll without dispatching on opaque codes.

Wire-shape matches internal/bchain.Client in luxfi/bridge exactly — daemon already calls these method names, so no daemon-side change is required.

Architecture

Per CLAUDE.md "one and one way only, separation of concerns":

  • VM is authoritative for everything observable about a bridge — quote, lifecycle, signature, info. No daemon-cached fallback.
  • Daemon is a thin REST shim — proxies requests to bchain RPC; never makes settlement decisions; never enforces caps.
  • No per-swap or per-day caps on the daemon — block-level limits (MaxBridgeAmount, DailyBridgeLimit) live in the VM as consensus rules, enforced by the validator quorum collectively.

Test plan

  • go test ./bridgevm/... -count=1 → 36/36 pass (30 pre-existing + 6 new)
  • go vet ./bridgevm/... clean
  • daemon's internal/bchain/... build + tests untouched + still green
  • downstream: tag luxfi/bridge v2.1.0 once this merges so consumers pick up the now-authoritative discovery responses

Tests added

  • TestRPC_GetInfo — version, threshold, MPC-not-ready surface, totals
  • TestRPC_GetSupportedChains — chain count, confirmations, enabled flag
  • TestRPC_GetChainConfig — case-insensitive match + unknown-chain error + empty-id error
  • TestRPC_GetSignature_NotYetAvailable — distinct error vs not-found
  • TestRPC_GetSignature_AfterSign — happy path via swap-store Patch
  • TestRPC_GetSignature_NotFound — missing swap → "not found" error

…, getChainConfig, getSignature)

The luxfi/bridge daemon's bchain client (internal/bchain.Client) calls
bridge_getInfo / bridge_getSupportedChains / bridge_getChainConfig /
bridge_getSignature against the B-Chain RPC for permissionless discovery
+ MPC signature retrieval. Until now BridgeVM only implemented the
settlement subset (estimateFee, submitRequest, getStatus, cancelRequest,
health, getMPCPublicKey) — daemons fell back to assumed local values
for the discovery surface, a centralization vector.

This commit:
- Adds GetBridgeInfo, GetSupportedChains, GetChainConfig, GetSignature
  to bridgevm.Service.
- Wires all four into the JSON-RPC dispatcher (bridge_* and bridge.*
  aliases).
- GetSignature reads from the swap-store record (populated by the MPC
  signing pipeline once the threshold quorum aggregates shares).
  Distinguishes "no such swap" from "still signing" via separate errors
  so callers can poll without dispatching on a generic error code.
- GetChainConfig matches the ChainID case-insensitively and surfaces
  the requested id in the error message when the chain is not in
  SupportedChains.
- Adds 6 table-driven tests covering happy paths, not-found, empty
  params, and the not-yet-available signature poll.

After this lands the luxfi/bridge daemon stops needing any cached
fallback for these four endpoints — the B-Chain VM is authoritative
end-to-end. Daemon code itself needs no change; its bchain.Client
already calls these method names.

Tests: go test ./bridgevm/... — 36/36 pass (30 pre-existing + 6 new).
@hanzo-dev hanzo-dev merged commit ff21886 into main May 31, 2026
6 of 7 checks passed
@hanzo-dev hanzo-dev deleted the feat/bridgevm-canonical branch May 31, 2026 03:06
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.

1 participant