Skip to content

Implement a compute budget estimation entry point for all major operations #351

Description

@Kingsman-99

Overview

Add a simulation-only entry point that returns the estimated compute units (CPU instructions + memory bytes) for each major contract operation given its inputs, without mutating state. This allows SDK/frontend callers to pre-estimate fees before submitting a real transaction.

Requirements

  • estimate_compute(env, operation: Symbol, params: Map<Symbol, Val>) -> ComputeEstimate read-only entry point
  • ComputeEstimate { cpu_insns: u64, mem_bytes: u64, fee_stroops: i128 } return type
  • Support estimating: create_invoice, pay, release, refund, open_dispute, approve_release
  • Use Soroban's env.budget() API to capture actual instruction counts during simulation
  • Write tests asserting estimates are within 10% of actual measured costs
  • Document each operation's typical budget range in docs/COMPUTE_BUDGETS.md

Acceptance Criteria

  • estimate_compute returns valid estimates for all 6 operations
  • Estimates within 10% of actual costs verified in tests
  • docs/COMPUTE_BUDGETS.md updated with measured ranges
  • cargo test --workspace passes with zero failures
  • cargo clippy --all-targets -- -D warnings produces zero warnings

Definition of Done

All CI checks must pass before the PR is reviewed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaigncomplexity: highComplex feature requiring deep knowledge - 200 ptsgrantfoxIssue for GrantFox programoptimizationGas and compute optimisation

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions