Skip to content

Commit c80f17e

Browse files
Alenarsfauveldlachaume
committed
Adjustements from PR reviews & fix broken doc tests
- Aggregator `cardano_transactions_signing_config.step` from 90 to 120. - Adjusts/fix multiples comments - Add missing types in `mithril-client` re-exported common types. Co-authored-by: Sébastien Fauvel <[email protected]> Co-authored-by: Damien Lachaume <[email protected]>
1 parent 8840169 commit c80f17e

File tree

11 files changed

+27
-22
lines changed

11 files changed

+27
-22
lines changed

internal/mithril-persistence/src/database/repository/cardano_transaction_repository.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl CardanoTransactionRepository {
106106
.fetch_collect(InsertBlockRangeRootQuery::insert_many(records)?)
107107
}
108108

109-
/// Get the highest [BlockNumber] of the cardano transactions stored in the database.
109+
/// Get the highest [ChainPoint] of the cardano transactions stored in the database.
110110
pub async fn get_transaction_highest_chain_point(&self) -> StdResult<Option<ChainPoint>> {
111111
let first_transaction_with_highest_block_number = self
112112
.connection

mithril-aggregator/src/artifact_builder/cardano_transactions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl ArtifactBuilder<BlockNumber, CardanoTransactionsSnapshot>
4343
))
4444
.with_context(|| {
4545
format!(
46-
"Can not compute CardanoTransactionsCommitment artifact for signed_entity: {:?}",
46+
"Can not compute CardanoTransactionsSnapshot artifact for signed_entity: {:?}",
4747
SignedEntityType::CardanoTransactions(certificate.epoch, beacon)
4848
)
4949
})?;

mithril-aggregator/src/configuration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub struct Configuration {
158158
pub cardano_transactions_prover_cache_pool_size: usize,
159159

160160
/// Cardano transactions signing configuration
161-
#[example = "`{ security_parameter: 3000, step: 90 }`"]
161+
#[example = "`{ security_parameter: 3000, step: 120 }`"]
162162
pub cardano_transactions_signing_config: CardanoTransactionsSigningConfig,
163163
}
164164

@@ -405,7 +405,7 @@ impl Default for DefaultConfiguration {
405405
cardano_transactions_prover_cache_pool_size: 10,
406406
cardano_transactions_signing_config: CardanoTransactionsSigningConfig {
407407
security_parameter: 3000,
408-
step: 90,
408+
step: 120,
409409
},
410410
}
411411
}

mithril-aggregator/src/services/signed_entity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl MithrilSignedEntityService {
135135
.await
136136
.with_context(|| {
137137
format!(
138-
"Signed Entity Service can not compute artifact for entity type: '{block_number}'"
138+
"Signed Entity Service can not compute artifact for entity type: '{signed_entity_type}'"
139139
)
140140
})?,
141141
)),

mithril-client/src/cardano_transaction_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
//! let client = ClientBuilder::aggregator("YOUR_AGGREGATOR_ENDPOINT", "YOUR_GENESIS_VERIFICATION_KEY").build()?;
5252
//! let cardano_transaction_snapshot = client.cardano_transaction().get_snapshot("CARDANO_TRANSACTION_SNAPSHOT_HASH").await?.unwrap();
5353
//!
54-
//! println!("Cardano transaction snapshot hash={}, epoch={}", cardano_transaction_snapshot.hash, cardano_transaction_snapshot.beacon.epoch);
54+
//! println!("Cardano transaction snapshot hash={}, epoch={}", cardano_transaction_snapshot.hash, cardano_transaction_snapshot.epoch);
5555
//! # Ok(())
5656
//! # }
5757
//! ```
@@ -68,7 +68,7 @@
6868
//! let cardano_transaction_snapshots = client.cardano_transaction().list_snapshots().await?;
6969
//!
7070
//! for cardano_transaction_snapshot in cardano_transaction_snapshots {
71-
//! println!("Cardano transaction snapshot hash={}, epoch={}", cardano_transaction_snapshot.hash, cardano_transaction_snapshot.beacon.epoch);
71+
//! println!("Cardano transaction snapshot hash={}, epoch={}", cardano_transaction_snapshot.hash, cardano_transaction_snapshot.epoch);
7272
//! }
7373
//! # Ok(())
7474
//! # }

mithril-client/src/type_alias.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ cfg_unstable! {
5757
/// `mithril-common` re-exports
5858
pub mod common {
5959
pub use mithril_common::entities::{
60-
CardanoDbBeacon, CompressionAlgorithm, Epoch, ProtocolMessage, ProtocolMessagePartKey,
61-
ProtocolParameters,
60+
CardanoDbBeacon, CompressionAlgorithm, Epoch, ImmutableFileNumber, ProtocolMessage,
61+
ProtocolMessagePartKey, ProtocolParameters,
6262
};
6363
cfg_unstable! {
64-
pub use mithril_common::entities::{ChainPoint, TransactionHash};
64+
pub use mithril_common::entities::{ChainPoint, TransactionHash, SlotNumber, BlockHash, BlockNumber};
6565
}
6666
}

mithril-common/src/cardano_block_scanner/block_scanner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::digesters::ImmutableFile;
99
use crate::entities::{BlockNumber, ChainPoint, ImmutableFileNumber};
1010
use crate::StdResult;
1111

12-
/// Trait to find the lower bound that should be used the [block scanner][CardanoBlockScanner] when
12+
/// Trait to find the lower bound that should be used by the [block scanner][CardanoBlockScanner] when
1313
/// scanning.
1414
#[cfg_attr(test, mockall::automock)]
1515
#[async_trait]

mithril-common/src/entities/signed_entity_type.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ pub enum SignedEntityType {
5050
///
5151
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
5252
pub struct CardanoTransactionsSigningConfig {
53-
/// Number of blocks to wait before taking in account a transaction.
53+
/// Number of blocks to discard from the tip of the chain when importing transactions.
5454
pub security_parameter: BlockNumber,
5555

56-
/// The frequency at which the transactions are signed.
56+
/// The number of blocks between signature of the transactions.
5757
///
58-
/// *Note: The step is adjusted to be a multiple of the block range length in order.*
58+
/// *Note: The step is adjusted to be a multiple of the block range length in order
59+
/// to guarantee that the block number signed in a certificate is effectively signed.*
5960
pub step: BlockNumber,
6061
}
6162

@@ -70,12 +71,16 @@ impl CardanoTransactionsSigningConfig {
7071
}
7172
}
7273

73-
/// Compute the block number to be signed based on che chain tip block number.
74+
/// Compute the block number to be signed based on the chain tip block number.
75+
///
76+
/// The latest block number to be signed is the highest multiple of the step less or equal than the
77+
/// block number minus the security parameter.
78+
///
79+
/// The formula is as follows:
7480
///
75-
/// Given k' = `security_parameter` and n = `step`,
76-
/// the latest block number to be signed is computed as *(this use a integer division)*:
81+
/// `block_number = ⌊(tip.block_number - security_parameter) / step⌋ × step`
7782
///
78-
/// **block_number = ((tip.block_number - k') / n) × n**
83+
/// where `⌊x⌋` is the floor function which rounds to the greatest integer less than or equal to `x`.
7984
///
8085
/// *Note: The step is adjusted to be a multiple of the block range length in order
8186
/// to guarantee that the block number signed in a certificate is effectively signed.*

mithril-common/src/messages/cardano_transaction_snapshot.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub struct CardanoTransactionSnapshotMessage {
1313
/// Epoch of the Cardano transactions snapshot
1414
pub epoch: Epoch,
1515

16-
/// ChainPoint of the Cardano transactions snapshot
16+
/// Block number of the Cardano transactions snapshot
1717
pub block_number: BlockNumber,
1818

1919
/// Hash of the Cardano Transactions snapshot
@@ -63,7 +63,7 @@ mod tests {
6363

6464
// Test the retro compatibility with possible future upgrades.
6565
#[test]
66-
fn test_v2() {
66+
fn test_v1() {
6767
let json = r#"{
6868
"merkle_root": "mkroot-123",
6969
"epoch": 8,

mithril-common/src/messages/cardano_transaction_snapshot_list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ mod tests {
6565

6666
// Test the retro compatibility with possible future upgrades.
6767
#[test]
68-
fn test_v2() {
68+
fn test_v1() {
6969
let json = r#"[{
7070
"merkle_root": "mkroot-123",
7171
"epoch": 7,

0 commit comments

Comments
 (0)