crypsinous_playground: simulation epochs as arg

This commit is contained in:
aggstam
2022-10-27 21:21:53 +03:00
parent e9a8b594a8
commit ef3c52e6b6
2 changed files with 46 additions and 33 deletions

View File

@@ -11,3 +11,6 @@
# Password for the wallet database
#wallet_pass = "changeme"
# How many epochs to simulate
#epochs = 1

View File

@@ -35,6 +35,10 @@ struct Args {
/// Password for the wallet database
wallet_pass: String,
#[structopt(short, default_value = "1")]
/// How many epochs to simulate
epochs: u64,
#[structopt(short, parse(from_occurrences))]
/// Increase verbosity (-vvv supported)
verbose: u8,
@@ -46,6 +50,14 @@ struct Args {
async_daemonize!(realmain);
async fn realmain(args: Args, _ex: Arc<smol::Executor<'_>>) -> Result<()> {
// Epochs sanity check
let epochs = args.epochs;
if epochs < 1 {
error!("Epochs must be a positive number.");
return Ok(());
}
info!("Simulation epochs: {}", epochs);
// Initialize wallet that holds coins for staking
let wallet = init_wallet(&args.wallet_path, &args.wallet_pass).await?;
@@ -69,15 +81,13 @@ async fn realmain(args: Args, _ex: Arc<smol::Executor<'_>>) -> Result<()> {
let proving_key = ProvingKey::build(k, &LeadContract::default());
let verifying_key = VerifyingKey::build(k, &LeadContract::default());
// Simulating an epoch with 10 slots
let epoch = 0;
let slot = 0;
// Simulating epochs with 10 slots
for epoch in 0..epochs {
info!("Epoch {} started!", epoch);
// Generating epoch coins
// TODO: Retrieve previous lead proof
let eta = pallas::Base::one();
let epoch_coins = coins::create_epoch_coins(eta, &owned, epoch, slot);
let epoch_coins = coins::create_epoch_coins(eta, &owned, epoch, 0);
info!("Generated epoch_coins: {}", epoch_coins.len());
for slot in 0..10 {
// Checking if slot leader
@@ -102,7 +112,7 @@ async fn realmain(args: Args, _ex: Arc<smol::Executor<'_>>) -> Result<()> {
Ok(_) => info!("Proof veryfied succsessfully!"),
Err(e) => error!("Error during leader proof verification: {}", e),
}
}
}
Ok(())