Repository navigation
fix(factory): cap create_pools_batch length at MAX_BATCH_SIZE - #595
Merged
ritaifeoluwa merged 3 commits intoOct 21, 2026
Merged
Conversation
Each batch entry deploys a full farming-pool WASM instance inside create_pool_inner, so an unbounded batch can exhaust the transaction's resource budget and trap with an opaque host error rather than a typed failure. Add MAX_BATCH_SIZE (10) and reject oversized batches with a new BatchTooLarge error before any pool is deployed (SmartDropLabs#528-SmartDropLabs#531).
Verify that a batch exceeding MAX_BATCH_SIZE is rejected with BatchTooLarge and that a batch of exactly MAX_BATCH_SIZE succeeds.
|
@DeFiVC 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! 🚀 |
✅ Deploy Preview for sdcontracts ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Closes #528, Closes #529, Closes #530, Closes #531
Type of Change
Summary
create_pools_batchaccepted an unbounded number of entries, each of which deploys a full farming-pool WASM instance. A large batch exhausts the transaction's resource budget and traps with an opaque host error rather than a typed failure. This PR caps the batch atMAX_BATCH_SIZE(10) and rejects oversized batches with a newBatchTooLargeerror before any pool is deployed.Motivation / Context
Closes #528, Closes #529, Closes #530, Closes #531 — each batch entry triggers a WASM deploy inside
create_pool_inner, so an unbounded batch is a resource-exhaustion vector. The guard runs before the deployment loop, so a caller gets a deterministicFactoryError::BatchTooLargeinstead of a non-deterministic budget trap.Changes
soroban/contracts/factory/src/lib.rs— addedMAX_BATCH_SIZE = 10constant and a length check at the top ofcreate_pools_batchthat returnsFactoryError::BatchTooLargebefore any pool is created.soroban/contracts/factory/src/types.rs— addedBatchTooLarge = 20toFactoryError.soroban/contracts/factory/src/test.rs— added 2 regression tests: one rejects a batch ofMAX_BATCH_SIZE + 1withBatchTooLargeand zero pools created; one accepts a batch of exactlyMAX_BATCH_SIZEand registers all pools.cargo fmtacross the factory crate to resolve pre-existing formatting drift (required by CI'scargo fmt --checkgate).Testing
cargo check -p factory --libpasses cleanly.cargo fmt -p factory -- --checkpasses after formatting fixes.cargo clippy -p factory --libcompiles without warnings.cargo test -p factory --libcannot run in the current environment — the farming-pool WASM (136 KB) exceeds Soroban's 128 KB contract-code limit, sosetup()fails withBudget, ExceededLimiton every test that uploads it. This is pre-existing onmain(upstream CI run39517565845also fails). The new tests follow the exact same patterns as the existing batch tests and will pass once the WASM size is addressed.Tradeoffs
MAX_BATCH_SIZE = 10is conservative but sufficient for legitimate batch-creation use cases while capping per-transaction resource usage. The value is a named constant and trivially adjustable.Out of scope
tests/create_pool_*_validation.rsstub files from PR Create pool parameter validation tests #553 (todo!()helpers) — pre-existing and unrelated.