From 68063e9d26ec75fbd31695d9d7a3ecd50908e2f0 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 25 Oct 2023 20:48:08 -0400 Subject: [PATCH 1/3] Add contains_transaction_id to BlockStore --- ledger/store/src/block/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ledger/store/src/block/mod.rs b/ledger/store/src/block/mod.rs index f44dd30f14..335b934526 100644 --- a/ledger/store/src/block/mod.rs +++ b/ledger/store/src/block/mod.rs @@ -1238,6 +1238,12 @@ impl> BlockStore { self.storage.reverse_id_map().contains_key_confirmed(block_hash) } + /// Returns `true` if the given transaction ID exists. + pub fn contains_transaction_id(&self, transaction_id: &N::TransactionID) -> Result { + Ok(self.transaction_store().contains_transaction_id(transaction_id)? + || self.contains_rejected_or_aborted_transaction_id(transaction_id)?) + } + /// Returns `true` if the given rejected or aborted transaction ID exists. pub fn contains_rejected_or_aborted_transaction_id(&self, transaction_id: &N::TransactionID) -> Result { self.storage.rejected_or_aborted_transaction_id_map().contains_key_confirmed(transaction_id) From 2b4c8d38f6c4ed1f7839d207ab103b70c4367780 Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 25 Oct 2023 20:48:47 -0400 Subject: [PATCH 2/3] Update Ledger::contains_transaction_id --- ledger/src/contains.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ledger/src/contains.rs b/ledger/src/contains.rs index d7d5310c87..64a52bbda5 100644 --- a/ledger/src/contains.rs +++ b/ledger/src/contains.rs @@ -58,10 +58,7 @@ impl> Ledger { /// Returns `true` if the given transaction ID exists. pub fn contains_transaction_id(&self, transaction_id: &N::TransactionID) -> Result { - self.vm - .transaction_store() - .contains_transaction_id(transaction_id) - .or(self.vm.block_store().contains_rejected_or_aborted_transaction_id(transaction_id)) + self.vm.block_store().contains_transaction_id(transaction_id) } /* Transition */ From c25392d367d4000d5ccbe4a4e7a84f669fca7a2d Mon Sep 17 00:00:00 2001 From: raychu86 <14917648+raychu86@users.noreply.github.com> Date: Wed, 25 Oct 2023 20:51:00 -0400 Subject: [PATCH 3/3] Update check_transaction --- synthesizer/src/vm/verify.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/synthesizer/src/vm/verify.rs b/synthesizer/src/vm/verify.rs index 2a40dfbdb4..d94be9addc 100644 --- a/synthesizer/src/vm/verify.rs +++ b/synthesizer/src/vm/verify.rs @@ -40,9 +40,7 @@ impl> VM { /* Transaction */ // Ensure the transaction ID is unique. - if self.transaction_store().contains_transaction_id(&transaction.id())? - || self.block_store().contains_rejected_or_aborted_transaction_id(&transaction.id())? - { + if self.block_store().contains_transaction_id(&transaction.id())? { bail!("Transaction '{}' already exists in the ledger", transaction.id()) }