diff --git a/crates/starknet_gateway/src/sync_state_reader.rs b/crates/starknet_gateway/src/sync_state_reader.rs index 17c9dba820..8fbd809d06 100644 --- a/crates/starknet_gateway/src/sync_state_reader.rs +++ b/crates/starknet_gateway/src/sync_state_reader.rs @@ -2,9 +2,10 @@ use blockifier::execution::contract_class::RunnableCompiledClass; use blockifier::state::errors::StateError; use blockifier::state::state_api::{StateReader as BlockifierStateReader, StateResult}; use futures::executor::block_on; -use starknet_api::block::{BlockInfo, BlockNumber}; +use starknet_api::block::{BlockInfo, BlockNumber, GasPriceVector, GasPrices}; use starknet_api::contract_class::ContractClass; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; +use starknet_api::data_availability::L1DataAvailabilityMode; use starknet_api::state::StorageKey; use starknet_state_sync_types::communication::SharedStateSyncClient; use starknet_types_core::felt::Felt; @@ -28,7 +29,31 @@ impl SyncStateReader { impl MempoolStateReader for SyncStateReader { fn get_block_info(&self) -> StateResult { - todo!() + let block = block_on(self.state_sync_client.get_block(self.block_number)) + .map_err(|e| StateError::StateReadError(e.to_string()))? + .ok_or(StateError::StateReadError("Block not found".to_string()))?; + + let block_header = block.block_header_without_hash; + let block_info = BlockInfo { + block_number: block_header.block_number, + block_timestamp: block_header.timestamp, + sequencer_address: block_header.sequencer.0, + gas_prices: GasPrices { + eth_gas_prices: GasPriceVector { + l1_gas_price: block_header.l1_gas_price.price_in_wei.try_into()?, + l1_data_gas_price: block_header.l1_data_gas_price.price_in_wei.try_into()?, + l2_gas_price: block_header.l2_gas_price.price_in_wei.try_into()?, + }, + strk_gas_prices: GasPriceVector { + l1_gas_price: block_header.l1_gas_price.price_in_fri.try_into()?, + l1_data_gas_price: block_header.l1_data_gas_price.price_in_fri.try_into()?, + l2_gas_price: block_header.l2_gas_price.price_in_fri.try_into()?, + }, + }, + use_kzg_da: matches!(block_header.l1_da_mode, L1DataAvailabilityMode::Blob), + }; + + Ok(block_info) } } diff --git a/crates/starknet_state_sync_types/src/communication.rs b/crates/starknet_state_sync_types/src/communication.rs index 8b3522e9a6..013d5d2647 100644 --- a/crates/starknet_state_sync_types/src/communication.rs +++ b/crates/starknet_state_sync_types/src/communication.rs @@ -69,7 +69,6 @@ pub trait StateSyncClient: Send + Sync { ) -> StateSyncClientResult; // TODO: Add get_compiled_class_hash for StateSyncReader - // TODO: Add get_block_info for StateSyncReader } #[derive(Clone, Debug, Error)]