Repository navigation
feat(sdk): add diagnostics, retry classification, tx recovery, and structured tx logging (#277) - #290
Open
hieuk48 wants to merge 14 commits into
Conversation
|
@hieuk48 is attempting to deploy a commit to the Sendi John's projects Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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.
🎯 Overview & Context
Resolves #277 by adding the SDK's reliability layer: retry classification, transaction recovery/lookup, simulation diagnostics, and structured transaction logging with automatic secret redaction.
📦 Key Features Added
1. RPC Retry Classification & Backoff (
sdk/src/recovery/retry.ts)isRetryable(error): boolean: Distinguishes transient RPC/network/sequencing failures (503,rate limit,txBadSeq,ETIMEDOUT) from deterministic rejections (insufficient funds, unauthorized, validation).mayHaveReachedServer(error): boolean: Detects ambiguous timeouts (504 Gateway Timeout,ECONNRESET,fetch failed) where a transaction may have been accepted into the mempool.withRpcRetry(fn, options): Robust exponential backoff with full jitter andonRetrycallback hooks.2. Transaction Recovery (
sdk/src/recovery/lookup.ts)lookupTransaction(hash, { server, timeoutMs, pollIntervalMs }): Recovers transaction outcome (pending | success | failed | timeout | not_found) without throwing raw RPC exceptions.lookupTransactionbefore blindly submitting again.3. Simulation Diagnostics (
sdk/src/diagnostics/simulation.ts&diagnostics.ts)summarizeSimulation(simulation): SimulationEstimate: Produces log-safe numeric summaries ({ instructions, readBytes, writeBytes, feeStroops }) while explicitly stripping raw XDR payloads to avoid leaking ledger arguments into telemetry.classifyContractError(err): ContractErrorDiagnostic | null: Maps raw Soroban host error asserts to normalized typed codes (POOL_PAUSED,NOT_A_MEMBER,DEADLINE_PASSED, etc.) adhering to existing repository taxonomy.4. Structured Transaction Logging & Redaction (
sdk/src/diagnostics/logger.ts)TxLoggerinterface &TxLogEventcovering all transaction phases:"build" | "simulate" | "sign" | "submit" | "confirm" | "error".redactSensitiveData()&createSafeLogEvent(): Strips Stellar secret keys (S...) and Bearer tokens by default.consoleTxLoggerimplementation for development and testing.🧪 Verification & Acceptance Criteria
pnpm test)pnpm typecheck)pnpm build)pnpm check:api)