Skip to content

chore(moolah-vault): increase MAX_QUEUE_LENGTH from 100 to 1000 - #222

Merged
qingyang-lista merged 1 commit into
masterfrom
chore/increase-max-supply-queue-length
Aug 11, 2026
Merged

chore(moolah-vault): increase MAX_QUEUE_LENGTH from 100 to 1000#222
qingyang-lista merged 1 commit into
masterfrom
chore/increase-max-supply-queue-length

Conversation

@razww

@razww razww commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Increases the hardcoded maximum supply/withdraw queue length in MoolahVault from 100 to 1000.

  • src/moolah-vault/libraries/ConstantsLib.sol: MAX_QUEUE_LENGTH 1001000

This constant caps both the supply and withdraw queues, enforced in:

  • MoolahVault.setSupplyQueue (MoolahVault.sol:245)
  • MoolahVault.updateWithdrawQueue (MoolahVault.sol:643)

Both now allow up to 1000 markets in the queue.

Testing

  • forge build passes.

🤖 Generated with Claude Code

@hashdit-bot

hashdit-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

Pull Request Review

This Solidity PR increases MAX_QUEUE_LENGTH in ConstantsLib from 100 to 1000. As a result, MoolahVault can permit up to 1000 markets in its supply and withdrawal queues.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@hashdit-bot

hashdit-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

Pull Request Review

This Solidity PR increases MoolahVault’s maximum supply and withdrawal queue length from 100 to 1000 markets. It also updates the Foundry tests to create queue-boundary markets on demand while keeping the shared test setup fixed at 100 markets.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

…o 600

Bump ConstantsLib.MAX_QUEUE_LENGTH from 100 to 600. Capped at 600 (not
higher) so a full-length setSupplyQueue -- one cold SSTORE (~22.1k) plus a
cold validation SLOAD (~2.1k) per element, ~24.9k/element -- stays under the
BEP-652 per-transaction gas limit of 16,777,216; 1000 elements (~25M gas)
would make a full-length supply queue unsettable.

Adapt the vault unit tests to the larger limit:
- Decouple NB_MARKETS from MAX_QUEUE_LENGTH so the shared setUp no longer
  creates one market per queue slot for every vault test.
- Rewrite testAcceptCapMaxQueueLengthExceeded to create markets on demand and
  enable them via direct O(1) setCap instead of the O(n^2) supply-queue
  rebuilding helper.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@razww
razww force-pushed the chore/increase-max-supply-queue-length branch from 7c5ed09 to ba75a70 Compare August 10, 2026 08:26
@hashdit-bot

hashdit-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

Pull Request Review

This Solidity PR raises MoolahVault’s maximum supply/withdraw queue length from 100 to 600, despite the title and description stating 1000. It also updates Foundry tests to create queue-boundary markets on demand while keeping the shared test setup fixed at 100 markets.

Sensitive Content

No sensitive content detected.

Security Issues

🟠 [HIGH] Larger queues may make vault deposits or withdrawals exceed the transaction gas limit

File: src/moolah-vault/libraries/ConstantsLib.sol
Raising MAX_QUEUE_LENGTH from 100 to 600 permits substantially more markets in operational supply and withdrawal queues. The documented gas analysis covers setSupplyQueue, but vault deposit/mint and withdraw/redeem paths may also traverse these queues and perform storage reads, accounting, and external market calls per entry; a worst-case 600-market traversal could exceed BEP-652’s 16,777,216 gas limit, potentially preventing users from depositing or accessing funds until a privileged allocator reorders or shortens the queue.
Recommendation: Benchmark and test the worst-case gas consumption of every production path that traverses either queue, especially withdrawals where liquidity is available only near the end. Set the limit according to the most expensive path—not only setSupplyQueue—or redesign traversal using bounded batches/pagination while ensuring users retain a reliable withdrawal path.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@qingyang-lista qingyang-lista left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@qingyang-lista
qingyang-lista merged commit 4882d30 into master Aug 11, 2026
8 checks passed
@qingyang-lista
qingyang-lista deleted the chore/increase-max-supply-queue-length branch August 11, 2026 06:49
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.

2 participants