@@ -28,15 +28,8 @@ use blockifier::state::state_reader_and_contract_manager::{
2828} ;
2929use blockifier:: transaction:: transaction_execution:: Transaction as BlockifierTransaction ;
3030use serde:: Serialize ;
31- use serde_json:: { json, to_value, Value } ;
32- use starknet_api:: block:: {
33- BlockHash ,
34- BlockHashAndNumber ,
35- BlockInfo ,
36- BlockNumber ,
37- GasPricePerToken ,
38- StarknetVersion ,
39- } ;
31+ use serde_json:: { json, Value } ;
32+ use starknet_api:: block:: { BlockHash , BlockHashAndNumber , BlockInfo , BlockNumber , StarknetVersion } ;
4033use starknet_api:: core:: { ChainId , ClassHash , CompiledClassHash , ContractAddress , Nonce } ;
4134use starknet_api:: state:: { SierraContractClass , StorageKey } ;
4235use starknet_api:: transaction:: { Transaction , TransactionHash } ;
@@ -231,32 +224,21 @@ impl RpcStateReader {
231224 RpcStateReader :: new ( & get_rpc_state_reader_config ( ) , ChainId :: Mainnet , block_number, false )
232225 }
233226
234- /// Get the block info of the current block.
235- /// If l2_gas_price is not present in the block header, it will be set to 1.
236- pub fn get_block_info ( & self ) -> ReexecutionResult < BlockInfo > {
237- let mut json = retry_request ! ( self . retry_config, || {
227+ /// Get the block header of the current block.
228+ pub fn get_block_header ( & self ) -> ReexecutionResult < BlockHeader > {
229+ let json = retry_request ! ( self . retry_config, || {
238230 self . rpc_state_reader. send_rpc_request(
239231 "starknet_getBlockWithTxHashes" ,
240232 GetBlockWithTxHashesParams { block_id: self . rpc_state_reader. block_id } ,
241233 )
242234 } ) ?;
243235
244- let block_header_map = json. as_object_mut ( ) . ok_or ( StateError :: StateReadError (
245- "starknet_getBlockWithTxHashes should return JSON value of type Object" . to_string ( ) ,
246- ) ) ?;
247-
248- if block_header_map. get ( "l2_gas_price" ) . is_none ( ) {
249- // In old blocks, the l2_gas_price field is not present.
250- block_header_map. insert (
251- "l2_gas_price" . to_string ( ) ,
252- to_value ( GasPricePerToken {
253- price_in_wei : 1_u8 . into ( ) ,
254- price_in_fri : 1_u8 . into ( ) ,
255- } ) ?,
256- ) ;
257- }
236+ Ok ( serde_json:: from_value :: < BlockHeader > ( json) ?)
237+ }
258238
259- Ok ( serde_json:: from_value :: < BlockHeader > ( json) ?. try_into ( ) ?)
239+ /// Get the block info of the current block.
240+ pub fn get_block_info ( & self ) -> ReexecutionResult < BlockInfo > {
241+ Ok ( self . get_block_header ( ) ?. try_into ( ) ?)
260242 }
261243
262244 pub fn get_starknet_version ( & self ) -> ReexecutionResult < StarknetVersion > {
0 commit comments