diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 469d6ad591f27b..b18914f9b07ba4 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -14,9 +14,6 @@ use crate::{ message_processor::{MessageProcessor, ProcessInstruction}, nonce_utils, rent_collector::RentCollector, - serde_utils::{ - deserialize_atomicbool, deserialize_atomicu64, serialize_atomicbool, serialize_atomicu64, - }, stakes::Stakes, status_cache::{SlotDelta, StatusCache}, system_instruction_processor::{self, get_system_account_kind, SystemAccountKind}, @@ -271,23 +268,15 @@ pub struct Bank { hard_forks: Arc>, /// The number of transactions processed without error - #[serde(serialize_with = "serialize_atomicu64")] - #[serde(deserialize_with = "deserialize_atomicu64")] transaction_count: AtomicU64, /// Bank tick height - #[serde(serialize_with = "serialize_atomicu64")] - #[serde(deserialize_with = "deserialize_atomicu64")] tick_height: AtomicU64, /// The number of signatures from valid transactions in this slot - #[serde(serialize_with = "serialize_atomicu64")] - #[serde(deserialize_with = "deserialize_atomicu64")] signature_count: AtomicU64, /// Total capitalization, used to calculate inflation - #[serde(serialize_with = "serialize_atomicu64")] - #[serde(deserialize_with = "deserialize_atomicu64")] capitalization: AtomicU64, // Bank max_tick_height @@ -324,8 +313,6 @@ pub struct Bank { collector_id: Pubkey, /// Fees that have been collected - #[serde(serialize_with = "serialize_atomicu64")] - #[serde(deserialize_with = "deserialize_atomicu64")] collector_fees: AtomicU64, /// Latest transaction fees for transactions processed by this bank @@ -335,8 +322,6 @@ pub struct Bank { fee_rate_governor: FeeRateGovernor, /// Rent that have been collected - #[serde(serialize_with = "serialize_atomicu64")] - #[serde(deserialize_with = "deserialize_atomicu64")] collected_rent: AtomicU64, /// latest rent collector, knows the epoch @@ -360,8 +345,6 @@ pub struct Bank { /// A boolean reflecting whether any entries were recorded into the PoH /// stream for the slot == self.slot - #[serde(serialize_with = "serialize_atomicbool")] - #[serde(deserialize_with = "deserialize_atomicbool")] is_delta: AtomicBool, /// The Message processor diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 4a0edda70e071d..1063242374becf 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -13,7 +13,6 @@ pub mod message_processor; mod native_loader; pub mod nonce_utils; pub mod rent_collector; -mod serde_utils; pub mod stakes; pub mod status_cache; mod system_instruction_processor; diff --git a/runtime/src/serde_utils.rs b/runtime/src/serde_utils.rs deleted file mode 100644 index 527c590e4213c2..00000000000000 --- a/runtime/src/serde_utils.rs +++ /dev/null @@ -1,64 +0,0 @@ -use std::{ - fmt, - sync::atomic::{AtomicBool, AtomicU64, Ordering}, -}; - -struct U64Visitor; -impl<'a> serde::de::Visitor<'a> for U64Visitor { - type Value = u64; - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Expecting u64") - } - fn visit_u64(self, data: u64) -> std::result::Result - where - E: serde::de::Error, - { - Ok(data) - } -} - -pub fn deserialize_atomicu64<'de, D>(d: D) -> Result -where - D: serde::de::Deserializer<'de>, -{ - let value = d.deserialize_u64(U64Visitor)?; - Ok(AtomicU64::new(value)) -} - -pub fn serialize_atomicu64(x: &AtomicU64, s: S) -> Result -where - S: serde::Serializer, -{ - s.serialize_u64(x.load(Ordering::Relaxed)) -} - -struct BoolVisitor; -impl<'a> serde::de::Visitor<'a> for BoolVisitor { - type Value = bool; - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Expecting bool") - } - fn visit_bool(self, data: bool) -> std::result::Result - where - E: serde::de::Error, - { - Ok(data) - } -} - -pub fn deserialize_atomicbool<'de, D>(d: D) -> Result -where - D: serde::de::Deserializer<'de>, -{ - let value = d.deserialize_bool(BoolVisitor)?; - Ok(AtomicBool::new(value)) -} - -pub fn serialize_atomicbool(x: &AtomicBool, s: S) -> Result -where - S: serde::Serializer, -{ - s.serialize_bool(x.load(Ordering::Relaxed)) -}