Skip to content

Commit 298ebb9

Browse files
committed
Merge branch 'main' into feat/split-kes-period-functions
2 parents 9cae5c5 + a52e282 commit 298ebb9

File tree

242 files changed

+3069
-4370
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

242 files changed

+3069
-4370
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,13 @@ jobs:
266266
matrix:
267267
mode: [ "std" ]
268268
era: ${{ fromJSON(needs.build-ubuntu-X64.outputs.eras) }}
269-
cardano_node_version: [ "8.7.3" ]
269+
cardano_node_version: [ "8.7.3", "8.8.1-pre", "8.9.0" ]
270270
hard_fork_latest_era_at_epoch: [ 0,10,100 ]
271-
run_id: [ "#1","#2" ]
271+
run_id: [ "#1" ]
272272
extra_args: [ "" ]
273273

274274
include:
275-
# Include a hard fork test for `8.1.2` which is not concerned
275+
# Include a test for `8.1.2` which is not concerned by the hard fork
276276
- mode: "std"
277277
era: ${{ fromJSON(needs.build-ubuntu-X64.outputs.eras)[0] }}
278278
cardano_node_version: "8.1.2"
@@ -527,7 +527,7 @@ jobs:
527527
version-name: unstable-${{ steps.slug.outputs.sha8 }}
528528
download-url-base: ${{ github.server_url }}/${{ github.repository }}/releases/download/unstable
529529
gpg-secret-key: ${{ secrets.GPG_SECRET_KEY }}
530-
compatibility-table: '{ "release-mainnet": "⛔", "release-preprod": "⛔", "pre-release-preview": "⛔", "testing-preview": "✔" }'
530+
compatibility-table: '{ "release-mainnet": "⛔", "release-preprod": "⛔", "pre-release-preview": "⛔", "testing-preview": "✔", "testing-sanchonet": "✔" }'
531531

532532
- name: Update unstable release
533533
uses: marvinpinto/action-automatic-releases@latest

.github/workflows/pre-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
version-name: ${{ github.ref_name }}
6565
download-url-base: ${{ github.server_url }}/${{ github.repository }}/releases/download/${{ github.ref_name }}
6666
gpg-secret-key: ${{ secrets.GPG_SECRET_KEY }}
67-
compatibility-table: '{ "release-mainnet": "⛔", "release-preprod": "⛔", "pre-release-preview": "✔", "testing-preview": "✔" }'
67+
compatibility-table: '{ "release-mainnet": "⛔", "release-preprod": "⛔", "pre-release-preview": "✔", "testing-preview": "✔", "testing-sanchonet": "✔" }'
6868

6969
- name: Create pre-release ${{ github.ref_name }}
7070
uses: marvinpinto/action-automatic-releases@latest

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-aggregator/Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ RUN /app/target/release/mithril-aggregator --version
3232
FROM debian:11-slim
3333

3434
# Args
35-
ARG CARDANO_NODE_VERSION=8.7.3
35+
ARG CARDANO_NODE_VERSION=8.9.0
3636
ARG CARDANO_BIN_URL=https://github.com/input-output-hk/cardano-node/releases/download/$CARDANO_NODE_VERSION/cardano-node-$CARDANO_NODE_VERSION-linux.tar.gz
3737

3838
# Upgrade
@@ -47,16 +47,16 @@ COPY --from=rustbuilder /app/target/release/mithril-aggregator /app/bin/mithril-
4747
# Copy the config files
4848
COPY --from=rustbuilder /app/mithril-aggregator/config /app/config
4949

50-
#Workdir
51-
WORKDIR /app/
52-
RUN chown -R appuser /app/
53-
5450
# Install cardano-cli
5551
RUN wget -nv -O cardano-bin.tar.gz $CARDANO_BIN_URL
56-
RUN tar xzf cardano-bin.tar.gz ./cardano-cli && mv cardano-cli /app/bin
52+
RUN (tar xzf cardano-bin.tar.gz ./bin/cardano-cli && mv /bin/cardano-cli /app/bin) || (tar xzf cardano-bin.tar.gz ./cardano-cli && mv cardano-cli /app/bin)
5753
RUN /app/bin/cardano-cli --version
5854
RUN rm -f cardano-bin.tar.gz
5955

56+
#Workdir
57+
WORKDIR /app/
58+
RUN chown -R appuser /app/
59+
6060
# Use an unprivileged user
6161
USER appuser
6262

mithril-aggregator/Dockerfile.ci

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ RUN mkdir -p /app/bin
1414
RUN apt-get update -y && apt-get install -y libssl-dev ca-certificates wget && apt-get clean && rm -rf /var/lib/apt/lists/*
1515

1616
# Install cardano-cli
17-
ARG CARDANO_NODE_VERSION=8.7.3
17+
ARG CARDANO_NODE_VERSION=8.9.0
1818
ARG CARDANO_BIN_URL=https://github.com/input-output-hk/cardano-node/releases/download/$CARDANO_NODE_VERSION/cardano-node-$CARDANO_NODE_VERSION-linux.tar.gz
1919
RUN wget -nv -O cardano-bin.tar.gz $CARDANO_BIN_URL \
20-
&& tar xzf cardano-bin.tar.gz ./cardano-cli && mv cardano-cli /app/bin \
20+
&& (tar xzf cardano-bin.tar.gz ./bin/cardano-cli && mv /bin/cardano-cli /app/bin) || (tar xzf cardano-bin.tar.gz ./cardano-cli && mv cardano-cli /app/bin) \
2121
&& /app/bin/cardano-cli --version \
2222
&& rm -f cardano-bin.tar.gz
2323

mithril-aggregator/src/http_server/routes/proof_routes.rs

Lines changed: 64 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ fn proof_cardano_transaction(
3737
}
3838

3939
mod handlers {
40+
use mithril_common::{
41+
entities::{CardanoTransactionsSnapshot, SignedEntity},
42+
messages::CardanoTransactionsProofsMessage,
43+
StdResult,
44+
};
4045
use reqwest::StatusCode;
4146
use slog_scope::{debug, warn};
4247
use std::{convert::Infallible, sync::Arc};
@@ -72,23 +77,9 @@ mod handlers {
7277
"proof_cardano_transaction::error"
7378
) {
7479
Some(signed_entity) => {
75-
let transactions_set_proofs = unwrap_to_internal_server_error!(
76-
prover_service
77-
.compute_transactions_proofs(
78-
&signed_entity.artifact.beacon,
79-
transaction_hashes.as_slice(),
80-
)
81-
.await,
82-
"proof_cardano_transaction::error"
83-
);
84-
8580
let message = unwrap_to_internal_server_error!(
86-
ToCardanoTransactionsProofsMessageAdapter::try_adapt(
87-
&signed_entity.certificate_id,
88-
transactions_set_proofs,
89-
transaction_hashes,
90-
),
91-
"proof_cardano_transaction::error"
81+
build_response_message(prover_service, signed_entity, transaction_hashes).await,
82+
"proof_cardano_transaction"
9283
);
9384
Ok(reply::json(&message, StatusCode::OK))
9485
}
@@ -98,14 +89,34 @@ mod handlers {
9889
}
9990
}
10091
}
92+
93+
pub async fn build_response_message(
94+
prover_service: Arc<dyn ProverService>,
95+
signed_entity: SignedEntity<CardanoTransactionsSnapshot>,
96+
transaction_hashes: Vec<String>,
97+
) -> StdResult<CardanoTransactionsProofsMessage> {
98+
let transactions_set_proofs = prover_service
99+
.compute_transactions_proofs(
100+
&signed_entity.artifact.beacon,
101+
transaction_hashes.as_slice(),
102+
)
103+
.await?;
104+
let message = ToCardanoTransactionsProofsMessageAdapter::try_adapt(
105+
signed_entity,
106+
transactions_set_proofs,
107+
transaction_hashes,
108+
)?;
109+
110+
Ok(message)
111+
}
101112
}
102113

103114
#[cfg(test)]
104115
mod tests {
105116
use super::*;
106117
use std::vec;
107118

108-
use mithril_common::test_utils::apispec::APISpec;
119+
use mithril_common::{entities::Beacon, test_utils::apispec::APISpec};
109120

110121
use anyhow::anyhow;
111122
use mithril_common::entities::{
@@ -136,6 +147,42 @@ mod tests {
136147
.and(routes(dependency_manager).with(cors))
137148
}
138149

150+
#[tokio::test]
151+
async fn build_response_message_return_immutable_file_number_from_artifact_beacon() {
152+
// Arrange
153+
let mut mock_prover_service = MockProverService::new();
154+
mock_prover_service
155+
.expect_compute_transactions_proofs()
156+
.returning(|_, _| Ok(vec![CardanoTransactionsSetProof::dummy()]));
157+
158+
let cardano_transactions_snapshot = {
159+
let merkle_root = String::new();
160+
let beacon = Beacon {
161+
immutable_file_number: 2309,
162+
..Beacon::default()
163+
};
164+
CardanoTransactionsSnapshot::new(merkle_root, beacon)
165+
};
166+
167+
let signed_entity = SignedEntity::<CardanoTransactionsSnapshot> {
168+
artifact: cardano_transactions_snapshot,
169+
..SignedEntity::<CardanoTransactionsSnapshot>::dummy()
170+
};
171+
172+
// Action
173+
let transaction_hashes = vec![];
174+
let message = handlers::build_response_message(
175+
Arc::new(mock_prover_service),
176+
signed_entity,
177+
transaction_hashes,
178+
)
179+
.await
180+
.unwrap();
181+
182+
// Assert
183+
assert_eq!(message.latest_immutable_file_number, 2309)
184+
}
185+
139186
#[tokio::test]
140187
async fn proof_cardano_transaction_ok() {
141188
let config = Configuration::new_sample();

mithril-aggregator/src/message_adapters/to_cardano_transactions_proof_message.rs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use mithril_common::entities::{CardanoTransactionsSnapshot, SignedEntity};
12
use mithril_common::messages::CardanoTransactionsSetProofMessagePart;
23
use mithril_common::{
34
entities::{CardanoTransactionsSetProof, TransactionHash},
@@ -11,7 +12,7 @@ pub struct ToCardanoTransactionsProofsMessageAdapter;
1112
impl ToCardanoTransactionsProofsMessageAdapter {
1213
/// Turn an entity instance into message.
1314
pub fn try_adapt(
14-
certificate_hash: &str,
15+
signed_entity: SignedEntity<CardanoTransactionsSnapshot>,
1516
transactions_set_proofs: Vec<CardanoTransactionsSetProof>,
1617
transaction_hashes_to_certify: Vec<TransactionHash>,
1718
) -> StdResult<CardanoTransactionsProofsMessage> {
@@ -21,9 +22,10 @@ impl ToCardanoTransactionsProofsMessageAdapter {
2122
);
2223

2324
Ok(CardanoTransactionsProofsMessage::new(
24-
certificate_hash,
25+
&signed_entity.certificate_id,
2526
try_adapt_set_proof_message(transactions_set_proofs)?,
2627
transactions_hashes_not_certified,
28+
signed_entity.artifact.beacon.immutable_file_number,
2729
))
2830
}
2931
}
@@ -76,30 +78,33 @@ mod tests {
7678
let transactions_hashes_certified = &transaction_hashes[0..5];
7779
let transactions_hashes_non_certified = &transaction_hashes[5..];
7880

79-
let mut transactions_set_proofs = Vec::new();
80-
for transaction_hashes_in_chunk in transactions_hashes_certified.chunks(2) {
81-
let mk_proof = MKProof::from_leaves(transaction_hashes_in_chunk).unwrap();
82-
transactions_set_proofs.push(CardanoTransactionsSetProof::new(
83-
transaction_hashes_in_chunk.to_vec(),
84-
mk_proof,
85-
))
86-
}
81+
let transactions_set_proofs = transactions_hashes_certified
82+
.chunks(2)
83+
.map(|transaction_hashes_in_chunk| {
84+
let mk_proof = MKProof::from_leaves(transaction_hashes_in_chunk).unwrap();
85+
CardanoTransactionsSetProof::new(transaction_hashes_in_chunk.to_vec(), mk_proof)
86+
})
87+
.collect::<Vec<_>>();
88+
89+
let signed_entity = SignedEntity::<CardanoTransactionsSnapshot>::dummy();
8790

88-
let certificate_hash = "certificate_hash";
8991
let message = ToCardanoTransactionsProofsMessageAdapter::try_adapt(
90-
certificate_hash,
92+
signed_entity.clone(),
9193
transactions_set_proofs.clone(),
9294
transaction_hashes.to_vec(),
9395
)
9496
.unwrap();
95-
let transactions_set_proofs = transactions_set_proofs
97+
98+
let transactions_set_proof_message_part = transactions_set_proofs
9699
.into_iter()
97100
.map(|p| p.try_into().unwrap())
98101
.collect();
102+
99103
let expected_message = CardanoTransactionsProofsMessage::new(
100-
certificate_hash,
101-
transactions_set_proofs,
104+
&signed_entity.certificate_id,
105+
transactions_set_proof_message_part,
102106
transactions_hashes_non_certified.to_vec(),
107+
signed_entity.artifact.beacon.immutable_file_number,
103108
);
104109
assert_eq!(expected_message, message);
105110
}

mithril-client/src/cardano_transaction_client.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,12 @@ mod tests {
239239
let mut aggregator_client = MockAggregatorHTTPClient::new();
240240
let certificate_hash = "cert-hash-123".to_string();
241241
let set_proof = CardanoTransactionsSetProof::dummy();
242-
let transactions_proofs =
243-
CardanoTransactionsProofs::new(&certificate_hash, vec![set_proof.clone()], vec![]);
242+
let transactions_proofs = CardanoTransactionsProofs::new(
243+
&certificate_hash,
244+
vec![set_proof.clone()],
245+
vec![],
246+
99999,
247+
);
244248
let expected_transactions_proofs = transactions_proofs.clone();
245249
aggregator_client
246250
.expect_get_content()

mithril-client/tests/extensions/fake.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ mod proof {
163163
proof: ProtocolMkProof::new(proof.clone()).to_json_hex().unwrap(),
164164
}],
165165
non_certified_transactions: vec![],
166+
latest_immutable_file_number: 9999,
166167
})
167168
.unwrap();
168169

@@ -175,6 +176,10 @@ mod proof {
175176
ProtocolMessagePartKey::CardanoTransactionsMerkleRoot,
176177
proof.root().to_hex(),
177178
);
179+
cert.protocol_message.set_message_part(
180+
ProtocolMessagePartKey::LatestImmutableFileNumber,
181+
9999.to_string(),
182+
);
178183
cert.signed_message = cert.protocol_message.compute_hash();
179184
cert
180185
};

0 commit comments

Comments
 (0)