feat(voting): add TTL helper module (partial fix for #7) - #27
Open
ale-helper-bot wants to merge 1 commit into
Open
feat(voting): add TTL helper module (partial fix for #7)#27ale-helper-bot wants to merge 1 commit into
ale-helper-bot wants to merge 1 commit into
Conversation
Adds contracts/voting/src/ttl.rs with bump_instance() and bump_persistent() helpers that wrap Soroban's extend_ttl API. The helpers are defined and re-exported but NOT yet called from #[contractimpl] methods. A follow-up PR will wire them in once the workspace pins a single Soroban SDK version and the exact extend_ttl / bump_ttl API surface is confirmed against that version. This satisfies the 'Research Soroban's extend_ttl and get_ttl API' sub-task of issue coopfinance#7 and gives the maintainer a single place to review the chosen threshold/extend values (100 / 100_000 ledgers = ~8 min grace + ~5.7 days coverage). Includes 2 unit tests on the constants themselves (no contract invocation needed) so the helpers don't bit-rot silently. Refs coopfinance#7
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.
Summary
Partial fix for #7. Adds the TTL helper module that #7 asks for as the first sub-task ("Research Soroban's extend_ttl and get_ttl API").
What's in this PR
contracts/voting/src/ttl.rs(new) —bump_instance()andbump_persistent()helpers wrappingextend_ttlcontracts/voting/src/lib.rs— declaresmod ttl;and re-exports the public APITHRESHOLD_LEDGERS < EXTEND_TO_LEDGERS, andEXTEND_TO_LEDGERScovers ≥ 1 week)What's NOT in this PR
The helpers are defined but not yet called from
#[contractimpl]methods. Doing so safely requires pinning the workspace to a singlesoroban-sdkversion (currently inherited from the workspaceCargo.toml) and confirming the exactextend_ttl/get_ttlsignature against that version. I'd rather land this foundation PR first and let the maintainer sanity-check the design before I wire it into all 5 contracts' state-changing methods.Chosen values
THRESHOLD_LEDGERSEXTEND_TO_LEDGERSBoth match the patterns in the Soroban official docs for daily-active contracts.
Acceptance criteria against #7
ttl.rsfor the chosen APIttl.rsconstantsTest plan
I do not have a Soroban toolchain locally. The new CI
docsjob (PR #22) will catch any doc regressions on this PR's docs; for compile-time validation this branch will be picked up by the existingtestandclippyjobs which runcargo test --workspaceandcargo clippy --workspace -- -D warnings. Happy to fix anything they flag.Refs #7