Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Backport writing new fields to snapshot #26394

Merged
merged 2 commits into from
Jul 7, 2022
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
21 changes: 19 additions & 2 deletions runtime/src/serde_snapshot/newer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ impl<'a> TypeContext<'a> for Context {
where
Self: std::marker::Sized,
{
// ONLY FOR THE BACKPORT, extra field is serialized on master
let ancestors = HashMap::from(&serializable_bank.bank.ancestors);
let fields = serializable_bank.bank.get_fields_to_serialize(&ancestors);
let lamports_per_signature = fields.fee_rate_governor.lamports_per_signature;
(
SerializableVersionedBank::from(fields),
SerializableAccountsDb::<'a, Self> {
Expand All @@ -199,6 +199,9 @@ impl<'a> TypeContext<'a> for Context {
account_storage_entries: serializable_bank.snapshot_storages,
phantom: std::marker::PhantomData::default(),
},
// Field that isn't part SerializableVersionedBank, but that we want to
// be able to store / read back on restart
lamports_per_signature,
)
.serialize(serializer)
}
Expand Down Expand Up @@ -262,7 +265,21 @@ impl<'a> TypeContext<'a> for Context {
.clone();

let mut serialize_account_storage_timer = Measure::start("serialize_account_storage_ms");
let result = (entries, version, slot, hash).serialize(serializer);

// Serialize historical_roots and historical_roots_with_hash default data; defaults are
// used for the sake of being able to backport serializing lamports_per_signature while
// keeping snapshots produced by v1.10 and master/v1.11 clients compatible
let historical_roots = Vec::<Slot>::default();
let historical_roots_with_hash = Vec::<(Slot, Hash)>::default();
let result = (
entries,
version,
slot,
hash,
historical_roots,
historical_roots_with_hash,
)
.serialize(serializer);
serialize_account_storage_timer.stop();
datapoint_info!(
"serialize_account_storage_ms",
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/serde_snapshot/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ mod test_bank_serialize {

// This some what long test harness is required to freeze the ABI of
// Bank's serialization due to versioned nature
#[frozen_abi(digest = "ERbJJzaQD39td9tiE4FPAud374S2Hvk6pvsxejm6quWf")]
#[frozen_abi(digest = "dU93dNba5nEH7o8KR4QbTT6SYRfDFdjXrZdqQjNGzKa")]
#[derive(Serialize, AbiExample)]
pub struct BankAbiTestWrapperNewer {
#[serde(serialize_with = "wrapper_newer")]
Expand Down