Skip to content

Commit

Permalink
Vdf security parameters update (#772)
Browse files Browse the repository at this point in the history
* refresh seed peers

* catch state tree error and handle

* refactor block execution to reduce calls.

* patch setting upstream connection on client

* remove deprecated args in tower start

* make log levels in ureq go away

* benchmarking vdf

* make vdf delay and verify receive params.

* make all tower apis receive difficulty and security params

* change transaction api for tower and account creation.

* more benches

* patch tower tests

* patch native function arg parsing

* patch miner and vdf tests

* consolidate names challenge/solution

* patch e2e reconfig test.

* rebuild upgarde fixtures

* patch autopay integration tests

* get toml file from fixtures

* change VDF scheme BREAKING CHANGE

* set new vdf parameters

* change native function

* created test fixtures

* fixtures makefile

* make test mode only TEST=y

* create prod fixtures

* updating move test fixtures

* build stdlib

* get blocks from fixtures

* get block fixtures from files

* wip patching miner tests

* cleanup

* patch build

* remove mentions of 2048

* fix imports in genesis

* wip patch vdf proofs

* vdf tets passing

* add block 1 fixtures

* add eve block 1 fixtures

* complete move fixtures

* patch miner tests

* all tests passing.

* tower tests passing

* patching e2e tests and tools tests

* more sane fixtures managment for e2e tests

* update makefile

* patch fixtures helpers locations

* remove duplicate fixtures helper
  • Loading branch information
0o-de-lally authored Oct 22, 2021
1 parent 634971e commit 8d27568
Show file tree
Hide file tree
Showing 144 changed files with 1,768 additions and 1,555 deletions.
16 changes: 5 additions & 11 deletions Cargo.lock

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

7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ reset-safety:
jq -r '.["${ACC}-oper/safety_data"].value = { "epoch": 0, "last_voted_round": 0, "preferred_round": 0, "last_vote": null }' ${DATA_PATH}/key_store.json > ${DATA_PATH}/temp_key_store && mv ${DATA_PATH}/temp_key_store ${DATA_PATH}/key_store.json




backup:
cd ~ && rsync -av --exclude db/ --exclude logs/ ~/.0L ~/0L_backup_$(shell date +"%m-%d-%y")

Expand All @@ -150,6 +148,9 @@ reset-safety:
@echo CLEARING SAFETY RULES IN KEY_STORE.JSON
jq -r '.["${ACC}-oper/safety_data"].value = { "epoch": 0, "last_voted_round": 0, "preferred_round": 0, "last_vote": null }' ${DATA_PATH}/key_store.json > ${DATA_PATH}/temp_key_store && mv ${DATA_PATH}/temp_key_store ${DATA_PATH}/key_store.json


move-test:
cd language/move-lang/functional-tests/ && cargo t 0L
#### GENESIS BACKEND SETUP ####
init-backend:
curl -X POST -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/orgs/${REPO_ORG}/repos -d '{"name":"${REPO_NAME}", "private": "true", "auto_init": "true"}'
Expand Down Expand Up @@ -189,7 +190,7 @@ genesis-miner:


gen-onboard:
cargo run -p onboard ${CARGO_ARGS} -- val --genesis-ceremony --skip-mining
cargo run -p onboard ${CARGO_ARGS} -- val --genesis-ceremony

ceremony: gen-fork-repo gen-onboard

Expand Down
20 changes: 19 additions & 1 deletion config/global-constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
//! (and better allow these constants to be updated in a single location), we define them here.
#![forbid(unsafe_code)]

use std::env;

/// Definitions of global cryptographic keys (e.g., as held in secure storage)
pub const CONSENSUS_KEY: &str = "consensus";
pub const EXECUTION_KEY: &str = "execution";
Expand All @@ -33,6 +35,22 @@ 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 = 2048;
pub const VDF_SECURITY_PARAM: u16 = 512;

/// Filename for 0L configs
pub const CONFIG_FILE: &str = "0L.toml";


// TODO: make this lazy static.
/// Switch settings between production and testing
pub fn delay_difficulty() -> u64 {
let node_env = match env::var("NODE_ENV") {
Ok(val) => val,
_ => "prod".to_string() // default to "prod" if not set
};
// must explicitly set env to prod to use production difficulty.
if node_env == "prod" {
return 120_000_000
}
return 100 // difficulty for test suites and on local for debugging purposes.
}
1 change: 0 additions & 1 deletion config/management/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ diem-wallet = { path = "../../testsuite/cli/diem-wallet", version = "0.1.0"}
ol-keys = { path = "../../ol/keys", version = "0.1.0" }
dirs = "2.0.2"
serde_json = "1"
ol-fixtures = {path = "../../ol/fixtures"}

[dev-dependencies]
diem-config = { path = "..", features = ["fuzzing"] }
Expand Down
1 change: 0 additions & 1 deletion config/management/genesis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ ol-keys = { path = "../../../ol/keys", version = "0.1.0" }
hex = "0.4.2"
dirs = "2.0.2"
serde_json = "1"
ol-fixtures = {path = "../../../ol/fixtures"}
diem-github-client = { path = "../../../secure/storage/github" }
ol-types = {path = "../../../ol/types"}

Expand Down
4 changes: 2 additions & 2 deletions config/management/genesis/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use diem_types::{
};
use std::{fs::File, io::{Read, Write}, path::PathBuf};
use structopt::StructOpt;
use vm_genesis::{OperatorAssignment, OperatorRegistration, GenesisMiningProof};
use vm_genesis::{OperatorAssignment, OperatorRegistration};

//////// 0L ////////
use ol_types::account::ValConfigs;
use ol_types::{account::ValConfigs, genesis_proof::GenesisMiningProof};

/// Note, it is implicitly expected that the storage supports
/// a namespace but one has not been set.
Expand Down
14 changes: 6 additions & 8 deletions config/management/genesis/src/storage_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ use std::{
path::{Path, PathBuf},
};
use structopt::StructOpt;
use vm_genesis::GenesisMiningProof;
use ol_keys::scheme::KeyScheme;
use ol_types::{ fixtures, genesis_proof::GenesisMiningProof};

pub struct StorageHelper {
temppath: diem_temppath::TempPath,
Expand Down Expand Up @@ -203,8 +203,6 @@ impl StorageHelper {
// 0L: change, initialize the 0-4th accounts with a fixture mnemonics.
// So we can reliably test miner and other transactions.
pub fn initialize_by_idx(&self, namespace: String, idx: usize) {
// let mnem_alice = "talent sunset lizard pill fame nuclear spy noodle basket okay critic grow sleep legend hurry pitch blanket clerk impose rough degree sock insane purse".to_string();
// let mnem_alice = ol_fixtures::get_persona_mnem("alice");

let partial_seed = bcs::to_bytes(&idx).unwrap();
let mut seed = [0u8; 32];
Expand All @@ -217,30 +215,30 @@ impl StorageHelper {
// user personas
match idx {
1 => {
let user = ol_fixtures::get_persona_mnem("alice");
let user = fixtures::get_persona_mnem("alice");
dbg!("swarm 3", &user);

self.initialize_with_mnemonic_swarm(
namespace,
ol_fixtures::get_persona_mnem("alice"),
fixtures::get_persona_mnem("alice"),
);
}
2 => {
self.initialize_with_mnemonic_swarm(
namespace,
ol_fixtures::get_persona_mnem("bob"),
fixtures::get_persona_mnem("bob"),
);
}
3 => {
self.initialize_with_mnemonic_swarm(
namespace,
ol_fixtures::get_persona_mnem("carol"),
fixtures::get_persona_mnem("carol"),
);
}
4 => {
self.initialize_with_mnemonic_swarm(
namespace,
ol_fixtures::get_persona_mnem("dave"),
fixtures::get_persona_mnem("dave"),
);
}
_ => {
Expand Down
16 changes: 11 additions & 5 deletions language/diem-framework/modules/0L/Globals.move
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,16 @@ module Globals {
}

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

/// Get the current vdf_difficulty
public fun get_vdf_security(): u64 {
512
}


/// Get the mining threshold
public fun get_epoch_mining_thres_lower(): u64 {
get_constants().epoch_mining_thres_lower
Expand Down Expand Up @@ -85,7 +91,7 @@ module Globals {
subsidy_ceiling_gas: 296 * coin_scale,
vdf_difficulty: 100,
epoch_mining_thres_lower: 1,
epoch_mining_thres_upper: 240, // upper bound enforced at 6 mins per proof.
epoch_mining_thres_upper: 1000, // upper bound unlimited
epoch_slow_wallet_unlock: 10,
}
};
Expand All @@ -97,7 +103,7 @@ module Globals {
subsidy_ceiling_gas: 8640000 * coin_scale,
vdf_difficulty: 5000000,
epoch_mining_thres_lower: 1,
epoch_mining_thres_upper: 240, // upper bound enforced at 6 mins per proof.
epoch_mining_thres_upper: 72, // upper bound enforced at 20 mins per proof.
epoch_slow_wallet_unlock: 10000000,
}
} else {
Expand All @@ -111,8 +117,8 @@ module Globals {
// uses "scaled representation", since there are no decimals.
subsidy_ceiling_gas: 8640000 * coin_scale, // subsidy amount assumes 24 hour epoch lengths. Also needs to be adjusted for coin_scale the onchain representation of human readable value.
vdf_difficulty: 5000000, // FYI approx 10 mins per proof on 2020 macbook pro 2.5 ghz quadcore
epoch_mining_thres_lower: 20,
epoch_mining_thres_upper: 240, // upper bound enforced at 6 mins per proof.
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_scale, // approx 10 years for largest accounts in genesis.
}
}
Expand Down
Loading

0 comments on commit 8d27568

Please sign in to comment.