Skip to content

Commit

Permalink
scaffold for genesis wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed Feb 28, 2023
1 parent f1da95b commit 3fbe012
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 12 deletions.
30 changes: 21 additions & 9 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion ol/genesis-tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ diem-config = { path = "../../config" }
diem-secure-storage = { path = "../../secure/storage/", version = "0.1.0" }
diem-vm = { path = "../../diem-move/diem-vm", version = "0.1.0" }
diem-framework-releases = { path = "../../diem-move/diem-framework/DPN/releases" }

ol-smoke-tests = { path = "../smoke-tests/"}
diem-management = { path = "../../config/management" }
indicatif = "0.17.3"
dialoguer = "0.8.0"
dirs = "4.0.0"
onboard = { path = "../onboard" }

[dev-dependencies]
tokio-test = "*"
Expand Down
3 changes: 2 additions & 1 deletion ol/genesis-tools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ pub mod db_utils;
pub mod fork_genesis;
pub mod process_snapshot;
pub mod read_snapshot;
// pub mod recover;
pub(crate) mod wizard;

// pub mod swarm_genesis; // Note: 0L deleted: starting a test environment (Swarm in v5) has changed. Now we would use Forge. And that would be external to main code. Either in ./src/tests or in the Smoke tests directory.
13 changes: 12 additions & 1 deletion ol/genesis-tools/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
mod wizard;

use anyhow::Result;
use diem_secure_storage::{GitHubStorage, Storage};
use vm_genesis::{TestValidator, Validator};
Expand All @@ -15,11 +17,13 @@ use ol_genesis_tools::{
};
use indicatif::ProgressIterator;


#[tokio::main]
async fn main() -> Result<()> {
#[derive(Debug, Options)]
struct Args {
#[options(help = "use wizard")]
wizard: bool,

#[options(help = "org of remote github repo for genesis coordination")]
genesis_repo_owner: Option<String>,

Expand Down Expand Up @@ -56,7 +60,14 @@ async fn main() -> Result<()> {
check: bool,
}



let opts = Args::parse_args_default_or_exit();

if opts.wizard {
wizard::start_wizard();
}

if opts.fork {
// create a genesis.blob
// there are two paths here
Expand Down
102 changes: 102 additions & 0 deletions ol/genesis-tools/src/wizard.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
//! workflow for genesis


use dialoguer::{Confirm, Input};
use std::path::Path;
use dirs;
use onboard::commands::wizard_val_cmd::ValWizardCmd;

#[test]
fn test_wizard() {
start_wizard();
}

/// wizard for running genesis
pub fn start_wizard() {

Confirm::new()
.with_prompt("Let's do this?")
.interact()
.unwrap();

let h = dirs::home_dir().expect("no home dir found");
let has_data_path = Path::exists(&h.join(".0L/"));

if !has_data_path {
println!("let's initialize this host");

let wiz_cmd = ValWizardCmd::default();
}



// Enter the path of your 0L folder
// fs::
// let input: String = Input::new()
// .with_prompt("Enter the full path to use (e.g. /home/name)")
// .interact_text()
// .unwrap();
// check if we have a github token


// Dialog: git username
// stretch: check the token is useful on that account.

// check if .0L folder is clean

// initialize app configs

// Fork the repo, if it doesn't exist

// Run registration

// run genesis

// create the files

// empty the DB

// reset the safety rules

// verify genesis

}



// # ENVIRONMENT
// # 1. You must have a github personal access token at ~/.0L/github_token.txt
// # 2. export the environment variable `GITHUB_USER=<your github username`


// # All nodes must initialize their configs.
// # You can optionally use the key generator to use a new account in this genesis.

// v6-keys:
// cargo r -p onboard -- keygen

// # Initialize basic files. Take advantage to build the stdlib, in case.
// v6-init: stdlib init

// # Each validator will have their own github REPO for the purposes of
// # Registering for genesis. THis repo is a fork of the coordinating repo.
// # Once registered (in next step), a pull request will be sent back to the original repo with
// # the node's registration information.
// v6-github: gen-fork-repo

// # Each validator registers for genesis ON THEIR OWN GITHUB FORK.
// v6-register: gen-register

// # One person should write to the coordination repo with the list of validators.
// # or can be manually by pull request, changing set_layout.toml
// v6-validators: layout

// v6-genesis: fork-genesis

// # Create the files necessary to start node. Includes new waypoint from genesis
// v6-files: set-waypoint node-files
// # DESTROYING DB
// rm -rf ~/.0L/db

// # Verify the local configuration and the genesis.
// v6-verify: verify-gen

0 comments on commit 3fbe012

Please sign in to comment.