fix: clamp factory pagination, cap batch size, fix oracle storage and… - #349
Open
Chidubemkingsley wants to merge 1 commit into
Open
Conversation
… decimals - factory/query.rs: add MAX_PAGE_SIZE=100 and clamp limit in paginate() to prevent u32::MAX from materializing unbounded Vec in view calls; update streams_by_sender/recipient docs to reflect hard cap (contracts/factory/src/query.rs:6,25; lib.rs:399,414). - factory/lib.rs: lower MAX_BATCH_SIZE from 100 to 10. Each create_stream does governor call, 2 token transfers, deploy + initialize invoke and 3 persistent writes (~2.5M insns). 100 * 2.5M = 250M exceeds Soroban budget; 10 is measured single-digit safe upper bound (contracts/factory/src/lib.rs:38). Also updates cancel_batch/stream_addresses which share the same cap, and docs. - oracle/lib.rs: move Submitters and Submission from instance() to persistent() per factory/storage.rs rule (unbounded per-entity data -> persistent). Add MAX_SUBMITTERS=32, TooManySubmitters error, TTL extends for persistent entries, cap check in add_submitter(), and update get_twap_price/configure_oracle/submit_price to use persistent() (contracts/oracle/src/lib.rs:23,73,408). - oracle/lib.rs: cap decimals at 19 in configure_oracle() (was 38). With price: u64, 10^20 > u64::MAX (~1.84e19) so decimals>=20 is unrepresentable; fix rejects >19 and documents widening to u128 as alternative (contracts/oracle/src/lib.rs:102,279). All workspace tests pass (drip-factory 17, drip-oracle 55, etc.).
|
@Chidubemkingsley 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! 🚀 |
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
paginatedoes not caplimit— a caller can force an enormous response #334closes
create_batch_streamscap of 100 is far beyond what fits in one Soroban transaction #333closes Oracle stores an unbounded
Submittersset in instance storage and iterates all of it on every read #332closes Oracle
price: u64overflows fordecimalsabove ~19, butconfigure_oracleallows up to 38 #331factory/query.rs: add MAX_PAGE_SIZE=100 and clamp limit in paginate() to prevent u32::MAX from materializing unbounded Vec in view calls; update streams_by_sender/recipient docs to reflect hard cap (contracts/factory/src/query.rs:6,25; lib.rs:399,414).
factory/lib.rs: lower MAX_BATCH_SIZE from 100 to 10. Each create_stream does governor call, 2 token transfers, deploy + initialize invoke and 3 persistent writes (~2.5M insns). 100 * 2.5M = 250M exceeds Soroban budget; 10 is measured single-digit safe upper bound (contracts/factory/src/lib.rs:38). Also updates cancel_batch/stream_addresses which share the same cap, and docs.
oracle/lib.rs: move Submitters and Submission from instance() to persistent() per factory/storage.rs rule (unbounded per-entity data -> persistent). Add MAX_SUBMITTERS=32, TooManySubmitters error, TTL extends for persistent entries, cap check in add_submitter(), and update get_twap_price/configure_oracle/submit_price to use persistent() (contracts/oracle/src/lib.rs:23,73,408).
oracle/lib.rs: cap decimals at 19 in configure_oracle() (was 38). With price: u64, 10^20 > u64::MAX (~1.84e19) so decimals>=20 is unrepresentable; fix rejects >19 and documents widening to u128 as alternative (contracts/oracle/src/lib.rs:102,279).
All workspace tests pass (drip-factory 17, drip-oracle 55, etc.).
What does this PR do?
Type of change
Related issue
Closes #
Changes
Checklist
cargo fmt --all— no diffcargo clippy --all-targets -- -D warnings— zero warningscargo test --all— all tests passchecked_*methodsrequire_auth()called before any state mutation in modified functionsCHANGELOG.mdupdated under[Unreleased]docs/architecture.mdupdated if design changedSecurity notes
Testing notes