Skip to content

Commit

Permalink
Add operating_mode and remove unused_accounts for Future
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoqun committed Jul 2, 2020
1 parent 4a3b515 commit cd83759
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
10 changes: 9 additions & 1 deletion runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ pub(crate) struct BankFieldsToDeserialize {
pub(crate) stakes: Stakes,
pub(crate) epoch_stakes: HashMap<Epoch, EpochStakes>,
pub(crate) is_delta: bool,
// Stop wrapping with Option once we are after snapshot version 1.X!
pub(crate) operating_mode: Option<solana_sdk::genesis_config::OperatingMode>,
}

// Bank's common fields shared by all supported snapshot versions for serialization.
Expand Down Expand Up @@ -261,6 +263,7 @@ pub(crate) struct BankFieldsToSerialize<'a> {
pub(crate) stakes: &'a RwLock<Stakes>,
pub(crate) epoch_stakes: &'a HashMap<Epoch, EpochStakes>,
pub(crate) is_delta: bool,
pub(crate) operating_mode: OperatingMode,
}

/// Manager for the state of all accounts and programs after processing its entries.
Expand Down Expand Up @@ -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<OperatingMode>,

pub lazy_rent_collection: AtomicBool,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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(),
}
}

Expand Down
8 changes: 4 additions & 4 deletions runtime/src/serde_snapshot/future.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use super::common::*;
use {super::*, solana_measure::measure::Measure, std::cell::RefCell};

type AccountsDbFields = super::AccountsDbFields<SerializableAccountStorageEntry>;
Expand Down Expand Up @@ -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<Epoch, EpochStakes>,
pub(crate) is_delta: bool,
pub(crate) message_processor: MessageProcessor,
pub(crate) operating_mode: solana_sdk::genesis_config::OperatingMode,
}

impl Into<BankFieldsToDeserialize> for DeserializableVersionedBank {
Expand Down Expand Up @@ -100,6 +99,7 @@ impl Into<BankFieldsToDeserialize> for DeserializableVersionedBank {
stakes: self.stakes,
epoch_stakes: self.epoch_stakes,
is_delta: self.is_delta,
operating_mode: Some(self.operating_mode),
}
}
}
Expand Down Expand Up @@ -136,10 +136,10 @@ pub(crate) struct SerializableVersionedBank<'a> {
pub(crate) epoch_schedule: EpochSchedule,
pub(crate) inflation: Inflation,
pub(crate) stakes: &'a RwLock<Stakes>,
pub(crate) unused_accounts: UnusedAccounts,
pub(crate) epoch_stakes: &'a HashMap<Epoch, EpochStakes>,
pub(crate) is_delta: bool,
pub(crate) message_processor: MessageProcessor,
pub(crate) operating_mode: solana_sdk::genesis_config::OperatingMode,
}

impl<'a> From<crate::bank::BankFieldsToSerialize<'a>> for SerializableVersionedBank<'a> {
Expand Down Expand Up @@ -177,10 +177,10 @@ impl<'a> From<crate::bank::BankFieldsToSerialize<'a>> 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,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions runtime/src/serde_snapshot/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ impl Into<BankFieldsToDeserialize> for DeserializableVersionedBank {
stakes: self.stakes,
epoch_stakes: self.epoch_stakes,
is_delta: self.is_delta,
operating_mode: None,
}
}
}
Expand Down

0 comments on commit cd83759

Please sign in to comment.