Skip to content

Closes #542 - #1025

Merged
greatest0fallt1me merged 1 commit into
CalloraOrg:mainfrom
mansur-codes:feature/price-write-rl
Jul 30, 2026
Merged

Closes #542#1025
greatest0fallt1me merged 1 commit into
CalloraOrg:mainfrom
mansur-codes:feature/price-write-rl

Conversation

@mansur-codes

Copy link
Copy Markdown
Contributor

closes #542

Adds a write rate limit to price_registry.rs so admins can't spam price updates faster than the configured cooldown. The limit kicks in after the first write; subsequent writes check the ledger sequence gap against PRICE_WRITE_RATE_LIMIT and reject with WriteRateLimitExceeded if it's too soon.

What changed

price_registry.rs holds the core logic: set_price now reads PriceRegistryLastWrite from storage before writing, computes the sequence delta, and short-circuits if the gap is under the threshold. First write skips the check. get_price and remove_price are unchanged functionally; remove_price clears the last-write entry alongside the price itself so a removal doesn't ghost-lock the registry.

The other files were mostly cleanup that the implementation forced: duplicate SettlementError, StorageKey, and Price variants scattered across lib.rs, errors.rs, and types.rs got consolidated. ClaimSimulation was missing from types.rs entirely. lib.rs now exposes the three entrypoints via pub mod price_registry instead of inlining them.

Tests

All rate-limit behaviour is covered in price_registry.rs: first write allowed, second write within cooldown rejected, write after cooldown passes, and the sequence-number edge at exactly the boundary. 126 tests pass. The 17 failures are pre-existing and unrelated to this issue; 16 are test_ttl_bump variants blocked by soroban-sdk's newer contract-context restriction on extend_ttl(), and one is a Wasm-hash issue in test_upgrade_emits_upgraded_event.

Notes

require_auth is on every state-changing entrypoint. Math is overflow-safe throughout. No unwrap() in production paths.

@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@mansur-codes 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

@greatest0fallt1me
greatest0fallt1me merged commit d070e57 into CalloraOrg:main Jul 30, 2026
6 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

Development

Successfully merging this pull request may close these issues.

Add admin-set price_registry write rate limit

2 participants