feat: implement batch transaction execution with gas optimization (#129) - #141
Merged
elizabetheonoja-art merged 1 commit intoAug 22, 2026
Conversation
elizabetheonoja-art
merged commit Aug 22, 2026
8a43100
into
Utility-Protocol:main
7 of 11 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
**Close #129
Summary of the issue
Users need the ability to execute multiple operations within a single Soroban transaction to optimize gas costs and guarantee atomic execution. Previously, operations were submitted individually, which increased transaction fees and risked partial application of state if sequential transactions failed.
Root cause
The main
UtilityContractlacked a unified proxy entry point to bundle and route multiple cross-contract function calls in a single atomic payload.Solution implemented
Implemented a new
batch_executormodule that allows users to pass an array ofBatchOperationstructs (containing contract address, function symbol, and arguments). The executor iteratively routes these calls and bundles their return values. If any operation within the batch fails, the entire transaction is atomically reverted (Soroban's default panic bubbling mechanism).Key changes made
batch_executor.rsto encapsulate the logic for iterative execution and define theBatchOperationstructure.batch_executor_tests.rsto validate batch size limits (max 20), verify atomic execution, and ensure successful cross-contract data returns.estimate_batch_gasheuristic helper to gauge total off-chain gas consumption based on standard per-op estimates.execute_batchandestimate_batch_gason theUtilityContractinterface inlib.rs.Any trade-offs or considerations
try_invoke_contractand implementing custom cleanup patterns, we lean on Soroban's native SDK behavior where a panic on a sub-contract call naturally reverts the entire state. This provides strict atomic safety (all-or-nothing) with zero overhead.Testing steps (how to verify the fix)
contracts/utility_contracts.cargo test test_batchto run the specific unit tests confirming batch boundary bounds and atomic execution behavior.BatchOperationstructs.Please kindly review this task. If there are any corrections, improvements, adjustments, or merge conflicts that you notice regarding my implementation, I'd really appreciate your feedback. I'd also love to hear your overall review of my work on this branch.
Thank you!