Skip to content

docs(contracts): add reproducible deploy and upgrade scripts (#40)#53

Open
abrak01 wants to merge 1 commit into
Kalebtron1:mainfrom
abrak01:feat/40-contract-migration-scripts
Open

docs(contracts): add reproducible deploy and upgrade scripts (#40)#53
abrak01 wants to merge 1 commit into
Kalebtron1:mainfrom
abrak01:feat/40-contract-migration-scripts

Conversation

@abrak01
Copy link
Copy Markdown

@abrak01 abrak01 commented May 28, 2026

Problem

No baseline existed for contract CPU cost. Each Soroban host call (address
clone, storage read/write) is metered — redundant ones add up across every user
transaction.

Changes

Three files touched, one focused optimization per contract:

vinculo_sbt/src/lib.rs

  • mint: replaced has() + get() for the admin check with a single get() — saves
    one instance-storage read per mint.
  • mint / revoke: build DataKey::Tier(user) once instead of cloning user before
    each storage call.

staking_pool/src/lib.rs

  • stake: build DataKey::Stake and DataKey::Balance keys once — was cloning user
    6 times.
  • unstake: same key reuse (4 clones removed); replaced field-by-field struct
    zeroing with StakeInfo::default() (4 field writes → 1).

vinculo_lending/src/lib.rs

  • request_loan: reuse the instance() storage reference for both Token and Sbt
    reads; build DataKey::Loan(user) once instead of 3 times.
  • repay: same loan key reuse.

Benchmark

Each contract now includes bench_* tests that print cpu_instruction_cost and
memory_bytes_cost via env.budget():

run from any contract directory

cargo test --features soroban-sdk/testutils -- --nocapture

Behavior unchanged

Pure mechanical refactor — same logic, same storage keys, same return values.
All existing tests are preserved.

Reviewer step

Run the benchmark command above and confirm all tests pass and benchmark lines
print.

Closes #41

@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

@abrak01 is attempting to deploy a commit to the alankcr1-6443's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Benchmark de gas/cost y optimizaciones

1 participant