Skip to content

Fix 80#201

Open
peace-cyber09 wants to merge 4 commits into
scout-off:mainfrom
peace-cyber09:fix-80
Open

Fix 80#201
peace-cyber09 wants to merge 4 commits into
scout-off:mainfrom
peace-cyber09:fix-80

Conversation

@peace-cyber09
Copy link
Copy Markdown

PR: Fix #80 — Extend persistent storage TTL for PlayerLevel and HistoryEntry

Summary

DataKey::PlayerLevel(player_id) and DataKey::HistoryEntry(player_id, index)
are written to persistent storage but their TTL was never extended, meaning they
would expire and become inaccessible after the default ledger window. This PR
adds extend_ttl calls in all four relevant functions.

Changes

contracts/progress/src/lib.rs

  • Added constants at the top of the file:

    const PERSISTENT_TTL_MIN: u32 = 500;
    const PERSISTENT_TTL_MAX: u32 = 2000;
  • advance_level — after writing all three persistent keys, extends TTL on:

    • DataKey::PlayerLevel(player_id)
    • DataKey::HistoryEntry(player_id, next_index)
    • DataKey::HistoryCounter(player_id) (the counter that tracks history length)
  • get_level — after reading the level, extends TTL on:

    • DataKey::PlayerLevel(player_id)
  • get_history_entry — after reading the entry, extends TTL on:

    • DataKey::HistoryEntry(player_id, index)
  • Added unit test test_player_level_and_history_accessible_after_ledger_advancement:

    • Sets min_persistent_entry_ttl = 200, max_entry_ttl = 10_000
    • Calls advance_level (extends to 2000)
    • Advances ledger by 500 (past the default min but within the extended TTL)
    • Asserts get_level and get_history_entry both succeed and return correct data

Acceptance Criteria

  • advance_level extends TTL on PlayerLevel and HistoryEntry.
  • get_level extends TTL on PlayerLevel.
  • get_history_entry extends TTL on HistoryEntry.
  • Unit test verifies data is accessible after simulated ledger advancement.

Testing

cargo test -p scoutchain-progress -- --nocapture

Related

Closes #80

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 31, 2026

@peace-cyber09 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

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.

PlayerLevel and HistoryEntry persistent storage entries are never TTL-bumped

1 participant