@@ -275,23 +275,21 @@ impl Blockchain {
275275 ChainError :: WitnessGeneration ( "Failed to access account from trie" . to_string ( ) )
276276 } ) ?;
277277 // Get storage trie at before updates
278- if !acc_keys. is_empty ( ) {
279- if let Ok ( Some ( storage_trie) ) = self . storage . storage_trie ( parent_hash, * account)
280- {
281- let ( storage_trie_witness, storage_trie) =
282- TrieLogger :: open_trie ( storage_trie) ;
283- // Access all the keys
284- for storage_key in acc_keys {
285- let hashed_key = hash_key ( storage_key) ;
286- storage_trie. get ( & hashed_key) . map_err ( |_e| {
287- ChainError :: WitnessGeneration (
288- "Failed to access storage key" . to_string ( ) ,
289- )
290- } ) ?;
291- }
292- // Store the tries to reuse when applying account updates
293- used_storage_tries. insert ( * account, ( storage_trie_witness, storage_trie) ) ;
278+ if !acc_keys. is_empty ( )
279+ && let Ok ( Some ( storage_trie) ) = self . storage . storage_trie ( parent_hash, * account)
280+ {
281+ let ( storage_trie_witness, storage_trie) = TrieLogger :: open_trie ( storage_trie) ;
282+ // Access all the keys
283+ for storage_key in acc_keys {
284+ let hashed_key = hash_key ( storage_key) ;
285+ storage_trie. get ( & hashed_key) . map_err ( |_e| {
286+ ChainError :: WitnessGeneration (
287+ "Failed to access storage key" . to_string ( ) ,
288+ )
289+ } ) ?;
294290 }
291+ // Store the tries to reuse when applying account updates
292+ used_storage_tries. insert ( * account, ( storage_trie_witness, storage_trie) ) ;
295293 }
296294 }
297295 // Store all the accessed evm bytecodes
@@ -343,10 +341,10 @@ impl Blockchain {
343341 let state_trie_witness = std:: mem:: take ( & mut * state_trie_witness) ;
344342 used_trie_nodes. extend_from_slice ( & Vec :: from_iter ( state_trie_witness. into_iter ( ) ) ) ;
345343 // If the witness is empty at least try to store the root
346- if used_trie_nodes. is_empty ( ) {
347- if let Some ( root) = root_node {
348- used_trie_nodes . push ( root . encode_raw ( ) ) ;
349- }
344+ if used_trie_nodes. is_empty ( )
345+ && let Some ( root) = root_node
346+ {
347+ used_trie_nodes . push ( root . encode_raw ( ) ) ;
350348 }
351349
352350 let mut needed_block_numbers = block_hashes. keys ( ) . collect :: < Vec < _ > > ( ) ;
@@ -361,10 +359,10 @@ impl Blockchain {
361359 . saturating_sub ( 1 ) ;
362360 // The first block number we need is either the parent of the first block number or the earliest block number used by BLOCKHASH
363361 let mut first_needed_block_number = first_block_header. number . saturating_sub ( 1 ) ;
364- if let Some ( block_number_from_logger) = needed_block_numbers. first ( ) {
365- if * * block_number_from_logger < first_needed_block_number {
366- first_needed_block_number = * * block_number_from_logger ;
367- }
362+ if let Some ( block_number_from_logger) = needed_block_numbers. first ( )
363+ && * * block_number_from_logger < first_needed_block_number
364+ {
365+ first_needed_block_number = * * block_number_from_logger ;
368366 }
369367 let mut block_headers_bytes = Vec :: new ( ) ;
370368 for block_number in first_needed_block_number..=last_needed_block_number {
@@ -851,10 +849,11 @@ impl Blockchain {
851849 // If it exists check if the new tx has higher fees
852850 let tx_to_replace_hash = self . mempool . find_tx_to_replace ( sender, nonce, tx) ?;
853851
854- if let Some ( chain_id) = tx. chain_id ( ) {
855- if chain_id != config. chain_id {
856- return Err ( MempoolError :: InvalidChainId ( config. chain_id ) ) ;
857- }
852+ if tx
853+ . chain_id ( )
854+ . is_some_and ( |chain_id| chain_id != config. chain_id )
855+ {
856+ return Err ( MempoolError :: InvalidChainId ( config. chain_id ) ) ;
858857 }
859858
860859 Ok ( tx_to_replace_hash)
@@ -1072,12 +1071,12 @@ pub fn validate_gas_used(
10721071 receipts : & [ Receipt ] ,
10731072 block_header : & BlockHeader ,
10741073) -> Result < ( ) , ChainError > {
1075- if let Some ( last) = receipts. last ( ) {
1076- if last. cumulative_gas_used != block_header. gas_used {
1077- return Err ( ChainError :: InvalidBlock (
1078- InvalidBlockError :: GasUsedMismatch ( last . cumulative_gas_used , block_header . gas_used ) ,
1079- ) ) ;
1080- }
1074+ if let Some ( last) = receipts. last ( )
1075+ && last. cumulative_gas_used != block_header. gas_used
1076+ {
1077+ return Err ( ChainError :: InvalidBlock (
1078+ InvalidBlockError :: GasUsedMismatch ( last . cumulative_gas_used , block_header . gas_used ) ,
1079+ ) ) ;
10811080 }
10821081 Ok ( ( ) )
10831082}
0 commit comments