Skip to content

feat: KMS-backed relayer signer with atomic sequence tracking (BE-060) - #1988

Open
hilarybuilds wants to merge 1 commit into
StellarDevHub:mainfrom
hilarybuilds:fix/issue-1807-be-060-kms-hsm-backed-master-relayer-signer
Open

hilarybuilds wants to merge 1 commit into
StellarDevHub:mainfrom
hilarybuilds:fix/issue-1807-be-060-kms-hsm-backed-master-relayer-signer

Conversation

@hilarybuilds

Copy link
Copy Markdown

Overview

This PR moves gas-relayer signing off plain-text environment keys and onto a KMS/HSM-backed signer, and adds an atomic sequence-number tracker with automatic txBAD_SEQ re-fetch and retry. It targets the BE-060 requirements: keys never held in application memory or env vars, safe concurrent submission, and recovery from ledger sequence desynchronization within 2 retries.

Related Issue

Closes #BE-060

Changes

🔐 KMS / HSM Signing

  • [ADD] backend/src/blockchain/kmsSigner.ts

    • Signer adapter that delegates Soroban transaction signing to a remote KMS/HSM so the private key is never materialized in process memory.
  • [ADD] backend/src/services/kmsSignerService.ts

    • Service wrapper exposing signing and public-key lookup to the relayer, with error mapping for KMS failures.

🔁 Sequence Tracking & Relay Logic

  • [MODIFY] backend/src/blockchain/gasRelayer.service.ts
    • Routes relay submissions through the KMS signer.
    • Integrates sequence-number acquisition and retries on txBAD_SEQ, re-fetching the account sequence before resubmitting (bounded to 2 retries).

🌐 Routing

  • [MODIFY] backend/src/routes/relayer.routes.ts
    • Points relay endpoints at the updated relayer service.

Verification Results

Not included in this PR. Concurrency (100 tx/sec without sequence conflicts) and KMS integration tests should be added and run before merge.

Acceptance Criteria Status
Private keys never touch application memory or environment variables in plain text ✅ Signing delegated to KMS/HSM via kmsSigner.ts
High-concurrency submissions (100 tx/sec) execute without sequence conflicts ⚠️ Sequence handling implemented; load test not yet included
Auto-recovers from ledger sequence desynchronization within 2 retries ✅ txBAD_SEQ re-fetch with bounded retry in gasRelayer.service.ts

Closes #1807

@vercel

vercel Bot commented Nov 25, 2026

Copy link
Copy Markdown

@hilarybuilds is attempting to deploy a commit to the Ayomide Adeniran's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Nov 25, 2026

Copy link
Copy Markdown

@hilarybuilds Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

This branch has not been deployed

No deployments
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.

[BE-060] KMS / HSM-Backed Master Relayer Signer Service with Automated Nonce Tracking

1 participant