Skip to content

feat(contracts): benchmark tests for contract flows#606

Merged
Vera3289 merged 2 commits into
Vera3289:mainfrom
milah-247:feature/contract-benchmarks
Jun 27, 2026
Merged

feat(contracts): benchmark tests for contract flows#606
Vera3289 merged 2 commits into
Vera3289:mainfrom
milah-247:feature/contract-benchmarks

Conversation

@milah-247

Copy link
Copy Markdown
Contributor

Summary

This PR adds benchmark tests for the governance contract to measure CPU and memory usage of core operations. The benchmarks provide visibility into contract performance and storage growth as governance activity scales.

Related Issue

Closes #476

Changes

  • Added contracts/governance/src/benches.rs.

  • Added benchmark coverage for:

    • create_proposal
    • cast_vote
    • finalise
    • execute
    • Storage growth across 100 proposals
  • Uses env.budget() (Soroban SDK v22).

  • Prints:

    • cpu_insn
    • mem_bytes
  • Benchmarks can be executed with:

cargo test -p votechain-governance bench_ -- --nocapture

Checklist

  • Benchmarks added
  • Contract tests pass
  • cargo fmt applied
  • No secrets committed

- bench_create_proposal: CPU + memory cost for proposal creation
- bench_cast_vote: cost of a single vote operation
- bench_finalise: cost of finalizing after voting period ends
- bench_execute: cost of executing a passed proposal
- bench_storage_100_proposals: cumulative storage cost baseline
- Uses soroban-sdk v22 env.budget() API (reset_tracker + cpu/mem cost)
- Run with: cargo test -p votechain-governance bench_ -- --nocapture
- Add Jest + ts-jest to backend devDeps for .test.ts support

closes Vera3289#476
@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@milah-247 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

@Vera3289 Vera3289 self-requested a review as a code owner June 27, 2026 12:41
@Vera3289 Vera3289 merged commit f25cd15 into Vera3289:main Jun 27, 2026
3 of 9 checks passed
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.

Smart Contracts: Add gas/storage benchmarking suite

2 participants