Skip to content

Commit

Permalink
Merge pull request AleoNet#2808 from AleoHQ/feat/unconfirmed-tx
Browse files Browse the repository at this point in the history
Switches to use unconfirmed tx
  • Loading branch information
howardwu authored Oct 31, 2023
2 parents ca3e84c + 8155b95 commit 771dcf6
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 17 deletions.
6 changes: 3 additions & 3 deletions node/bft/ledger-service/src/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ impl<N: Network, C: ConsensusStorage<N>> LedgerService<N> for CoreLedgerService<
self.ledger.get_solution(solution_id)
}

/// Returns the transaction for the given transaction ID.
fn get_transaction(&self, transaction_id: N::TransactionID) -> Result<Transaction<N>> {
self.ledger.get_transaction(transaction_id)
/// Returns the unconfirmed transaction for the given transaction ID.
fn get_unconfirmed_transaction(&self, transaction_id: N::TransactionID) -> Result<Transaction<N>> {
self.ledger.get_unconfirmed_transaction(&transaction_id)
}

/// Returns the batch certificate for the given batch certificate ID.
Expand Down
6 changes: 3 additions & 3 deletions node/bft/ledger-service/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ impl<N: Network> LedgerService<N> for MockLedgerService<N> {
unreachable!("MockLedgerService does not support get_solution")
}

/// Returns the transaction for the given transaction ID.
fn get_transaction(&self, _transaction_id: N::TransactionID) -> Result<Transaction<N>> {
unreachable!("MockLedgerService does not support get_transaction")
/// Returns the unconfirmed transaction for the given transaction ID.
fn get_unconfirmed_transaction(&self, _transaction_id: N::TransactionID) -> Result<Transaction<N>> {
unreachable!("MockLedgerService does not support get_unconfirmed_transaction")
}

/// Returns the batch certificate for the given batch certificate ID.
Expand Down
4 changes: 2 additions & 2 deletions node/bft/ledger-service/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ impl<N: Network> LedgerService<N> for ProverLedgerService<N> {
bail!("Solution '{solution_id}' does not exist in prover")
}

/// Returns the transaction for the given transaction ID.
fn get_transaction(&self, transaction_id: N::TransactionID) -> Result<Transaction<N>> {
/// Returns the unconfirmed transaction for the given transaction ID.
fn get_unconfirmed_transaction(&self, transaction_id: N::TransactionID) -> Result<Transaction<N>> {
bail!("Transaction '{transaction_id}' does not exist in prover")
}

Expand Down
4 changes: 2 additions & 2 deletions node/bft/ledger-service/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ pub trait LedgerService<N: Network>: Debug + Send + Sync {
/// Returns the solution for the given solution ID.
fn get_solution(&self, solution_id: &PuzzleCommitment<N>) -> Result<ProverSolution<N>>;

/// Returns the transaction for the given transaction ID.
fn get_transaction(&self, transaction_id: N::TransactionID) -> Result<Transaction<N>>;
/// Returns the unconfirmed transaction for the given transaction ID.
fn get_unconfirmed_transaction(&self, transaction_id: N::TransactionID) -> Result<Transaction<N>>;

/// Returns the batch certificate for the given batch certificate ID.
fn get_batch_certificate(&self, certificate_id: &Field<N>) -> Result<BatchCertificate<N>>;
Expand Down
6 changes: 3 additions & 3 deletions node/bft/ledger-service/src/translucent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ impl<N: Network, C: ConsensusStorage<N>> LedgerService<N> for TranslucentLedgerS
self.inner.get_solution(solution_id)
}

/// Returns the transaction for the given transaction ID.
fn get_transaction(&self, transaction_id: N::TransactionID) -> Result<Transaction<N>> {
self.inner.get_transaction(transaction_id)
/// Returns the unconfirmed transaction for the given transaction ID.
fn get_unconfirmed_transaction(&self, transaction_id: N::TransactionID) -> Result<Transaction<N>> {
self.inner.get_unconfirmed_transaction(transaction_id)
}

/// Returns the batch certificate for the given batch certificate ID.
Expand Down
6 changes: 5 additions & 1 deletion node/bft/src/bft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,11 @@ impl<N: Network> BFT<N> {
}
// Retrieve the transmission.
let Some(transmission) = self.storage().get_transmission(*transmission_id) else {
bail!("BFT failed to retrieve transmission {}", fmt_id(transmission_id));
bail!(
"BFT failed to retrieve transmission '{}' from round {}",
fmt_id(transmission_id),
certificate.round()
);
};
// Add the transmission to the set.
transmissions.insert(*transmission_id, transmission);
Expand Down
4 changes: 2 additions & 2 deletions node/bft/src/helpers/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,8 @@ impl<N: Network> Storage<N> {
match unconfirmed_transactions.remove(transaction_id) {
// Insert the transaction.
Some(transaction) => missing_transmissions.insert(*transmission_id, transaction.into()),
// Otherwise, try to load the transaction from the ledger.
None => match self.ledger.get_transaction(*transaction_id) {
// Otherwise, try to load the unconfirmed transaction from the ledger.
None => match self.ledger.get_unconfirmed_transaction(*transaction_id) {
// Insert the transaction.
Ok(transaction) => missing_transmissions.insert(*transmission_id, transaction.into()),
Err(_) => {
Expand Down
2 changes: 1 addition & 1 deletion node/bft/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ mod tests {
fn get_block(&self, height: u32) -> Result<Block<N>>;
fn get_blocks(&self, heights: Range<u32>) -> Result<Vec<Block<N>>>;
fn get_solution(&self, solution_id: &PuzzleCommitment<N>) -> Result<ProverSolution<N>>;
fn get_transaction(&self, transaction_id: N::TransactionID) -> Result<Transaction<N>>;
fn get_unconfirmed_transaction(&self, transaction_id: N::TransactionID) -> Result<Transaction<N>>;
fn get_batch_certificate(&self, certificate_id: &Field<N>) -> Result<BatchCertificate<N>>;
fn current_committee(&self) -> Result<Committee<N>>;
fn get_committee_for_round(&self, round: u64) -> Result<Committee<N>>;
Expand Down

0 comments on commit 771dcf6

Please sign in to comment.