Rename Floonet to Testnet (#3431)

* Rename Floonet to Testnet

* Fix test

* Rename test and docker
This commit is contained in:
Quentin Le Sceller 2020-10-07 09:36:02 -04:00 committed by GitHub
parent 4c6d1dd4bd
commit cf2a65242d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 111 additions and 111 deletions

View file

@ -14,5 +14,5 @@ Before submitting your PR for final review, please ensure that it:
* Explains whether/how the change is consensus breaking or breaks existing client functionality * Explains whether/how the change is consensus breaking or breaks existing client functionality
* Contains unit tests exercising new/changed functionality * Contains unit tests exercising new/changed functionality
* Fully considers the potential impact of the change on other parts of the system * Fully considers the potential impact of the change on other parts of the system
* Describes how you've tested the change (e.g. against Floonet, etc) * Describes how you've tested the change (e.g. against Testnet, etc)
* Updates any documentation that's affected by the PR * Updates any documentation that's affected by the PR

View file

@ -17,7 +17,7 @@ Since mainnet has been released, the bar for having PRs accepted has been raised
* Explains whether/how the change is consensus breaking or breaks existing client functionality * Explains whether/how the change is consensus breaking or breaks existing client functionality
* Contains unit tests exercising new/changed functionality * Contains unit tests exercising new/changed functionality
* Fully considers the potential impact of the change on other parts of the system * Fully considers the potential impact of the change on other parts of the system
* Describes how you've tested the change (e.g. against Floonet, etc) * Describes how you've tested the change (e.g. against Testnet, etc)
* Updates any documentation that's affected by the PR * Updates any documentation that's affected by the PR
If submitting a PR consisting of documentation changes only, please try to ensure that the change is significantly more substantial than one or two lines. For example, working through an install document and making changes and updates throughout as you find issues is worth a PR. For typos and other small changes, either contact one of the developers, or if you think it's a significant enough error to cause problems for other users, please feel free to open an issue. If submitting a PR consisting of documentation changes only, please try to ensure that the change is significantly more substantial than one or two lines. For example, working through an install document and making changes and updates throughout as you find issues is worth a PR. For typos and other small changes, either contact one of the developers, or if you think it's a significant enough error to cause problems for other users, please feel free to open an issue.

View file

@ -986,7 +986,7 @@ impl Chain {
/// Specific tmp dir. /// Specific tmp dir.
/// Normally it's ~/.grin/main/tmp for mainnet /// Normally it's ~/.grin/main/tmp for mainnet
/// or ~/.grin/floo/tmp for floonet /// or ~/.grin/test/tmp for Testnet
pub fn get_tmp_dir(&self) -> PathBuf { pub fn get_tmp_dir(&self) -> PathBuf {
let mut tmp_dir = PathBuf::from(self.db_root.clone()); let mut tmp_dir = PathBuf::from(self.db_root.clone());
tmp_dir = tmp_dir tmp_dir = tmp_dir

View file

@ -87,7 +87,7 @@ fn comments() -> HashMap<String, String> {
#parameters used for mining as well as wallet output coinbase maturity. Can be: #parameters used for mining as well as wallet output coinbase maturity. Can be:
#AutomatedTesting - For CI builds and instant blockchain creation #AutomatedTesting - For CI builds and instant blockchain creation
#UserTesting - For regular user testing (cuckoo 16) #UserTesting - For regular user testing (cuckoo 16)
#Floonet - For the long term floonet test network #Testnet - For the long term test network
#Mainnet - For mainnet #Mainnet - For mainnet
" "
.to_string(), .to_string(),

View file

@ -168,7 +168,7 @@ impl GlobalConfig {
match *chain_type { match *chain_type {
global::ChainTypes::Mainnet => {} global::ChainTypes::Mainnet => {}
global::ChainTypes::Floonet => { global::ChainTypes::Testnet => {
defaults.api_http_addr = "127.0.0.1:13413".to_owned(); defaults.api_http_addr = "127.0.0.1:13413".to_owned();
defaults.p2p_config.port = 13414; defaults.p2p_config.port = 13414;
defaults defaults

View file

@ -127,14 +127,14 @@ pub const MAX_BLOCK_WEIGHT: u64 = 40_000;
/// Fork every 6 months. /// Fork every 6 months.
pub const HARD_FORK_INTERVAL: u64 = YEAR_HEIGHT / 2; pub const HARD_FORK_INTERVAL: u64 = YEAR_HEIGHT / 2;
/// Floonet first hard fork height, set to happen around 2019-06-20 /// Testnet first hard fork height, set to happen around 2019-06-20
pub const FLOONET_FIRST_HARD_FORK: u64 = 185_040; pub const TESTNET_FIRST_HARD_FORK: u64 = 185_040;
/// Floonet second hard fork height, set to happen around 2019-12-19 /// Testnet second hard fork height, set to happen around 2019-12-19
pub const FLOONET_SECOND_HARD_FORK: u64 = 298_080; pub const TESTNET_SECOND_HARD_FORK: u64 = 298_080;
/// Floonet second hard fork height, set to happen around 2020-06-20 /// Testnet second hard fork height, set to happen around 2020-06-20
pub const FLOONET_THIRD_HARD_FORK: u64 = 552_960; pub const TESTNET_THIRD_HARD_FORK: u64 = 552_960;
/// AutomatedTesting and UserTesting HF1 height. /// AutomatedTesting and UserTesting HF1 height.
pub const TESTING_FIRST_HARD_FORK: u64 = 3; pub const TESTING_FIRST_HARD_FORK: u64 = 3;
@ -152,12 +152,12 @@ pub fn header_version(height: u64) -> HeaderVersion {
let hf_interval = (1 + height / HARD_FORK_INTERVAL) as u16; let hf_interval = (1 + height / HARD_FORK_INTERVAL) as u16;
match chain_type { match chain_type {
global::ChainTypes::Mainnet => HeaderVersion(hf_interval), global::ChainTypes::Mainnet => HeaderVersion(hf_interval),
global::ChainTypes::Floonet => { global::ChainTypes::Testnet => {
if height < FLOONET_FIRST_HARD_FORK { if height < TESTNET_FIRST_HARD_FORK {
HeaderVersion(1) HeaderVersion(1)
} else if height < FLOONET_SECOND_HARD_FORK { } else if height < TESTNET_SECOND_HARD_FORK {
HeaderVersion(2) HeaderVersion(2)
} else if height < FLOONET_THIRD_HARD_FORK { } else if height < TESTNET_THIRD_HARD_FORK {
HeaderVersion(3) HeaderVersion(3)
} else if height < 4 * HARD_FORK_INTERVAL { } else if height < 4 * HARD_FORK_INTERVAL {
HeaderVersion(4) HeaderVersion(4)

View file

@ -44,8 +44,8 @@ pub fn genesis_dev() -> core::Block {
}) })
} }
/// Floonet genesis block /// Testnet genesis block
pub fn genesis_floo() -> core::Block { pub fn genesis_test() -> core::Block {
let gen = core::Block::with_header(core::BlockHeader { let gen = core::Block::with_header(core::BlockHeader {
height: 0, height: 0,
timestamp: Utc.ymd(2018, 12, 28).and_hms(20, 48, 4), timestamp: Utc.ymd(2018, 12, 28).and_hms(20, 48, 4),
@ -277,12 +277,12 @@ mod test {
use util::ToHex; use util::ToHex;
#[test] #[test]
fn floonet_genesis_hash() { fn testnet_genesis_hash() {
global::set_local_chain_type(global::ChainTypes::Floonet); global::set_local_chain_type(global::ChainTypes::Testnet);
let gen_hash = genesis_floo().hash(); let gen_hash = genesis_test().hash();
println!("floonet genesis hash: {}", gen_hash.to_hex()); println!("testnet genesis hash: {}", gen_hash.to_hex());
let gen_bin = ser::ser_vec(&genesis_floo(), ProtocolVersion(1)).unwrap(); let gen_bin = ser::ser_vec(&genesis_test(), ProtocolVersion(1)).unwrap();
println!("floonet genesis full hash: {}\n", gen_bin.hash().to_hex()); println!("testnet genesis full hash: {}\n", gen_bin.hash().to_hex());
assert_eq!( assert_eq!(
gen_hash.to_hex(), gen_hash.to_hex(),
"edc758c1370d43e1d733f70f58cf187c3be8242830429b1676b89fd91ccf2dab" "edc758c1370d43e1d733f70f58cf187c3be8242830429b1676b89fd91ccf2dab"

View file

@ -115,18 +115,18 @@ pub enum ChainTypes {
/// For User testing /// For User testing
UserTesting, UserTesting,
/// Protocol testing network /// Protocol testing network
Floonet, Testnet,
/// Main production network /// Main production network
Mainnet, Mainnet,
} }
impl ChainTypes { impl ChainTypes {
/// Short name representing the chain type ("floo", "main", etc.) /// Short name representing the chain type ("test", "main", etc.)
pub fn shortname(&self) -> String { pub fn shortname(&self) -> String {
match *self { match *self {
ChainTypes::AutomatedTesting => "auto".to_owned(), ChainTypes::AutomatedTesting => "auto".to_owned(),
ChainTypes::UserTesting => "user".to_owned(), ChainTypes::UserTesting => "user".to_owned(),
ChainTypes::Floonet => "floo".to_owned(), ChainTypes::Testnet => "test".to_owned(),
ChainTypes::Mainnet => "main".to_owned(), ChainTypes::Mainnet => "main".to_owned(),
} }
} }
@ -151,7 +151,7 @@ lazy_static! {
} }
thread_local! { thread_local! {
/// Mainnet|Floonet|UserTesting|AutomatedTesting /// Mainnet|Testnet|UserTesting|AutomatedTesting
pub static CHAIN_TYPE: Cell<Option<ChainTypes>> = Cell::new(None); pub static CHAIN_TYPE: Cell<Option<ChainTypes>> = Cell::new(None);
/// Local feature flag for NRD kernel support. /// Local feature flag for NRD kernel support.
@ -238,18 +238,18 @@ pub fn create_pow_context<T>(
} }
ChainTypes::Mainnet => new_cuckaroo_ctx(edge_bits, proof_size), ChainTypes::Mainnet => new_cuckaroo_ctx(edge_bits, proof_size),
// Same for Floonet // Same for Testnet
ChainTypes::Floonet if edge_bits > 29 => new_cuckatoo_ctx(edge_bits, proof_size, max_sols), ChainTypes::Testnet if edge_bits > 29 => new_cuckatoo_ctx(edge_bits, proof_size, max_sols),
ChainTypes::Floonet if valid_header_version(height, HeaderVersion(4)) => { ChainTypes::Testnet if valid_header_version(height, HeaderVersion(4)) => {
new_cuckarooz_ctx(edge_bits, proof_size) new_cuckarooz_ctx(edge_bits, proof_size)
} }
ChainTypes::Floonet if valid_header_version(height, HeaderVersion(3)) => { ChainTypes::Testnet if valid_header_version(height, HeaderVersion(3)) => {
new_cuckaroom_ctx(edge_bits, proof_size) new_cuckaroom_ctx(edge_bits, proof_size)
} }
ChainTypes::Floonet if valid_header_version(height, HeaderVersion(2)) => { ChainTypes::Testnet if valid_header_version(height, HeaderVersion(2)) => {
new_cuckarood_ctx(edge_bits, proof_size) new_cuckarood_ctx(edge_bits, proof_size)
} }
ChainTypes::Floonet => new_cuckaroo_ctx(edge_bits, proof_size), ChainTypes::Testnet => new_cuckaroo_ctx(edge_bits, proof_size),
// Everything else is Cuckatoo only // Everything else is Cuckatoo only
_ => new_cuckatoo_ctx(edge_bits, proof_size, max_sols), _ => new_cuckatoo_ctx(edge_bits, proof_size, max_sols),
@ -299,7 +299,7 @@ pub fn initial_block_difficulty() -> u64 {
match get_chain_type() { match get_chain_type() {
ChainTypes::AutomatedTesting => TESTING_INITIAL_DIFFICULTY, ChainTypes::AutomatedTesting => TESTING_INITIAL_DIFFICULTY,
ChainTypes::UserTesting => TESTING_INITIAL_DIFFICULTY, ChainTypes::UserTesting => TESTING_INITIAL_DIFFICULTY,
ChainTypes::Floonet => INITIAL_DIFFICULTY, ChainTypes::Testnet => INITIAL_DIFFICULTY,
ChainTypes::Mainnet => INITIAL_DIFFICULTY, ChainTypes::Mainnet => INITIAL_DIFFICULTY,
} }
} }
@ -308,7 +308,7 @@ pub fn initial_graph_weight() -> u32 {
match get_chain_type() { match get_chain_type() {
ChainTypes::AutomatedTesting => TESTING_INITIAL_GRAPH_WEIGHT, ChainTypes::AutomatedTesting => TESTING_INITIAL_GRAPH_WEIGHT,
ChainTypes::UserTesting => TESTING_INITIAL_GRAPH_WEIGHT, ChainTypes::UserTesting => TESTING_INITIAL_GRAPH_WEIGHT,
ChainTypes::Floonet => graph_weight(0, SECOND_POW_EDGE_BITS) as u32, ChainTypes::Testnet => graph_weight(0, SECOND_POW_EDGE_BITS) as u32,
ChainTypes::Mainnet => graph_weight(0, SECOND_POW_EDGE_BITS) as u32, ChainTypes::Mainnet => graph_weight(0, SECOND_POW_EDGE_BITS) as u32,
} }
} }
@ -318,7 +318,7 @@ pub fn max_block_weight() -> u64 {
match get_chain_type() { match get_chain_type() {
ChainTypes::AutomatedTesting => TESTING_MAX_BLOCK_WEIGHT, ChainTypes::AutomatedTesting => TESTING_MAX_BLOCK_WEIGHT,
ChainTypes::UserTesting => TESTING_MAX_BLOCK_WEIGHT, ChainTypes::UserTesting => TESTING_MAX_BLOCK_WEIGHT,
ChainTypes::Floonet => MAX_BLOCK_WEIGHT, ChainTypes::Testnet => MAX_BLOCK_WEIGHT,
ChainTypes::Mainnet => MAX_BLOCK_WEIGHT, ChainTypes::Mainnet => MAX_BLOCK_WEIGHT,
} }
} }
@ -360,19 +360,19 @@ pub fn txhashset_archive_interval() -> u64 {
/// Production defined as a live public network, testnet[n] or mainnet. /// Production defined as a live public network, testnet[n] or mainnet.
pub fn is_production_mode() -> bool { pub fn is_production_mode() -> bool {
match get_chain_type() { match get_chain_type() {
ChainTypes::Floonet => true, ChainTypes::Testnet => true,
ChainTypes::Mainnet => true, ChainTypes::Mainnet => true,
_ => false, _ => false,
} }
} }
/// Are we in floonet? /// Are we in testnet?
/// Note: We do not have a corresponding is_mainnet() as we want any tests to be as close /// Note: We do not have a corresponding is_mainnet() as we want any tests to be as close
/// as possible to "mainnet" configuration as possible. /// as possible to "mainnet" configuration as possible.
/// We want to avoid missing any mainnet only code paths. /// We want to avoid missing any mainnet only code paths.
pub fn is_floonet() -> bool { pub fn is_testnet() -> bool {
match get_chain_type() { match get_chain_type() {
ChainTypes::Floonet => true, ChainTypes::Testnet => true,
_ => false, _ => false,
} }
} }
@ -448,9 +448,9 @@ mod test {
} }
#[test] #[test]
fn floonet_header_len() { fn testnet_header_len() {
set_local_chain_type(ChainTypes::Floonet); set_local_chain_type(ChainTypes::Testnet);
test_header_len(genesis_floo()); test_header_len(genesis_test());
} }
#[test] #[test]

View file

@ -412,7 +412,7 @@ impl ProofBuild for ViewKey {
} }
let mut key = self.clone(); let mut key = self.clone();
let mut hasher = BIP32GrinHasher::new(self.is_floo); let mut hasher = BIP32GrinHasher::new(self.is_test);
for i in self.depth..path.depth { for i in self.depth..path.depth {
let child_number = path.path[i as usize]; let child_number = path.path[i as usize];
if child_number.is_hardened() { if child_number.is_hardened() {

View file

@ -12,17 +12,17 @@
// limitations under the License. // limitations under the License.
use grin_core::consensus::{ use grin_core::consensus::{
secondary_pow_ratio, valid_header_version, FLOONET_FIRST_HARD_FORK, FLOONET_SECOND_HARD_FORK, secondary_pow_ratio, valid_header_version, HARD_FORK_INTERVAL, TESTNET_FIRST_HARD_FORK,
FLOONET_THIRD_HARD_FORK, HARD_FORK_INTERVAL, TESTNET_SECOND_HARD_FORK, TESTNET_THIRD_HARD_FORK,
}; };
use grin_core::core::HeaderVersion; use grin_core::core::HeaderVersion;
use grin_core::global; use grin_core::global;
#[test] #[test]
fn test_secondary_pow_ratio() { fn test_secondary_pow_ratio() {
// Tests for Floonet chain type (covers pre and post hardfork). // Tests for Testnet chain type (covers pre and post hardfork).
global::set_local_chain_type(global::ChainTypes::Floonet); global::set_local_chain_type(global::ChainTypes::Testnet);
assert_eq!(global::is_floonet(), true); assert_eq!(global::is_testnet(), true);
assert_eq!(secondary_pow_ratio(1), 90); assert_eq!(secondary_pow_ratio(1), 90);
assert_eq!(secondary_pow_ratio(89), 90); assert_eq!(secondary_pow_ratio(89), 90);
@ -63,69 +63,69 @@ fn test_secondary_pow_ratio() {
#[test] #[test]
fn hard_forks() { fn hard_forks() {
global::set_local_chain_type(global::ChainTypes::Floonet); global::set_local_chain_type(global::ChainTypes::Testnet);
assert_eq!(global::is_floonet(), true); assert_eq!(global::is_testnet(), true);
assert!(valid_header_version(0, HeaderVersion(1))); assert!(valid_header_version(0, HeaderVersion(1)));
assert!(valid_header_version(10, HeaderVersion(1))); assert!(valid_header_version(10, HeaderVersion(1)));
assert!(!valid_header_version(10, HeaderVersion(2))); assert!(!valid_header_version(10, HeaderVersion(2)));
assert!(valid_header_version( assert!(valid_header_version(
FLOONET_FIRST_HARD_FORK - 1, TESTNET_FIRST_HARD_FORK - 1,
HeaderVersion(1) HeaderVersion(1)
)); ));
assert!(valid_header_version( assert!(valid_header_version(
FLOONET_FIRST_HARD_FORK, TESTNET_FIRST_HARD_FORK,
HeaderVersion(2) HeaderVersion(2)
)); ));
assert!(valid_header_version( assert!(valid_header_version(
FLOONET_FIRST_HARD_FORK + 1, TESTNET_FIRST_HARD_FORK + 1,
HeaderVersion(2) HeaderVersion(2)
)); ));
assert!(!valid_header_version( assert!(!valid_header_version(
FLOONET_FIRST_HARD_FORK, TESTNET_FIRST_HARD_FORK,
HeaderVersion(1) HeaderVersion(1)
)); ));
assert!(valid_header_version( assert!(valid_header_version(
FLOONET_SECOND_HARD_FORK - 1, TESTNET_SECOND_HARD_FORK - 1,
HeaderVersion(2) HeaderVersion(2)
)); ));
assert!(valid_header_version( assert!(valid_header_version(
FLOONET_SECOND_HARD_FORK, TESTNET_SECOND_HARD_FORK,
HeaderVersion(3) HeaderVersion(3)
)); ));
assert!(valid_header_version( assert!(valid_header_version(
FLOONET_SECOND_HARD_FORK + 1, TESTNET_SECOND_HARD_FORK + 1,
HeaderVersion(3) HeaderVersion(3)
)); ));
assert!(!valid_header_version( assert!(!valid_header_version(
FLOONET_SECOND_HARD_FORK, TESTNET_SECOND_HARD_FORK,
HeaderVersion(2) HeaderVersion(2)
)); ));
assert!(!valid_header_version( assert!(!valid_header_version(
FLOONET_SECOND_HARD_FORK, TESTNET_SECOND_HARD_FORK,
HeaderVersion(1) HeaderVersion(1)
)); ));
assert!(valid_header_version( assert!(valid_header_version(
FLOONET_THIRD_HARD_FORK - 1, TESTNET_THIRD_HARD_FORK - 1,
HeaderVersion(3) HeaderVersion(3)
)); ));
assert!(valid_header_version( assert!(valid_header_version(
FLOONET_THIRD_HARD_FORK, TESTNET_THIRD_HARD_FORK,
HeaderVersion(4) HeaderVersion(4)
)); ));
assert!(valid_header_version( assert!(valid_header_version(
FLOONET_THIRD_HARD_FORK + 1, TESTNET_THIRD_HARD_FORK + 1,
HeaderVersion(4) HeaderVersion(4)
)); ));
assert!(!valid_header_version( assert!(!valid_header_version(
FLOONET_THIRD_HARD_FORK, TESTNET_THIRD_HARD_FORK,
HeaderVersion(3) HeaderVersion(3)
)); ));
assert!(!valid_header_version( assert!(!valid_header_version(
FLOONET_THIRD_HARD_FORK, TESTNET_THIRD_HARD_FORK,
HeaderVersion(2) HeaderVersion(2)
)); ));
assert!(!valid_header_version( assert!(!valid_header_version(
FLOONET_THIRD_HARD_FORK, TESTNET_THIRD_HARD_FORK,
HeaderVersion(1) HeaderVersion(1)
)); ));

View file

@ -108,7 +108,7 @@ grin client --help
```sh ```sh
docker build -t grin -f etc/Dockerfile . docker build -t grin -f etc/Dockerfile .
``` ```
For floonet, use `etc/Dockerfile.floonet` instead For testnet, use `etc/Dockerfile.testnet` instead
You can bind-mount your grin cache to run inside the container. You can bind-mount your grin cache to run inside the container.

View file

@ -102,7 +102,7 @@ grin client --help
```sh ```sh
docker build -t grin -f etc/Dockerfile . docker build -t grin -f etc/Dockerfile .
``` ```
floonetを使用する場合、代わりに`etc/Dockerfile.floonet`を指定。 testnetを使用する場合、代わりに`etc/Dockerfile.testnet`を指定。
コンテナ内で実行する場合、grinのキャッシュをバインドマウントすることも可能。 コンテナ内で実行する場合、grinのキャッシュをバインドマウントすることも可能。

View file

@ -104,7 +104,7 @@ grin client --help
docker build -t grin -f etc/Dockerfile . docker build -t grin -f etc/Dockerfile .
``` ```
floonet을 사용하려면 `etc/Dockerfile.floonet` 을 사용하세요. testnet을 사용하려면 `etc/Dockerfile.testnet` 을 사용하세요.
container 안에서 grin cache를 bind-mount로 사용 할 수 있습니다. container 안에서 grin cache를 bind-mount로 사용 할 수 있습니다.
```sh ```sh

View file

@ -100,7 +100,7 @@ grin client --help
```sh ```sh
docker build -t grin -f etc/Dockerfile . docker build -t grin -f etc/Dockerfile .
``` ```
对于 floonet, 使用 `etc/Dockerfile.floonet` 代替 对于 testnet, 使用 `etc/Dockerfile.testnet` 代替
您可以绑定安装您的 grin 缓存以在容器中运行。 您可以绑定安装您的 grin 缓存以在容器中运行。

View file

@ -37,13 +37,13 @@ COPY --from=builder /usr/src/grin/target/release/grin /usr/local/bin/grin
WORKDIR /root/.grin WORKDIR /root/.grin
RUN grin --floonet server config && \ RUN grin --testnet server config && \
sed -i -e 's/run_tui = true/run_tui = false/' grin-server.toml sed -i -e 's/run_tui = true/run_tui = false/' grin-server.toml
VOLUME ["/root/.grin"] VOLUME ["/root/.grin"]
EXPOSE 13413 13414 13415 13416 EXPOSE 13413 13414 13415 13416
ENTRYPOINT ["grin", "--floonet"] ENTRYPOINT ["grin", "--testnet"]
CMD ["server", "run"] CMD ["server", "run"]

View file

@ -91,15 +91,15 @@ pub trait BIP32Hasher {
/// Implementation of the above that uses the standard BIP32 Hash algorithms /// Implementation of the above that uses the standard BIP32 Hash algorithms
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct BIP32GrinHasher { pub struct BIP32GrinHasher {
is_floo: bool, is_test: bool,
hmac_sha512: Hmac<Sha512>, hmac_sha512: Hmac<Sha512>,
} }
impl BIP32GrinHasher { impl BIP32GrinHasher {
/// New empty hasher /// New empty hasher
pub fn new(is_floo: bool) -> BIP32GrinHasher { pub fn new(is_test: bool) -> BIP32GrinHasher {
BIP32GrinHasher { BIP32GrinHasher {
is_floo: is_floo, is_test: is_test,
hmac_sha512: HmacSha512::new(GenericArray::from_slice(&[0u8; 128])), hmac_sha512: HmacSha512::new(GenericArray::from_slice(&[0u8; 128])),
} }
} }
@ -107,14 +107,14 @@ impl BIP32GrinHasher {
impl BIP32Hasher for BIP32GrinHasher { impl BIP32Hasher for BIP32GrinHasher {
fn network_priv(&self) -> [u8; 4] { fn network_priv(&self) -> [u8; 4] {
if self.is_floo { if self.is_test {
[0x03, 0x27, 0x3A, 0x10] [0x03, 0x27, 0x3A, 0x10]
} else { } else {
[0x03, 0x3C, 0x04, 0xA4] [0x03, 0x3C, 0x04, 0xA4]
} }
} }
fn network_pub(&self) -> [u8; 4] { fn network_pub(&self) -> [u8; 4] {
if self.is_floo { if self.is_test {
[0x03, 0x27, 0x3E, 0x4B] [0x03, 0x27, 0x3E, 0x4B]
} else { } else {
[0x03, 0x3C, 0x08, 0xDF] [0x03, 0x3C, 0x08, 0xDF]
@ -370,10 +370,10 @@ impl ExtendedPrivKey {
secp: &Secp256k1, secp: &Secp256k1,
mnemonic: &str, mnemonic: &str,
passphrase: &str, passphrase: &str,
is_floo: bool, is_test: bool,
) -> Result<ExtendedPrivKey, Error> { ) -> Result<ExtendedPrivKey, Error> {
let seed = mnemonic::to_seed(mnemonic, passphrase).map_err(Error::MnemonicError)?; let seed = mnemonic::to_seed(mnemonic, passphrase).map_err(Error::MnemonicError)?;
let mut hasher = BIP32GrinHasher::new(is_floo); let mut hasher = BIP32GrinHasher::new(is_test);
let key = ExtendedPrivKey::new_master(secp, &mut hasher, &seed)?; let key = ExtendedPrivKey::new_master(secp, &mut hasher, &seed)?;
Ok(key) Ok(key)
} }

View file

@ -45,8 +45,8 @@ impl ExtKeychain {
} }
impl Keychain for ExtKeychain { impl Keychain for ExtKeychain {
fn from_seed(seed: &[u8], is_floo: bool) -> Result<ExtKeychain, Error> { fn from_seed(seed: &[u8], is_test: bool) -> Result<ExtKeychain, Error> {
let mut h = BIP32GrinHasher::new(is_floo); let mut h = BIP32GrinHasher::new(is_test);
let secp = secp::Secp256k1::with_caps(secp::ContextFlag::Commit); let secp = secp::Secp256k1::with_caps(secp::ContextFlag::Commit);
let master = ExtendedPrivKey::new_master(&secp, &mut h, seed)?; let master = ExtendedPrivKey::new_master(&secp, &mut h, seed)?;
let keychain = ExtKeychain { let keychain = ExtKeychain {
@ -57,10 +57,10 @@ impl Keychain for ExtKeychain {
Ok(keychain) Ok(keychain)
} }
fn from_mnemonic(word_list: &str, extension_word: &str, is_floo: bool) -> Result<Self, Error> { fn from_mnemonic(word_list: &str, extension_word: &str, is_test: bool) -> Result<Self, Error> {
let secp = secp::Secp256k1::with_caps(secp::ContextFlag::Commit); let secp = secp::Secp256k1::with_caps(secp::ContextFlag::Commit);
let h = BIP32GrinHasher::new(is_floo); let h = BIP32GrinHasher::new(is_test);
let master = ExtendedPrivKey::from_mnemonic(&secp, word_list, extension_word, is_floo)?; let master = ExtendedPrivKey::from_mnemonic(&secp, word_list, extension_word, is_test)?;
let keychain = ExtKeychain { let keychain = ExtKeychain {
secp: secp, secp: secp,
master: master, master: master,
@ -77,10 +77,10 @@ impl Keychain for ExtKeychain {
} }
/// For testing - probably not a good idea to use outside of tests. /// For testing - probably not a good idea to use outside of tests.
fn from_random_seed(is_floo: bool) -> Result<ExtKeychain, Error> { fn from_random_seed(is_test: bool) -> Result<ExtKeychain, Error> {
let seed: String = thread_rng().sample_iter(&Alphanumeric).take(16).collect(); let seed: String = thread_rng().sample_iter(&Alphanumeric).take(16).collect();
let seed = blake2b(32, &[], seed.as_bytes()); let seed = blake2b(32, &[], seed.as_bytes());
ExtKeychain::from_seed(seed.as_bytes(), is_floo) ExtKeychain::from_seed(seed.as_bytes(), is_test)
} }
fn root_key_id() -> Identifier { fn root_key_id() -> Identifier {

View file

@ -436,13 +436,13 @@ pub struct ValueExtKeychainPath {
pub trait Keychain: Sync + Send + Clone { pub trait Keychain: Sync + Send + Clone {
/// Generates a keychain from a raw binary seed (which has already been /// Generates a keychain from a raw binary seed (which has already been
/// decrypted if applicable). /// decrypted if applicable).
fn from_seed(seed: &[u8], is_floo: bool) -> Result<Self, Error>; fn from_seed(seed: &[u8], is_test: bool) -> Result<Self, Error>;
/// Generates a keychain from a list of space-separated mnemonic words /// Generates a keychain from a list of space-separated mnemonic words
fn from_mnemonic(word_list: &str, extension_word: &str, is_floo: bool) -> Result<Self, Error>; fn from_mnemonic(word_list: &str, extension_word: &str, is_test: bool) -> Result<Self, Error>;
/// Generates a keychain from a randomly generated seed. Mostly used for tests. /// Generates a keychain from a randomly generated seed. Mostly used for tests.
fn from_random_seed(is_floo: bool) -> Result<Self, Error>; fn from_random_seed(is_test: bool) -> Result<Self, Error>;
/// XOR masks the keychain's master key against another key /// XOR masks the keychain's master key against another key
fn mask_master_key(&mut self, mask: &SecretKey) -> Result<(), Error>; fn mask_master_key(&mut self, mask: &SecretKey) -> Result<(), Error>;

View file

@ -12,8 +12,8 @@ use crate::util::secp::key::{PublicKey, SecretKey};
use crate::util::secp::Secp256k1; use crate::util::secp::Secp256k1;
use crate::SwitchCommitmentType; use crate::SwitchCommitmentType;
/*const VERSION_FLOO_NS: [u8;4] = [0x03, 0x27, 0x3E, 0x4B]; /*const VERSION_TEST_NS: [u8;4] = [0x03, 0x27, 0x3E, 0x4B];
const VERSION_FLOO: [u8;4] = [0x03, 0x27, 0x3E, 0x4B]; const VERSION_TEST: [u8;4] = [0x03, 0x27, 0x3E, 0x4B];
const VERSION_MAIN_NS: [u8;4] = [0x03, 0x3C, 0x08, 0xDF]; const VERSION_MAIN_NS: [u8;4] = [0x03, 0x3C, 0x08, 0xDF];
const VERSION_MAIN: [u8;4] = [0x03, 0x3C, 0x08, 0xDF];*/ const VERSION_MAIN: [u8;4] = [0x03, 0x3C, 0x08, 0xDF];*/
@ -22,8 +22,8 @@ const VERSION_MAIN: [u8;4] = [0x03, 0x3C, 0x08, 0xDF];*/
/// At the moment only depth 0 keys can be used /// At the moment only depth 0 keys can be used
#[derive(Clone, PartialEq, Eq, Debug)] #[derive(Clone, PartialEq, Eq, Debug)]
pub struct ViewKey { pub struct ViewKey {
/// Whether this view key is meant for floonet or not /// Whether this view key is meant for testnet or not
pub is_floo: bool, pub is_test: bool,
/// How many derivations this key is from the master (which is 0) /// How many derivations this key is from the master (which is 0)
pub depth: u8, pub depth: u8,
/// Fingerprint of the parent key /// Fingerprint of the parent key
@ -45,7 +45,7 @@ impl ViewKey {
keychain: &K, keychain: &K,
ext_key: ExtendedPrivKey, ext_key: ExtendedPrivKey,
hasher: &mut H, hasher: &mut H,
is_floo: bool, is_test: bool,
) -> Result<Self, Error> ) -> Result<Self, Error>
where where
K: Keychain, K: Keychain,
@ -69,7 +69,7 @@ impl ViewKey {
let rewind_hash = Self::rewind_hash(secp, keychain.public_root_key()); let rewind_hash = Self::rewind_hash(secp, keychain.public_root_key());
Ok(Self { Ok(Self {
is_floo, is_test,
depth, depth,
parent_fingerprint, parent_fingerprint,
child_number, child_number,
@ -136,7 +136,7 @@ impl ViewKey {
}; };
Ok(Self { Ok(Self {
is_floo: self.is_floo, is_test: self.is_test,
depth: self.depth + 1, depth: self.depth + 1,
parent_fingerprint: self.fingerprint(secp, hasher), parent_fingerprint: self.fingerprint(secp, hasher),
child_number: i, child_number: i,

View file

@ -40,7 +40,7 @@ pub const USER_AGENT: &str = concat!("MW/Grin ", env!("CARGO_PKG_VERSION"));
/// Magic numbers expected in the header of every message /// Magic numbers expected in the header of every message
const OTHER_MAGIC: [u8; 2] = [73, 43]; const OTHER_MAGIC: [u8; 2] = [73, 43];
const FLOONET_MAGIC: [u8; 2] = [83, 59]; const TESTNET_MAGIC: [u8; 2] = [83, 59];
const MAINNET_MAGIC: [u8; 2] = [97, 61]; const MAINNET_MAGIC: [u8; 2] = [97, 61];
// Types of messages. // Types of messages.
@ -112,7 +112,7 @@ fn max_msg_size(msg_type: Type) -> u64 {
fn magic() -> [u8; 2] { fn magic() -> [u8; 2] {
match global::get_chain_type() { match global::get_chain_type() {
global::ChainTypes::Floonet => FLOONET_MAGIC, global::ChainTypes::Testnet => TESTNET_MAGIC,
global::ChainTypes::Mainnet => MAINNET_MAGIC, global::ChainTypes::Mainnet => MAINNET_MAGIC,
_ => OTHER_MAGIC, _ => OTHER_MAGIC,
} }

View file

@ -236,9 +236,9 @@ impl std::fmt::Display for PeerAddr {
impl PeerAddr { impl PeerAddr {
/// Convenient way of constructing a new peer_addr from an ip_addr /// Convenient way of constructing a new peer_addr from an ip_addr
/// defaults to port 3414 on mainnet and 13414 on floonet. /// defaults to port 3414 on mainnet and 13414 on testnet.
pub fn from_ip(addr: IpAddr) -> PeerAddr { pub fn from_ip(addr: IpAddr) -> PeerAddr {
let port = if global::is_floonet() { 13414 } else { 3414 }; let port = if global::is_testnet() { 13414 } else { 3414 };
PeerAddr(SocketAddr::new(addr, port)) PeerAddr(SocketAddr::new(addr, port))
} }

View file

@ -40,7 +40,7 @@ const MAINNET_DNS_SEEDS: &[&str] = &[
"grinseed.yeastplume.org", // yeastplume@protonmail.com "grinseed.yeastplume.org", // yeastplume@protonmail.com
"mainnet-seed.grinnode.live", // info@grinnode.live "mainnet-seed.grinnode.live", // info@grinnode.live
]; ];
const FLOONET_DNS_SEEDS: &[&str] = &[ const TESTNET_DNS_SEEDS: &[&str] = &[
"floonet.seed.grin.icu", // gary.peverell@protonmail.com "floonet.seed.grin.icu", // gary.peverell@protonmail.com
"floonet.seed.713.mw", // jasper@713.mw "floonet.seed.713.mw", // jasper@713.mw
"floonet.seed.grin.lesceller.com", // q.lesceller@gmail.com "floonet.seed.grin.lesceller.com", // q.lesceller@gmail.com
@ -359,8 +359,8 @@ fn listen_for_addrs(
pub fn default_dns_seeds() -> Box<dyn Fn() -> Vec<PeerAddr> + Send> { pub fn default_dns_seeds() -> Box<dyn Fn() -> Vec<PeerAddr> + Send> {
Box::new(|| { Box::new(|| {
let net_seeds = if global::is_floonet() { let net_seeds = if global::is_testnet() {
FLOONET_DNS_SEEDS TESTNET_DNS_SEEDS
} else { } else {
MAINNET_DNS_SEEDS MAINNET_DNS_SEEDS
}; };
@ -369,7 +369,7 @@ pub fn default_dns_seeds() -> Box<dyn Fn() -> Vec<PeerAddr> + Send> {
.iter() .iter()
.map(|s| { .map(|s| {
s.to_string() s.to_string()
+ if global::is_floonet() { + if global::is_testnet() {
":13414" ":13414"
} else { } else {
":3414" ":3414"

View file

@ -188,7 +188,7 @@ impl Server {
let genesis = match config.chain_type { let genesis = match config.chain_type {
global::ChainTypes::AutomatedTesting => pow::mine_genesis_block().unwrap(), global::ChainTypes::AutomatedTesting => pow::mine_genesis_block().unwrap(),
global::ChainTypes::UserTesting => pow::mine_genesis_block().unwrap(), global::ChainTypes::UserTesting => pow::mine_genesis_block().unwrap(),
global::ChainTypes::Floonet => genesis::genesis_floo(), global::ChainTypes::Testnet => genesis::genesis_test(),
global::ChainTypes::Mainnet => genesis::genesis_main(), global::ChainTypes::Mainnet => genesis::genesis_main(),
}; };

View file

@ -221,7 +221,7 @@ fn build_block(
/// ///
fn burn_reward(block_fees: BlockFees) -> Result<(core::Output, core::TxKernel, BlockFees), Error> { fn burn_reward(block_fees: BlockFees) -> Result<(core::Output, core::TxKernel, BlockFees), Error> {
warn!("Burning block fees: {:?}", block_fees); warn!("Burning block fees: {:?}", block_fees);
let keychain = ExtKeychain::from_random_seed(global::is_floonet())?; let keychain = ExtKeychain::from_random_seed(global::is_testnet())?;
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0); let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
let (out, kernel) = crate::core::libtx::reward::output( let (out, kernel) = crate::core::libtx::reward::output(
&keychain, &keychain,

View file

@ -80,8 +80,8 @@ fn real_main() -> i32 {
.get_matches(); .get_matches();
let node_config; let node_config;
let chain_type = if args.is_present("floonet") { let chain_type = if args.is_present("testnet") {
global::ChainTypes::Floonet global::ChainTypes::Testnet
} else if args.is_present("usernet") { } else if args.is_present("usernet") {
global::ChainTypes::UserTesting global::ChainTypes::UserTesting
} else { } else {

View file

@ -3,9 +3,9 @@ about: Lightweight implementation of the Mimblewimble protocol.
author: The Grin Team author: The Grin Team
args: args:
- floonet: - testnet:
help: Run grin against the Floonet (as opposed to mainnet) help: Run grin against the Testnet (as opposed to mainnet)
long: floonet long: testnet
takes_value: false takes_value: false
- usernet: - usernet:
help: Run grin as a local-only network. Doesn't block peer connections but will not connect to any peer or seed help: Run grin as a local-only network. Doesn't block peer connections but will not connect to any peer or seed