Skip to content

Feat/soroban resource fee estimation#354

Open
Benedict315 wants to merge 4 commits intoDXmakers:mainfrom
Benedict315:feat/soroban-resource-fee-estimation
Open

Feat/soroban resource fee estimation#354
Benedict315 wants to merge 4 commits intoDXmakers:mainfrom
Benedict315:feat/soroban-resource-fee-estimation

Conversation

@Benedict315
Copy link
Copy Markdown

Summary

Implements the "Handle Soroban Resource Fee Estimation" component to bridge the application layer with the Soroban smart contract environment. This module provides comprehensive transaction construction, fee estimation, and secure submission capabilities for escrow deposits, milestone releases, and dispute resolutions.

Changes

Core Implementation

  • New soroban-resource-estimator.ts

    • SorobanResourceEstimator class with dynamic fee calculation
    • Resource limit analysis with safety margins (20% buffer)
    • Pre-flight simulation with detailed CPU/memory/ledger breakdown
    • Warning system for resources approaching limits (>80% utilization)
    • XDR debugging tools for development environments
  • Enhanced soroban-pipeline.ts

    • 5-step transaction pipeline: Build → Simulate → Sign → Submit → Confirm
    • Sequence number mismatch handling with automatic retry (3 attempts)
    • Asynchronous RPC polling with configurable timeout
    • Progress callbacks for real-time UI updates
    • Detailed simulation logs with raw XDR exposure (dev mode)

UI Components

  • New soroban-transaction-tracker.tsx
    • Progress tracker with animated step indicators
    • Monospace typography for XDR/transaction hashes
    • High-contrast success/error states
    • Direct block explorer links (stellar.expert)
    • Expandable technical details accordion (simulation results, raw XDR)
    • Fee breakdown display with resource warnings

React Hooks

  • New use-soroban-estimate.ts
    • useSorobanEstimate hook with debounced estimation
    • Automatic re-estimation on parameter changes
    • Error handling with retry capability
    • Reactive loading states and derived values (fee summary, utilization %)

Security Features

  • All cryptographic signatures handled through connected wallet provider
  • No private key exposure in application code
  • Signed XDR redaction in production logs
  • Safe retry logic for transient failures

Transaction Lifecycle

  1. Build: Construct unsigned transaction with XDR
  2. Simulate: Estimate fees/resources via Soroban RPC
  3. Sign: Request wallet signature on prepared transaction
  4. Submit: Send to Testnet/Mainnet RPC
  5. Confirm: Poll until on-chain confirmation (max 60s)

Error Handling

  • Sequence number mismatch: Auto-refresh account and retry
  • Simulation errors: Detailed error messages with debugging info
  • RPC timeouts: Exponential backoff with max retry limit
  • On-chain failures: Raw XDR result logging for debugging

Developer Experience

  • Comprehensive TypeScript types exported
  • Dev mode logging with raw XDR inspection
  • Simulation logs with resource utilization percentages
  • Direct links to Stellar Expert block explorer

Checklist

  • Latest Stellar SDK for JavaScript/TypeScript
  • Comprehensive XDR building logic with custom types
  • Transaction simulation with fee estimation
  • Asynchronous RPC polling for confirmation
  • Secure wallet signature handling
  • Sequence number mismatch retry logic
  • Detailed XDR and simulation logs (dev environments)
  • Dynamic resource limit adjustment
  • Technical UI with monospace typography
  • Multi-step progress tracker with animations
  • Block explorer integration
    closes Handle Soroban Resource Fee Estimation #167

…onitoring

Implements the 'Security: Audit storage footprints regularly' component:

Core Features:
- StorageAuditor with table-level footprint analysis
- Background worker with configurable intervals (default 1 hour)
- Anomaly detection for large tables (>100MB), rapid growth (>50%), bloat (>20% dead tuples)
- Idempotent operations with Postgres checkpointing

Database Schema:
- storage_audits: audit run records
- storage_audit_tables: per-table footprint data
- storage_anomalies: detected issues with resolution tracking

API Endpoints:
- GET/POST /api/v1/storage/audits/* for audit management
- GET/POST /api/v1/storage/anomalies/* for anomaly resolution
- GET /api/v1/storage/summary for storage overview

Monitoring:
- Prometheus metrics: storage_audit_total_*, storage_audit_total_bytes, etc.
- Grafana dashboard with 6 new panels for storage monitoring
- Structured logging via Tracing crate

Configuration via env vars:
- STORAGE_AUDIT_INTERVAL_SECS (default 3600)
- STORAGE_AUDIT_MAX_GROWTH_PERCENT (default 50.0)
- STORAGE_AUDIT_ANOMALY_THRESHOLD_BYTES (default 100MB)
- STORAGE_AUDIT_ENABLE_ALERTS (default true)

Includes comprehensive runbook documentation for production deployment.
- Add SorobanResourceEstimator with dynamic fee calculation
- Create transaction pipeline with Build→Simulate→Sign→Submit→Confirm flow
- Add comprehensive UI components for transaction progress tracking
- Implement React hook useSorobanEstimate for reactive state management
- Handle sequence number mismatch with automatic retry
- Add detailed XDR debugging tools for dev environments
- Include resource limit warnings and recommendations
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 29, 2026

@Benedict315 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

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.

Handle Soroban Resource Fee Estimation

1 participant