From 08f622d06f998f6890d548388d7b3f62c9493ba0 Mon Sep 17 00:00:00 2001 From: rymnc <43716372+rymnc@users.noreply.github.com> Date: Fri, 21 Mar 2025 21:43:16 +0530 Subject: [PATCH 1/7] fix(compression_service): post merge reviews --- crates/fuel-core/src/database.rs | 3 ++ .../database_description/compression.rs | 2 +- crates/fuel-core/src/graphql_api/storage.rs | 8 ++-- .../service/adapters/compression_adapters.rs | 13 +---- .../src/state/in_memory/memory_store.rs | 10 +++- .../compression/src/ports/block_source.rs | 48 ++++++++++--------- crates/services/compression/src/service.rs | 45 +++++++++-------- crates/storage/src/merkle/column.rs | 23 +++++---- 8 files changed, 82 insertions(+), 70 deletions(-) diff --git a/crates/fuel-core/src/database.rs b/crates/fuel-core/src/database.rs index 0b88b5992e3..1b01c036db3 100644 --- a/crates/fuel-core/src/database.rs +++ b/crates/fuel-core/src/database.rs @@ -825,6 +825,9 @@ mod tests { }; use fuel_core_storage::transactional::WriteTransaction; + // this invariant doesn't hold anymore + // because we have removed columns from the storage + #[ignore] #[test] fn column_keys_not_exceed_count_test() { column_keys_not_exceed_count::(); diff --git a/crates/fuel-core/src/database/database_description/compression.rs b/crates/fuel-core/src/database/database_description/compression.rs index 3cb94016135..d19817e0566 100644 --- a/crates/fuel-core/src/database/database_description/compression.rs +++ b/crates/fuel-core/src/database/database_description/compression.rs @@ -19,7 +19,7 @@ impl DatabaseDescription for CompressionDatabase { } fn metadata_column() -> Self::Column { - Self::Column::MerkleMetadataColumn + Self::Column::Metadata } fn prefix(_column: &Self::Column) -> Option { diff --git a/crates/fuel-core/src/graphql_api/storage.rs b/crates/fuel-core/src/graphql_api/storage.rs index 420782a5aa8..e0f69602915 100644 --- a/crates/fuel-core/src/graphql_api/storage.rs +++ b/crates/fuel-core/src/graphql_api/storage.rs @@ -96,13 +96,13 @@ pub enum Column { /// See [`SpentMessages`](messages::SpentMessages) SpentMessages = 13, /// Coin balances per account and asset. - CoinBalances = 14, + CoinBalances = 23, /// Message balances per account. - MessageBalances = 15, + MessageBalances = 24, /// See [`AssetsInfo`](assets::AssetsInfo) - AssetsInfo = 16, + AssetsInfo = 25, /// Index of the coins that are available to spend. - CoinsToSpend = 17, + CoinsToSpend = 26, } impl Column { diff --git a/crates/fuel-core/src/service/adapters/compression_adapters.rs b/crates/fuel-core/src/service/adapters/compression_adapters.rs index e3f8776910d..916a308337f 100644 --- a/crates/fuel-core/src/service/adapters/compression_adapters.rs +++ b/crates/fuel-core/src/service/adapters/compression_adapters.rs @@ -12,20 +12,11 @@ use fuel_core_compression_service::{ configuration, }, }; -use fuel_core_services::stream::IntoBoxStream; +use fuel_core_types::services::block_importer::SharedImportResult; impl block_source::BlockSource for BlockImporterAdapter { - fn subscribe( - &self, - ) -> fuel_core_services::stream::BoxStream { - use futures::StreamExt; + fn subscribe(&self) -> fuel_core_services::stream::BoxStream { self.events_shared_result() - .map(|result| { - let sealed_block = result.sealed_block.clone(); - let events = result.events.clone(); - block_source::BlockWithMetadata::new(sealed_block.entity, events) - }) - .into_boxed() } } diff --git a/crates/fuel-core/src/state/in_memory/memory_store.rs b/crates/fuel-core/src/state/in_memory/memory_store.rs index 335eb88ae2c..7f720feb2bd 100644 --- a/crates/fuel-core/src/state/in_memory/memory_store.rs +++ b/crates/fuel-core/src/state/in_memory/memory_store.rs @@ -63,9 +63,15 @@ where Description: DatabaseDescription, { fn default() -> Self { - use strum::EnumCount; + use enum_iterator::all; + + let largest_column_idx = all::() + .map(|column| column.as_usize()) + .max() + .expect("there should be atleast 1 column in the storage"); + Self { - inner: (0..Description::Column::COUNT) + inner: (0..=largest_column_idx) .map(|_| Mutex::new(BTreeMap::new())) .collect(), _marker: Default::default(), diff --git a/crates/services/compression/src/ports/block_source.rs b/crates/services/compression/src/ports/block_source.rs index 453ba2e582b..a11ed95963f 100644 --- a/crates/services/compression/src/ports/block_source.rs +++ b/crates/services/compression/src/ports/block_source.rs @@ -1,35 +1,37 @@ use fuel_core_services::stream::BoxStream; - -/// Block with metadata needed for compression -#[cfg_attr(feature = "test-helpers", derive(Default))] -#[derive(Clone, Debug)] -pub struct BlockWithMetadata { - block: fuel_core_types::blockchain::block::Block, - // todo: perhaps slice with lifetime? (https://github.com/FuelLabs/fuel-core/issues/2870) - events: Vec, -} +pub(crate) use fuel_core_types::services::block_importer::SharedImportResult as BlockWithMetadata; pub(crate) type BlockHeight = u32; -impl BlockWithMetadata { - /// Create a new block with metadata - pub fn new( - block: fuel_core_types::blockchain::block::Block, - events: Vec, - ) -> Self { - Self { block, events } +// we can't define a newtype that wraps over SharedImportResult because its `dyn Deref` +pub(crate) mod block_helpers { + use super::*; + + /// Get events from BlockWithMetadata + pub(crate) fn events( + block_with_metadata: &BlockWithMetadata, + ) -> &[fuel_core_types::services::executor::Event] { + block_with_metadata.events.as_ref() } - pub(crate) fn height(&self) -> BlockHeight { - (*self.block.header().height()).into() + /// Get sealed block from BlockWithMetadata + pub(crate) fn block( + block_with_metadata: &BlockWithMetadata, + ) -> &fuel_core_types::blockchain::block::Block { + &block_with_metadata.sealed_block.entity } - pub(crate) fn events(&self) -> &[fuel_core_types::services::executor::Event] { - &self.events + /// Get block height from BlockWithMetadata + pub(crate) fn height(block_with_metadata: &BlockWithMetadata) -> &BlockHeight { + block(block_with_metadata).header().height() } - pub(crate) fn block(&self) -> &fuel_core_types::blockchain::block::Block { - &self.block + /// Get the default BlockWithMetadata + #[cfg(test)] + pub fn default() -> BlockWithMetadata { + std::sync::Arc::new( + fuel_core_types::services::block_importer::ImportResult::default(), + ) } } @@ -39,5 +41,5 @@ pub type BlockStream = BoxStream; /// Port for L2 blocks source pub trait BlockSource { /// Should provide a stream of blocks with metadata - fn subscribe(&self) -> BoxStream; + fn subscribe(&self) -> BlockStream; } diff --git a/crates/services/compression/src/service.rs b/crates/services/compression/src/service.rs index 30702a22fa6..6826cc12210 100644 --- a/crates/services/compression/src/service.rs +++ b/crates/services/compression/src/service.rs @@ -1,7 +1,11 @@ use crate::{ config::CompressionConfig, ports::{ - block_source::BlockSource, + block_source::{ + block_helpers, + BlockSource, + BlockWithMetadata, + }, compression_storage::{ CompressionStorage, WriteCompressedBlock, @@ -71,7 +75,7 @@ where { fn compress_block( &mut self, - block_with_metadata: &crate::ports::block_source::BlockWithMetadata, + block_with_metadata: &BlockWithMetadata, ) -> crate::Result<()> { let mut storage_tx = self.storage.write_transaction(); @@ -80,19 +84,21 @@ where compression_storage: CompressionStorageWrapper { storage_tx: &mut storage_tx, }, - block_events: block_with_metadata.events(), + block_events: block_helpers::events(block_with_metadata), }; let compressed_block = compress( self.config.into(), compression_context, - block_with_metadata.block(), + block_helpers::block(block_with_metadata), ) .now_or_never() .expect("The current implementation should resolve all futures instantly") .map_err(crate::errors::CompressionError::FailedToCompressBlock)?; - storage_tx - .write_compressed_block(&block_with_metadata.height(), &compressed_block)?; + storage_tx.write_compressed_block( + block_helpers::height(block_with_metadata), + &compressed_block, + )?; storage_tx .commit() @@ -103,26 +109,20 @@ where fn handle_new_block( &mut self, - block_with_metadata: &crate::ports::block_source::BlockWithMetadata, + block_with_metadata: &BlockWithMetadata, ) -> crate::Result<()> { // set the status to not synced - if let Err(err) = self - .sync_notifier + self.sync_notifier .send(crate::sync_state::SyncState::NotSynced) - { - tracing::error!("Failed to set sync status to not synced: {:?}", err); - } + .ok(); // compress the block self.compress_block(block_with_metadata)?; // set the status to synced - if let Err(err) = self - .sync_notifier + self.sync_notifier .send(crate::sync_state::SyncState::Synced( - block_with_metadata.height(), + *block_helpers::height(block_with_metadata), )) - { - tracing::error!("Failed to set sync status to synced: {:?}", err); - } + .ok(); Ok(()) } } @@ -203,7 +203,7 @@ where fuel_core_services::TaskNextAction::Stop } Some(block_with_metadata) => { - tracing::debug!("Got new block: {:?}", block_with_metadata.height()); + tracing::debug!("Got new block: {:?}", block_helpers::height(&block_with_metadata)); if let Err(e) = self.handle_new_block(&block_with_metadata) { tracing::error!("Error handling new block: {:?}", e); return fuel_core_services::TaskNextAction::ErrorContinue(anyhow::anyhow!(e)); @@ -245,7 +245,10 @@ where mod tests { use super::*; use crate::{ - ports::block_source::BlockWithMetadata, + ports::block_source::{ + block_helpers, + BlockWithMetadata, + }, storage, }; use fuel_core_services::{ @@ -358,7 +361,7 @@ mod tests { async fn compression_service__run__compresses_blocks() { // given // we provide a block source that will return a block upon calling .next() - let block_with_metadata = BlockWithMetadata::default(); + let block_with_metadata = block_helpers::default(); let block_source = MockBlockSource::new(vec![block_with_metadata]); let storage = test_storage(); let config_provider = MockConfigProvider::default(); diff --git a/crates/storage/src/merkle/column.rs b/crates/storage/src/merkle/column.rs index 0faa56c6d30..61b489f402a 100644 --- a/crates/storage/src/merkle/column.rs +++ b/crates/storage/src/merkle/column.rs @@ -22,12 +22,14 @@ use alloc::{ strum_macros::IntoStaticStr, )] pub enum MerkleizedColumn { + /// The Metadata column (non-merkleized) + Metadata, + /// The merkleized metadata column. + MerkleMetadataColumn, /// The column with the specific data. TableColumn(TC), /// The column with the merkle tree nodes. MerkleDataColumn(TC), - /// The merkle metadata column. - MerkleMetadataColumn, } impl strum::EnumCount for MerkleizedColumn @@ -36,8 +38,8 @@ where { /// The total count of variants in the enum. /// Since we have two columns for each table column and one for the merkle data, - /// we have to multiply the count of the table columns by 2 and add one for the merkle metadata. - const COUNT: usize = TC::COUNT * 2 + 1; + /// we have to multiply the count of the table columns by 2 and add 2 for the metadata tables. + const COUNT: usize = TC::COUNT * 2 + 2; } /// The trait to convert the column to the `u32`. @@ -56,9 +58,12 @@ where /// The start of the merkle data columns. pub const MERKLE_DATA_COLUMNS_START: u32 = u16::MAX as u32; + /// The metadata column (non-merkleized) + pub const METADATA_COLUMN: u32 = 0; + /// The merkle metadata column - // we set it to 0, since any future column updates will be added after this column - pub const MERKLE_METADATA_COLUMN: u32 = 0; + // we set it to 1, since any future column updates will be added after this column + pub const MERKLE_METADATA_COLUMN: u32 = 1; #[inline] fn with_metadata_offset(column: u32) -> u32 { @@ -68,11 +73,12 @@ where /// Returns the `u32` representation of the `Column`. pub fn as_u32(&self) -> u32 { match self { + Self::Metadata => Self::METADATA_COLUMN, + Self::MerkleMetadataColumn => Self::MERKLE_METADATA_COLUMN, Self::TableColumn(column) => Self::with_metadata_offset(column.as_u32()), Self::MerkleDataColumn(column) => Self::with_metadata_offset( Self::MERKLE_DATA_COLUMNS_START.wrapping_add(column.as_u32()), ), - Self::MerkleMetadataColumn => Self::MERKLE_METADATA_COLUMN, } } } @@ -83,13 +89,14 @@ where { fn name(&self) -> String { match self { + Self::Metadata => "Metadata".to_string(), + MerkleizedColumn::MerkleMetadataColumn => "MerkleMetadata".to_string(), Self::TableColumn(column) => { format!("{:?}", column) } Self::MerkleDataColumn(column) => { format!("Merkle{:?}", column) } - MerkleizedColumn::MerkleMetadataColumn => "MerkleMetadata".to_string(), } } From 36cd3b48f18c63b75c523933ba1c42fa000a10e5 Mon Sep 17 00:00:00 2001 From: rymnc <43716372+rymnc@users.noreply.github.com> Date: Mon, 24 Mar 2025 16:44:50 +0530 Subject: [PATCH 2/7] chore: display that it doesnt work --- .../compression/src/ports/block_source.rs | 37 +++++++++---------- crates/services/compression/src/service.rs | 16 ++++---- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/crates/services/compression/src/ports/block_source.rs b/crates/services/compression/src/ports/block_source.rs index a11ed95963f..e473e130313 100644 --- a/crates/services/compression/src/ports/block_source.rs +++ b/crates/services/compression/src/ports/block_source.rs @@ -3,32 +3,31 @@ pub(crate) use fuel_core_types::services::block_importer::SharedImportResult as pub(crate) type BlockHeight = u32; -// we can't define a newtype that wraps over SharedImportResult because its `dyn Deref` -pub(crate) mod block_helpers { - use super::*; - - /// Get events from BlockWithMetadata - pub(crate) fn events( - block_with_metadata: &BlockWithMetadata, - ) -> &[fuel_core_types::services::executor::Event] { - block_with_metadata.events.as_ref() +pub(crate) trait BlockWithMetadataExt { + fn height(&self) -> &BlockHeight; + fn block(&self) -> &fuel_core_types::blockchain::block::Block; + fn events(&self) -> &[fuel_core_types::services::executor::Event]; + #[cfg(test)] + fn default() -> BlockWithMetadata; +} + +impl BlockWithMetadataExt for BlockWithMetadata { + fn height(&self) -> &BlockHeight { + ::block(self) + .header() + .height() } - /// Get sealed block from BlockWithMetadata - pub(crate) fn block( - block_with_metadata: &BlockWithMetadata, - ) -> &fuel_core_types::blockchain::block::Block { - &block_with_metadata.sealed_block.entity + fn block(&self) -> &fuel_core_types::blockchain::block::Block { + &self.sealed_block.entity } - /// Get block height from BlockWithMetadata - pub(crate) fn height(block_with_metadata: &BlockWithMetadata) -> &BlockHeight { - block(block_with_metadata).header().height() + fn events(&self) -> &[fuel_core_types::services::executor::Event] { + self.events.as_ref() } - /// Get the default BlockWithMetadata #[cfg(test)] - pub fn default() -> BlockWithMetadata { + fn default() -> BlockWithMetadata { std::sync::Arc::new( fuel_core_types::services::block_importer::ImportResult::default(), ) diff --git a/crates/services/compression/src/service.rs b/crates/services/compression/src/service.rs index 6826cc12210..f2640986efd 100644 --- a/crates/services/compression/src/service.rs +++ b/crates/services/compression/src/service.rs @@ -2,9 +2,9 @@ use crate::{ config::CompressionConfig, ports::{ block_source::{ - block_helpers, BlockSource, BlockWithMetadata, + BlockWithMetadataExt, }, compression_storage::{ CompressionStorage, @@ -84,21 +84,19 @@ where compression_storage: CompressionStorageWrapper { storage_tx: &mut storage_tx, }, - block_events: block_helpers::events(block_with_metadata), + block_events: block_with_metadata.events(), }; let compressed_block = compress( self.config.into(), compression_context, - block_helpers::block(block_with_metadata), + block_with_metadata.block(), ) .now_or_never() .expect("The current implementation should resolve all futures instantly") .map_err(crate::errors::CompressionError::FailedToCompressBlock)?; - storage_tx.write_compressed_block( - block_helpers::height(block_with_metadata), - &compressed_block, - )?; + storage_tx + .write_compressed_block(block_with_metadata.height(), &compressed_block)?; storage_tx .commit() @@ -120,7 +118,7 @@ where // set the status to synced self.sync_notifier .send(crate::sync_state::SyncState::Synced( - *block_helpers::height(block_with_metadata), + *block_with_metadata.height(), )) .ok(); Ok(()) @@ -203,7 +201,7 @@ where fuel_core_services::TaskNextAction::Stop } Some(block_with_metadata) => { - tracing::debug!("Got new block: {:?}", block_helpers::height(&block_with_metadata)); + tracing::debug!("Got new block: {:?}", &block_with_metadata.height()); if let Err(e) = self.handle_new_block(&block_with_metadata) { tracing::error!("Error handling new block: {:?}", e); return fuel_core_services::TaskNextAction::ErrorContinue(anyhow::anyhow!(e)); From 44d1918f04b8bdb0d52648fa6412ac0bc78ffa26 Mon Sep 17 00:00:00 2001 From: rymnc <43716372+rymnc@users.noreply.github.com> Date: Mon, 24 Mar 2025 18:56:28 +0530 Subject: [PATCH 3/7] Revert "chore: display that it doesnt work" This reverts commit ea5a67246bc9741494c061d7529664e02b999b8c. --- .../compression/src/ports/block_source.rs | 37 ++++++++++--------- crates/services/compression/src/service.rs | 16 ++++---- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/crates/services/compression/src/ports/block_source.rs b/crates/services/compression/src/ports/block_source.rs index e473e130313..a11ed95963f 100644 --- a/crates/services/compression/src/ports/block_source.rs +++ b/crates/services/compression/src/ports/block_source.rs @@ -3,31 +3,32 @@ pub(crate) use fuel_core_types::services::block_importer::SharedImportResult as pub(crate) type BlockHeight = u32; -pub(crate) trait BlockWithMetadataExt { - fn height(&self) -> &BlockHeight; - fn block(&self) -> &fuel_core_types::blockchain::block::Block; - fn events(&self) -> &[fuel_core_types::services::executor::Event]; - #[cfg(test)] - fn default() -> BlockWithMetadata; -} - -impl BlockWithMetadataExt for BlockWithMetadata { - fn height(&self) -> &BlockHeight { - ::block(self) - .header() - .height() +// we can't define a newtype that wraps over SharedImportResult because its `dyn Deref` +pub(crate) mod block_helpers { + use super::*; + + /// Get events from BlockWithMetadata + pub(crate) fn events( + block_with_metadata: &BlockWithMetadata, + ) -> &[fuel_core_types::services::executor::Event] { + block_with_metadata.events.as_ref() } - fn block(&self) -> &fuel_core_types::blockchain::block::Block { - &self.sealed_block.entity + /// Get sealed block from BlockWithMetadata + pub(crate) fn block( + block_with_metadata: &BlockWithMetadata, + ) -> &fuel_core_types::blockchain::block::Block { + &block_with_metadata.sealed_block.entity } - fn events(&self) -> &[fuel_core_types::services::executor::Event] { - self.events.as_ref() + /// Get block height from BlockWithMetadata + pub(crate) fn height(block_with_metadata: &BlockWithMetadata) -> &BlockHeight { + block(block_with_metadata).header().height() } + /// Get the default BlockWithMetadata #[cfg(test)] - fn default() -> BlockWithMetadata { + pub fn default() -> BlockWithMetadata { std::sync::Arc::new( fuel_core_types::services::block_importer::ImportResult::default(), ) diff --git a/crates/services/compression/src/service.rs b/crates/services/compression/src/service.rs index f2640986efd..6826cc12210 100644 --- a/crates/services/compression/src/service.rs +++ b/crates/services/compression/src/service.rs @@ -2,9 +2,9 @@ use crate::{ config::CompressionConfig, ports::{ block_source::{ + block_helpers, BlockSource, BlockWithMetadata, - BlockWithMetadataExt, }, compression_storage::{ CompressionStorage, @@ -84,19 +84,21 @@ where compression_storage: CompressionStorageWrapper { storage_tx: &mut storage_tx, }, - block_events: block_with_metadata.events(), + block_events: block_helpers::events(block_with_metadata), }; let compressed_block = compress( self.config.into(), compression_context, - block_with_metadata.block(), + block_helpers::block(block_with_metadata), ) .now_or_never() .expect("The current implementation should resolve all futures instantly") .map_err(crate::errors::CompressionError::FailedToCompressBlock)?; - storage_tx - .write_compressed_block(block_with_metadata.height(), &compressed_block)?; + storage_tx.write_compressed_block( + block_helpers::height(block_with_metadata), + &compressed_block, + )?; storage_tx .commit() @@ -118,7 +120,7 @@ where // set the status to synced self.sync_notifier .send(crate::sync_state::SyncState::Synced( - *block_with_metadata.height(), + *block_helpers::height(block_with_metadata), )) .ok(); Ok(()) @@ -201,7 +203,7 @@ where fuel_core_services::TaskNextAction::Stop } Some(block_with_metadata) => { - tracing::debug!("Got new block: {:?}", &block_with_metadata.height()); + tracing::debug!("Got new block: {:?}", block_helpers::height(&block_with_metadata)); if let Err(e) = self.handle_new_block(&block_with_metadata) { tracing::error!("Error handling new block: {:?}", e); return fuel_core_services::TaskNextAction::ErrorContinue(anyhow::anyhow!(e)); From 4790befc398a920556465fcbea78003c346d8c26 Mon Sep 17 00:00:00 2001 From: rymnc <43716372+rymnc@users.noreply.github.com> Date: Tue, 25 Mar 2025 14:52:56 +0530 Subject: [PATCH 4/7] fix: use helper trait now that it works --- .../compression/src/ports/block_source.rs | 43 +++++++++---------- crates/services/compression/src/service.rs | 20 ++++----- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/crates/services/compression/src/ports/block_source.rs b/crates/services/compression/src/ports/block_source.rs index a11ed95963f..baad818798e 100644 --- a/crates/services/compression/src/ports/block_source.rs +++ b/crates/services/compression/src/ports/block_source.rs @@ -3,35 +3,34 @@ pub(crate) use fuel_core_types::services::block_importer::SharedImportResult as pub(crate) type BlockHeight = u32; -// we can't define a newtype that wraps over SharedImportResult because its `dyn Deref` -pub(crate) mod block_helpers { - use super::*; - - /// Get events from BlockWithMetadata - pub(crate) fn events( - block_with_metadata: &BlockWithMetadata, - ) -> &[fuel_core_types::services::executor::Event] { - block_with_metadata.events.as_ref() +pub(crate) trait BlockWithMetadataExt { + fn height(&self) -> &BlockHeight; + fn events(&self) -> &[fuel_core_types::services::executor::Event]; + fn block(&self) -> &fuel_core_types::blockchain::block::Block; + #[cfg(test)] + fn default() -> Self; +} + +impl BlockWithMetadataExt for BlockWithMetadata { + fn events(&self) -> &[fuel_core_types::services::executor::Event] { + self.events.as_ref() } - /// Get sealed block from BlockWithMetadata - pub(crate) fn block( - block_with_metadata: &BlockWithMetadata, - ) -> &fuel_core_types::blockchain::block::Block { - &block_with_metadata.sealed_block.entity + fn height(&self) -> &BlockHeight { + ::block(&self) + .header() + .height() } - /// Get block height from BlockWithMetadata - pub(crate) fn height(block_with_metadata: &BlockWithMetadata) -> &BlockHeight { - block(block_with_metadata).header().height() + fn block(&self) -> &fuel_core_types::blockchain::block::Block { + &self.sealed_block.entity } - /// Get the default BlockWithMetadata #[cfg(test)] - pub fn default() -> BlockWithMetadata { - std::sync::Arc::new( - fuel_core_types::services::block_importer::ImportResult::default(), - ) + fn default() -> Self { + use fuel_core_types::services::block_importer::ImportResult; + + std::sync::Arc::new(ImportResult::default().wrap()) } } diff --git a/crates/services/compression/src/service.rs b/crates/services/compression/src/service.rs index 6826cc12210..e434b7d03c0 100644 --- a/crates/services/compression/src/service.rs +++ b/crates/services/compression/src/service.rs @@ -2,9 +2,9 @@ use crate::{ config::CompressionConfig, ports::{ block_source::{ - block_helpers, BlockSource, BlockWithMetadata, + BlockWithMetadataExt, }, compression_storage::{ CompressionStorage, @@ -84,21 +84,19 @@ where compression_storage: CompressionStorageWrapper { storage_tx: &mut storage_tx, }, - block_events: block_helpers::events(block_with_metadata), + block_events: &block_with_metadata.events(), }; let compressed_block = compress( self.config.into(), compression_context, - block_helpers::block(block_with_metadata), + block_with_metadata.block(), ) .now_or_never() .expect("The current implementation should resolve all futures instantly") .map_err(crate::errors::CompressionError::FailedToCompressBlock)?; - storage_tx.write_compressed_block( - block_helpers::height(block_with_metadata), - &compressed_block, - )?; + storage_tx + .write_compressed_block(block_with_metadata.height(), &compressed_block)?; storage_tx .commit() @@ -120,7 +118,7 @@ where // set the status to synced self.sync_notifier .send(crate::sync_state::SyncState::Synced( - *block_helpers::height(block_with_metadata), + *block_with_metadata.height(), )) .ok(); Ok(()) @@ -203,7 +201,7 @@ where fuel_core_services::TaskNextAction::Stop } Some(block_with_metadata) => { - tracing::debug!("Got new block: {:?}", block_helpers::height(&block_with_metadata)); + tracing::debug!("Got new block: {:?}", &block_with_metadata.height()); if let Err(e) = self.handle_new_block(&block_with_metadata) { tracing::error!("Error handling new block: {:?}", e); return fuel_core_services::TaskNextAction::ErrorContinue(anyhow::anyhow!(e)); @@ -246,8 +244,8 @@ mod tests { use super::*; use crate::{ ports::block_source::{ - block_helpers, BlockWithMetadata, + BlockWithMetadataExt, }, storage, }; @@ -361,7 +359,7 @@ mod tests { async fn compression_service__run__compresses_blocks() { // given // we provide a block source that will return a block upon calling .next() - let block_with_metadata = block_helpers::default(); + let block_with_metadata = BlockWithMetadata::default(); let block_source = MockBlockSource::new(vec![block_with_metadata]); let storage = test_storage(); let config_provider = MockConfigProvider::default(); From 4a9b3d88f9c5726831d2853c0c67ebcf97b5c132 Mon Sep 17 00:00:00 2001 From: Aaryamann Challani <43716372+rymnc@users.noreply.github.com> Date: Tue, 25 Mar 2025 15:14:51 +0530 Subject: [PATCH 5/7] fix: clippy --- crates/services/compression/src/ports/block_source.rs | 2 +- crates/services/compression/src/service.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/services/compression/src/ports/block_source.rs b/crates/services/compression/src/ports/block_source.rs index baad818798e..74515717d7e 100644 --- a/crates/services/compression/src/ports/block_source.rs +++ b/crates/services/compression/src/ports/block_source.rs @@ -17,7 +17,7 @@ impl BlockWithMetadataExt for BlockWithMetadata { } fn height(&self) -> &BlockHeight { - ::block(&self) + ::block(self) .header() .height() } diff --git a/crates/services/compression/src/service.rs b/crates/services/compression/src/service.rs index e434b7d03c0..ba8126ab485 100644 --- a/crates/services/compression/src/service.rs +++ b/crates/services/compression/src/service.rs @@ -84,7 +84,7 @@ where compression_storage: CompressionStorageWrapper { storage_tx: &mut storage_tx, }, - block_events: &block_with_metadata.events(), + block_events: block_with_metadata.events(), }; let compressed_block = compress( self.config.into(), From a7dd92895132547632f20d0e8608d6cf03295ffb Mon Sep 17 00:00:00 2001 From: rymnc <43716372+rymnc@users.noreply.github.com> Date: Tue, 25 Mar 2025 19:07:21 +0530 Subject: [PATCH 6/7] fix: implicit self --- crates/services/compression/src/ports/block_source.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/services/compression/src/ports/block_source.rs b/crates/services/compression/src/ports/block_source.rs index 74515717d7e..abd43cd220a 100644 --- a/crates/services/compression/src/ports/block_source.rs +++ b/crates/services/compression/src/ports/block_source.rs @@ -17,9 +17,7 @@ impl BlockWithMetadataExt for BlockWithMetadata { } fn height(&self) -> &BlockHeight { - ::block(self) - .header() - .height() + self.block().header().height() } fn block(&self) -> &fuel_core_types::blockchain::block::Block { From c439f86b4dd0045b6d22bef9a2430cb2a68893b5 Mon Sep 17 00:00:00 2001 From: rymnc <43716372+rymnc@users.noreply.github.com> Date: Wed, 26 Mar 2025 01:37:36 +0530 Subject: [PATCH 7/7] fix: remove test altogether --- crates/fuel-core/src/database.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/crates/fuel-core/src/database.rs b/crates/fuel-core/src/database.rs index 1b01c036db3..2a532edc8c5 100644 --- a/crates/fuel-core/src/database.rs +++ b/crates/fuel-core/src/database.rs @@ -825,14 +825,6 @@ mod tests { }; use fuel_core_storage::transactional::WriteTransaction; - // this invariant doesn't hold anymore - // because we have removed columns from the storage - #[ignore] - #[test] - fn column_keys_not_exceed_count_test() { - column_keys_not_exceed_count::(); - } - #[test] fn database_advances_with_a_new_block() { // Given