mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-09 22:57:59 -05:00
crypsinous_playground: simulation epochs as arg
This commit is contained in:
@@ -11,3 +11,6 @@
|
|||||||
|
|
||||||
# Password for the wallet database
|
# Password for the wallet database
|
||||||
#wallet_pass = "changeme"
|
#wallet_pass = "changeme"
|
||||||
|
|
||||||
|
# How many epochs to simulate
|
||||||
|
#epochs = 1
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ struct Args {
|
|||||||
/// Password for the wallet database
|
/// Password for the wallet database
|
||||||
wallet_pass: String,
|
wallet_pass: String,
|
||||||
|
|
||||||
|
#[structopt(short, default_value = "1")]
|
||||||
|
/// How many epochs to simulate
|
||||||
|
epochs: u64,
|
||||||
|
|
||||||
#[structopt(short, parse(from_occurrences))]
|
#[structopt(short, parse(from_occurrences))]
|
||||||
/// Increase verbosity (-vvv supported)
|
/// Increase verbosity (-vvv supported)
|
||||||
verbose: u8,
|
verbose: u8,
|
||||||
@@ -46,6 +50,14 @@ struct Args {
|
|||||||
async_daemonize!(realmain);
|
async_daemonize!(realmain);
|
||||||
async fn realmain(args: Args, _ex: Arc<smol::Executor<'_>>) -> Result<()> {
|
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
|
// Initialize wallet that holds coins for staking
|
||||||
let wallet = init_wallet(&args.wallet_path, &args.wallet_pass).await?;
|
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 proving_key = ProvingKey::build(k, &LeadContract::default());
|
||||||
let verifying_key = VerifyingKey::build(k, &LeadContract::default());
|
let verifying_key = VerifyingKey::build(k, &LeadContract::default());
|
||||||
|
|
||||||
// Simulating an epoch with 10 slots
|
// Simulating epochs with 10 slots
|
||||||
let epoch = 0;
|
for epoch in 0..epochs {
|
||||||
let slot = 0;
|
|
||||||
info!("Epoch {} started!", epoch);
|
info!("Epoch {} started!", epoch);
|
||||||
|
|
||||||
// Generating epoch coins
|
// Generating epoch coins
|
||||||
// TODO: Retrieve previous lead proof
|
// TODO: Retrieve previous lead proof
|
||||||
let eta = pallas::Base::one();
|
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());
|
info!("Generated epoch_coins: {}", epoch_coins.len());
|
||||||
for slot in 0..10 {
|
for slot in 0..10 {
|
||||||
// Checking if slot leader
|
// Checking if slot leader
|
||||||
@@ -102,7 +112,7 @@ async fn realmain(args: Args, _ex: Arc<smol::Executor<'_>>) -> Result<()> {
|
|||||||
Ok(_) => info!("Proof veryfied succsessfully!"),
|
Ok(_) => info!("Proof veryfied succsessfully!"),
|
||||||
Err(e) => error!("Error during leader proof verification: {}", e),
|
Err(e) => error!("Error during leader proof verification: {}", e),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user