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
Definition of Done
All CI checks must pass before the PR is reviewed.
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>) -> ComputeEstimateread-only entry pointComputeEstimate { cpu_insns: u64, mem_bytes: u64, fee_stroops: i128 }return typecreate_invoice,pay,release,refund,open_dispute,approve_releaseenv.budget()API to capture actual instruction counts during simulationdocs/COMPUTE_BUDGETS.mdAcceptance Criteria
estimate_computereturns valid estimates for all 6 operationsdocs/COMPUTE_BUDGETS.mdupdated with measured rangescargo test --workspacepasses with zero failurescargo clippy --all-targets -- -D warningsproduces zero warningsDefinition of Done
All CI checks must pass before the PR is reviewed.