Skip to content

POC - Mithril signature diffusion with a "fake Cardano network layer" #1902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
17e38c2
Scaffold fake node with a simple directory observer for message input
Alenar Aug 21, 2024
ed45898
Move message structure to an `entities` module since it will be shared
Alenar Aug 21, 2024
9542e3c
Make TestHttpServer able to run through an unix socket
Alenar Aug 21, 2024
20570bd
Add `HttpUnixSocketWriter` in `mithril-common`
Alenar Aug 21, 2024
54bac70
Further scaffold fake node by handling logs, startup & shutdown
Alenar Aug 21, 2024
a047dbd
Use a `lib` to manage fake node imports
Alenar Aug 22, 2024
6d85c6d
Add http server over unix socket on fake node
Alenar Aug 22, 2024
1739c8d
Add read capability to the SocketClient (new name of SocketWriter)
Alenar Aug 22, 2024
0941d62
Handle error case in SocketClient::read
Alenar Aug 22, 2024
7c5d81c
Implement `/pull-signatures` on fake node
Alenar Aug 22, 2024
a14fa65
Add `MessageListener`
Alenar Aug 23, 2024
fec0860
Make clippy happier & some code quality enhancement
Alenar Aug 23, 2024
903a43d
Fake node now listen for message in its input folder
Alenar Aug 23, 2024
f8d1944
Add `/register-signatures` POST route to http server on fake node socket
Alenar Aug 23, 2024
44f64ce
Add `peers_input_directories` param to fake node + add alternate log …
Alenar Aug 23, 2024
fe2c6a0
Scaffold `MessageSender`
Alenar Aug 23, 2024
c577fb5
`MessageSender` can now forward message to one peer
Alenar Aug 23, 2024
2d76880
`MessageSender` can now forward message to multiple peers
Alenar Aug 23, 2024
b5eefac
Make fake node forward message to peers
Alenar Aug 23, 2024
ce9a7c3
Fix DirectoryObserver: deserialize the crate Message type instead of …
Alenar Aug 23, 2024
903ef89
Rework fake node logging: removed slog_scope, pass a parent logger in…
Alenar Aug 23, 2024
a385014
Better path handling in fake node:
Alenar Aug 26, 2024
363d115
Move signatures publication abstraction in signer
Alenar Aug 26, 2024
bd564de
Add a sig publisher that use unix socket on mithril-signer
Alenar Aug 26, 2024
65b24e3
Add `SignatureConsumer` to aggregator
Alenar Aug 27, 2024
d1437b5
Add `signature-network-node` to CI built binaries
Alenar Aug 27, 2024
d62675b
Fix: fake nodes were not pushing signatures received through socket t…
Alenar Aug 27, 2024
c064983
Move `signature_publisher` module to `services`
Alenar Aug 29, 2024
01f7c5d
Demo Adjustments:
Alenar Sep 25, 2024
8c3cdcd
Make e2e start one fake nodes for each mithril node
Alenar Aug 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ runs:
target/release/mithril-signer.exe
target/release/mithril-relay
target/release/mithril-relay.exe
target/release/signature-network-node
if-no-files-found: error
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ jobs:
- name: Build Mithril workspace & publish artifacts
uses: ./.github/workflows/actions/build-upload-mithril-artifact
with:
binaries-build-args: --bin mithril-aggregator --bin mithril-signer --bin mithril-client --bin mithril-relay --features bundle_openssl,full
binaries-build-args: |
--bin mithril-aggregator \
--bin mithril-signer \
--bin mithril-client \
--bin mithril-relay \
--bin signature-network-node \
--features bundle_openssl,full
libraries-build-args: --package mithril-stm --package mithril-client --features full,unstable

- name: Build Debian packages
Expand Down Expand Up @@ -342,6 +348,7 @@ jobs:
chmod +x ./bin/mithril-client
chmod +x ./bin/mithril-signer
chmod +x ./bin/mithril-relay
chmod +x ./bin/signature-network-node
chmod +x ./mithril-end-to-end
mkdir artifacts

Expand Down
152 changes: 149 additions & 3 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ members = [
"mithril-stm",
"mithril-test-lab/mithril-aggregator-fake",
"mithril-test-lab/mithril-end-to-end",
"mithril-test-lab/signature-network-node",
]

[workspace.package]
Expand Down
11 changes: 11 additions & 0 deletions mithril-aggregator/src/commands/serve_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,17 @@ impl ServeCommand {
});
}

if let Some(signature_consumer) = dependencies_builder
.create_signature_consumer()
.await
.with_context(|| "Dependencies Builder can not create signature consumer")?
{
join_set.spawn(async move {
signature_consumer.listen().await;
Ok(())
});
}

join_set.spawn(async { tokio::signal::ctrl_c().await.map_err(|e| e.to_string()) });
dependencies_builder.vanish().await;

Expand Down
7 changes: 7 additions & 0 deletions mithril-aggregator/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ pub struct Configuration {
#[example = "`/tmp/cardano.sock`"]
pub cardano_node_socket_path: PathBuf,

/// Path of the socket used by a signature network node to publish signatures
///
/// If not set, the signatures will be published to the aggregator using the HTTP API.
#[example = "`/tmp/signature-network-node_1/node.sock`"]
pub signature_network_node_socket_path: Option<PathBuf>,

/// Cardano node version.
///
/// **NOTE**: This cannot be verified for now (see [this
Expand Down Expand Up @@ -225,6 +231,7 @@ impl Configuration {
environment: ExecutionEnvironment::Test,
cardano_cli_path: PathBuf::new(),
cardano_node_socket_path: PathBuf::new(),
signature_network_node_socket_path: None,
cardano_node_version: "0.0.1".to_string(),
network_magic: Some(42),
network: "devnet".to_string(),
Expand Down
22 changes: 22 additions & 0 deletions mithril-aggregator/src/dependency_injection/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ use mithril_persistence::{
};

use super::{DependenciesBuilderError, EpochServiceWrapper, Result};
use crate::services::SignatureConsumer;
use crate::{
artifact_builder::{
CardanoImmutableFilesFullArtifactBuilder, CardanoStakeDistributionArtifactBuilder,
Expand Down Expand Up @@ -1453,6 +1454,27 @@ impl DependenciesBuilder {
Ok(runtime)
}

/// Create a [SignatureConsumer] instance if `signature_network_node_socket_path`
/// is set in the [Configuration].
pub async fn create_signature_consumer(&mut self) -> Result<Option<SignatureConsumer>> {
let signature_network_node_socket_path = &self
.configuration
.signature_network_node_socket_path
.clone();
match signature_network_node_socket_path {
Some(socket_path) => {
let consumer = SignatureConsumer::new(
socket_path,
Duration::from_millis(50),
self.get_certifier_service().await?,
&self.root_logger(),
);
Ok(Some(consumer))
}
None => Ok(None),
}
}

/// Create the HTTP route instance
pub async fn create_http_routes(
&mut self,
Expand Down
11 changes: 9 additions & 2 deletions mithril-aggregator/src/runtime/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ impl AggregatorRuntime {
.with_context(|| "AggregatorRuntime can not get the current open message")?
{
// transition READY > SIGNING
info!(self.logger, "→ Transitioning to SIGNING");
info!(
self.logger, "→ Transitioning to SIGNING";
"signed_entity_type" => ?open_message.signed_entity_type
);
let new_state = self
.transition_from_ready_to_signing(last_time_point.clone(), open_message.clone())
.await.with_context(|| format!("AggregatorRuntime can not perform a transition from READY state to SIGNING with entity_type: '{:?}'", open_message.signed_entity_type))?;
Expand Down Expand Up @@ -220,10 +223,14 @@ impl AggregatorRuntime {
self.state = AggregatorState::Ready(new_state);
} else {
// SIGNING > READY
let signed_entity_type = state.open_message.signed_entity_type.clone();
let new_state = self
.transition_from_signing_to_ready_multisignature(state)
.await?;
info!(self.logger, "→ A multi-signature has been created, build an artifact & a certificate and transitioning back to READY");
info!(
self.logger, "→ A multi-signature has been created, build an artifact & a certificate and transitioning back to READY";
"signed_entity_type" => ?signed_entity_type
);
self.state = AggregatorState::Ready(new_state);
}
}
Expand Down
2 changes: 2 additions & 0 deletions mithril-aggregator/src/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod epoch_service;
mod message;
mod prover;
mod signable_builder;
mod signature_consumer;
mod signed_entity;
mod stake_distribution;
mod upkeep;
Expand All @@ -25,6 +26,7 @@ pub use epoch_service::*;
pub use message::*;
pub use prover::*;
pub use signable_builder::*;
pub use signature_consumer::*;
pub use signed_entity::*;
pub use stake_distribution::*;
pub use upkeep::*;
Loading
Loading