Skip to content

Commit

Permalink
Merge pull request #1723 from input-output-hk/jpraynaud/1722-fix-ctx-…
Browse files Browse the repository at this point in the history
…prover-performance-more-5-txs

Make Cardano transaction prover able to certify more than 5 transactions
  • Loading branch information
jpraynaud authored Jun 4, 2024
2 parents adec324 + c188939 commit 3b542fd
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/mithril-persistence/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-persistence"
version = "0.2.0"
version = "0.2.1"
description = "Common types, interfaces, and utilities to persist data for Mithril nodes."
authors = { workspace = true }
edition = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,17 @@ impl CardanoTransactionRepository {
&self,
block_ranges: Vec<BlockRange>,
) -> StdResult<Vec<CardanoTransactionRecord>> {
self.connection
.fetch_collect(GetCardanoTransactionQuery::by_block_ranges(block_ranges))
let mut transactions = vec![];
for block_range in block_ranges {
let block_range_transactions: Vec<CardanoTransactionRecord> = self
.connection
.fetch_collect(GetCardanoTransactionQuery::by_block_ranges(vec![
block_range,
]))?;
transactions.extend(block_range_transactions);
}

Ok(transactions)
}

/// Prune the transactions older than the given number of blocks (based on the block range root
Expand Down
2 changes: 1 addition & 1 deletion mithril-aggregator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-aggregator"
version = "0.5.13"
version = "0.5.14"
description = "A Mithril Aggregator server"
authors = { workspace = true }
edition = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion mithril-aggregator/src/dependency_injection/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ impl DependenciesBuilder {
Ok(self.message_service.as_ref().cloned().unwrap())
}

/// build Prover service
/// Build Prover service
pub async fn build_prover_service(&mut self) -> Result<Arc<dyn ProverService>> {
let mk_map_pool_size = self
.configuration
Expand Down
28 changes: 14 additions & 14 deletions mithril-aggregator/src/services/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,18 +374,18 @@ mod tests {
test_data::filter_transactions_for_indices(&[1, 2, 4], &transactions);
let test_data = test_data::build_test_data(&transactions_to_prove, &transactions);
let prover = build_prover(
|retriever_mock| {
|transaction_retriever_mock| {
let transaction_hashes_to_prove = test_data.transaction_hashes_to_prove.clone();
let transactions_to_prove = transactions_to_prove.clone();
retriever_mock
transaction_retriever_mock
.expect_get_by_hashes()
.with(eq(transaction_hashes_to_prove))
.return_once(move |_| Ok(transactions_to_prove));

let block_ranges_to_prove = test_data.block_ranges_to_prove.clone();
let all_transactions_in_block_ranges_to_prove =
test_data.all_transactions_in_block_ranges_to_prove.clone();
retriever_mock
transaction_retriever_mock
.expect_get_by_block_ranges()
.with(eq(block_ranges_to_prove))
.return_once(move |_| Ok(all_transactions_in_block_ranges_to_prove));
Expand Down Expand Up @@ -428,18 +428,18 @@ mod tests {
let mut test_data = test_data::build_test_data(&transactions_to_prove, &transactions);
test_data.transaction_hashes_to_prove = vec!["tx-unknown-123".to_string()];
let prover = build_prover(
|retriever_mock| {
|transaction_retriever_mock| {
let transaction_hashes_to_prove = test_data.transaction_hashes_to_prove.clone();
let transactions_to_prove = transactions_to_prove.clone();
retriever_mock
transaction_retriever_mock
.expect_get_by_hashes()
.with(eq(transaction_hashes_to_prove))
.return_once(move |_| Ok(transactions_to_prove));

let block_ranges_to_prove = test_data.block_ranges_to_prove.clone();
let all_transactions_in_block_ranges_to_prove =
test_data.all_transactions_in_block_ranges_to_prove.clone();
retriever_mock
transaction_retriever_mock
.expect_get_by_block_ranges()
.with(eq(block_ranges_to_prove))
.return_once(move |_| Ok(all_transactions_in_block_ranges_to_prove));
Expand Down Expand Up @@ -485,18 +485,18 @@ mod tests {
]
.concat();
let prover = build_prover(
|retriever_mock| {
|transaction_retriever_mock| {
let transaction_hashes_to_prove = test_data.transaction_hashes_to_prove.clone();
let transactions_to_prove = transactions_to_prove.clone();
retriever_mock
transaction_retriever_mock
.expect_get_by_hashes()
.with(eq(transaction_hashes_to_prove))
.return_once(move |_| Ok(transactions_to_prove));

let block_ranges_to_prove = test_data.block_ranges_to_prove.clone();
let all_transactions_in_block_ranges_to_prove =
test_data.all_transactions_in_block_ranges_to_prove.clone();
retriever_mock
transaction_retriever_mock
.expect_get_by_block_ranges()
.with(eq(block_ranges_to_prove))
.return_once(move |_| Ok(all_transactions_in_block_ranges_to_prove));
Expand Down Expand Up @@ -539,8 +539,8 @@ mod tests {
test_data::filter_transactions_for_indices(&[1, 2, 4], &transactions);
let test_data = test_data::build_test_data(&transactions_to_prove, &transactions);
let prover = build_prover(
|retriever_mock| {
retriever_mock
|transaction_retriever_mock| {
transaction_retriever_mock
.expect_get_by_hashes()
.returning(|_| Err(anyhow!("Error")));
},
Expand Down Expand Up @@ -570,15 +570,15 @@ mod tests {
test_data::filter_transactions_for_indices(&[1, 2, 4], &transactions);
let test_data = test_data::build_test_data(&transactions_to_prove, &transactions);
let prover = build_prover(
|retriever_mock| {
|transaction_retriever_mock| {
let transactions_to_prove = transactions_to_prove.clone();
retriever_mock
transaction_retriever_mock
.expect_get_by_hashes()
.return_once(move |_| Ok(transactions_to_prove));

let all_transactions_in_block_ranges_to_prove =
test_data.all_transactions_in_block_ranges_to_prove.clone();
retriever_mock
transaction_retriever_mock
.expect_get_by_block_ranges()
.return_once(move |_| Ok(all_transactions_in_block_ranges_to_prove));
},
Expand Down

0 comments on commit 3b542fd

Please sign in to comment.