mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-20 19:11:08 +03:00
Rename Floonet to Testnet (#3431)
* Rename Floonet to Testnet * Fix test * Rename test and docker
This commit is contained in:
parent
4c6d1dd4bd
commit
cf2a65242d
26 changed files with 111 additions and 111 deletions
2
.github/pull_request_template.md
vendored
2
.github/pull_request_template.md
vendored
|
@ -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
|
||||
* Contains unit tests exercising new/changed functionality
|
||||
* 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
|
||||
|
|
|
@ -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
|
||||
* Contains unit tests exercising new/changed functionality
|
||||
* 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
|
||||
|
||||
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.
|
||||
|
|
|
@ -986,7 +986,7 @@ impl Chain {
|
|||
|
||||
/// Specific tmp dir.
|
||||
/// 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 {
|
||||
let mut tmp_dir = PathBuf::from(self.db_root.clone());
|
||||
tmp_dir = tmp_dir
|
||||
|
|
|
@ -87,7 +87,7 @@ fn comments() -> HashMap<String, String> {
|
|||
#parameters used for mining as well as wallet output coinbase maturity. Can be:
|
||||
#AutomatedTesting - For CI builds and instant blockchain creation
|
||||
#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
|
||||
"
|
||||
.to_string(),
|
||||
|
|
|
@ -168,7 +168,7 @@ impl GlobalConfig {
|
|||
|
||||
match *chain_type {
|
||||
global::ChainTypes::Mainnet => {}
|
||||
global::ChainTypes::Floonet => {
|
||||
global::ChainTypes::Testnet => {
|
||||
defaults.api_http_addr = "127.0.0.1:13413".to_owned();
|
||||
defaults.p2p_config.port = 13414;
|
||||
defaults
|
||||
|
|
|
@ -127,14 +127,14 @@ pub const MAX_BLOCK_WEIGHT: u64 = 40_000;
|
|||
/// Fork every 6 months.
|
||||
pub const HARD_FORK_INTERVAL: u64 = YEAR_HEIGHT / 2;
|
||||
|
||||
/// Floonet first hard fork height, set to happen around 2019-06-20
|
||||
pub const FLOONET_FIRST_HARD_FORK: u64 = 185_040;
|
||||
/// Testnet first hard fork height, set to happen around 2019-06-20
|
||||
pub const TESTNET_FIRST_HARD_FORK: u64 = 185_040;
|
||||
|
||||
/// Floonet second hard fork height, set to happen around 2019-12-19
|
||||
pub const FLOONET_SECOND_HARD_FORK: u64 = 298_080;
|
||||
/// Testnet second hard fork height, set to happen around 2019-12-19
|
||||
pub const TESTNET_SECOND_HARD_FORK: u64 = 298_080;
|
||||
|
||||
/// Floonet second hard fork height, set to happen around 2020-06-20
|
||||
pub const FLOONET_THIRD_HARD_FORK: u64 = 552_960;
|
||||
/// Testnet second hard fork height, set to happen around 2020-06-20
|
||||
pub const TESTNET_THIRD_HARD_FORK: u64 = 552_960;
|
||||
|
||||
/// AutomatedTesting and UserTesting HF1 height.
|
||||
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;
|
||||
match chain_type {
|
||||
global::ChainTypes::Mainnet => HeaderVersion(hf_interval),
|
||||
global::ChainTypes::Floonet => {
|
||||
if height < FLOONET_FIRST_HARD_FORK {
|
||||
global::ChainTypes::Testnet => {
|
||||
if height < TESTNET_FIRST_HARD_FORK {
|
||||
HeaderVersion(1)
|
||||
} else if height < FLOONET_SECOND_HARD_FORK {
|
||||
} else if height < TESTNET_SECOND_HARD_FORK {
|
||||
HeaderVersion(2)
|
||||
} else if height < FLOONET_THIRD_HARD_FORK {
|
||||
} else if height < TESTNET_THIRD_HARD_FORK {
|
||||
HeaderVersion(3)
|
||||
} else if height < 4 * HARD_FORK_INTERVAL {
|
||||
HeaderVersion(4)
|
||||
|
|
|
@ -44,8 +44,8 @@ pub fn genesis_dev() -> core::Block {
|
|||
})
|
||||
}
|
||||
|
||||
/// Floonet genesis block
|
||||
pub fn genesis_floo() -> core::Block {
|
||||
/// Testnet genesis block
|
||||
pub fn genesis_test() -> core::Block {
|
||||
let gen = core::Block::with_header(core::BlockHeader {
|
||||
height: 0,
|
||||
timestamp: Utc.ymd(2018, 12, 28).and_hms(20, 48, 4),
|
||||
|
@ -277,12 +277,12 @@ mod test {
|
|||
use util::ToHex;
|
||||
|
||||
#[test]
|
||||
fn floonet_genesis_hash() {
|
||||
global::set_local_chain_type(global::ChainTypes::Floonet);
|
||||
let gen_hash = genesis_floo().hash();
|
||||
println!("floonet genesis hash: {}", gen_hash.to_hex());
|
||||
let gen_bin = ser::ser_vec(&genesis_floo(), ProtocolVersion(1)).unwrap();
|
||||
println!("floonet genesis full hash: {}\n", gen_bin.hash().to_hex());
|
||||
fn testnet_genesis_hash() {
|
||||
global::set_local_chain_type(global::ChainTypes::Testnet);
|
||||
let gen_hash = genesis_test().hash();
|
||||
println!("testnet genesis hash: {}", gen_hash.to_hex());
|
||||
let gen_bin = ser::ser_vec(&genesis_test(), ProtocolVersion(1)).unwrap();
|
||||
println!("testnet genesis full hash: {}\n", gen_bin.hash().to_hex());
|
||||
assert_eq!(
|
||||
gen_hash.to_hex(),
|
||||
"edc758c1370d43e1d733f70f58cf187c3be8242830429b1676b89fd91ccf2dab"
|
||||
|
|
|
@ -115,18 +115,18 @@ pub enum ChainTypes {
|
|||
/// For User testing
|
||||
UserTesting,
|
||||
/// Protocol testing network
|
||||
Floonet,
|
||||
Testnet,
|
||||
/// Main production network
|
||||
Mainnet,
|
||||
}
|
||||
|
||||
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 {
|
||||
match *self {
|
||||
ChainTypes::AutomatedTesting => "auto".to_owned(),
|
||||
ChainTypes::UserTesting => "user".to_owned(),
|
||||
ChainTypes::Floonet => "floo".to_owned(),
|
||||
ChainTypes::Testnet => "test".to_owned(),
|
||||
ChainTypes::Mainnet => "main".to_owned(),
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ lazy_static! {
|
|||
}
|
||||
|
||||
thread_local! {
|
||||
/// Mainnet|Floonet|UserTesting|AutomatedTesting
|
||||
/// Mainnet|Testnet|UserTesting|AutomatedTesting
|
||||
pub static CHAIN_TYPE: Cell<Option<ChainTypes>> = Cell::new(None);
|
||||
|
||||
/// 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),
|
||||
|
||||
// Same for Floonet
|
||||
ChainTypes::Floonet if edge_bits > 29 => new_cuckatoo_ctx(edge_bits, proof_size, max_sols),
|
||||
ChainTypes::Floonet if valid_header_version(height, HeaderVersion(4)) => {
|
||||
// Same for Testnet
|
||||
ChainTypes::Testnet if edge_bits > 29 => new_cuckatoo_ctx(edge_bits, proof_size, max_sols),
|
||||
ChainTypes::Testnet if valid_header_version(height, HeaderVersion(4)) => {
|
||||
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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
ChainTypes::Floonet => new_cuckaroo_ctx(edge_bits, proof_size),
|
||||
ChainTypes::Testnet => new_cuckaroo_ctx(edge_bits, proof_size),
|
||||
|
||||
// Everything else is Cuckatoo only
|
||||
_ => new_cuckatoo_ctx(edge_bits, proof_size, max_sols),
|
||||
|
@ -299,7 +299,7 @@ pub fn initial_block_difficulty() -> u64 {
|
|||
match get_chain_type() {
|
||||
ChainTypes::AutomatedTesting => TESTING_INITIAL_DIFFICULTY,
|
||||
ChainTypes::UserTesting => TESTING_INITIAL_DIFFICULTY,
|
||||
ChainTypes::Floonet => INITIAL_DIFFICULTY,
|
||||
ChainTypes::Testnet => INITIAL_DIFFICULTY,
|
||||
ChainTypes::Mainnet => INITIAL_DIFFICULTY,
|
||||
}
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ pub fn initial_graph_weight() -> u32 {
|
|||
match get_chain_type() {
|
||||
ChainTypes::AutomatedTesting => 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,
|
||||
}
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ pub fn max_block_weight() -> u64 {
|
|||
match get_chain_type() {
|
||||
ChainTypes::AutomatedTesting => 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,
|
||||
}
|
||||
}
|
||||
|
@ -360,19 +360,19 @@ pub fn txhashset_archive_interval() -> u64 {
|
|||
/// Production defined as a live public network, testnet[n] or mainnet.
|
||||
pub fn is_production_mode() -> bool {
|
||||
match get_chain_type() {
|
||||
ChainTypes::Floonet => true,
|
||||
ChainTypes::Testnet => true,
|
||||
ChainTypes::Mainnet => true,
|
||||
_ => 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
|
||||
/// as possible to "mainnet" configuration as possible.
|
||||
/// We want to avoid missing any mainnet only code paths.
|
||||
pub fn is_floonet() -> bool {
|
||||
pub fn is_testnet() -> bool {
|
||||
match get_chain_type() {
|
||||
ChainTypes::Floonet => true,
|
||||
ChainTypes::Testnet => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -448,9 +448,9 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn floonet_header_len() {
|
||||
set_local_chain_type(ChainTypes::Floonet);
|
||||
test_header_len(genesis_floo());
|
||||
fn testnet_header_len() {
|
||||
set_local_chain_type(ChainTypes::Testnet);
|
||||
test_header_len(genesis_test());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -412,7 +412,7 @@ impl ProofBuild for ViewKey {
|
|||
}
|
||||
|
||||
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 {
|
||||
let child_number = path.path[i as usize];
|
||||
if child_number.is_hardened() {
|
||||
|
|
|
@ -12,17 +12,17 @@
|
|||
// limitations under the License.
|
||||
|
||||
use grin_core::consensus::{
|
||||
secondary_pow_ratio, valid_header_version, FLOONET_FIRST_HARD_FORK, FLOONET_SECOND_HARD_FORK,
|
||||
FLOONET_THIRD_HARD_FORK, HARD_FORK_INTERVAL,
|
||||
secondary_pow_ratio, valid_header_version, HARD_FORK_INTERVAL, TESTNET_FIRST_HARD_FORK,
|
||||
TESTNET_SECOND_HARD_FORK, TESTNET_THIRD_HARD_FORK,
|
||||
};
|
||||
use grin_core::core::HeaderVersion;
|
||||
use grin_core::global;
|
||||
|
||||
#[test]
|
||||
fn test_secondary_pow_ratio() {
|
||||
// Tests for Floonet chain type (covers pre and post hardfork).
|
||||
global::set_local_chain_type(global::ChainTypes::Floonet);
|
||||
assert_eq!(global::is_floonet(), true);
|
||||
// Tests for Testnet chain type (covers pre and post hardfork).
|
||||
global::set_local_chain_type(global::ChainTypes::Testnet);
|
||||
assert_eq!(global::is_testnet(), true);
|
||||
|
||||
assert_eq!(secondary_pow_ratio(1), 90);
|
||||
assert_eq!(secondary_pow_ratio(89), 90);
|
||||
|
@ -63,69 +63,69 @@ fn test_secondary_pow_ratio() {
|
|||
|
||||
#[test]
|
||||
fn hard_forks() {
|
||||
global::set_local_chain_type(global::ChainTypes::Floonet);
|
||||
assert_eq!(global::is_floonet(), true);
|
||||
global::set_local_chain_type(global::ChainTypes::Testnet);
|
||||
assert_eq!(global::is_testnet(), true);
|
||||
assert!(valid_header_version(0, HeaderVersion(1)));
|
||||
assert!(valid_header_version(10, HeaderVersion(1)));
|
||||
assert!(!valid_header_version(10, HeaderVersion(2)));
|
||||
assert!(valid_header_version(
|
||||
FLOONET_FIRST_HARD_FORK - 1,
|
||||
TESTNET_FIRST_HARD_FORK - 1,
|
||||
HeaderVersion(1)
|
||||
));
|
||||
assert!(valid_header_version(
|
||||
FLOONET_FIRST_HARD_FORK,
|
||||
TESTNET_FIRST_HARD_FORK,
|
||||
HeaderVersion(2)
|
||||
));
|
||||
assert!(valid_header_version(
|
||||
FLOONET_FIRST_HARD_FORK + 1,
|
||||
TESTNET_FIRST_HARD_FORK + 1,
|
||||
HeaderVersion(2)
|
||||
));
|
||||
assert!(!valid_header_version(
|
||||
FLOONET_FIRST_HARD_FORK,
|
||||
TESTNET_FIRST_HARD_FORK,
|
||||
HeaderVersion(1)
|
||||
));
|
||||
assert!(valid_header_version(
|
||||
FLOONET_SECOND_HARD_FORK - 1,
|
||||
TESTNET_SECOND_HARD_FORK - 1,
|
||||
HeaderVersion(2)
|
||||
));
|
||||
assert!(valid_header_version(
|
||||
FLOONET_SECOND_HARD_FORK,
|
||||
TESTNET_SECOND_HARD_FORK,
|
||||
HeaderVersion(3)
|
||||
));
|
||||
assert!(valid_header_version(
|
||||
FLOONET_SECOND_HARD_FORK + 1,
|
||||
TESTNET_SECOND_HARD_FORK + 1,
|
||||
HeaderVersion(3)
|
||||
));
|
||||
assert!(!valid_header_version(
|
||||
FLOONET_SECOND_HARD_FORK,
|
||||
TESTNET_SECOND_HARD_FORK,
|
||||
HeaderVersion(2)
|
||||
));
|
||||
assert!(!valid_header_version(
|
||||
FLOONET_SECOND_HARD_FORK,
|
||||
TESTNET_SECOND_HARD_FORK,
|
||||
HeaderVersion(1)
|
||||
));
|
||||
assert!(valid_header_version(
|
||||
FLOONET_THIRD_HARD_FORK - 1,
|
||||
TESTNET_THIRD_HARD_FORK - 1,
|
||||
HeaderVersion(3)
|
||||
));
|
||||
assert!(valid_header_version(
|
||||
FLOONET_THIRD_HARD_FORK,
|
||||
TESTNET_THIRD_HARD_FORK,
|
||||
HeaderVersion(4)
|
||||
));
|
||||
assert!(valid_header_version(
|
||||
FLOONET_THIRD_HARD_FORK + 1,
|
||||
TESTNET_THIRD_HARD_FORK + 1,
|
||||
HeaderVersion(4)
|
||||
));
|
||||
assert!(!valid_header_version(
|
||||
FLOONET_THIRD_HARD_FORK,
|
||||
TESTNET_THIRD_HARD_FORK,
|
||||
HeaderVersion(3)
|
||||
));
|
||||
assert!(!valid_header_version(
|
||||
FLOONET_THIRD_HARD_FORK,
|
||||
TESTNET_THIRD_HARD_FORK,
|
||||
HeaderVersion(2)
|
||||
));
|
||||
assert!(!valid_header_version(
|
||||
FLOONET_THIRD_HARD_FORK,
|
||||
TESTNET_THIRD_HARD_FORK,
|
||||
HeaderVersion(1)
|
||||
));
|
||||
|
|
@ -108,7 +108,7 @@ grin client --help
|
|||
```sh
|
||||
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.
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ grin client --help
|
|||
```sh
|
||||
docker build -t grin -f etc/Dockerfile .
|
||||
```
|
||||
floonetを使用する場合、代わりに`etc/Dockerfile.floonet`を指定。
|
||||
testnetを使用する場合、代わりに`etc/Dockerfile.testnet`を指定。
|
||||
|
||||
コンテナ内で実行する場合、grinのキャッシュをバインドマウントすることも可能。
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ grin client --help
|
|||
docker build -t grin -f etc/Dockerfile .
|
||||
```
|
||||
|
||||
floonet을 사용하려면 `etc/Dockerfile.floonet` 을 사용하세요.
|
||||
testnet을 사용하려면 `etc/Dockerfile.testnet` 을 사용하세요.
|
||||
container 안에서 grin cache를 bind-mount로 사용 할 수 있습니다.
|
||||
|
||||
```sh
|
||||
|
|
|
@ -100,7 +100,7 @@ grin client --help
|
|||
```sh
|
||||
docker build -t grin -f etc/Dockerfile .
|
||||
```
|
||||
对于 floonet, 使用 `etc/Dockerfile.floonet` 代替
|
||||
对于 testnet, 使用 `etc/Dockerfile.testnet` 代替
|
||||
|
||||
您可以绑定安装您的 grin 缓存以在容器中运行。
|
||||
|
||||
|
|
|
@ -37,13 +37,13 @@ COPY --from=builder /usr/src/grin/target/release/grin /usr/local/bin/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
|
||||
|
||||
VOLUME ["/root/.grin"]
|
||||
|
||||
EXPOSE 13413 13414 13415 13416
|
||||
|
||||
ENTRYPOINT ["grin", "--floonet"]
|
||||
ENTRYPOINT ["grin", "--testnet"]
|
||||
|
||||
CMD ["server", "run"]
|
|
@ -91,15 +91,15 @@ pub trait BIP32Hasher {
|
|||
/// Implementation of the above that uses the standard BIP32 Hash algorithms
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct BIP32GrinHasher {
|
||||
is_floo: bool,
|
||||
is_test: bool,
|
||||
hmac_sha512: Hmac<Sha512>,
|
||||
}
|
||||
|
||||
impl BIP32GrinHasher {
|
||||
/// New empty hasher
|
||||
pub fn new(is_floo: bool) -> BIP32GrinHasher {
|
||||
pub fn new(is_test: bool) -> BIP32GrinHasher {
|
||||
BIP32GrinHasher {
|
||||
is_floo: is_floo,
|
||||
is_test: is_test,
|
||||
hmac_sha512: HmacSha512::new(GenericArray::from_slice(&[0u8; 128])),
|
||||
}
|
||||
}
|
||||
|
@ -107,14 +107,14 @@ impl BIP32GrinHasher {
|
|||
|
||||
impl BIP32Hasher for BIP32GrinHasher {
|
||||
fn network_priv(&self) -> [u8; 4] {
|
||||
if self.is_floo {
|
||||
if self.is_test {
|
||||
[0x03, 0x27, 0x3A, 0x10]
|
||||
} else {
|
||||
[0x03, 0x3C, 0x04, 0xA4]
|
||||
}
|
||||
}
|
||||
fn network_pub(&self) -> [u8; 4] {
|
||||
if self.is_floo {
|
||||
if self.is_test {
|
||||
[0x03, 0x27, 0x3E, 0x4B]
|
||||
} else {
|
||||
[0x03, 0x3C, 0x08, 0xDF]
|
||||
|
@ -370,10 +370,10 @@ impl ExtendedPrivKey {
|
|||
secp: &Secp256k1,
|
||||
mnemonic: &str,
|
||||
passphrase: &str,
|
||||
is_floo: bool,
|
||||
is_test: bool,
|
||||
) -> Result<ExtendedPrivKey, Error> {
|
||||
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)?;
|
||||
Ok(key)
|
||||
}
|
||||
|
|
|
@ -45,8 +45,8 @@ impl ExtKeychain {
|
|||
}
|
||||
|
||||
impl Keychain for ExtKeychain {
|
||||
fn from_seed(seed: &[u8], is_floo: bool) -> Result<ExtKeychain, Error> {
|
||||
let mut h = BIP32GrinHasher::new(is_floo);
|
||||
fn from_seed(seed: &[u8], is_test: bool) -> Result<ExtKeychain, Error> {
|
||||
let mut h = BIP32GrinHasher::new(is_test);
|
||||
let secp = secp::Secp256k1::with_caps(secp::ContextFlag::Commit);
|
||||
let master = ExtendedPrivKey::new_master(&secp, &mut h, seed)?;
|
||||
let keychain = ExtKeychain {
|
||||
|
@ -57,10 +57,10 @@ impl Keychain for ExtKeychain {
|
|||
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 h = BIP32GrinHasher::new(is_floo);
|
||||
let master = ExtendedPrivKey::from_mnemonic(&secp, word_list, extension_word, is_floo)?;
|
||||
let h = BIP32GrinHasher::new(is_test);
|
||||
let master = ExtendedPrivKey::from_mnemonic(&secp, word_list, extension_word, is_test)?;
|
||||
let keychain = ExtKeychain {
|
||||
secp: secp,
|
||||
master: master,
|
||||
|
@ -77,10 +77,10 @@ impl Keychain for ExtKeychain {
|
|||
}
|
||||
|
||||
/// 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 = 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 {
|
||||
|
|
|
@ -436,13 +436,13 @@ pub struct ValueExtKeychainPath {
|
|||
pub trait Keychain: Sync + Send + Clone {
|
||||
/// Generates a keychain from a raw binary seed (which has already been
|
||||
/// 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
|
||||
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.
|
||||
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
|
||||
fn mask_master_key(&mut self, mask: &SecretKey) -> Result<(), Error>;
|
||||
|
|
|
@ -12,8 +12,8 @@ use crate::util::secp::key::{PublicKey, SecretKey};
|
|||
use crate::util::secp::Secp256k1;
|
||||
use crate::SwitchCommitmentType;
|
||||
|
||||
/*const VERSION_FLOO_NS: [u8;4] = [0x03, 0x27, 0x3E, 0x4B];
|
||||
const VERSION_FLOO: [u8;4] = [0x03, 0x27, 0x3E, 0x4B];
|
||||
/*const VERSION_TEST_NS: [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: [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
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct ViewKey {
|
||||
/// Whether this view key is meant for floonet or not
|
||||
pub is_floo: bool,
|
||||
/// Whether this view key is meant for testnet or not
|
||||
pub is_test: bool,
|
||||
/// How many derivations this key is from the master (which is 0)
|
||||
pub depth: u8,
|
||||
/// Fingerprint of the parent key
|
||||
|
@ -45,7 +45,7 @@ impl ViewKey {
|
|||
keychain: &K,
|
||||
ext_key: ExtendedPrivKey,
|
||||
hasher: &mut H,
|
||||
is_floo: bool,
|
||||
is_test: bool,
|
||||
) -> Result<Self, Error>
|
||||
where
|
||||
K: Keychain,
|
||||
|
@ -69,7 +69,7 @@ impl ViewKey {
|
|||
let rewind_hash = Self::rewind_hash(secp, keychain.public_root_key());
|
||||
|
||||
Ok(Self {
|
||||
is_floo,
|
||||
is_test,
|
||||
depth,
|
||||
parent_fingerprint,
|
||||
child_number,
|
||||
|
@ -136,7 +136,7 @@ impl ViewKey {
|
|||
};
|
||||
|
||||
Ok(Self {
|
||||
is_floo: self.is_floo,
|
||||
is_test: self.is_test,
|
||||
depth: self.depth + 1,
|
||||
parent_fingerprint: self.fingerprint(secp, hasher),
|
||||
child_number: i,
|
||||
|
|
|
@ -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
|
||||
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];
|
||||
|
||||
// Types of messages.
|
||||
|
@ -112,7 +112,7 @@ fn max_msg_size(msg_type: Type) -> u64 {
|
|||
|
||||
fn magic() -> [u8; 2] {
|
||||
match global::get_chain_type() {
|
||||
global::ChainTypes::Floonet => FLOONET_MAGIC,
|
||||
global::ChainTypes::Testnet => TESTNET_MAGIC,
|
||||
global::ChainTypes::Mainnet => MAINNET_MAGIC,
|
||||
_ => OTHER_MAGIC,
|
||||
}
|
||||
|
|
|
@ -236,9 +236,9 @@ impl std::fmt::Display for PeerAddr {
|
|||
|
||||
impl PeerAddr {
|
||||
/// 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 {
|
||||
let port = if global::is_floonet() { 13414 } else { 3414 };
|
||||
let port = if global::is_testnet() { 13414 } else { 3414 };
|
||||
PeerAddr(SocketAddr::new(addr, port))
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ const MAINNET_DNS_SEEDS: &[&str] = &[
|
|||
"grinseed.yeastplume.org", // yeastplume@protonmail.com
|
||||
"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.713.mw", // jasper@713.mw
|
||||
"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> {
|
||||
Box::new(|| {
|
||||
let net_seeds = if global::is_floonet() {
|
||||
FLOONET_DNS_SEEDS
|
||||
let net_seeds = if global::is_testnet() {
|
||||
TESTNET_DNS_SEEDS
|
||||
} else {
|
||||
MAINNET_DNS_SEEDS
|
||||
};
|
||||
|
@ -369,7 +369,7 @@ pub fn default_dns_seeds() -> Box<dyn Fn() -> Vec<PeerAddr> + Send> {
|
|||
.iter()
|
||||
.map(|s| {
|
||||
s.to_string()
|
||||
+ if global::is_floonet() {
|
||||
+ if global::is_testnet() {
|
||||
":13414"
|
||||
} else {
|
||||
":3414"
|
||||
|
|
|
@ -188,7 +188,7 @@ impl Server {
|
|||
let genesis = match config.chain_type {
|
||||
global::ChainTypes::AutomatedTesting => 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(),
|
||||
};
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ fn build_block(
|
|||
///
|
||||
fn burn_reward(block_fees: BlockFees) -> Result<(core::Output, core::TxKernel, BlockFees), Error> {
|
||||
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 (out, kernel) = crate::core::libtx::reward::output(
|
||||
&keychain,
|
||||
|
|
|
@ -80,8 +80,8 @@ fn real_main() -> i32 {
|
|||
.get_matches();
|
||||
let node_config;
|
||||
|
||||
let chain_type = if args.is_present("floonet") {
|
||||
global::ChainTypes::Floonet
|
||||
let chain_type = if args.is_present("testnet") {
|
||||
global::ChainTypes::Testnet
|
||||
} else if args.is_present("usernet") {
|
||||
global::ChainTypes::UserTesting
|
||||
} else {
|
||||
|
|
|
@ -3,9 +3,9 @@ about: Lightweight implementation of the Mimblewimble protocol.
|
|||
author: The Grin Team
|
||||
|
||||
args:
|
||||
- floonet:
|
||||
help: Run grin against the Floonet (as opposed to mainnet)
|
||||
long: floonet
|
||||
- testnet:
|
||||
help: Run grin against the Testnet (as opposed to mainnet)
|
||||
long: testnet
|
||||
takes_value: false
|
||||
- usernet:
|
||||
help: Run grin as a local-only network. Doesn't block peer connections but will not connect to any peer or seed
|
||||
|
|
Loading…
Reference in a new issue