Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions contracts/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,19 @@ where
.persistent()
.extend_ttl(key, extend_to, extend_to);
}

/// Shared threshold (ledgers) before instance storage TTL extension triggers.
pub const INSTANCE_TTL_THRESHOLD: u32 = 100_000;
/// Shared target (ledgers) to extend instance storage TTL to.
pub const INSTANCE_TTL_EXTEND_TO: u32 = 500_000;

/// Extends the TTL of the contract's instance storage (#38). Instance
/// storage holds Admin, Treasury, FeeBps, etc. — losing it takes down
/// the entire contract. Uses conservative defaults suitable for a
/// multi-month bounty lifecycle.
pub fn extend_instance_ttl(env: &Env) {
env.storage()
.instance()
.extend_ttl(INSTANCE_TTL_THRESHOLD, INSTANCE_TTL_EXTEND_TO);
}

2 changes: 1 addition & 1 deletion contracts/escrow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ pub(crate) fn extend_ttl(env: &Env, key: &DataKey) {
/// takes down the entire contract for every issue. Uses the same
/// threshold/extend_to as persistent records for consistency.
pub(crate) fn extend_instance_ttl(env: &Env) {
env.storage().instance().extend_ttl(100_000, 500_000);
mergefi_common::extend_instance_ttl(env);
}

/// Extends the TTL of a persistent entry to (approximately) survive until
Expand Down
2 changes: 1 addition & 1 deletion contracts/maintenance-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,5 +572,5 @@ fn extend_ttl(env: &Env, key: &DataKey) {
/// storage holds Admin, Treasury, and FeeBps — losing it takes down the
/// entire contract for every pool.
fn extend_instance_ttl(env: &Env) {
env.storage().instance().extend_ttl(100_000, 500_000);
mergefi_common::extend_instance_ttl(env);
}
2 changes: 1 addition & 1 deletion contracts/milestones/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,5 +935,5 @@ fn extend_ttl(env: &Env, key: &DataKey) {
/// storage holds Admin, Treasury, FeeBps, and MaxSponsors — losing it
/// takes down the entire contract for every milestone.
fn extend_instance_ttl(env: &Env) {
env.storage().instance().extend_ttl(100_000, 500_000);
mergefi_common::extend_instance_ttl(env);
}