perf: skip TTL bump on read-only schedule views (#16)#263
Open
MrShiroLu wants to merge 3 commits into
Open
Conversation
Add initialize, upgrade, and transfer_admin entrypoints so the contract can be upgraded via a stored admin address instead of having no upgrade path at all. Non-admin calls return Unauthorized, and initialize can only run once to stop admin takeover. Also fix a duplicate error discriminant (two error codes both used 9) that was blocking compilation.
claimable_amount is polled on every UI refresh, but routed through the same storage::get_schedule helper as the mutating entry points, paying for an extend_ttl (write) on every call. Split it into a TTL-bumping get_schedule for claim_vested/cancel_stream/emergency_drain and a plain get_schedule_readonly for the pure views, cutting the dominant per-call cost without changing any claim/cliff arithmetic.
#[contracterror]/#[contracttype]/#[contract] generate inherent impl blocks (spec_xdr(), spec_xdr_<method>()) that carry no doc comments of their own. rustc doesn't propagate an item-level #[allow(missing_docs)] onto these macro-generated sibling impls, so `stellar contract build` and `cargo check --lib` were failing on a clean main. Scope the allow at module level in error.rs, types.rs, and contract.rs instead, and add the one genuinely missing doc comment (the VestingDrips struct itself).
MrShiroLu
force-pushed
the
perf/claimable-amount-view-cost
branch
from
July 15, 2026 11:41
86539df to
336be60
Compare
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
claimable_amount(and the other pure views:get_schedule,is_cliff_passed,get_status,get_stats) no longer pay for anextend_ttlwrite on every call. Addedstorage::get_schedule_readonly, used only by these views;get_schedule(TTL-bumping) stays on the mutating paths (claim_vested,cancel_stream,emergency_drain) where it's actually needed.#[contracterror]/#[contracttype]/#[contract]generatespec_xdr()inherent impls with no doc comments, which#![deny(missing_docs)]was rejecting under the currently installed rustc —stellar contract buildfailed on a cleanmainbefore this PR. Scoped#![allow(missing_docs)]at module level inerror.rs/types.rs/contract.rsto fix it.docs/benchmarks.mddocumenting the methodology and rationale (realstellar contract invoke --costnumbers still need to be captured —cargo testis blocked in this environment by an unrelated upstream dependency conflict:soroban-env-hostpinsed25519-dalek 3.0.0, which needsrand_core 0.10.1, but no compatiblerand_chachais published yet).Test plan
stellar contract buildsucceedscargo check --libsucceeds (no errors, only pre-existing warnings)cargo test— blocked by the upstreamed25519-dalek/rand_chachaversion conflict described above; could not run in this environmenttest_claimable_amount_does_not_bump_ttlto lock in the optimization; renamedtest_ttl_bumped_on_read→test_ttl_bumped_on_mutating_read(now exercised viaclaim_vested)