diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 9661c104e15311..e660b8bf4265f4 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -223,6 +223,8 @@ pub(crate) struct BankFieldsToDeserialize { pub(crate) stakes: Stakes, pub(crate) epoch_stakes: HashMap, pub(crate) is_delta: bool, + // Stop wrapping with Option once we are after snapshot version 1.X! + pub(crate) operating_mode: Option, } // Bank's common fields shared by all supported snapshot versions for serialization. @@ -261,6 +263,7 @@ pub(crate) struct BankFieldsToSerialize<'a> { pub(crate) stakes: &'a RwLock, pub(crate) epoch_stakes: &'a HashMap, pub(crate) is_delta: bool, + pub(crate) operating_mode: OperatingMode, } /// Manager for the state of all accounts and programs after processing its entries. @@ -381,6 +384,7 @@ pub struct Bank { pub skip_drop: AtomicBool, + // Stop wrapping with Option once we are after snapshot version 1.X! pub operating_mode: Option, pub lazy_rent_collection: AtomicBool, @@ -602,7 +606,10 @@ impl Bank { last_vote_sync: new(), rewards: new(), skip_drop: new(), - operating_mode: Some(genesis_config.operating_mode), + // Always use fields.operating_mode once we are after snapshot version 1.X! and stop using genesis_config + operating_mode: fields + .operating_mode + .or(Some(genesis_config.operating_mode)), lazy_rent_collection: new(), }; bank.finish_init(); @@ -643,6 +650,7 @@ impl Bank { stakes: &self.stakes, epoch_stakes: &self.epoch_stakes, is_delta: self.is_delta.load(Ordering::Relaxed), + operating_mode: self.operating_mode.unwrap(), } } diff --git a/runtime/src/serde_snapshot/future.rs b/runtime/src/serde_snapshot/future.rs index 8629166cd9be28..57951b0a4121c6 100644 --- a/runtime/src/serde_snapshot/future.rs +++ b/runtime/src/serde_snapshot/future.rs @@ -1,4 +1,3 @@ -use super::common::*; use {super::*, solana_measure::measure::Measure, std::cell::RefCell}; type AccountsDbFields = super::AccountsDbFields; @@ -60,10 +59,10 @@ pub(crate) struct DeserializableVersionedBank { pub(crate) epoch_schedule: EpochSchedule, pub(crate) inflation: Inflation, pub(crate) stakes: Stakes, - pub(crate) unused_accounts: UnusedAccounts, pub(crate) epoch_stakes: HashMap, pub(crate) is_delta: bool, pub(crate) message_processor: MessageProcessor, + pub(crate) operating_mode: solana_sdk::genesis_config::OperatingMode, } impl Into for DeserializableVersionedBank { @@ -100,6 +99,7 @@ impl Into for DeserializableVersionedBank { stakes: self.stakes, epoch_stakes: self.epoch_stakes, is_delta: self.is_delta, + operating_mode: Some(self.operating_mode), } } } @@ -136,10 +136,10 @@ pub(crate) struct SerializableVersionedBank<'a> { pub(crate) epoch_schedule: EpochSchedule, pub(crate) inflation: Inflation, pub(crate) stakes: &'a RwLock, - pub(crate) unused_accounts: UnusedAccounts, pub(crate) epoch_stakes: &'a HashMap, pub(crate) is_delta: bool, pub(crate) message_processor: MessageProcessor, + pub(crate) operating_mode: solana_sdk::genesis_config::OperatingMode, } impl<'a> From> for SerializableVersionedBank<'a> { @@ -177,10 +177,10 @@ impl<'a> From> for SerializableVersionedB epoch_schedule: rhs.epoch_schedule, inflation: rhs.inflation, stakes: rhs.stakes, - unused_accounts: new(), epoch_stakes: rhs.epoch_stakes, is_delta: rhs.is_delta, message_processor: new(), + operating_mode: rhs.operating_mode, } } } diff --git a/runtime/src/serde_snapshot/legacy.rs b/runtime/src/serde_snapshot/legacy.rs index f0dd71d8e41ae8..066e39087e6780 100644 --- a/runtime/src/serde_snapshot/legacy.rs +++ b/runtime/src/serde_snapshot/legacy.rs @@ -170,6 +170,7 @@ impl Into for DeserializableVersionedBank { stakes: self.stakes, epoch_stakes: self.epoch_stakes, is_delta: self.is_delta, + operating_mode: None, } } }