add tendermint seal
This commit is contained in:
parent
a74bce2c06
commit
943efc21bb
@ -19,8 +19,12 @@
|
|||||||
},
|
},
|
||||||
"genesis": {
|
"genesis": {
|
||||||
"seal": {
|
"seal": {
|
||||||
"generic": {
|
"tendermint": {
|
||||||
"rlp": "f88980b8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f843b8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
"round": "0x0",
|
||||||
|
"proposal": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||||
|
"precommits": [
|
||||||
|
"0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"difficulty": "0x20000",
|
"difficulty": "0x20000",
|
||||||
|
@ -44,6 +44,16 @@ pub struct AuthorityRound {
|
|||||||
pub signature: H520,
|
pub signature: H520,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Tendermint seal.
|
||||||
|
pub struct AuthorityRound {
|
||||||
|
/// Seal round.
|
||||||
|
pub round: usize,
|
||||||
|
/// Proposal seal signature.
|
||||||
|
pub proposal: H520,
|
||||||
|
/// Precommit seal signatures.
|
||||||
|
pub precommits: Vec<H520>,
|
||||||
|
}
|
||||||
|
|
||||||
impl Into<Generic> for AuthorityRound {
|
impl Into<Generic> for AuthorityRound {
|
||||||
fn into(self) -> Generic {
|
fn into(self) -> Generic {
|
||||||
let mut s = RlpStream::new_list(2);
|
let mut s = RlpStream::new_list(2);
|
||||||
@ -52,6 +62,14 @@ impl Into<Generic> for AuthorityRound {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Into<Generic> for AuthorityRound {
|
||||||
|
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<u8>);
|
pub struct Generic(pub Vec<u8>);
|
||||||
|
|
||||||
/// Genesis seal type.
|
/// Genesis seal type.
|
||||||
@ -60,6 +78,8 @@ pub enum Seal {
|
|||||||
Ethereum(Ethereum),
|
Ethereum(Ethereum),
|
||||||
/// AuthorityRound seal.
|
/// AuthorityRound seal.
|
||||||
AuthorityRound(AuthorityRound),
|
AuthorityRound(AuthorityRound),
|
||||||
|
/// Tendermint seal.
|
||||||
|
Tendermint(Tendermint),
|
||||||
/// Generic RLP seal.
|
/// Generic RLP seal.
|
||||||
Generic(Generic),
|
Generic(Generic),
|
||||||
}
|
}
|
||||||
@ -75,6 +95,11 @@ impl From<ethjson::spec::Seal> for Seal {
|
|||||||
step: ar.step.into(),
|
step: ar.step.into(),
|
||||||
signature: ar.signature.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())),
|
ethjson::spec::Seal::Generic(g) => Seal::Generic(Generic(g.into())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,6 +111,7 @@ impl Into<Generic> for Seal {
|
|||||||
Seal::Generic(generic) => generic,
|
Seal::Generic(generic) => generic,
|
||||||
Seal::Ethereum(eth) => eth.into(),
|
Seal::Ethereum(eth) => eth.into(),
|
||||||
Seal::AuthorityRound(ar) => ar.into(),
|
Seal::AuthorityRound(ar) => ar.into(),
|
||||||
|
Seal::Tendermint(tender) => tender.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ pub use self::builtin::{Builtin, Pricing, Linear};
|
|||||||
pub use self::genesis::Genesis;
|
pub use self::genesis::Genesis;
|
||||||
pub use self::params::Params;
|
pub use self::params::Params;
|
||||||
pub use self::spec::Spec;
|
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::engine::Engine;
|
||||||
pub use self::state::State;
|
pub use self::state::State;
|
||||||
pub use self::ethash::{Ethash, EthashParams};
|
pub use self::ethash::{Ethash, EthashParams};
|
||||||
|
@ -39,6 +39,17 @@ pub struct AuthorityRoundSeal {
|
|||||||
pub signature: H520,
|
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<H520>,
|
||||||
|
}
|
||||||
|
|
||||||
/// Seal variants.
|
/// Seal variants.
|
||||||
#[derive(Debug, PartialEq, Deserialize)]
|
#[derive(Debug, PartialEq, Deserialize)]
|
||||||
pub enum Seal {
|
pub enum Seal {
|
||||||
@ -48,6 +59,9 @@ pub enum Seal {
|
|||||||
/// AuthorityRound seal.
|
/// AuthorityRound seal.
|
||||||
#[serde(rename="authority_round")]
|
#[serde(rename="authority_round")]
|
||||||
AuthorityRound(AuthorityRoundSeal),
|
AuthorityRound(AuthorityRoundSeal),
|
||||||
|
/// Tendermint seal.
|
||||||
|
#[serde(rename="tendermint")]
|
||||||
|
Tendermint(TendermintSeal),
|
||||||
/// Generic seal.
|
/// Generic seal.
|
||||||
#[serde(rename="generic")]
|
#[serde(rename="generic")]
|
||||||
Generic(Bytes),
|
Generic(Bytes),
|
||||||
@ -72,6 +86,14 @@ mod tests {
|
|||||||
"step": "0x0",
|
"step": "0x0",
|
||||||
"signature": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
"signature": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
||||||
}
|
}
|
||||||
|
},{
|
||||||
|
"tendermint": {
|
||||||
|
"round": "0x0",
|
||||||
|
"proposal": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||||
|
"precommits": [
|
||||||
|
"0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
||||||
|
]
|
||||||
|
}
|
||||||
}]"#;
|
}]"#;
|
||||||
let _deserialized: Vec<Seal> = serde_json::from_str(s).unwrap();
|
let _deserialized: Vec<Seal> = serde_json::from_str(s).unwrap();
|
||||||
// TODO: validate all fields
|
// TODO: validate all fields
|
||||||
|
Loading…
Reference in New Issue
Block a user