feat(emergency): bump storage TTL on hot read paths (#709) - #1030
Open
DeePrincipal-dev-lang wants to merge 2 commits into
Open
feat(emergency): bump storage TTL on hot read paths (#709)#1030DeePrincipal-dev-lang wants to merge 2 commits into
DeePrincipal-dev-lang wants to merge 2 commits into
Conversation
Add extend_ttl calls to all read-only entrypoints in the emergency contract so frequently-queried deployments do not archive due to infrequent writes. Changes: - contracts/emergency/src/migrate.rs: add LEDGERS_PER_DAY, INSTANCE_BUMP_THRESHOLD, INSTANCE_BUMP_AMOUNT, PERSISTENT_BUMP_THRESHOLD, PERSISTENT_BUMP_AMOUNT constants; bump instance TTL in get_current(), version(), is_upgrade_authorised() - contracts/emergency/src/views.rs: add TTL constants; bump instance TTL in capabilities() - contracts/emergency/src/lib.rs: re-export TTL constants from crate root; update capabilities() doc comment; wire test_ttl_bump module - contracts/emergency/src/test_ttl_bump.rs: 11 focused tests covering every bumped read path and an end-to-end archival-prevention scenario - docs/EMERGENCY_TTL_BUMP.md: document new constants, changed entrypoints, security notes, and test coverage - Cargo.toml: add contracts/emergency to workspace members Closes CalloraOrg#709
|
@DeePrincipal-dev-lang 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.
feat(emergency): bump storage TTL on hot read paths — Closes #709
Problem
The callora-emergency contract exposes several read-only entrypoints (capabilities,
get_current, version, is_upgrade_authorised) that are polled frequently by monitoring tools and
off-chain clients. On Stellar/Soroban, write operations automatically extend storage TTL but
read operations do not — so a contract queried often but written rarely will gradually approach
archival, at which point reads fail until a fee is paid to restore the entry.
Solution
Add env.storage().instance().extend_ttl(INSTANCE_BUMP_THRESHOLD, INSTANCE_BUMP_AMOUNT) to all
four hot read paths. The call is a no-op when TTL is already above the threshold (common case),
so the gas overhead is minimal.
Changes
contracts/emergency/src/migrate.rs
INSTANCE_BUMP_AMOUNT (~60 days), PERSISTENT_BUMP_THRESHOLD, PERSISTENT_BUMP_AMOUNT
contracts/emergency/src/views.rs
contracts/emergency/src/lib.rs
external use
contracts/emergency/src/test_ttl_bump.rs (new)
is restored to INSTANCE_BUMP_AMOUNT
past the original write-path TTL window
docs/EMERGENCY_TTL_BUMP.md (new)
Cargo.toml
Security
Testing
cargo test -p callora-emergency
closes #709