bridgevm: close daemon-discovery RPC gap (info/supportedChains/chainConfig/signature)#5
Merged
Merged
Conversation
…, 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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ed623cb). 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 ofChainConfigderived fromvm.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.Clientinluxfi/bridgeexactly — 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":
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/...cleaninternal/bchain/...build + tests untouched + still greenluxfi/bridge v2.1.0once this merges so consumers pick up the now-authoritative discovery responsesTests added
TestRPC_GetInfo— version, threshold, MPC-not-ready surface, totalsTestRPC_GetSupportedChains— chain count, confirmations, enabled flagTestRPC_GetChainConfig— case-insensitive match + unknown-chain error + empty-id errorTestRPC_GetSignature_NotYetAvailable— distinct error vs not-foundTestRPC_GetSignature_AfterSign— happy path via swap-store PatchTestRPC_GetSignature_NotFound— missing swap → "not found" error