From 384f8e5737882a32fccf0663a354cfb9e22e146b Mon Sep 17 00:00:00 2001 From: Renato Dinhani <101204870+dinhani-cw@users.noreply.github.com> Date: Fri, 15 Mar 2024 10:44:19 -0300 Subject: [PATCH] chore: docs (#368) --- src/bin/importer_offline.rs | 4 ++-- src/eth/executor.rs | 4 ++-- src/eth/storage/permanent_storage.rs | 2 +- src/eth/storage/sled/sled_temporary.rs | 2 -- src/eth/storage/temporary_storage.rs | 4 ++-- tests/test_import_offline_snapshot.rs | 2 +- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/bin/importer_offline.rs b/src/bin/importer_offline.rs index f75b43469..953912b86 100644 --- a/src/bin/importer_offline.rs +++ b/src/bin/importer_offline.rs @@ -98,7 +98,7 @@ async fn execute_block_importer( let start = Instant::now(); match csv { - // when exporting to csv, only persist temporary changes because permanent will be bulk loaded at the end + // when exporting to csv, only persist temporary changes because permanent will be bulk loaded at the end of the process Some(ref mut csv) => { let block = executor.import_external_to_temp(block, &mut receipts).await?; let number = *block.number(); @@ -107,7 +107,7 @@ async fn execute_block_importer( stratus_storage.flush_account_changes_to_temp().await?; } } - // when not exporting to csv, persist the entire block to permanent immediatly + // when not exporting to csv, persist the entire block to permanent immediately None => { executor.import_external_to_perm(block, &mut receipts).await?; } diff --git a/src/eth/executor.rs b/src/eth/executor.rs index f5a5caa39..29f1bca1c 100644 --- a/src/eth/executor.rs +++ b/src/eth/executor.rs @@ -69,7 +69,7 @@ impl EthExecutor { // Transaction execution // ------------------------------------------------------------------------- - /// Re-executes an external block locally and imports it to the storage. + /// Re-executes an external block locally and imports it to the permanent storage. pub async fn import_external_to_perm(&self, block: ExternalBlock, receipts: &mut ExternalReceipts) -> anyhow::Result { // import block let block = self.import_external_to_temp(block, receipts).await?; @@ -85,7 +85,7 @@ impl EthExecutor { Ok(block) } - /// Re-executes an external block locally. + /// Re-executes an external block locally and imports it to the temporary storage. pub async fn import_external_to_temp(&self, block: ExternalBlock, receipts: &mut ExternalReceipts) -> anyhow::Result { let start = Instant::now(); let mut block_metrics = ExecutionMetrics::default(); diff --git a/src/eth/storage/permanent_storage.rs b/src/eth/storage/permanent_storage.rs index 060f01e0f..1b89ed77a 100644 --- a/src/eth/storage/permanent_storage.rs +++ b/src/eth/storage/permanent_storage.rs @@ -26,7 +26,7 @@ pub trait PermanentStorage: Send + Sync { /// Atomically increments the block number, returning the new value. /// - /// TODO: this will probably be removed because set_ and read_ may be enough. + /// TODO: this can probably be removed because set_mined_block_number and set_active_block_number may be enough. async fn increment_block_number(&self) -> anyhow::Result; /// Retrieves an account from the storage. Returns Option when not found. diff --git a/src/eth/storage/sled/sled_temporary.rs b/src/eth/storage/sled/sled_temporary.rs index 8e2db4007..82faf6736 100644 --- a/src/eth/storage/sled/sled_temporary.rs +++ b/src/eth/storage/sled/sled_temporary.rs @@ -11,8 +11,6 @@ use crate::eth::storage::TemporaryStorage; use crate::log_and_err; pub struct SledTemporary { - // keep transactional data in here until flush is called - // sled supports transactions, but I still have to learn how to use it because it accepts a closure instead of returning an object temp: InMemoryTemporaryStorage, db: sled::Db, } diff --git a/src/eth/storage/temporary_storage.rs b/src/eth/storage/temporary_storage.rs index 992bcae97..c13393465 100644 --- a/src/eth/storage/temporary_storage.rs +++ b/src/eth/storage/temporary_storage.rs @@ -10,10 +10,10 @@ use crate::eth::primitives::SlotIndex; /// Temporary storage (in-between blocks) operations #[async_trait] pub trait TemporaryStorage: Send + Sync { - /// Sets the block number being mined. + /// Sets the block number activelly being mined. async fn set_active_block_number(&self, number: BlockNumber) -> anyhow::Result<()>; - // Retrieves the block number being mined. + // Retrieves the block number activelly being mined. async fn read_active_block_number(&self) -> anyhow::Result>; /// Retrieves an account from the storage. Returns Option when not found. diff --git a/tests/test_import_offline_snapshot.rs b/tests/test_import_offline_snapshot.rs index 728e83b44..69250e351 100644 --- a/tests/test_import_offline_snapshot.rs +++ b/tests/test_import_offline_snapshot.rs @@ -94,7 +94,7 @@ async fn test_import_offline_snapshot() { // init executor and execute let storage = Arc::new(StratusStorage::new(Arc::new(InMemoryTemporaryStorage::default()), Arc::new(pg))); let executor = config.init_executor(storage); - executor.import_external_to_temp(block, &mut receipts).await.unwrap(); + executor.import_external_to_perm(block, &mut receipts).await.unwrap(); // get metrics from prometheus // sleep to ensure prometheus collected