diff --git a/bin/katana/src/args.rs b/bin/katana/src/args.rs index f8dc48623c..bd42cb97e4 100644 --- a/bin/katana/src/args.rs +++ b/bin/katana/src/args.rs @@ -177,7 +177,7 @@ impl KatanaArgs { pub fn init_logging(&self) -> Result<(), Box> { const DEFAULT_LOG_FILTER: &str = "info,executor=trace,forked_backend=trace,server=debug,\ katana_core=trace,blockifier=off,jsonrpsee_server=off,\ - hyper=off,messaging=debug"; + hyper=off,messaging=debug,node=error"; let builder = fmt::Subscriber::builder().with_env_filter( EnvFilter::try_from_default_env().or(EnvFilter::try_new(DEFAULT_LOG_FILTER))?, diff --git a/crates/katana/core/src/sequencer.rs b/crates/katana/core/src/sequencer.rs index 16c3ca9b7e..adcf173916 100644 --- a/crates/katana/core/src/sequencer.rs +++ b/crates/katana/core/src/sequencer.rs @@ -76,7 +76,9 @@ impl KatanaSequencer { let block_producer = if config.block_time.is_some() || config.no_mining { let block_num = backend.blockchain.provider().latest_number()?; - let block_env = backend.blockchain.provider().block_env_at(block_num.into())?.unwrap(); + let mut block_env = + backend.blockchain.provider().block_env_at(block_num.into())?.unwrap(); + backend.update_block_env(&mut block_env); let cfg_env = backend.chain_cfg_env(); if let Some(interval) = config.block_time { @@ -551,3 +553,32 @@ fn filter_events_by_params( } (filtered_events, index) } + +#[cfg(test)] +mod tests { + use katana_provider::traits::block::BlockNumberProvider; + + use super::{KatanaSequencer, SequencerConfig}; + use crate::backend::config::StarknetConfig; + + #[tokio::test] + async fn init_interval_block_producer_with_correct_block_env() { + let sequencer = KatanaSequencer::new( + SequencerConfig { no_mining: true, ..Default::default() }, + StarknetConfig::default(), + ) + .await + .unwrap(); + + let provider = sequencer.backend.blockchain.provider(); + + let latest_num = provider.latest_number().unwrap(); + let producer_block_env = sequencer.pending_state().unwrap().block_execution_envs().0; + + assert_eq!( + producer_block_env.number, + latest_num + 1, + "Pending block number should be latest block number + 1" + ); + } +} diff --git a/crates/katana/core/src/service/mod.rs b/crates/katana/core/src/service/mod.rs index 30635cc89d..3b803f83da 100644 --- a/crates/katana/core/src/service/mod.rs +++ b/crates/katana/core/src/service/mod.rs @@ -9,7 +9,7 @@ use futures::channel::mpsc::Receiver; use futures::stream::{Fuse, Stream, StreamExt}; use katana_primitives::transaction::ExecutableTxWithHash; use starknet::core::types::FieldElement; -use tracing::trace; +use tracing::{error, trace}; use self::block_producer::BlockProducer; use crate::pool::TransactionPool; @@ -68,7 +68,7 @@ impl Future for NodeService { } Err(err) => { - trace!(target: "node", "failed to mine block: {err}"); + error!(target: "node", "failed to mine block: {err}"); } } } diff --git a/crates/katana/storage/provider/tests/block.rs b/crates/katana/storage/provider/tests/block.rs index 93701dc1bb..e98f871c89 100644 --- a/crates/katana/storage/provider/tests/block.rs +++ b/crates/katana/storage/provider/tests/block.rs @@ -8,7 +8,7 @@ use katana_provider::providers::db::DbProvider; use katana_provider::providers::fork::ForkedProvider; use katana_provider::providers::in_memory::InMemoryProvider; use katana_provider::traits::block::{ - BlockHashProvider, BlockProvider, BlockStatusProvider, BlockWriter, + BlockHashProvider, BlockNumberProvider, BlockProvider, BlockStatusProvider, BlockWriter, }; use katana_provider::traits::env::BlockEnvProvider; use katana_provider::traits::state::StateRootProvider; @@ -69,6 +69,9 @@ where Default::default(), receipts.clone(), )?; + + assert_eq!(provider.latest_number().unwrap(), block.block.header.header.number); + assert_eq!(provider.latest_hash().unwrap(), block.block.header.hash); } let actual_blocks_in_range = provider.blocks_in_range(0..=count)?;