diff --git a/api/src/context.rs b/api/src/context.rs index 939276891d81c..4f8cf33054421 100644 --- a/api/src/context.rs +++ b/api/src/context.rs @@ -863,10 +863,9 @@ impl Context { pub fn get_transaction_by_hash( &self, hash: HashValue, - ledger_version: u64, ) -> Result> { self.db - .get_transaction_by_hash(hash, ledger_version, true)? + .get_transaction_by_hash(hash, true)? .map(|t| self.convert_into_transaction_on_chain_data(t)) .transpose() } diff --git a/api/src/transactions.rs b/api/src/transactions.rs index be5a46596f341..7fedb0452ead7 100644 --- a/api/src/transactions.rs +++ b/api/src/transactions.rs @@ -793,11 +793,10 @@ impl TransactionsApi { let context = self.context.clone(); let accept_type = accept_type.clone(); - let ledger_info = - api_spawn_blocking(move || context.get_latest_storage_ledger_info()).await?; + let ledger_info = api_spawn_blocking(move || context.get_latest_ledger_info()).await?; let txn_data = self - .get_by_hash(hash.into(), &ledger_info) + .get_by_hash(hash.into()) .await .context(format!("Failed to get transaction by hash {}", hash)) .map_err(|err| { @@ -837,7 +836,7 @@ impl TransactionsApi { api_spawn_blocking(move || context.get_latest_storage_ledger_info()).await?; let txn_data = self - .get_by_hash(hash.into(), &ledger_info) + .get_by_hash(hash.into()) .await .context(format!("Failed to get transaction by hash {}", hash)) .map_err(|err| { @@ -961,15 +960,12 @@ impl TransactionsApi { async fn get_by_hash( &self, hash: aptos_crypto::HashValue, - ledger_info: &LedgerInfo, ) -> anyhow::Result> { let context = self.context.clone(); - let version = ledger_info.version(); - let from_db = - tokio::task::spawn_blocking(move || context.get_transaction_by_hash(hash, version)) - .await - .context("Failed to join task to read transaction by hash")? - .context("Failed to read transaction by hash from DB")?; + let from_db = tokio::task::spawn_blocking(move || context.get_transaction_by_hash(hash)) + .await + .context("Failed to join task to read transaction by hash")? + .context("Failed to read transaction by hash from DB")?; Ok(match from_db { None => self .context diff --git a/peer-monitoring-service/server/src/tests.rs b/peer-monitoring-service/server/src/tests.rs index 00a213e046d25..583c8c4ffc15c 100644 --- a/peer-monitoring-service/server/src/tests.rs +++ b/peer-monitoring-service/server/src/tests.rs @@ -638,7 +638,6 @@ mod database_mock { fn get_transaction_by_hash( &self, hash: HashValue, - ledger_version: Version, fetch_events: bool, ) -> Result>; diff --git a/state-sync/state-sync-driver/src/tests/mocks.rs b/state-sync/state-sync-driver/src/tests/mocks.rs index 462bd0a76f4ee..cfd7c9b2d9e32 100644 --- a/state-sync/state-sync-driver/src/tests/mocks.rs +++ b/state-sync/state-sync-driver/src/tests/mocks.rs @@ -197,7 +197,6 @@ mock! { fn get_transaction_by_hash( &self, hash: HashValue, - ledger_version: Version, fetch_events: bool, ) -> Result>; diff --git a/state-sync/storage-service/server/src/tests/mock.rs b/state-sync/storage-service/server/src/tests/mock.rs index 2bb41b9cee1aa..bdceee597d0df 100644 --- a/state-sync/storage-service/server/src/tests/mock.rs +++ b/state-sync/storage-service/server/src/tests/mock.rs @@ -245,7 +245,6 @@ mock! { fn get_transaction_by_hash( &self, hash: HashValue, - ledger_version: Version, fetch_events: bool, ) -> aptos_storage_interface::Result>; diff --git a/storage/aptosdb/src/db/include/aptosdb_reader.rs b/storage/aptosdb/src/db/include/aptosdb_reader.rs index 3eac970c72161..d8650e8c5e270 100644 --- a/storage/aptosdb/src/db/include/aptosdb_reader.rs +++ b/storage/aptosdb/src/db/include/aptosdb_reader.rs @@ -125,14 +125,13 @@ impl DbReader for AptosDB { fn get_transaction_by_hash( &self, hash: HashValue, - ledger_version: Version, fetch_events: bool, ) -> Result> { gauged_api("get_transaction_by_hash", || { self.ledger_db .transaction_db() .get_transaction_version_by_hash(&hash)? - .map(|v| self.get_transaction_with_proof(v, ledger_version, fetch_events)) + .map(|v| self.get_transaction_with_proof(v, v, fetch_events)) .transpose() }) } diff --git a/storage/aptosdb/src/db/test_helper.rs b/storage/aptosdb/src/db/test_helper.rs index 570bdf8bd4433..9e5a293dd521a 100644 --- a/storage/aptosdb/src/db/test_helper.rs +++ b/storage/aptosdb/src/db/test_helper.rs @@ -832,7 +832,7 @@ pub fn verify_committed_transactions( .try_as_signed_user_txn() .unwrap(); let txn_with_proof = db - .get_transaction_by_hash(txn_to_commit.transaction().hash(), ledger_version, true) + .get_transaction_by_hash(txn_to_commit.transaction().hash(), true) .unwrap() .unwrap(); assert_eq!( diff --git a/storage/aptosdb/src/ledger_db/transaction_db_test.rs b/storage/aptosdb/src/ledger_db/transaction_db_test.rs index 8e490c1439224..52d4cd17d1ed7 100644 --- a/storage/aptosdb/src/ledger_db/transaction_db_test.rs +++ b/storage/aptosdb/src/ledger_db/transaction_db_test.rs @@ -34,6 +34,9 @@ proptest! { let hash = txn.hash(); prop_assert_eq!(transaction_db.get_transaction(version as Version).unwrap(), txn); prop_assert_eq!(transaction_db.get_transaction_version_by_hash(&hash).unwrap(), Some(version as Version)); + if version > 0 { + prop_assert_eq!(transaction_db.get_transaction_version_by_hash(&hash).unwrap(), None); + } } prop_assert!(transaction_db.get_transaction(num_txns as Version).is_err()); diff --git a/storage/storage-interface/src/lib.rs b/storage/storage-interface/src/lib.rs index ff09eca5e7095..06288d8b91845 100644 --- a/storage/storage-interface/src/lib.rs +++ b/storage/storage-interface/src/lib.rs @@ -148,7 +148,6 @@ pub trait DbReader: Send + Sync { fn get_transaction_by_hash( &self, hash: HashValue, - ledger_version: Version, fetch_events: bool, ) -> Result>;