From a42250445d1874e7c5347301135b6d4df33ad65f Mon Sep 17 00:00:00 2001 From: Ignotus Peverell Date: Tue, 18 Dec 2018 14:03:55 -0800 Subject: [PATCH] Floonet chain type and genesis, testnets cleanup (#2182) --- core/src/consensus.rs | 38 ++--------- core/src/genesis.rs | 133 +++++++++++++------------------------ core/src/global.rs | 66 ++++-------------- core/src/pow.rs | 2 +- core/tests/consensus.rs | 55 ++++----------- servers/src/grin/server.rs | 7 +- wallet/src/types.rs | 2 +- 7 files changed, 80 insertions(+), 223 deletions(-) diff --git a/core/src/consensus.rs b/core/src/consensus.rs index 804e5cd0..b14ec8d6 100644 --- a/core/src/consensus.rs +++ b/core/src/consensus.rs @@ -62,32 +62,13 @@ pub const COINBASE_MATURITY: u64 = DAY_HEIGHT; /// function of block height (time). Starts at 90% losing a percent /// approximately every week. Represented as an integer between 0 and 100. pub fn secondary_pow_ratio(height: u64) -> u64 { - if global::is_testnet() { - if height < T4_CUCKAROO_HARDFORK { - // Maintaining pre hardfork testnet4 behavior - 90u64.saturating_sub(height / WEEK_HEIGHT) - } else { - 90u64.saturating_sub(height / (2 * YEAR_HEIGHT / 90)) - } - } else { - // Mainnet (or testing mainnet code). - 90u64.saturating_sub(height / (2 * YEAR_HEIGHT / 90)) - } + 90u64.saturating_sub(height / (2 * YEAR_HEIGHT / 90)) } /// The AR scale damping factor to use. Dependent on block height /// to account for pre HF behavior on testnet4. -fn ar_scale_damp_factor(height: u64) -> u64 { - if global::is_testnet() { - if height < T4_CUCKAROO_HARDFORK { - DIFFICULTY_DAMP_FACTOR - } else { - AR_SCALE_DAMP_FACTOR - } - } else { - // Mainnet (or testing mainnet code). - AR_SCALE_DAMP_FACTOR - } +fn ar_scale_damp_factor(_height: u64) -> u64 { + AR_SCALE_DAMP_FACTOR } /// Cuckoo-cycle proof size (cycle length) @@ -99,10 +80,6 @@ pub const DEFAULT_MIN_EDGE_BITS: u8 = 31; /// Cuckaroo proof-of-work edge_bits, meant to be ASIC resistant. pub const SECOND_POW_EDGE_BITS: u8 = 29; -/// Block height at which testnet 4 hard forks to use Cuckaroo instead of -/// Cuckatoo for ASIC-resistant PoW -pub const T4_CUCKAROO_HARDFORK: u64 = 64_000; - /// Original reference edge_bits to compute difficulty factors for higher /// Cuckoo graph sizes, changing this would hard fork pub const BASE_EDGE_BITS: u8 = 24; @@ -332,15 +309,10 @@ where /// Count the number of "secondary" (AR) blocks in the provided window of blocks. /// Note: we skip the first one, but testnet4 was incorrectly including it before /// the hardfork. -fn ar_count(height: u64, diff_data: &[HeaderInfo]) -> u64 { - let mut to_skip = 1; - if global::is_testnet() && height < T4_CUCKAROO_HARDFORK { - // Maintain behavior of testnet4 pre-HF. - to_skip = 0; - } +fn ar_count(_height: u64, diff_data: &[HeaderInfo]) -> u64 { 100 * diff_data .iter() - .skip(to_skip) + .skip(1) .filter(|n| n.is_secondary) .count() as u64 } diff --git a/core/src/genesis.rs b/core/src/genesis.rs index 87e196e2..6eba2cdb 100644 --- a/core/src/genesis.rs +++ b/core/src/genesis.rs @@ -46,99 +46,46 @@ pub fn genesis_dev() -> core::Block { }) } -/// First testnet genesis block, still subject to change (especially the date, -/// will hopefully come before Christmas). -pub fn genesis_testnet1() -> core::Block { - core::Block::with_header(core::BlockHeader { +/// Placeholder for floonet genesis block, will definitely change before +/// release +pub fn genesis_floo() -> core::Block { + let gen = core::Block::with_header(core::BlockHeader { height: 0, - timestamp: Utc.ymd(2017, 11, 16).and_hms(20, 0, 0), + timestamp: Utc.ymd(2018, 12, 20).and_hms(20, 0, 0), // REPLACE + prev_root: Hash::default(), // REPLACE + output_root: Hash::default(), // REPLACE + range_proof_root: Hash::default(), // REPLACE + kernel_root: Hash::default(), // REPLACE + total_kernel_offset: BlindingFactor::zero(), // REPLACE + output_mmr_size: 1, + kernel_mmr_size: 1, pow: ProofOfWork { - total_difficulty: Difficulty::min(), - secondary_scaling: 1, - nonce: 28205, - proof: Proof::new(vec![ - 0x21e, 0x7a2, 0xeae, 0x144e, 0x1b1c, 0x1fbd, 0x203a, 0x214b, 0x293b, 0x2b74, - 0x2bfa, 0x2c26, 0x32bb, 0x346a, 0x34c7, 0x37c5, 0x4164, 0x42cc, 0x4cc3, 0x55af, - 0x5a70, 0x5b14, 0x5e1c, 0x5f76, 0x6061, 0x60f9, 0x61d7, 0x6318, 0x63a1, 0x63fb, - 0x649b, 0x64e5, 0x65a1, 0x6b69, 0x70f8, 0x71c7, 0x71cd, 0x7492, 0x7b11, 0x7db8, - 0x7f29, 0x7ff8, - ]), - }, - ..Default::default() - }) -} - -/// Second testnet genesis block (cuckoo30). -pub fn genesis_testnet2() -> core::Block { - core::Block::with_header(core::BlockHeader { - height: 0, - // previous: core::hash::Hash([0xff; 32]), - timestamp: Utc.ymd(2018, 3, 26).and_hms(16, 0, 0), - pow: ProofOfWork { - total_difficulty: Difficulty::from_num(global::initial_block_difficulty()), - secondary_scaling: 1, - nonce: 1060, - proof: Proof::new(vec![ - 0x1940730, 0x333b9d0, 0x4739d6f, 0x4c6cfb1, 0x6e3d6c3, 0x74408a3, 0x7ba2bd2, - 0x83e2024, 0x8ca22b5, 0x9d39ab8, 0xb6646dd, 0xc6698b6, 0xc6f78fe, 0xc99b662, - 0xcf2ae8c, 0xcf41eed, 0xdd073e6, 0xded6af8, 0xf08d1a5, 0x1156a144, 0x11d1160a, - 0x131bb0a5, 0x137ad703, 0x13b0831f, 0x1421683f, 0x147e3c1f, 0x1496fda0, 0x150ba22b, - 0x15cc5bc6, 0x16edf697, 0x17ced40c, 0x17d84f9e, 0x18a515c1, 0x19320d9c, 0x19da4f6d, - 0x1b50bcb1, 0x1b8bc72f, 0x1c7b6964, 0x1d07b3a9, 0x1d189d4d, 0x1d1f9a15, 0x1dafcd41, - ]), - }, - ..Default::default() - }) -} - -/// Second testnet genesis block (cuckoo30). Temporary values for now. -pub fn genesis_testnet3() -> core::Block { - core::Block::with_header(core::BlockHeader { - height: 0, - // previous: core::hash::Hash([0xff; 32]), - timestamp: Utc.ymd(2018, 7, 8).and_hms(18, 0, 0), - pow: ProofOfWork { - total_difficulty: Difficulty::from_num(global::initial_block_difficulty()), - secondary_scaling: 1, - nonce: 4956988373127691, - proof: Proof::new(vec![ - 0xa420dc, 0xc8ffee, 0x10e433e, 0x1de9428, 0x2ed4cea, 0x52d907b, 0x5af0e3f, - 0x6b8fcae, 0x8319b53, 0x845ca8c, 0x8d2a13e, 0x8d6e4cc, 0x9349e8d, 0xa7a33c5, - 0xaeac3cb, 0xb193e23, 0xb502e19, 0xb5d9804, 0xc9ac184, 0xd4f4de3, 0xd7a23b8, - 0xf1d8660, 0xf443756, 0x10b833d2, 0x11418fc5, 0x11b8aeaf, 0x131836ec, 0x132ab818, - 0x13a46a55, 0x13df89fe, 0x145d65b5, 0x166f9c3a, 0x166fe0ef, 0x178cb36f, 0x185baf68, - 0x1bbfe563, 0x1bd637b4, 0x1cfc8382, 0x1d1ed012, 0x1e391ca5, 0x1e999b4c, 0x1f7c6d21, - ]), - }, - ..Default::default() - }) -} - -/// 4th testnet genesis block (cuckatoo29 AR, 30+ AF). Temporary values for now (Pow won't verify) -/// NB: Currently set to intenal pre-testnet values -pub fn genesis_testnet4() -> core::Block { - core::Block::with_header(core::BlockHeader { - height: 0, - timestamp: Utc.ymd(2018, 10, 17).and_hms(20, 0, 0), - pow: ProofOfWork { - total_difficulty: Difficulty::from_num(global::initial_block_difficulty()), - secondary_scaling: global::initial_graph_weight(), - nonce: 8612241555342799290, + total_difficulty: Difficulty::from_num(10_u64.pow(6)), + secondary_scaling: 1856, + nonce: 1, // REPLACE proof: Proof { - nonces: vec![ - 0x46f3b4, 0x1135f8c, 0x1a1596f, 0x1e10f71, 0x41c03ea, 0x63fe8e7, 0x65af34f, - 0x73c16d3, 0x8216dc3, 0x9bc75d0, 0xae7d9ad, 0xc1cb12b, 0xc65e957, 0xf67a152, - 0xfac6559, 0x100c3d71, 0x11eea08b, 0x1225dfbb, 0x124d61a1, 0x132a14b4, - 0x13f4ec38, 0x1542d236, 0x155f2df0, 0x1577394e, 0x163c3513, 0x19349845, - 0x19d46953, 0x19f65ed4, 0x1a0411b9, 0x1a2fa039, 0x1a72a06c, 0x1b02ddd2, - 0x1b594d59, 0x1b7bffd3, 0x1befe12e, 0x1c82e4cd, 0x1d492478, 0x1de132a5, - 0x1e578b3c, 0x1ed96855, 0x1f222896, 0x1fea0da6, - ], + nonces: vec![0; 42], // REPLACE edge_bits: 29, }, }, ..Default::default() - }) + }); + let kernel = core::TxKernel { + features: core::KernelFeatures::COINBASE, + fee: 0, + lock_height: 0, + excess: Commitment::from_vec(vec![]), // REPLACE + excess_sig: Signature::from_raw_data(&[0; 64]).unwrap(), //REPLACE + }; + let output = core::Output { + features: core::OutputFeatures::COINBASE, + commit: Commitment::from_vec(vec![]), // REPLACE + proof: RangeProof { + plen: SINGLE_BULLET_PROOF_SIZE, + proof: [0; SINGLE_BULLET_PROOF_SIZE], // REPLACE + }, + }; + gen.with_reward(output, kernel) } /// Placeholder for mainnet genesis block, will definitely change before @@ -166,14 +113,14 @@ pub fn genesis_main() -> core::Block { ..Default::default() }); let kernel = core::TxKernel { - features: core::KernelFeatures::COINBASE_KERNEL, + features: core::KernelFeatures::COINBASE, fee: 0, lock_height: 0, excess: Commitment::from_vec(vec![]), // REPLACE excess_sig: Signature::from_raw_data(&[0; 64]).unwrap(), //REPLACE }; let output = core::Output { - features: core::OutputFeatures::COINBASE_OUTPUT, + features: core::OutputFeatures::COINBASE, commit: Commitment::from_vec(vec![]), // REPLACE proof: RangeProof { plen: SINGLE_BULLET_PROOF_SIZE, @@ -189,6 +136,16 @@ mod test { use crate::ser; use crate::core::hash::Hashed; + // TODO hardcode the hashes once genesis is set + #[test] + fn floonet_genesis_hash() { + let gen_hash = genesis_floo().hash(); + println!("floonet genesis hash: {}", gen_hash.to_hex()); + let gen_bin = ser::ser_vec(&genesis_floo()).unwrap(); + println!("floonet genesis full hash: {}\n", gen_bin.hash().to_hex()); + //assert_eq!(gene_hash.to_hex, ""); + } + // TODO hardcode the hashes once genesis is set #[test] fn mainnet_genesis_hash() { diff --git a/core/src/global.rs b/core/src/global.rs index fbf51a98..be7db1f7 100644 --- a/core/src/global.rs +++ b/core/src/global.rs @@ -20,7 +20,7 @@ use crate::consensus::HeaderInfo; use crate::consensus::{ graph_weight, BASE_EDGE_BITS, BLOCK_TIME_SEC, COINBASE_MATURITY, CUT_THROUGH_HORIZON, DAY_HEIGHT, DEFAULT_MIN_EDGE_BITS, DIFFICULTY_ADJUST_WINDOW, INITIAL_DIFFICULTY, PROOFSIZE, - SECOND_POW_EDGE_BITS, STATE_SYNC_THRESHOLD, T4_CUCKAROO_HARDFORK, UNIT_DIFFICULTY, + SECOND_POW_EDGE_BITS, STATE_SYNC_THRESHOLD, }; use crate::pow::{self, new_cuckaroo_ctx, new_cuckatoo_ctx, EdgeType, PoWContext}; /// An enum collecting sets of parameters used throughout the @@ -62,13 +62,6 @@ pub const TESTING_INITIAL_GRAPH_WEIGHT: u32 = 1; /// Testing initial block difficulty pub const TESTING_INITIAL_DIFFICULTY: u64 = 1; -/// Testnet 2 initial block difficulty, high to see how it goes -pub const TESTNET2_INITIAL_DIFFICULTY: u64 = 1000; - -/// Testnet 3 initial block difficulty, moderately high, taking into account -/// a 30x Cuckoo adjustment factor -pub const TESTNET3_INITIAL_DIFFICULTY: u64 = 30000; - /// If a peer's last updated difficulty is 2 hours ago and its difficulty's lower than ours, /// we're sure this peer is a stuck node, and we will kick out such kind of stuck peers. pub const STUCK_PEER_KICK_TIME: i64 = 2 * 3600 * 1000; @@ -79,13 +72,6 @@ const PEER_EXPIRATION_DAYS: i64 = 7 * 2; /// Constant that expresses defunct peer timeout in seconds to be used in checks. pub const PEER_EXPIRATION_REMOVE_TIME: i64 = PEER_EXPIRATION_DAYS * 24 * 3600; -/// Testnet 4 initial block difficulty -/// 1_000 times natural scale factor for cuckatoo29 -pub const TESTNET4_INITIAL_DIFFICULTY: u64 = 1_000 * UNIT_DIFFICULTY; - -/// Cuckatoo edge_bits on T4 -pub const TESTNET4_MIN_EDGE_BITS: u8 = 30; - /// Trigger compaction check on average every day for all nodes. /// Randomized per node - roll the dice on every block to decide. /// Will compact the txhashset to remove pruned data. @@ -101,21 +87,15 @@ pub enum ChainTypes { AutomatedTesting, /// For User testing UserTesting, - /// First test network - Testnet1, - /// Second test network - Testnet2, - /// Third test network - Testnet3, - /// Fourth test network - Testnet4, + /// Protocol testing network + Floonet, /// Main production network Mainnet, } impl Default for ChainTypes { fn default() -> ChainTypes { - ChainTypes::Testnet4 + ChainTypes::Floonet } } @@ -149,7 +129,7 @@ pub fn set_mining_mode(mode: ChainTypes) { /// Return either a cuckoo context or a cuckatoo context /// Single change point pub fn create_pow_context( - height: u64, + _height: u64, edge_bits: u8, proof_size: usize, max_sols: u32, @@ -163,12 +143,9 @@ where ChainTypes::Mainnet if edge_bits == 29 => new_cuckaroo_ctx(edge_bits, proof_size), ChainTypes::Mainnet => new_cuckatoo_ctx(edge_bits, proof_size, max_sols), - // T4 has Cuckatoo for everything up to hard fork, then Cuckaroo29 for AR - // and Cuckatoo30+ for AF PoW - ChainTypes::Testnet4 if edge_bits == 29 && height >= T4_CUCKAROO_HARDFORK => { - new_cuckaroo_ctx(edge_bits, proof_size) - } - ChainTypes::Testnet4 => new_cuckatoo_ctx(edge_bits, proof_size, max_sols), + // Same for Floonet + ChainTypes::Floonet if edge_bits == 29 => new_cuckaroo_ctx(edge_bits, proof_size), + ChainTypes::Floonet => new_cuckatoo_ctx(edge_bits, proof_size, max_sols), // Everything else is Cuckatoo only _ => new_cuckatoo_ctx(edge_bits, proof_size, max_sols), @@ -186,8 +163,6 @@ pub fn min_edge_bits() -> u8 { match *param_ref { ChainTypes::AutomatedTesting => AUTOMATED_TESTING_MIN_EDGE_BITS, ChainTypes::UserTesting => USER_TESTING_MIN_EDGE_BITS, - ChainTypes::Testnet1 => USER_TESTING_MIN_EDGE_BITS, - ChainTypes::Testnet4 => TESTNET4_MIN_EDGE_BITS, _ => DEFAULT_MIN_EDGE_BITS, } } @@ -200,7 +175,6 @@ pub fn base_edge_bits() -> u8 { match *param_ref { ChainTypes::AutomatedTesting => AUTOMATED_TESTING_MIN_EDGE_BITS, ChainTypes::UserTesting => USER_TESTING_MIN_EDGE_BITS, - ChainTypes::Testnet1 => USER_TESTING_MIN_EDGE_BITS, _ => BASE_EDGE_BITS, } } @@ -231,10 +205,7 @@ pub fn initial_block_difficulty() -> u64 { match *param_ref { ChainTypes::AutomatedTesting => TESTING_INITIAL_DIFFICULTY, ChainTypes::UserTesting => TESTING_INITIAL_DIFFICULTY, - ChainTypes::Testnet1 => TESTING_INITIAL_DIFFICULTY, - ChainTypes::Testnet2 => TESTNET2_INITIAL_DIFFICULTY, - ChainTypes::Testnet3 => TESTNET3_INITIAL_DIFFICULTY, - ChainTypes::Testnet4 => TESTNET4_INITIAL_DIFFICULTY, + ChainTypes::Floonet => INITIAL_DIFFICULTY, ChainTypes::Mainnet => INITIAL_DIFFICULTY, } } @@ -244,10 +215,7 @@ pub fn initial_graph_weight() -> u32 { match *param_ref { ChainTypes::AutomatedTesting => TESTING_INITIAL_GRAPH_WEIGHT, ChainTypes::UserTesting => TESTING_INITIAL_GRAPH_WEIGHT, - ChainTypes::Testnet1 => TESTING_INITIAL_GRAPH_WEIGHT, - ChainTypes::Testnet2 => TESTING_INITIAL_GRAPH_WEIGHT, - ChainTypes::Testnet3 => TESTING_INITIAL_GRAPH_WEIGHT, - ChainTypes::Testnet4 => graph_weight(0, SECOND_POW_EDGE_BITS) as u32, + ChainTypes::Floonet => graph_weight(0, SECOND_POW_EDGE_BITS) as u32, ChainTypes::Mainnet => graph_weight(0, SECOND_POW_EDGE_BITS) as u32, } } @@ -288,20 +256,14 @@ pub fn is_user_testing_mode() -> bool { /// Production defined as a live public network, testnet[n] or mainnet. pub fn is_production_mode() -> bool { let param_ref = CHAIN_TYPE.read(); - ChainTypes::Testnet1 == *param_ref - || ChainTypes::Testnet2 == *param_ref - || ChainTypes::Testnet3 == *param_ref - || ChainTypes::Testnet4 == *param_ref + ChainTypes::Floonet == *param_ref || ChainTypes::Mainnet == *param_ref } /// Are we in one of our (many) testnets? pub fn is_testnet() -> bool { let param_ref = CHAIN_TYPE.read(); - ChainTypes::Testnet1 == *param_ref - || ChainTypes::Testnet2 == *param_ref - || ChainTypes::Testnet3 == *param_ref - || ChainTypes::Testnet4 == *param_ref + ChainTypes::Floonet == *param_ref } /// Helper function to get a nonce known to create a valid POW on @@ -316,9 +278,9 @@ pub fn get_genesis_nonce() -> u64 { // Magic nonce for current genesis block at cuckatoo15 ChainTypes::UserTesting => 27944, // Placeholder, obviously not the right value + ChainTypes::Floonet => 0, + // Placeholder, obviously not the right value ChainTypes::Mainnet => 0, - // Magic nonce for genesis block for testnet2 (cuckatoo29) - _ => panic!("Pre-set"), } } diff --git a/core/src/pow.rs b/core/src/pow.rs index e3110c30..52136afb 100644 --- a/core/src/pow.rs +++ b/core/src/pow.rs @@ -69,7 +69,7 @@ pub fn verify_size(bh: &BlockHeader) -> Result<(), Error> { /// Mines a genesis block using the internal miner pub fn mine_genesis_block() -> Result { - let mut gen = genesis::genesis_testnet2(); + let mut gen = genesis::genesis_dev(); if global::is_user_testing_mode() || global::is_automated_testing_mode() { gen = genesis::genesis_dev(); gen.header.timestamp = Utc::now(); diff --git a/core/tests/consensus.rs b/core/tests/consensus.rs index 8178c456..fbb1ab2c 100644 --- a/core/tests/consensus.rs +++ b/core/tests/consensus.rs @@ -206,18 +206,6 @@ fn add_block( ret_chain_sim } -// Adds many defined blocks -fn add_blocks( - intervals: Vec, - chain_sim: Vec<(HeaderInfo, DiffStats)>, -) -> Vec<(HeaderInfo, DiffStats)> { - let mut return_chain = chain_sim.clone(); - for i in intervals { - return_chain = add_block(i, return_chain.clone()); - } - return_chain -} - // Adds another n 'blocks' to the iterator, with difficulty calculated fn add_block_repeated( interval: u64, @@ -355,25 +343,6 @@ fn adjustment_scenarios() { print_chain_sim(chain_sim); println!("*********************************************************"); - // Actual testnet 2 timings - let testnet2_intervals = [ - 2880, 16701, 1882, 3466, 614, 605, 1551, 538, 931, 23, 690, 1397, 2112, 2058, 605, 721, - 2148, 1605, 134, 1234, 1569, 482, 1775, 2732, 540, 958, 883, 3475, 518, 1346, 1926, 780, - 865, 269, 1079, 141, 105, 781, 289, 256, 709, 68, 165, 1813, 3899, 1458, 955, 2336, 239, - 674, 1059, 157, 214, 15, 157, 558, 1945, 1677, 1825, 1307, 1973, 660, 77, 3134, 410, 347, - 537, 649, 325, 370, 2271, 106, 19, 329, - ]; - - global::set_mining_mode(global::ChainTypes::Testnet2); - let chain_sim = create_chain_sim(global::initial_block_difficulty()); - let chain_sim = add_blocks(testnet2_intervals.to_vec(), chain_sim); - - println!(""); - println!("*********************************************************"); - println!("Scenario 6) Testnet2"); - println!("*********************************************************"); - print_chain_sim(chain_sim); - println!("*********************************************************"); } /// Checks different next_target adjustments and difficulty boundaries @@ -526,7 +495,7 @@ fn test_secondary_pow_ratio() { // Tests for testnet4 chain type (covers pre and post hardfork). { - global::set_mining_mode(global::ChainTypes::Testnet4); + global::set_mining_mode(global::ChainTypes::Floonet); assert_eq!(global::is_testnet(), true); assert_eq!(secondary_pow_ratio(1), 90); @@ -539,16 +508,16 @@ fn test_secondary_pow_ratio() { let one_week = 60 * 24 * 7; assert_eq!(secondary_pow_ratio(one_week - 1), 90); - assert_eq!(secondary_pow_ratio(one_week), 89); - assert_eq!(secondary_pow_ratio(one_week + 1), 89); + assert_eq!(secondary_pow_ratio(one_week), 90); + assert_eq!(secondary_pow_ratio(one_week + 1), 90); let two_weeks = one_week * 2; assert_eq!(secondary_pow_ratio(two_weeks - 1), 89); - assert_eq!(secondary_pow_ratio(two_weeks), 88); - assert_eq!(secondary_pow_ratio(two_weeks + 1), 88); + assert_eq!(secondary_pow_ratio(two_weeks), 89); + assert_eq!(secondary_pow_ratio(two_weeks + 1), 89); let t4_fork_height = 64_000; - assert_eq!(secondary_pow_ratio(t4_fork_height - 1), 84); + assert_eq!(secondary_pow_ratio(t4_fork_height - 1), 85); assert_eq!(secondary_pow_ratio(t4_fork_height), 85); assert_eq!(secondary_pow_ratio(t4_fork_height + 1), 85); @@ -572,9 +541,9 @@ fn test_secondary_pow_scale() { let window = DIFFICULTY_ADJUST_WINDOW; let mut hi = HeaderInfo::from_diff_scaling(Difficulty::from_num(10), 100); - // testnet4 testing + // floonet testing { - global::set_mining_mode(global::ChainTypes::Testnet4); + global::set_mining_mode(global::ChainTypes::Floonet); assert_eq!(global::is_testnet(), true); // all primary, factor should increase so it becomes easier to find a high @@ -582,13 +551,13 @@ fn test_secondary_pow_scale() { hi.is_secondary = false; assert_eq!( secondary_pow_scaling(1, &(0..window).map(|_| hi.clone()).collect::>()), - 147 + 106 ); // all secondary on 90%, factor should go down a bit hi.is_secondary = true; assert_eq!( secondary_pow_scaling(1, &(0..window).map(|_| hi.clone()).collect::>()), - 94 + 97 ); // all secondary on 1%, factor should go down to bound (divide by 2) assert_eq!( @@ -631,7 +600,7 @@ fn test_secondary_pow_scale() { .chain((0..(window * 95 / 100)).map(|_| hi.clone())) .collect::>() ), - 94 + 96 ); // 40% secondary, should come up based on 70 average assert_eq!( @@ -642,7 +611,7 @@ fn test_secondary_pow_scale() { .chain((0..(window * 4 / 10)).map(|_| hi.clone())) .collect::>() ), - 84 + 72 ); } diff --git a/servers/src/grin/server.rs b/servers/src/grin/server.rs index 89b1e3f9..e8ace36d 100644 --- a/servers/src/grin/server.rs +++ b/servers/src/grin/server.rs @@ -133,13 +133,10 @@ impl Server { )); let genesis = match config.chain_type { - global::ChainTypes::Testnet1 => genesis::genesis_testnet1(), - global::ChainTypes::Testnet2 => genesis::genesis_testnet2(), - global::ChainTypes::Testnet3 => genesis::genesis_testnet3(), - global::ChainTypes::Testnet4 => genesis::genesis_testnet4(), global::ChainTypes::AutomatedTesting => genesis::genesis_dev(), global::ChainTypes::UserTesting => genesis::genesis_dev(), - global::ChainTypes::Mainnet => genesis::genesis_testnet2(), //TODO: Fix, obviously + global::ChainTypes::Floonet => genesis::genesis_floo(), + global::ChainTypes::Mainnet => genesis::genesis_main(), }; info!("Starting server, genesis block: {}", genesis.hash()); diff --git a/wallet/src/types.rs b/wallet/src/types.rs index fcdd68f4..3e25ae5f 100644 --- a/wallet/src/types.rs +++ b/wallet/src/types.rs @@ -62,7 +62,7 @@ pub struct WalletConfig { impl Default for WalletConfig { fn default() -> WalletConfig { WalletConfig { - chain_type: Some(ChainTypes::Testnet4), + chain_type: Some(ChainTypes::Floonet), api_listen_interface: "127.0.0.1".to_string(), api_listen_port: 13415, api_secret_path: Some(".api_secret".to_string()),