From c480966cea5987fea644968225a7bf762777ca4b Mon Sep 17 00:00:00 2001 From: Alon Lukatch Date: Tue, 17 Dec 2024 13:31:07 +0200 Subject: [PATCH] chore(papyrus_storage): rename events table to emitter_to_events --- crates/papyrus_storage/src/body/events.rs | 4 ++-- crates/papyrus_storage/src/body/events_test.rs | 8 ++++---- crates/papyrus_storage/src/body/mod.rs | 8 ++++---- crates/papyrus_storage/src/lib.rs | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/papyrus_storage/src/body/events.rs b/crates/papyrus_storage/src/body/events.rs index b4cfe849c3..22410c1565 100644 --- a/crates/papyrus_storage/src/body/events.rs +++ b/crates/papyrus_storage/src/body/events.rs @@ -265,8 +265,8 @@ where key: (ContractAddress, EventIndex), ) -> StorageResult> { let transaction_metadata_table = self.open_table(&self.tables.transaction_metadata)?; - let events_table = self.open_table(&self.tables.events)?; - let mut cursor = events_table.cursor(&self.txn)?; + let emitter_to_events_table = self.open_table(&self.tables.emitter_to_events)?; + let mut cursor = emitter_to_events_table.cursor(&self.txn)?; let events_queue = if let Some((contract_address, tx_index)) = cursor.lower_bound(&(key.0, key.1.0))?.map(|(key, _)| key) { diff --git a/crates/papyrus_storage/src/body/events_test.rs b/crates/papyrus_storage/src/body/events_test.rs index 9bf024b4b4..e48879805d 100644 --- a/crates/papyrus_storage/src/body/events_test.rs +++ b/crates/papyrus_storage/src/body/events_test.rs @@ -162,12 +162,12 @@ fn revert_events() { // Test events raw table. let txn = storage_reader.begin_ro_txn().unwrap(); - let events_table = txn.txn.open_table(&txn.tables.events).unwrap(); + let emitter_to_events_table = txn.txn.open_table(&txn.tables.emitter_to_events).unwrap(); for (tx_idx, tx_output) in block.body.transaction_outputs.iter().enumerate() { let transaction_index = TransactionIndex(block_number, TransactionOffsetInBlock(tx_idx)); for event in tx_output.events().iter() { assert_matches!( - events_table.get(&txn.txn, &(event.from_address, transaction_index)), + emitter_to_events_table.get(&txn.txn, &(event.from_address, transaction_index)), Ok(Some(_)) ); } @@ -195,12 +195,12 @@ fn revert_events() { ); let txn = storage_reader.begin_ro_txn().unwrap(); - let events_table = txn.txn.open_table(&txn.tables.events).unwrap(); + let emitter_to_events_table = txn.txn.open_table(&txn.tables.emitter_to_events).unwrap(); for (tx_idx, tx_output) in block.body.transaction_outputs.iter().enumerate() { let transaction_index = TransactionIndex(block_number, TransactionOffsetInBlock(tx_idx)); for event in tx_output.events().iter() { assert_matches!( - events_table.get(&txn.txn, &(event.from_address, transaction_index)), + emitter_to_events_table.get(&txn.txn, &(event.from_address, transaction_index)), Ok(None) ); } diff --git a/crates/papyrus_storage/src/body/mod.rs b/crates/papyrus_storage/src/body/mod.rs index 4a560715f1..2f7c54f1b6 100644 --- a/crates/papyrus_storage/src/body/mod.rs +++ b/crates/papyrus_storage/src/body/mod.rs @@ -348,7 +348,7 @@ impl BodyStorageWriter for StorageTxn<'_, RW> { update_marker(&self.txn, &markers_table, block_number)?; if self.scope != StorageScope::StateOnly { - let events_table = self.open_table(&self.tables.events)?; + let emitter_to_events_table = self.open_table(&self.tables.emitter_to_events)?; let transaction_hash_to_idx_table = self.open_table(&self.tables.transaction_hash_to_idx)?; let transaction_metadata_table = self.open_table(&self.tables.transaction_metadata)?; @@ -361,7 +361,7 @@ impl BodyStorageWriter for StorageTxn<'_, RW> { &file_offset_table, &transaction_hash_to_idx_table, &transaction_metadata_table, - &events_table, + &emitter_to_events_table, block_number, )?; } @@ -397,7 +397,7 @@ impl BodyStorageWriter for StorageTxn<'_, RW> { let transaction_metadata_table = self.open_table(&self.tables.transaction_metadata)?; let transaction_hash_to_idx_table = self.open_table(&self.tables.transaction_hash_to_idx)?; - let events_table = self.open_table(&self.tables.events)?; + let emitter_to_events_table = self.open_table(&self.tables.emitter_to_events)?; let transactions = self .get_block_transactions(block_number)? @@ -416,7 +416,7 @@ impl BodyStorageWriter for StorageTxn<'_, RW> { let tx_index = TransactionIndex(block_number, TransactionOffsetInBlock(offset)); for event in tx_output.events().iter() { - events_table.delete(&self.txn, &(event.from_address, tx_index))?; + emitter_to_events_table.delete(&self.txn, &(event.from_address, tx_index))?; } transaction_hash_to_idx_table.delete(&self.txn, tx_hash)?; transaction_metadata_table.delete(&self.txn, &tx_index)?; diff --git a/crates/papyrus_storage/src/lib.rs b/crates/papyrus_storage/src/lib.rs index 7bcb8e67a7..e9492eb3f4 100644 --- a/crates/papyrus_storage/src/lib.rs +++ b/crates/papyrus_storage/src/lib.rs @@ -181,7 +181,7 @@ pub fn open_storage( deprecated_declared_classes: db_writer .create_simple_table("deprecated_declared_classes")?, deployed_contracts: db_writer.create_simple_table("deployed_contracts")?, - events: db_writer.create_common_prefix_table("events")?, + emitter_to_events: db_writer.create_common_prefix_table("emitter_to_events")?, headers: db_writer.create_simple_table("headers")?, markers: db_writer.create_simple_table("markers")?, nonces: db_writer.create_common_prefix_table("nonces")?, @@ -495,7 +495,7 @@ impl StorageTxn<'_, Mode> { ) -> StorageResult> { if self.scope == StorageScope::StateOnly { let unused_tables = [ - self.tables.events.name, + self.tables.emitter_to_events.name, self.tables.transaction_hash_to_idx.name, self.tables.transaction_metadata.name, ]; @@ -528,7 +528,7 @@ struct_field_names! { deprecated_declared_classes: TableIdentifier, SimpleTable>, // TODO(dvir): consider use here also the CommonPrefix table type. deployed_contracts: TableIdentifier<(ContractAddress, BlockNumber), VersionZeroWrapper, SimpleTable>, - events: TableIdentifier<(ContractAddress, TransactionIndex), NoVersionValueWrapper, CommonPrefix>, + emitter_to_events: TableIdentifier<(ContractAddress, TransactionIndex), NoVersionValueWrapper, CommonPrefix>, headers: TableIdentifier, SimpleTable>, markers: TableIdentifier, SimpleTable>, nonces: TableIdentifier<(ContractAddress, BlockNumber), VersionZeroWrapper, CommonPrefix>,