Skip to content
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

Enhance runtime configuration of Mithril Aggregator #291

Merged
merged 5 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion mithril-aggregator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ make build
./mithril-aggregator -r testnet

# Run with custom configuration with env vars
NETWORK=testnet URL_SNAPSHOT_MANIFEST=https://storage.googleapis.com/cardano-testnet/snapshots.json ./mithril-aggregator
RUN_INTERVAL=60000 NETWORK=testnet URL_SNAPSHOT_MANIFEST=https://storage.googleapis.com/cardano-testnet/snapshots.json ./mithril-aggregator
```

## Build and run Docker container
Expand Down
1 change: 1 addition & 0 deletions mithril-aggregator/config/dev.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"network": "testnet",
"run_interval": 30000,
"url_snapshot_manifest": "https://storage.googleapis.com/cardano-testnet/snapshots.json",
"snapshot_store_type": "local",
"snapshot_uploader_type": "local",
Expand Down
1 change: 1 addition & 0 deletions mithril-aggregator/config/testnet.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"network": "testnet",
"run_interval": 60000,
"url_snapshot_manifest": "https://storage.googleapis.com/cardano-testnet/snapshots.json",
"snapshot_store_type": "local",
"snapshot_uploader_type": "gcp",
Expand Down
1 change: 1 addition & 0 deletions mithril-aggregator/src/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ impl DependencyManager {
pub fn fake() -> DependencyManager {
let config = Config {
network: "testnet".to_string(),
run_interval: 1000,
url_snapshot_manifest: "https://storage.googleapis.com/cardano-testnet/snapshots.json"
.to_string(),
snapshot_store_type: SnapshotStoreType::Local,
Expand Down
3 changes: 3 additions & 0 deletions mithril-aggregator/src/entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ pub struct Config {
/// Server listening IP
pub server_url: String,

/// Run Interval is the interval between two runtime cycles in ms
pub run_interval: u64,

/// Directory to snapshot
pub db_directory: PathBuf,

Expand Down
9 changes: 2 additions & 7 deletions mithril-aggregator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ pub struct Args {
#[clap(short, long, default_value = "dev")]
run_mode: String,

/// Runtime interval, in seconds
/// Defaults to 10 minutes
#[clap(long, default_value_t = 600)]
runtime_interval: u32,

/// Directory to snapshot
#[clap(long, default_value = "/db")]
db_directory: PathBuf,
Expand Down Expand Up @@ -172,14 +167,14 @@ async fn main() -> Result<(), Box<dyn Error>> {
let runtime_dependencies = dependency_manager.clone();
let handle = tokio::spawn(async move {
let config = AggregatorConfig::new(
args.runtime_interval,
config.run_interval,
&config.network.clone(),
&config.db_directory.clone(),
&snapshot_directory,
runtime_dependencies,
);
let mut runtime = AggregatorRuntime::new(
Duration::from_secs(config.interval.into()),
Duration::from_millis(config.interval),
None,
Arc::new(AggregatorRunner::new(config)),
)
Expand Down
6 changes: 3 additions & 3 deletions mithril-aggregator/src/runtime/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use mockall::automock;

use super::RuntimeError;
pub struct AggregatorConfig {
/// Interval between each snapshot, in seconds
pub interval: u32,
/// Interval between each snapshot, in ms
pub interval: u64,

/// Cardano network
pub network: String,
Expand All @@ -37,7 +37,7 @@ pub struct AggregatorConfig {

impl AggregatorConfig {
pub fn new(
interval: u32,
interval: u64,
network: &str,
db_directory: &Path,
snapshot_directory: &Path,
Expand Down
2 changes: 1 addition & 1 deletion mithril-aggregator/src/runtime/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl AggregatorRuntime {
error!("{:?}", e)
}

info!("Sleeping for {} seconds", self.state_sleep.as_secs());
info!("Sleeping for {} ms", self.state_sleep.as_millis());
sleep(self.state_sleep).await;
}
}
Expand Down
6 changes: 6 additions & 0 deletions mithril-infra/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ services:
image: ghcr.io/input-output-hk/mithril-aggregator:${IMAGE_ID:-latest}
restart: always
environment:
- RUST_BACKTRACE=1
- GOOGLE_APPLICATION_CREDENTIALS_JSON=${GOOGLE_APPLICATION_CREDENTIALS_JSON}
- NETWORK=${NETWORK:-testnet}
- RUN_INTERVAL=60000
- URL_SNAPSHOT_MANIFEST=https://storage.googleapis.com/cardano-${NETWORK:-testnet}/snapshots.json
- SNAPSHOT_STORE_TYPE=local
- SNAPSHOT_UPLOADER_TYPE=gcp
Expand Down Expand Up @@ -61,6 +63,7 @@ services:
max-size: "100m"
max-file: "5"
environment:
- RUST_BACKTRACE=1
- AGGREGATOR_ENDPOINT=http://mithril-aggregator:8080/aggregator
- NETWORK=testnet
- PARTY_ID=0
Expand All @@ -80,6 +83,7 @@ services:
max-size: "100m"
max-file: "5"
environment:
- RUST_BACKTRACE=1
- AGGREGATOR_ENDPOINT=http://mithril-aggregator:8080/aggregator
- NETWORK=testnet
- PARTY_ID=1
Expand All @@ -99,6 +103,7 @@ services:
max-size: "100m"
max-file: "5"
environment:
- RUST_BACKTRACE=1
- AGGREGATOR_ENDPOINT=http://mithril-aggregator:8080/aggregator
- NETWORK=testnet
- PARTY_ID=2
Expand All @@ -118,6 +123,7 @@ services:
max-size: "100m"
max-file: "5"
environment:
- RUST_BACKTRACE=1
- AGGREGATOR_ENDPOINT=http://mithril-aggregator:8080/aggregator
- NETWORK=testnet
- PARTY_ID=3
Expand Down
2 changes: 1 addition & 1 deletion mithril-signer/src/entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct Config {
pub party_id: PartyId,

/// Run Interval
#[table(title = "Interval between two signatures attempts")]
#[table(title = "Interval between two runtime cycles in ms")]
pub run_interval: u64,

/// Directory to snapshot
Expand Down
3 changes: 1 addition & 2 deletions mithril-test-lab/mithril-devnet/devnet-mkfiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,7 @@ cat >> docker-compose.yaml <<EOF
- RUST_BACKTRACE=1
- GOOGLE_APPLICATION_CREDENTIALS_JSON=
- NETWORK=devnet
- RUN_INTERVAL=5000
- URL_SNAPSHOT_MANIFEST=
- SNAPSHOT_STORE_TYPE=local
- SNAPSHOT_UPLOADER_TYPE=local
Expand All @@ -783,8 +784,6 @@ cat >> docker-compose.yaml <<EOF
"/data/mithril/aggregator",
"--server-port",
"8080",
"--runtime-interval",
"5",
"-vvv"
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ impl Aggregator {
let port = server_port.to_string();
let env = HashMap::from([
("NETWORK", "testnet"),
("RUN_INTERVAL", "5000"),
("URL_SNAPSHOT_MANIFEST", ""),
("SNAPSHOT_STORE_TYPE", "local"),
("SNAPSHOT_UPLOADER_TYPE", "local"),
Expand All @@ -40,8 +41,6 @@ impl Aggregator {
db_directory.to_str().unwrap(),
"--server-port",
&port,
"--runtime-interval",
"5",
"-vvv",
];

Expand Down