Skip to content

Commit

Permalink
[tower] Allow tower to mine dynamic VDF parameters (0LNetworkCommunit…
Browse files Browse the repository at this point in the history
…y#1111)

* add vdf difficulty type in rust

* refactor fetching local block

* refactor mine once

* refactor mine_once

* remove depr tests

* tests passing

* move next_proof to own module

* move vdf difficulty type

* function to create next proof params from chain query

* switch between local and online mode for proof generation

* move code for allowing vdf praams to be stored instead  of hard coded.

* add toy_rng for tower state

* update VDF params at end of epoch

* check correct security in period

* cleanup

* patch tower cli build

* patch toy_rng for tests

* patch tower app test

* build stdlib

* test passing

* WIP make new miner methods work with swarm

* tower can get difficulty params from chain

* genesis to use test settings

* fix loop and backlog issue

* don't init difficulty at genesis

* reorder genesis tx so testnet is initialized before genesis settings

* patch merge

* patch test

* new towers will start from the baseline/genesis difficulty and security params

* refactor default vdf params for block zero

* update tests for toy_rng

* test epoch creates random difficulty

* catch error with len == 0

* bad makefile

* add test for continuous mining

* scaffold gc for tower

* scaffold

* find first discontinous proof

* collect subsequent proofs function

* delete files

* clean

* backlog checks a bad tx for garbage collection

* implement GC on failed proof

* while transitioning to dynamic vdf, tower should failover to localmode

* downgrade error msg to info

* cleanup unused prometheus log code

* downgrade state sync error message to info

* makefile for set-waypoint

* patch makefile

* refresh onchain state

* genesis should assign vouches

* set layout for devnet has 4 nodes

* init val in genesis first

* github repo tools can put file in genesis repo

* save files to genesis repo

* reorganize testnet scripts

* cleanup

* documentation

* documentation

* patch makefile

* patch makefile

* rename make recipes

* rename

* vdf difficulties must always be even numbers

* patch move

* makefile

* makefile

* text [skip-ci]

* update yaml configs so that node file uses multiple fullnode networks [skip-ci]

* patch [skip ci]

* patch ports [skip ci]

* validator init on genesis and ol init, will use seed peers

* trim whitespace on genesis_waypoint.txt

* makefile

* method to create  a genesis proof

* reverse state-sync default params

* add helper in init to reset safety data

* bump version

* ol restore has --boundary-only or -b which will not attempt to restore an advanced version. This is the safest restore option.

* ol restore defaults to only fetch the epoch boundary. --highest-version must be explicitly passed if the user wants versions beyond the epoch boundary (this is still experimental).

* ol serve: deprecating the --run-checks or -c option. We now assume the user wants to run checks while running the web-monitor

* improve error messages on safety rules initialize

* validator should panic on trying to startup safety rules

* patch

* makefile

* make config chain-id and instance of namedchain, breaking

* patch build

* make chainId::str_to_chain_id public

* parse namedchain from str

* use testing ID in tx_params

* make testnet start with alice, bob, carol only

* add execution.genesis_file_location to fullnode yaml

* set layout to have 5 addresses for testnet genesis

* alway use cargo release mode even in testnet

* undo

* update fixture files with ip addresses for reference.

* update check for prod settings for nextproof

* VDF native function was aborting instead of returning error.

* NextProof generate genesis proof from configs

* add derive traits to nextproof

* builds

* refactor get_next_proof_from_chain [skip-ci]

* patch test because chain_id options have changed

* patch testtepoch_random_difficulty.move

* refactor init and onboard to use new named chain property

* patch copy of fixture files in swarm

* patch wrong chainid for swarm

* patch test mining epochs

* patch chain_id build issues

* include more namedchain str parsing options

* tower: delete a vdf proof that cannot be parsed

* debug ci
  • Loading branch information
0o-de-lally authored Jul 26, 2022
1 parent 1fa8761 commit 4b6c05c
Show file tree
Hide file tree
Showing 78 changed files with 1,794 additions and 330 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
- name: MINING
run: RUSTC_WRAPPER=sccache SOURCE_PATH=./ make -f ol/integration-tests/test-mining.mk test

# - name: MINING ACROSS EPOCHS
# run: RUSTC_WRAPPER=sccache SOURCE_PATH=./ make -f ol/integration-tests/test-mining-epochs.mk test

- name: ONBOARD
run: RUSTC_WRAPPER=sccache SOURCE_PATH=./ make -f ol/integration-tests/test-onboard.mk test
- name: File permissions
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ key_store.json
*.swp

# prevent mv files from being committed
*.mv
*.mv
language/diem-framework/releases/
4 changes: 2 additions & 2 deletions config/global-constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub const PROOF_OF_WORK_PROOF: &str = "pow_proof";
pub const ACCOUNT_PROFILE: &str = "account_profile";
pub const SALT_0L: &str = "0L";
pub const SOURCE_DIR: &str = "libra/";
pub const VDF_SECURITY_PARAM: u16 = 512;
pub const GENESIS_VDF_SECURITY_PARAM: u64 = 512;

/// Filename for 0L configs
pub const CONFIG_FILE: &str = "0L.toml";
Expand All @@ -45,7 +45,7 @@ pub const DEFAULT_PUB_PORT: u64 = 6178;

// TODO: make this lazy static.
/// Switch settings between production and testing
pub fn delay_difficulty() -> u64 {
pub fn genesis_delay_difficulty() -> u64 {
let node_env = match env::var("NODE_ENV") {
Ok(val) => val,
_ => "prod".to_string() // default to "prod" if not set
Expand Down
10 changes: 5 additions & 5 deletions config/management/genesis/src/ol_node_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use diem_global_constants::{
};
use diem_management::{config::ConfigPath, error::Error, secure_backend::ValidatorBackend};
use diem_secure_storage::{CryptoStorage, KVStorage};
use diem_types::{account_address::AccountAddress, chain_id::ChainId, waypoint::Waypoint};
use diem_types::{account_address::AccountAddress, chain_id::{ChainId, NamedChain}, waypoint::Waypoint};
use ol_types::account::ValConfigs;
use serde::{Deserialize, Serialize};
use structopt::StructOpt;
Expand All @@ -45,7 +45,7 @@ pub struct Files {
#[structopt(long)]
repo: Option<String>,
#[structopt(long)]
chain_id: u8,
chain_id: NamedChain,
/// If specified, compares the internal state to that of a
/// provided genesis. Note, that a waypont might diverge from
/// the provided genesis after execution has begun.
Expand Down Expand Up @@ -90,7 +90,7 @@ impl Files {

pub fn onboard_helper_all_files(
output_dir: PathBuf,
chain_id: u8,
chain_name: NamedChain,
github_org: Option<String>,
repo: Option<String>,
namespace: &str,
Expand All @@ -100,8 +100,8 @@ pub fn onboard_helper_all_files(
layout_path: &Option<PathBuf>,
val_ip_address: Option<Ipv4Addr>,
) -> Result<NodeConfig, anyhow::Error> {
// TODO: Do we need github token path with public repo?
let chain_id = ChainId::new(chain_id);

let chain_id = ChainId::new(chain_name.id()) ;

let storage_helper = StorageHelper::get_with_path(output_dir.clone());

Expand Down
20 changes: 12 additions & 8 deletions language/diem-framework/modules/0L/Globals.move
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ module Globals {
epoch_length: u64,
max_validators_per_set: u64,
subsidy_ceiling_gas: u64,
vdf_difficulty: u64,
vdf_difficulty_baseline: u64,
vdf_security_baseline: u64,
epoch_mining_thres_lower: u64,
epoch_mining_thres_upper: u64,
epoch_slow_wallet_unlock: u64,
Expand Down Expand Up @@ -58,13 +59,13 @@ module Globals {
}

/// Get the current vdf_difficulty
public fun get_vdf_difficulty(): u64 {
get_constants().vdf_difficulty
public fun get_vdf_difficulty_baseline(): u64 {
get_constants().vdf_difficulty_baseline
}

/// Get the current vdf_difficulty
public fun get_vdf_security(): u64 {
512
public fun get_vdf_security_baseline(): u64 {
get_constants().vdf_security_baseline
}


Expand Down Expand Up @@ -100,7 +101,8 @@ module Globals {
epoch_length: 60, // seconds
max_validators_per_set: 100,
subsidy_ceiling_gas: 296 * COIN_SCALING_FACTOR,
vdf_difficulty: 100,
vdf_difficulty_baseline: 100,
vdf_security_baseline: 512,
epoch_mining_thres_lower: 2, //many tests depend on two proofs because the test harness already gives one at genesis to validators
epoch_mining_thres_upper: 1000, // upper bound unlimited
epoch_slow_wallet_unlock: 10,
Expand All @@ -113,7 +115,8 @@ module Globals {
epoch_length: 60 * 40, // 40 mins, enough for a hard miner proof.
max_validators_per_set: 100,
subsidy_ceiling_gas: 8640000 * COIN_SCALING_FACTOR,
vdf_difficulty: 120000000,
vdf_difficulty_baseline: 120000000,
vdf_security_baseline: 512,
epoch_mining_thres_lower: 1, // in testnet, staging, we don't want to wait too long between proofs.
epoch_mining_thres_upper: 72, // upper bound enforced at 20 mins per proof.
epoch_slow_wallet_unlock: 10000000,
Expand All @@ -129,7 +132,8 @@ module Globals {
// target transaction per sec max gas: 20
// uses "scaled representation", since there are no decimals.
subsidy_ceiling_gas: 8640000 * COIN_SCALING_FACTOR, // subsidy amount assumes 24 hour epoch lengths. Also needs to be adjusted for coin_scale the onchain representation of human readable value.
vdf_difficulty: 120000000, // FYI approx 30 mins per proof on 2020 macbook pro 2.5 ghz quadcore
vdf_difficulty_baseline: 120000000, // FYI approx 30 mins per proof on 2020 macbook pro 2.5 ghz quadcore
vdf_security_baseline: 512,
epoch_mining_thres_lower: 7, // NOTE: bootstrapping, allowance for operator error.
epoch_mining_thres_upper: 72, // upper bound enforced at 20 mins per proof.
epoch_slow_wallet_unlock: 1000 * COIN_SCALING_FACTOR, // approx 10 years for largest accounts in genesis.
Expand Down
Loading

0 comments on commit 4b6c05c

Please sign in to comment.