Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoS: keep 2 past epochs of data by default #1733

Merged
merged 2 commits into from
Jul 22, 2023
Merged
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
2 changes: 2 additions & 0 deletions .changelog/unreleased/miscellaneous/1733-pos-data-history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- PoS: Keep the data for last two epochs by default.
([\#1733](https://github.com/anoma/namada/pull/1733))
12 changes: 9 additions & 3 deletions proof_of_stake/src/epoched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ pub const LAST_UPDATE_SUB_KEY: &str = "last_update";
/// Sub-key for an epoched data structure's oldest epoch with some data
pub const OLDEST_EPOCH_SUB_KEY: &str = "oldest_epoch";

/// Default number of past epochs to keep.
const DEFAULT_NUM_PAST_EPOCHS: u64 = 2;

/// Discrete epoched data handle
pub struct Epoched<
Data,
FutureEpochs,
const NUM_PAST_EPOCHS: u64 = 0,
const NUM_PAST_EPOCHS: u64 = DEFAULT_NUM_PAST_EPOCHS,
SON = collections::Simple,
> {
storage_prefix: storage::Key,
Expand All @@ -38,8 +41,11 @@ pub struct Epoched<
}

/// Discrete epoched data handle with nested lazy structure
pub type NestedEpoched<Data, FutureEpochs, const NUM_PAST_EPOCHS: u64 = 0> =
Epoched<Data, FutureEpochs, NUM_PAST_EPOCHS, collections::Nested>;
pub type NestedEpoched<
Data,
FutureEpochs,
const NUM_PAST_EPOCHS: u64 = DEFAULT_NUM_PAST_EPOCHS,
> = Epoched<Data, FutureEpochs, NUM_PAST_EPOCHS, collections::Nested>;

/// Delta epoched data handle
pub struct EpochedDelta<Data, FutureEpochs, const NUM_PAST_EPOCHS: u64> {
Expand Down