mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
Changed magic number and seeds for Floonet (#2188)
* Changed magic number and seeds for Floonet. * Genesis generator now loads a local wallet seed to build coinbase.
This commit is contained in:
parent
b0c72827d9
commit
7284cfec72
4 changed files with 43 additions and 13 deletions
|
@ -17,14 +17,20 @@ path = "src/bin/gen_gen.rs"
|
||||||
chrono = "0.4.4"
|
chrono = "0.4.4"
|
||||||
cuckoo_miner = "0.4.2"
|
cuckoo_miner = "0.4.2"
|
||||||
curl = "0.4.19"
|
curl = "0.4.19"
|
||||||
grin_core = "0.4.2"
|
grin_core = { path = "../../core" }
|
||||||
grin_chain = "0.4.2"
|
grin_chain = { path = "../../chain" }
|
||||||
grin_keychain = "0.4.2"
|
grin_keychain = { path = "../../keychain" }
|
||||||
grin_miner_plugin = "0.4.2"
|
grin_miner_plugin = "0.4.2"
|
||||||
grin_store = "0.4.2"
|
grin_store = { path = "../../store" }
|
||||||
grin_util = "0.4.2"
|
grin_util = { path = "../../util" }
|
||||||
|
grin_wallet = { path = "../../wallet" }
|
||||||
|
rpassword = "2.0.0"
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
|
grin_api = { path = "../../api" }
|
||||||
grin_core = { path = "../../core" }
|
grin_core = { path = "../../core" }
|
||||||
|
grin_chain = { path = "../../chain" }
|
||||||
grin_keychain = { path = "../../keychain" }
|
grin_keychain = { path = "../../keychain" }
|
||||||
|
grin_util = { path = "../../util" }
|
||||||
|
grin_wallet = { path = "../../wallet" }
|
||||||
|
|
|
@ -21,6 +21,7 @@ use std::{fs, io, path, process};
|
||||||
use chrono::prelude::Utc;
|
use chrono::prelude::Utc;
|
||||||
use chrono::{Datelike, Duration, Timelike};
|
use chrono::{Datelike, Duration, Timelike};
|
||||||
use curl;
|
use curl;
|
||||||
|
use rpassword;
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
use cuckoo_miner as cuckoo;
|
use cuckoo_miner as cuckoo;
|
||||||
|
@ -29,6 +30,7 @@ use grin_core as core;
|
||||||
use grin_miner_plugin as plugin;
|
use grin_miner_plugin as plugin;
|
||||||
use grin_store as store;
|
use grin_store as store;
|
||||||
use grin_util as util;
|
use grin_util as util;
|
||||||
|
use grin_wallet as wallet;
|
||||||
|
|
||||||
use grin_core::core::hash::Hashed;
|
use grin_core::core::hash::Hashed;
|
||||||
use grin_core::core::verifier_cache::LruVerifierCache;
|
use grin_core::core::verifier_cache::LruVerifierCache;
|
||||||
|
@ -40,6 +42,7 @@ static BCHAIR_URL: &str = "https://api.blockchair.com/bitcoin/blocks?limit=2";
|
||||||
|
|
||||||
static GENESIS_RS_PATH: &str = "../../core/src/genesis.rs";
|
static GENESIS_RS_PATH: &str = "../../core/src/genesis.rs";
|
||||||
static PLUGIN_PATH: &str = "./cuckaroo_mean_cuda_29.cuckooplugin";
|
static PLUGIN_PATH: &str = "./cuckaroo_mean_cuda_29.cuckooplugin";
|
||||||
|
static WALLET_SEED_PATH: &str = "./wallet.seed";
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if !path::Path::new(GENESIS_RS_PATH).exists() {
|
if !path::Path::new(GENESIS_RS_PATH).exists() {
|
||||||
|
@ -54,6 +57,12 @@ fn main() {
|
||||||
PLUGIN_PATH
|
PLUGIN_PATH
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if !path::Path::new(WALLET_SEED_PATH).exists() {
|
||||||
|
panic!(
|
||||||
|
"File {} not found, make sure you're running this from the gen_gen directory",
|
||||||
|
WALLET_SEED_PATH
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// get the latest bitcoin hash
|
// get the latest bitcoin hash
|
||||||
let h1 = get_bchain_head();
|
let h1 = get_bchain_head();
|
||||||
|
@ -72,10 +81,14 @@ fn main() {
|
||||||
gen.header.timestamp = Utc::now() + Duration::minutes(30);
|
gen.header.timestamp = Utc::now() + Duration::minutes(30);
|
||||||
gen.header.prev_root = core::core::hash::Hash::from_hex(&h1).unwrap();
|
gen.header.prev_root = core::core::hash::Hash::from_hex(&h1).unwrap();
|
||||||
|
|
||||||
// TODO get the proper keychain and/or raw coinbase
|
// build the wallet seed and derive a coinbase from local wallet.seed
|
||||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
let seed = wallet::WalletSeed::from_file(
|
||||||
let key_id = ExtKeychain::derive_key_id(0, 1, 0, 0, 0);
|
&wallet::WalletConfig::default(),
|
||||||
let reward = core::libtx::reward::output(&keychain, &key_id, 0, 0).unwrap();
|
&rpassword::prompt_password_stdout("Password: ").unwrap()
|
||||||
|
).unwrap();
|
||||||
|
let keychain: ExtKeychain = seed.derive_keychain().unwrap();
|
||||||
|
let key_id = ExtKeychain::derive_key_id(2, 1, 0, 0, 0);
|
||||||
|
let reward = core::libtx::reward::output(&keychain, &key_id, 0).unwrap();
|
||||||
gen = gen.with_reward(reward.0, reward.1);
|
gen = gen.with_reward(reward.0, reward.1);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -284,6 +297,7 @@ fn setup_chain(dir_name: &str, genesis: core::core::Block) -> chain::Chain {
|
||||||
core::pow::verify_size,
|
core::pow::verify_size,
|
||||||
verifier_cache,
|
verifier_cache,
|
||||||
false,
|
false,
|
||||||
|
Arc::new(util::Mutex::new(util::StopState::new())),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
@ -322,3 +336,4 @@ fn get_json(url: &str) -> serde_json::Value {
|
||||||
}
|
}
|
||||||
serde_json::from_slice(&body).unwrap()
|
serde_json::from_slice(&body).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ pub const PROTOCOL_VERSION: u32 = 1;
|
||||||
pub const USER_AGENT: &'static str = concat!("MW/Grin ", env!("CARGO_PKG_VERSION"));
|
pub const USER_AGENT: &'static str = concat!("MW/Grin ", env!("CARGO_PKG_VERSION"));
|
||||||
|
|
||||||
/// Magic number expected in the header of every message
|
/// Magic number expected in the header of every message
|
||||||
const MAGIC: [u8; 2] = [0x54, 0x34];
|
const MAGIC: [u8; 2] = [0x53, 0x35];
|
||||||
|
|
||||||
/// Max theoretical size of a block filled with outputs.
|
/// Max theoretical size of a block filled with outputs.
|
||||||
const MAX_BLOCK_SIZE: u64 =
|
const MAX_BLOCK_SIZE: u64 =
|
||||||
|
|
|
@ -24,14 +24,18 @@ use std::net::{SocketAddr, ToSocketAddrs};
|
||||||
use std::sync::{mpsc, Arc};
|
use std::sync::{mpsc, Arc};
|
||||||
use std::{cmp, io, str, thread, time};
|
use std::{cmp, io, str, thread, time};
|
||||||
|
|
||||||
|
use crate::core::global;
|
||||||
use crate::p2p;
|
use crate::p2p;
|
||||||
use crate::p2p::ChainAdapter;
|
use crate::p2p::ChainAdapter;
|
||||||
use crate::pool::DandelionConfig;
|
use crate::pool::DandelionConfig;
|
||||||
use crate::util::{Mutex, StopState};
|
use crate::util::{Mutex, StopState};
|
||||||
|
|
||||||
// DNS Seeds with contact email associated
|
// DNS Seeds with contact email associated
|
||||||
const DNS_SEEDS: &'static [&'static str] = &[
|
const MAINNET_DNS_SEEDS: &'static [&'static str] = &[
|
||||||
"t4.seed.grin-tech.org", // igno.peverell@protonmail.com
|
"mainnet.seed.grin-tech.org", // igno.peverell@protonmail.com
|
||||||
|
];
|
||||||
|
const FLOONET_DNS_SEEDS: &'static [&'static str] = &[
|
||||||
|
"floonet.seed.grin-tech.org", // igno.peverell@protonmail.com
|
||||||
];
|
];
|
||||||
|
|
||||||
pub fn connect_and_monitor(
|
pub fn connect_and_monitor(
|
||||||
|
@ -331,7 +335,12 @@ fn listen_for_addrs(
|
||||||
pub fn dns_seeds() -> Box<dyn Fn() -> Vec<SocketAddr> + Send> {
|
pub fn dns_seeds() -> Box<dyn Fn() -> Vec<SocketAddr> + Send> {
|
||||||
Box::new(|| {
|
Box::new(|| {
|
||||||
let mut addresses: Vec<SocketAddr> = vec![];
|
let mut addresses: Vec<SocketAddr> = vec![];
|
||||||
for dns_seed in DNS_SEEDS {
|
let net_seeds = if global::is_testnet() {
|
||||||
|
FLOONET_DNS_SEEDS
|
||||||
|
} else {
|
||||||
|
MAINNET_DNS_SEEDS
|
||||||
|
};
|
||||||
|
for dns_seed in net_seeds {
|
||||||
let temp_addresses = addresses.clone();
|
let temp_addresses = addresses.clone();
|
||||||
debug!("Retrieving seed nodes from dns {}", dns_seed);
|
debug!("Retrieving seed nodes from dns {}", dns_seed);
|
||||||
match (dns_seed.to_owned(), 0).to_socket_addrs() {
|
match (dns_seed.to_owned(), 0).to_socket_addrs() {
|
||||||
|
|
Loading…
Reference in a new issue