diff --git a/ethcore/res/tendermint.json b/ethcore/res/tendermint.json index 38e5334a3..778757107 100644 --- a/ethcore/res/tendermint.json +++ b/ethcore/res/tendermint.json @@ -19,8 +19,12 @@ }, "genesis": { "seal": { - "generic": { - "rlp": "f88980b8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f843b8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "tendermint": { + "round": "0x0", + "proposal": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "precommits": [ + "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + ] } }, "difficulty": "0x20000", diff --git a/ethcore/src/spec/seal.rs b/ethcore/src/spec/seal.rs index d5257ab79..967ffc22b 100644 --- a/ethcore/src/spec/seal.rs +++ b/ethcore/src/spec/seal.rs @@ -44,6 +44,16 @@ pub struct AuthorityRound { pub signature: H520, } +/// Tendermint seal. +pub struct Tendermint { + /// Seal round. + pub round: usize, + /// Proposal seal signature. + pub proposal: H520, + /// Precommit seal signatures. + pub precommits: Vec, +} + impl Into for AuthorityRound { fn into(self) -> Generic { let mut s = RlpStream::new_list(2); @@ -52,6 +62,14 @@ impl Into for AuthorityRound { } } +impl Into for Tendermint { + fn into(self) -> Generic { + let mut s = RlpStream::new_list(3); + s.append(&self.round).append(&self.proposal).append(&self.precommits); + Generic(s.out()) + } +} + pub struct Generic(pub Vec); /// Genesis seal type. @@ -60,6 +78,8 @@ pub enum Seal { Ethereum(Ethereum), /// AuthorityRound seal. AuthorityRound(AuthorityRound), + /// Tendermint seal. + Tendermint(Tendermint), /// Generic RLP seal. Generic(Generic), } @@ -75,6 +95,11 @@ impl From for Seal { step: ar.step.into(), signature: ar.signature.into() }), + ethjson::spec::Seal::Tendermint(tender) => Seal::Tendermint(Tendermint { + round: tender.round.into(), + proposal: tender.proposal.into(), + precommits: tender.precommits.into_iter().map(Into::into).collect() + }), ethjson::spec::Seal::Generic(g) => Seal::Generic(Generic(g.into())), } } @@ -86,6 +111,7 @@ impl Into for Seal { Seal::Generic(generic) => generic, Seal::Ethereum(eth) => eth.into(), Seal::AuthorityRound(ar) => ar.into(), + Seal::Tendermint(tender) => tender.into(), } } } diff --git a/json/src/spec/mod.rs b/json/src/spec/mod.rs index f27b13b92..d923be069 100644 --- a/json/src/spec/mod.rs +++ b/json/src/spec/mod.rs @@ -34,7 +34,7 @@ pub use self::builtin::{Builtin, Pricing, Linear}; pub use self::genesis::Genesis; pub use self::params::Params; pub use self::spec::Spec; -pub use self::seal::{Seal, Ethereum, AuthorityRoundSeal}; +pub use self::seal::{Seal, Ethereum, AuthorityRoundSeal, TendermintSeal}; pub use self::engine::Engine; pub use self::state::State; pub use self::ethash::{Ethash, EthashParams}; diff --git a/json/src/spec/seal.rs b/json/src/spec/seal.rs index d586ed501..1cf1e86e6 100644 --- a/json/src/spec/seal.rs +++ b/json/src/spec/seal.rs @@ -39,6 +39,17 @@ pub struct AuthorityRoundSeal { pub signature: H520, } +/// Tendermint seal. +#[derive(Debug, PartialEq, Deserialize)] +pub struct TendermintSeal { + /// Seal round. + pub round: Uint, + /// Proposal seal signature. + pub proposal: H520, + /// Proposal seal signature. + pub precommits: Vec, +} + /// Seal variants. #[derive(Debug, PartialEq, Deserialize)] pub enum Seal { @@ -48,6 +59,9 @@ pub enum Seal { /// AuthorityRound seal. #[serde(rename="authority_round")] AuthorityRound(AuthorityRoundSeal), + /// Tendermint seal. + #[serde(rename="tendermint")] + Tendermint(TendermintSeal), /// Generic seal. #[serde(rename="generic")] Generic(Bytes), @@ -72,6 +86,14 @@ mod tests { "step": "0x0", "signature": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" } + },{ + "tendermint": { + "round": "0x0", + "proposal": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "precommits": [ + "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + ] + } }]"#; let _deserialized: Vec = serde_json::from_str(s).unwrap(); // TODO: validate all fields