Skip to content
Merged
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
11 changes: 11 additions & 0 deletions runtime/src/serde_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,16 @@ struct ExtraFieldsToDeserialize {
versioned_epoch_stakes: HashMap<u64, VersionedEpochStakes>,
#[serde(deserialize_with = "default_on_eof")]
accounts_lt_hash: Option<SerdeAccountsLtHash>,
/// In order to maintain snapshot compatibility between adjacent versions
/// (edge <-> beta, and beta <-> stable), we must be able to deserialize
/// (and ignore) this new field (block id) in adjacent versions *before*
/// we serialize the new field into snapshots.
/// Hence the annotation to allow dead code.
/// This code is not truly dead though, as it enables newer versions to
/// populate this field and have older versions still load the snapshot.
#[allow(dead_code)]
#[serde(deserialize_with = "default_on_eof")]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this default_on_eof makes things compatible if the block_id is not present?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, exactly! I'll add some more info to the PR description with additional testing I've done.

block_id: Option<Hash>,
}

/// Extra fields that are serialized at the end of snapshots.
Expand Down Expand Up @@ -474,6 +484,7 @@ where
_obsolete_epoch_accounts_hash,
versioned_epoch_stakes,
accounts_lt_hash,
block_id: _,
} = extra_fields;

bank_fields.fee_rate_governor = bank_fields
Expand Down
Loading