Skip to content

Add a context-aware retry/backoff and timeout to internal/soroban RPC Call and PollTransactionStatus #45

Description

@Jagadeeshftw

📌 Description

internal/soroban/rpc.go Call issues a single JSON-RPC request with no retry, and PollTransactionStatus polls on a hardcoded 2-second interval. Only the Horizon submit path in internal/soroban/tx.go (submitWithRetry) has backoff; the RPC layer (used by simulation and status reads) has none, so a transient RPC blip fails the whole operation.

💡 Why it matters: Soroban RPC endpoints are flaky under load; retrying idempotent reads and configurable poll intervals make on-chain operations far more reliable.

🧩 Requirements and context

  • Add bounded retry-with-backoff (reusing DefaultRetryConfig in internal/soroban/types.go) to Call for retryable RPC failures only.
  • Make PollTransactionStatus interval and total timeout configurable rather than hardcoded 2s.
  • Respect context cancellation on every attempt; never retry past the context deadline.
  • Do not retry non-idempotent submit calls.
  • Add tests with a mock RPC server returning transient-then-success.

Non-functional requirements

  • Must be secure, tested, and documented.
  • Should be efficient and easy to review.

🛠️ Suggested execution

1. Fork the repo and create a branch

git checkout -b feat/soroban-rpc-retry

2. Implement changes

  • Write/modify the relevant source: internal/soroban/rpc.go, internal/soroban/types.go
  • Write comprehensive tests: internal/soroban/rpc_test.go
  • Add documentation: GoDoc on retry semantics
  • Include GoDoc comments distinguishing retryable vs non-retryable
  • Validate security assumptions: cap retries to bound resource use

3. Test and commit

  • Run tests:
go test ./internal/soroban/...
  • Cover edge cases: transient error, permanent error, context cancelled mid-retry
  • Include test output and security notes in the PR description.

Example commit message

feat(soroban): add retry/backoff and configurable polling to RPC layer

✅ Acceptance criteria

  • Call retries retryable RPC errors with bounded backoff
  • Poll interval and timeout configurable
  • Context cancellation honored on every attempt
  • Mock-RPC tests cover transient-then-success and cancellation

🔒 Security notes

Only idempotent reads/simulations are retried; submit must never be retried to avoid double-spend.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Labels

GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial CampaignGrantFox official campaign issuebackendBackend / API workperformancePerformance / gas / resource usesmart-contractSoroban/Rust smart contract work
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions