Add POA Networks: Core and Sokol (#9413)

* ethcore: add poa network and sokol chainspecs

* rpc: simplify chain spec docs

* cli: rearrange networks by main/test and size/range

* parity: don't blacklist 0x00a328 on sokol testnet

* parity: add sokol and poanet to params and clean up a bit, add tests

* ethcore: add the poa networks and clean up a bit

* ethcore: fix path to poacore chain spec

* parity: rename poa networks to poacore and poasokol

* parity: fix configuration tests

* parity: fix parameter tests

* ethcore: rename POA Core and POA Sokol
This commit is contained in:
Afri Schoedon 2018-08-30 21:32:47 +02:00 committed by Thibaut Sardan
parent 07d97d5b26
commit 644d1db5ef
8 changed files with 332 additions and 52 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -42,31 +42,31 @@ fn load_machine(b: &[u8]) -> EthereumMachine {
Spec::load_machine(b).expect("chain spec is invalid") Spec::load_machine(b).expect("chain spec is invalid")
} }
/// Create a new Foundation Olympic chain spec. /// Create a new Foundation mainnet chain spec.
pub fn new_olympic<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/olympic.json"))
}
/// Create a new Foundation Mainnet chain spec.
pub fn new_foundation<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec { pub fn new_foundation<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/foundation.json")) load(params.into(), include_bytes!("../../res/ethereum/foundation.json"))
} }
/// Create a new Classic Mainnet chain spec without the DAO hardfork. /// Create a new Classic mainnet chain spec without the DAO hardfork.
pub fn new_classic<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec { pub fn new_classic<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/classic.json")) load(params.into(), include_bytes!("../../res/ethereum/classic.json"))
} }
/// Create a new POA Network mainnet chain spec.
pub fn new_poanet<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/poacore.json"))
}
/// Create a new Tobalaba mainnet chain spec.
pub fn new_tobalaba<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/tobalaba.json"))
}
/// Create a new Expanse mainnet chain spec. /// Create a new Expanse mainnet chain spec.
pub fn new_expanse<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec { pub fn new_expanse<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/expanse.json")) load(params.into(), include_bytes!("../../res/ethereum/expanse.json"))
} }
/// Create a new Tobalaba chain spec.
pub fn new_tobalaba<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/tobalaba.json"))
}
/// Create a new Musicoin mainnet chain spec. /// Create a new Musicoin mainnet chain spec.
pub fn new_musicoin<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec { pub fn new_musicoin<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/musicoin.json")) load(params.into(), include_bytes!("../../res/ethereum/musicoin.json"))
@ -87,19 +87,29 @@ pub fn new_social<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/social.json")) load(params.into(), include_bytes!("../../res/ethereum/social.json"))
} }
/// Create a new Olympic testnet chain spec.
pub fn new_olympic<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/olympic.json"))
}
/// Create a new Morden testnet chain spec.
pub fn new_morden<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/morden.json"))
}
/// Create a new Ropsten testnet chain spec.
pub fn new_ropsten<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/ropsten.json"))
}
/// Create a new Kovan testnet chain spec. /// Create a new Kovan testnet chain spec.
pub fn new_kovan<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec { pub fn new_kovan<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/kovan.json")) load(params.into(), include_bytes!("../../res/ethereum/kovan.json"))
} }
/// Create a new Foundation Ropsten chain spec. /// Create a new POA Sokol testnet chain spec.
pub fn new_ropsten<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec { pub fn new_sokol<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/ropsten.json")) load(params.into(), include_bytes!("../../res/ethereum/poasokol.json"))
}
/// Create a new Morden chain spec.
pub fn new_morden<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/morden.json"))
} }
// For tests // For tests

View File

@ -288,7 +288,7 @@ usage! {
ARG arg_chain: (String) = "foundation", or |c: &Config| c.parity.as_ref()?.chain.clone(), ARG arg_chain: (String) = "foundation", or |c: &Config| c.parity.as_ref()?.chain.clone(),
"--chain=[CHAIN]", "--chain=[CHAIN]",
"Specify the blockchain type. CHAIN may be either a JSON chain specification file or olympic, frontier, homestead, mainnet, morden, ropsten, classic, expanse, tobalaba, musicoin, ellaism, easthub, social, testnet, kovan or dev.", "Specify the blockchain type. CHAIN may be either a JSON chain specification file or ethereum, classic, poacore, tobalaba, expanse, musicoin, ellaism, easthub, social, olympic, morden, ropsten, kovan, poasokol, testnet, or dev.",
ARG arg_keys_path: (String) = "$BASE/keys", or |c: &Config| c.parity.as_ref()?.keys_path.clone(), ARG arg_keys_path: (String) = "$BASE/keys", or |c: &Config| c.parity.as_ref()?.keys_path.clone(),
"--keys-path=[PATH]", "--keys-path=[PATH]",

View File

@ -32,17 +32,19 @@ use user_defaults::UserDefaults;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub enum SpecType { pub enum SpecType {
Foundation, Foundation,
Morden,
Ropsten,
Tobalaba,
Kovan,
Olympic,
Classic, Classic,
Poanet,
Tobalaba,
Expanse, Expanse,
Musicoin, Musicoin,
Ellaism, Ellaism,
Easthub, Easthub,
Social, Social,
Olympic,
Morden,
Ropsten,
Kovan,
Sokol,
Dev, Dev,
Custom(String), Custom(String),
} }
@ -58,18 +60,20 @@ impl str::FromStr for SpecType {
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
let spec = match s { let spec = match s {
"foundation" | "frontier" | "homestead" | "mainnet" => SpecType::Foundation, "ethereum" | "frontier" | "homestead" | "byzantium" | "foundation" | "mainnet" => SpecType::Foundation,
"frontier-dogmatic" | "homestead-dogmatic" | "classic" => SpecType::Classic, "classic" | "frontier-dogmatic" | "homestead-dogmatic" => SpecType::Classic,
"morden" | "classic-testnet" => SpecType::Morden, "poanet" | "poacore" => SpecType::Poanet,
"ropsten" => SpecType::Ropsten,
"kovan" | "testnet" => SpecType::Kovan,
"tobalaba" => SpecType::Tobalaba, "tobalaba" => SpecType::Tobalaba,
"olympic" => SpecType::Olympic,
"expanse" => SpecType::Expanse, "expanse" => SpecType::Expanse,
"musicoin" => SpecType::Musicoin, "musicoin" => SpecType::Musicoin,
"ellaism" => SpecType::Ellaism, "ellaism" => SpecType::Ellaism,
"easthub" => SpecType::Easthub, "easthub" => SpecType::Easthub,
"social" => SpecType::Social, "social" => SpecType::Social,
"olympic" => SpecType::Olympic,
"morden" | "classic-testnet" => SpecType::Morden,
"ropsten" => SpecType::Ropsten,
"kovan" | "testnet" => SpecType::Kovan,
"sokol" | "poasokol" => SpecType::Sokol,
"dev" => SpecType::Dev, "dev" => SpecType::Dev,
other => SpecType::Custom(other.into()), other => SpecType::Custom(other.into()),
}; };
@ -81,17 +85,19 @@ impl fmt::Display for SpecType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(match *self { f.write_str(match *self {
SpecType::Foundation => "foundation", SpecType::Foundation => "foundation",
SpecType::Morden => "morden",
SpecType::Ropsten => "ropsten",
SpecType::Olympic => "olympic",
SpecType::Classic => "classic", SpecType::Classic => "classic",
SpecType::Poanet => "poanet",
SpecType::Tobalaba => "tobalaba",
SpecType::Expanse => "expanse", SpecType::Expanse => "expanse",
SpecType::Musicoin => "musicoin", SpecType::Musicoin => "musicoin",
SpecType::Ellaism => "ellaism", SpecType::Ellaism => "ellaism",
SpecType::Easthub => "easthub", SpecType::Easthub => "easthub",
SpecType::Social => "social", SpecType::Social => "social",
SpecType::Olympic => "olympic",
SpecType::Morden => "morden",
SpecType::Ropsten => "ropsten",
SpecType::Kovan => "kovan", SpecType::Kovan => "kovan",
SpecType::Tobalaba => "tobalaba", SpecType::Sokol => "sokol",
SpecType::Dev => "dev", SpecType::Dev => "dev",
SpecType::Custom(ref custom) => custom, SpecType::Custom(ref custom) => custom,
}) })
@ -103,17 +109,19 @@ impl SpecType {
let params = params.into(); let params = params.into();
match *self { match *self {
SpecType::Foundation => Ok(ethereum::new_foundation(params)), SpecType::Foundation => Ok(ethereum::new_foundation(params)),
SpecType::Morden => Ok(ethereum::new_morden(params)),
SpecType::Ropsten => Ok(ethereum::new_ropsten(params)),
SpecType::Olympic => Ok(ethereum::new_olympic(params)),
SpecType::Classic => Ok(ethereum::new_classic(params)), SpecType::Classic => Ok(ethereum::new_classic(params)),
SpecType::Poanet => Ok(ethereum::new_poanet(params)),
SpecType::Tobalaba => Ok(ethereum::new_tobalaba(params)),
SpecType::Expanse => Ok(ethereum::new_expanse(params)), SpecType::Expanse => Ok(ethereum::new_expanse(params)),
SpecType::Musicoin => Ok(ethereum::new_musicoin(params)), SpecType::Musicoin => Ok(ethereum::new_musicoin(params)),
SpecType::Ellaism => Ok(ethereum::new_ellaism(params)), SpecType::Ellaism => Ok(ethereum::new_ellaism(params)),
SpecType::Easthub => Ok(ethereum::new_easthub(params)), SpecType::Easthub => Ok(ethereum::new_easthub(params)),
SpecType::Social => Ok(ethereum::new_social(params)), SpecType::Social => Ok(ethereum::new_social(params)),
SpecType::Tobalaba => Ok(ethereum::new_tobalaba(params)), SpecType::Olympic => Ok(ethereum::new_olympic(params)),
SpecType::Morden => Ok(ethereum::new_morden(params)),
SpecType::Ropsten => Ok(ethereum::new_ropsten(params)),
SpecType::Kovan => Ok(ethereum::new_kovan(params)), SpecType::Kovan => Ok(ethereum::new_kovan(params)),
SpecType::Sokol => Ok(ethereum::new_sokol(params)),
SpecType::Dev => Ok(Spec::new_instant()), SpecType::Dev => Ok(Spec::new_instant()),
SpecType::Custom(ref filename) => { SpecType::Custom(ref filename) => {
let file = fs::File::open(filename).map_err(|e| format!("Could not load specification file at {}: {}", filename, e))?; let file = fs::File::open(filename).map_err(|e| format!("Could not load specification file at {}: {}", filename, e))?;
@ -345,17 +353,31 @@ mod tests {
#[test] #[test]
fn test_spec_type_parsing() { fn test_spec_type_parsing() {
assert_eq!(SpecType::Foundation, "foundation".parse().unwrap());
assert_eq!(SpecType::Foundation, "frontier".parse().unwrap()); assert_eq!(SpecType::Foundation, "frontier".parse().unwrap());
assert_eq!(SpecType::Foundation, "homestead".parse().unwrap()); assert_eq!(SpecType::Foundation, "homestead".parse().unwrap());
assert_eq!(SpecType::Foundation, "byzantium".parse().unwrap());
assert_eq!(SpecType::Foundation, "mainnet".parse().unwrap()); assert_eq!(SpecType::Foundation, "mainnet".parse().unwrap());
assert_eq!(SpecType::Foundation, "foundation".parse().unwrap()); assert_eq!(SpecType::Foundation, "ethereum".parse().unwrap());
assert_eq!(SpecType::Kovan, "testnet".parse().unwrap());
assert_eq!(SpecType::Kovan, "kovan".parse().unwrap());
assert_eq!(SpecType::Morden, "morden".parse().unwrap());
assert_eq!(SpecType::Ropsten, "ropsten".parse().unwrap());
assert_eq!(SpecType::Olympic, "olympic".parse().unwrap());
assert_eq!(SpecType::Classic, "classic".parse().unwrap()); assert_eq!(SpecType::Classic, "classic".parse().unwrap());
assert_eq!(SpecType::Classic, "frontier-dogmatic".parse().unwrap());
assert_eq!(SpecType::Classic, "homestead-dogmatic".parse().unwrap());
assert_eq!(SpecType::Poanet, "poanet".parse().unwrap());
assert_eq!(SpecType::Poanet, "poacore".parse().unwrap());
assert_eq!(SpecType::Tobalaba, "tobalaba".parse().unwrap());
assert_eq!(SpecType::Expanse, "expanse".parse().unwrap());
assert_eq!(SpecType::Musicoin, "musicoin".parse().unwrap());
assert_eq!(SpecType::Ellaism, "ellaism".parse().unwrap());
assert_eq!(SpecType::Easthub, "easthub".parse().unwrap());
assert_eq!(SpecType::Social, "social".parse().unwrap());
assert_eq!(SpecType::Olympic, "olympic".parse().unwrap());
assert_eq!(SpecType::Morden, "morden".parse().unwrap());
assert_eq!(SpecType::Morden, "classic-testnet".parse().unwrap()); assert_eq!(SpecType::Morden, "classic-testnet".parse().unwrap());
assert_eq!(SpecType::Ropsten, "ropsten".parse().unwrap());
assert_eq!(SpecType::Kovan, "kovan".parse().unwrap());
assert_eq!(SpecType::Kovan, "testnet".parse().unwrap());
assert_eq!(SpecType::Sokol, "sokol".parse().unwrap());
assert_eq!(SpecType::Sokol, "poasokol".parse().unwrap());
} }
#[test] #[test]
@ -366,13 +388,19 @@ mod tests {
#[test] #[test]
fn test_spec_type_display() { fn test_spec_type_display() {
assert_eq!(format!("{}", SpecType::Foundation), "foundation"); assert_eq!(format!("{}", SpecType::Foundation), "foundation");
assert_eq!(format!("{}", SpecType::Ropsten), "ropsten");
assert_eq!(format!("{}", SpecType::Morden), "morden");
assert_eq!(format!("{}", SpecType::Olympic), "olympic");
assert_eq!(format!("{}", SpecType::Classic), "classic"); assert_eq!(format!("{}", SpecType::Classic), "classic");
assert_eq!(format!("{}", SpecType::Poanet), "poanet");
assert_eq!(format!("{}", SpecType::Tobalaba), "tobalaba");
assert_eq!(format!("{}", SpecType::Expanse), "expanse"); assert_eq!(format!("{}", SpecType::Expanse), "expanse");
assert_eq!(format!("{}", SpecType::Musicoin), "musicoin"); assert_eq!(format!("{}", SpecType::Musicoin), "musicoin");
assert_eq!(format!("{}", SpecType::Ellaism), "ellaism");
assert_eq!(format!("{}", SpecType::Easthub), "easthub");
assert_eq!(format!("{}", SpecType::Social), "social");
assert_eq!(format!("{}", SpecType::Olympic), "olympic");
assert_eq!(format!("{}", SpecType::Morden), "morden");
assert_eq!(format!("{}", SpecType::Ropsten), "ropsten");
assert_eq!(format!("{}", SpecType::Kovan), "kovan"); assert_eq!(format!("{}", SpecType::Kovan), "kovan");
assert_eq!(format!("{}", SpecType::Sokol), "sokol");
assert_eq!(format!("{}", SpecType::Dev), "dev"); assert_eq!(format!("{}", SpecType::Dev), "dev");
assert_eq!(format!("{}", SpecType::Custom("foo/bar".into())), "foo/bar"); assert_eq!(format!("{}", SpecType::Custom("foo/bar".into())), "foo/bar");
} }

View File

@ -944,7 +944,7 @@ fn prepare_account_provider(spec: &SpecType, dirs: &Directories, data_dir: &str,
hardware_wallet_classic_key: spec == &SpecType::Classic, hardware_wallet_classic_key: spec == &SpecType::Classic,
unlock_keep_secret: cfg.enable_fast_unlock, unlock_keep_secret: cfg.enable_fast_unlock,
blacklisted_accounts: match *spec { blacklisted_accounts: match *spec {
SpecType::Morden | SpecType::Ropsten | SpecType::Kovan | SpecType::Dev => vec![], SpecType::Morden | SpecType::Ropsten | SpecType::Kovan | SpecType::Sokol | SpecType::Dev => vec![],
_ => vec![ _ => vec![
"00a329c0648769a73afac7f9381e08fb43dbea72".into() "00a329c0648769a73afac7f9381e08fb43dbea72".into()
], ],

View File

@ -178,7 +178,7 @@ build_rpc_trait! {
#[rpc(name = "parity_chainId")] #[rpc(name = "parity_chainId")]
fn chain_id(&self) -> Result<Option<U64>>; fn chain_id(&self) -> Result<Option<U64>>;
/// Get the chain name. Returns one of: "foundation", "kovan", &c. of a filename. /// Get the chain name. Returns one of the pre-configured chain names or a filename.
#[rpc(name = "parity_chain")] #[rpc(name = "parity_chain")]
fn chain(&self) -> Result<String>; fn chain(&self) -> Result<String>;

View File

@ -87,7 +87,7 @@ build_rpc_trait! {
#[rpc(name = "parity_setMode")] #[rpc(name = "parity_setMode")]
fn set_mode(&self, String) -> Result<bool>; fn set_mode(&self, String) -> Result<bool>;
/// Set the network spec. Argument must be one of: "foundation", "ropsten", "morden", "kovan", "olympic", "classic", "dev", "expanse", "musicoin" or a filename. /// Set the network spec. Argument must be one of pre-configured chains or a filename.
#[rpc(name = "parity_setChain")] #[rpc(name = "parity_setChain")]
fn set_spec_name(&self, String) -> Result<bool>; fn set_spec_name(&self, String) -> Result<bool>;