Skip to content

Commit 187ed6a

Browse files
Remove unused fields from Bank (backport solana-labs#22491) (solana-labs#22630)
* Remove unused fields from Bank (solana-labs#22491) (cherry picked from commit 9977396) # Conflicts: # runtime/src/serde_snapshot/future.rs * fixup the backport Co-authored-by: Brooks Prumo <[email protected]>
1 parent 91bc449 commit 187ed6a

File tree

2 files changed

+3
-24
lines changed

2 files changed

+3
-24
lines changed

runtime/src/bank.rs

-18
Original file line numberDiff line numberDiff line change
@@ -864,8 +864,6 @@ pub(crate) struct BankFieldsToDeserialize {
864864
pub(crate) ns_per_slot: u128,
865865
pub(crate) genesis_creation_time: UnixTimestamp,
866866
pub(crate) slots_per_year: f64,
867-
#[allow(dead_code)]
868-
pub(crate) unused: u64,
869867
pub(crate) slot: Slot,
870868
pub(crate) epoch: Epoch,
871869
pub(crate) block_height: u64,
@@ -904,7 +902,6 @@ pub(crate) struct BankFieldsToSerialize<'a> {
904902
pub(crate) ns_per_slot: u128,
905903
pub(crate) genesis_creation_time: UnixTimestamp,
906904
pub(crate) slots_per_year: f64,
907-
pub(crate) unused: u64,
908905
pub(crate) slot: Slot,
909906
pub(crate) epoch: Epoch,
910907
pub(crate) block_height: u64,
@@ -943,7 +940,6 @@ impl PartialEq for Bank {
943940
&& self.ns_per_slot == other.ns_per_slot
944941
&& self.genesis_creation_time == other.genesis_creation_time
945942
&& self.slots_per_year == other.slots_per_year
946-
&& self.unused == other.unused
947943
&& self.slot == other.slot
948944
&& self.epoch == other.epoch
949945
&& self.block_height == other.block_height
@@ -1095,9 +1091,6 @@ pub struct Bank {
10951091
/// The number of slots per year, used for inflation
10961092
slots_per_year: f64,
10971093

1098-
/// Unused
1099-
unused: u64,
1100-
11011094
/// Bank slot (i.e. block)
11021095
slot: Slot,
11031096

@@ -1300,7 +1293,6 @@ impl Bank {
13001293
ns_per_slot: u128::default(),
13011294
genesis_creation_time: UnixTimestamp::default(),
13021295
slots_per_year: f64::default(),
1303-
unused: u64::default(),
13041296
slot: Slot::default(),
13051297
bank_id: BankId::default(),
13061298
epoch: Epoch::default(),
@@ -1531,7 +1523,6 @@ impl Bank {
15311523
ticks_per_slot: parent.ticks_per_slot,
15321524
ns_per_slot: parent.ns_per_slot,
15331525
genesis_creation_time: parent.genesis_creation_time,
1534-
unused: parent.unused,
15351526
slots_per_year: parent.slots_per_year,
15361527
epoch_schedule,
15371528
collected_rent: AtomicU64::new(0),
@@ -1738,7 +1729,6 @@ impl Bank {
17381729
ns_per_slot: fields.ns_per_slot,
17391730
genesis_creation_time: fields.genesis_creation_time,
17401731
slots_per_year: fields.slots_per_year,
1741-
unused: genesis_config.unused,
17421732
slot: fields.slot,
17431733
bank_id: 0,
17441734
epoch: fields.epoch,
@@ -1798,7 +1788,6 @@ impl Bank {
17981788
* genesis_config.ticks_per_slot as u128
17991789
);
18001790
assert_eq!(bank.genesis_creation_time, genesis_config.creation_time);
1801-
assert_eq!(bank.unused, genesis_config.unused);
18021791
assert_eq!(bank.max_tick_height, (bank.slot + 1) * bank.ticks_per_slot);
18031792
assert_eq!(
18041793
bank.slots_per_year,
@@ -1843,7 +1832,6 @@ impl Bank {
18431832
ns_per_slot: self.ns_per_slot,
18441833
genesis_creation_time: self.genesis_creation_time,
18451834
slots_per_year: self.slots_per_year,
1846-
unused: self.unused,
18471835
slot: self.slot,
18481836
epoch: self.epoch,
18491837
block_height: self.block_height,
@@ -1980,11 +1968,6 @@ impl Bank {
19801968
)
19811969
}
19821970

1983-
/// Unused conversion
1984-
pub fn get_unused_from_slot(rooted_slot: Slot, unused: u64) -> u64 {
1985-
(rooted_slot + (unused - 1)) / unused
1986-
}
1987-
19881971
pub fn clock(&self) -> sysvar::clock::Clock {
19891972
from_account(&self.get_account(&sysvar::clock::id()).unwrap_or_default())
19901973
.unwrap_or_default()
@@ -2910,7 +2893,6 @@ impl Bank {
29102893
self.ticks_per_slot = genesis_config.ticks_per_slot();
29112894
self.ns_per_slot = genesis_config.ns_per_slot();
29122895
self.genesis_creation_time = genesis_config.creation_time;
2913-
self.unused = genesis_config.unused;
29142896
self.max_tick_height = (self.slot + 1) * self.ticks_per_slot;
29152897
self.slots_per_year = genesis_config.slots_per_year();
29162898

runtime/src/serde_snapshot/future.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ pub(crate) struct DeserializableVersionedBank {
6363
pub(crate) ns_per_slot: u128,
6464
pub(crate) genesis_creation_time: UnixTimestamp,
6565
pub(crate) slots_per_year: f64,
66+
#[allow(dead_code)]
6667
pub(crate) unused: u64,
6768
pub(crate) slot: Slot,
6869
pub(crate) epoch: Epoch,
@@ -101,7 +102,6 @@ impl From<DeserializableVersionedBank> for BankFieldsToDeserialize {
101102
ns_per_slot: dvb.ns_per_slot,
102103
genesis_creation_time: dvb.genesis_creation_time,
103104
slots_per_year: dvb.slots_per_year,
104-
unused: dvb.unused,
105105
slot: dvb.slot,
106106
epoch: dvb.epoch,
107107
block_height: dvb.block_height,
@@ -160,9 +160,6 @@ pub(crate) struct SerializableVersionedBank<'a> {
160160

161161
impl<'a> From<crate::bank::BankFieldsToSerialize<'a>> for SerializableVersionedBank<'a> {
162162
fn from(rhs: crate::bank::BankFieldsToSerialize<'a>) -> Self {
163-
fn new<T: Default>() -> T {
164-
T::default()
165-
}
166163
Self {
167164
blockhash_queue: rhs.blockhash_queue,
168165
ancestors: rhs.ancestors,
@@ -180,7 +177,7 @@ impl<'a> From<crate::bank::BankFieldsToSerialize<'a>> for SerializableVersionedB
180177
ns_per_slot: rhs.ns_per_slot,
181178
genesis_creation_time: rhs.genesis_creation_time,
182179
slots_per_year: rhs.slots_per_year,
183-
unused: rhs.unused,
180+
unused: u64::default(),
184181
slot: rhs.slot,
185182
epoch: rhs.epoch,
186183
block_height: rhs.block_height,
@@ -193,7 +190,7 @@ impl<'a> From<crate::bank::BankFieldsToSerialize<'a>> for SerializableVersionedB
193190
epoch_schedule: rhs.epoch_schedule,
194191
inflation: rhs.inflation,
195192
stakes: rhs.stakes,
196-
unused_accounts: new(),
193+
unused_accounts: UnusedAccounts::default(),
197194
epoch_stakes: rhs.epoch_stakes,
198195
is_delta: rhs.is_delta,
199196
}

0 commit comments

Comments
 (0)