diff --git a/ethcore/res/authority_round.json b/ethcore/res/authority_round.json index 85beb51b4..efc0cdeb4 100644 --- a/ethcore/res/authority_round.json +++ b/ethcore/res/authority_round.json @@ -21,8 +21,9 @@ }, "genesis": { "seal": { - "generic": { - "rlp": "0xc28080" + "authority_round": { + "step": "0x0", + "signature": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" } }, "difficulty": "0x20000", diff --git a/ethcore/res/basic_authority.json b/ethcore/res/basic_authority.json index 51276d487..db4374160 100644 --- a/ethcore/res/basic_authority.json +++ b/ethcore/res/basic_authority.json @@ -17,10 +17,7 @@ }, "genesis": { "seal": { - "generic": { - "fields": 1, - "rlp": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa" - } + "generic": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa" }, "difficulty": "0x20000", "author": "0x0000000000000000000000000000000000000000", diff --git a/ethcore/res/instant_seal.json b/ethcore/res/instant_seal.json index fbb650102..78d92e505 100644 --- a/ethcore/res/instant_seal.json +++ b/ethcore/res/instant_seal.json @@ -11,9 +11,7 @@ }, "genesis": { "seal": { - "generic": { - "rlp": "0x0" - } + "generic": "0x0" }, "difficulty": "0x20000", "author": "0x0000000000000000000000000000000000000000", diff --git a/ethcore/src/spec/seal.rs b/ethcore/src/spec/seal.rs index eaf951189..d5257ab79 100644 --- a/ethcore/src/spec/seal.rs +++ b/ethcore/src/spec/seal.rs @@ -17,7 +17,7 @@ //! Spec seal. use rlp::*; -use util::hash::{H64, H256}; +use util::hash::{H64, H256, H520}; use ethjson; /// Classic ethereum seal. @@ -32,23 +32,35 @@ impl Into for Ethereum { fn into(self) -> Generic { let mut s = RlpStream::new_list(2); s.append(&self.mix_hash).append(&self.nonce); - Generic { - rlp: s.out() - } + Generic(s.out()) } } -/// Generic seal. -pub struct Generic { - /// Seal rlp. - pub rlp: Vec, +/// AuthorityRound seal. +pub struct AuthorityRound { + /// Seal step. + pub step: usize, + /// Seal signature. + pub signature: H520, } +impl Into for AuthorityRound { + fn into(self) -> Generic { + let mut s = RlpStream::new_list(2); + s.append(&self.step).append(&self.signature); + Generic(s.out()) + } +} + +pub struct Generic(pub Vec); + /// Genesis seal type. pub enum Seal { /// Classic ethereum seal. Ethereum(Ethereum), - /// Generic seal. + /// AuthorityRound seal. + AuthorityRound(AuthorityRound), + /// Generic RLP seal. Generic(Generic), } @@ -59,9 +71,11 @@ impl From for Seal { nonce: eth.nonce.into(), mix_hash: eth.mix_hash.into() }), - ethjson::spec::Seal::Generic(g) => Seal::Generic(Generic { - rlp: g.rlp.into() - }) + ethjson::spec::Seal::AuthorityRound(ar) => Seal::AuthorityRound(AuthorityRound { + step: ar.step.into(), + signature: ar.signature.into() + }), + ethjson::spec::Seal::Generic(g) => Seal::Generic(Generic(g.into())), } } } @@ -70,7 +84,8 @@ impl Into for Seal { fn into(self) -> Generic { match self { Seal::Generic(generic) => generic, - Seal::Ethereum(eth) => eth.into() + Seal::Ethereum(eth) => eth.into(), + Seal::AuthorityRound(ar) => ar.into(), } } } diff --git a/ethcore/src/spec/spec.rs b/ethcore/src/spec/spec.rs index 5d0cc8360..bfd2ebd1d 100644 --- a/ethcore/src/spec/spec.rs +++ b/ethcore/src/spec/spec.rs @@ -107,7 +107,7 @@ impl From for Spec { fn from(s: ethjson::spec::Spec) -> Self { let builtins = s.accounts.builtins().into_iter().map(|p| (p.0.into(), From::from(p.1))).collect(); let g = Genesis::from(s.genesis); - let seal: GenericSeal = g.seal.into(); + let GenericSeal(seal_rlp) = g.seal.into(); let params = CommonParams::from(s.params); Spec { name: s.name.into(), @@ -124,7 +124,7 @@ impl From for Spec { gas_used: g.gas_used, timestamp: g.timestamp, extra_data: g.extra_data, - seal_rlp: seal.rlp, + seal_rlp: seal_rlp, state_root_memo: RwLock::new(g.state_root), genesis_state: From::from(s.accounts), } @@ -208,7 +208,7 @@ impl Spec { /// Overwrite the genesis components. pub fn overwrite_genesis_params(&mut self, g: Genesis) { - let seal: GenericSeal = g.seal.into(); + let GenericSeal(seal_rlp) = g.seal.into(); self.parent_hash = g.parent_hash; self.transactions_root = g.transactions_root; self.receipts_root = g.receipts_root; @@ -218,7 +218,7 @@ impl Spec { self.gas_used = g.gas_used; self.timestamp = g.timestamp; self.extra_data = g.extra_data; - self.seal_rlp = seal.rlp; + self.seal_rlp = seal_rlp; self.state_root_memo = RwLock::new(g.state_root); }