Skip to content

Implement Soroban Contract Gas Optimization - #503

Merged
Pidoko257 merged 1 commit into
Pidoko257:mainfrom
levoski1:feat/soroban-contract-gas-optimization
Aug 26, 2026
Merged

Implement Soroban Contract Gas Optimization#503
Pidoko257 merged 1 commit into
Pidoko257:mainfrom
levoski1:feat/soroban-contract-gas-optimization

Conversation

@levoski1

Copy link
Copy Markdown
Contributor

Summary

This PR implements gas optimizations for the Soroban smart contracts (escrow and HTLC).

Changes

Escrow Contract (contracts/escrow/src/lib.rs)

  • Added gas optimization documentation
  • Cache contract address (env.current_contract_address()) in local variables to avoid repeated calls in:
    • release() function
    • refund() function
    • emergency_refund() function
    • self_refund() function
  • Reuse token client instances instead of creating new ones for each transfer
  • Add optimization documentation comments

HTLC Contract (contracts/htlc/src/lib.rs)

  • Added gas optimization documentation
  • Cache contract address and token client in:
    • claim() function
    • refund() function
  • Use direct preimage reference with to_bytes() for sha256 hashing
  • Add optimization documentation comments

Both Contracts

  • Compile successfully
  • Maintain backward compatibility

Issue References

Closes #366
Closes #365
Closes #363
Closes #364

- Add gas optimization comments and improvements to escrow contract:
  - Cache contract address to avoid repeated env.current_contract_address() calls
  - Reuse token client instances instead of creating new ones
  - Cache contract address in release, refund, emergency_refund, and self_refund
  - Add optimization documentation

- Add gas optimization comments and improvements to HTLC contract:
  - Cache contract address and token client in claim and refund
  - Use direct preimage reference with to_bytes() for sha256
  - Add optimization documentation

- Both contracts compile successfully

Closes Pidoko257#366
Closes Pidoko257#365
Closes Pidoko257#363
Closes Pidoko257#364
@drips-wave

drips-wave Bot commented Aug 25, 2026

Copy link
Copy Markdown

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

@Pidoko257
Pidoko257 merged commit 67f9879 into Pidoko257:main Aug 26, 2026
12 of 20 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

2 participants