@@ -2927,6 +2927,13 @@ impl Bank {
29272927 }
29282928
29292929 // On epoch boundaries, update epoch_start_timestamp
2930+ //
2931+ // Note: the genesis block's bank is created via new_from_genesis, which calls update_clock
2932+ // unconditionally. In update_clock, we have a check for whether slot == 0, and if that's
2933+ // the case, the clock is set to self.unix_timestamp_from_genesis().
2934+ //
2935+ // As a result, we don't actually need the (0, _) case below, since it's never invoked.
2936+ // However, include this for completeness in the match statement.
29302937 let unix_timestamp_s = unix_timestamp_nanos / 1_000_000_000 ;
29312938 let epoch_start_timestamp = match ( self . slot , self . parent ( ) ) {
29322939 ( 0 , _) => self . unix_timestamp_from_genesis ( ) ,
@@ -2953,23 +2960,19 @@ impl Bank {
29532960 } ) ;
29542961
29552962 // Update Alpenglow clock
2956- let alpenclock_size = wincode:: serialized_size ( & unix_timestamp_nanos) . unwrap ( ) ;
2957- let lamports = Rent :: default ( ) . minimum_balance ( alpenclock_size as usize ) ;
2958- let alpenclock_account_data =
2959- AccountSharedData :: new_data ( lamports, & unix_timestamp_nanos, & system_program:: ID )
2960- . unwrap ( ) ;
2963+ let data = wincode:: serialize ( & unix_timestamp_nanos) . unwrap ( ) ;
2964+ let lamports = Rent :: default ( ) . minimum_balance ( data. len ( ) ) ;
2965+ let mut alpenclock_acct = AccountSharedData :: new ( lamports, data. len ( ) , & system_program:: ID ) ;
2966+ alpenclock_acct. set_data_from_slice ( & data) ;
29612967
2962- self . store_account_and_update_capitalization (
2963- & NANOSECOND_CLOCK_ACCOUNT ,
2964- & alpenclock_account_data,
2965- ) ;
2968+ self . store_account_and_update_capitalization ( & NANOSECOND_CLOCK_ACCOUNT , & alpenclock_acct) ;
29662969 }
29672970
29682971 /// Get the nanosecond clock value. Returns `None` if the nanosecond clock has not been
29692972 /// populated (i.e., before Alpenglow migration completes).
29702973 pub fn get_nanosecond_clock ( & self ) -> Option < i64 > {
29712974 self . get_account ( & NANOSECOND_CLOCK_ACCOUNT ) . map ( |acct| {
2972- acct. deserialize_data ( )
2975+ wincode :: deserialize ( acct. data ( ) )
29732976 . expect ( "Couldn't deserialize nanosecond resolution clock" )
29742977 } )
29752978 }
0 commit comments