Skip to content

Commit

Permalink
Merge pull request #2129 from AleoHQ/fix/contains-transaction-checks
Browse files Browse the repository at this point in the history
Fix `contains_transaction_id` check
  • Loading branch information
howardwu authored Oct 26, 2023
2 parents f0e332f + c25392d commit 9f605e8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 1 addition & 4 deletions ledger/src/contains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C> {

/// Returns `true` if the given transaction ID exists.
pub fn contains_transaction_id(&self, transaction_id: &N::TransactionID) -> Result<bool> {
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 */
Expand Down
6 changes: 6 additions & 0 deletions ledger/store/src/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,12 @@ impl<N: Network, B: BlockStorage<N>> BlockStore<N, B> {
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<bool> {
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<bool> {
self.storage.rejected_or_aborted_transaction_id_map().contains_key_confirmed(transaction_id)
Expand Down
4 changes: 1 addition & 3 deletions synthesizer/src/vm/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ impl<N: Network, C: ConsensusStorage<N>> VM<N, C> {
/* 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())
}

Expand Down

0 comments on commit 9f605e8

Please sign in to comment.