Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
make instantSeal engine backwards compatible, closes #9696 (#9700)
Browse files Browse the repository at this point in the history
  • Loading branch information
debris authored and 5chdn committed Oct 8, 2018
1 parent 0a50692 commit 91e700a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ethcore/src/engines/instant_seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use engines::{Engine, Seal};
use parity_machine::{Machine, Transactions, TotalScoredHeader};

/// `InstantSeal` params.
#[derive(Debug, PartialEq)]
#[derive(Default, Debug, PartialEq)]
pub struct InstantSealParams {
/// Whether to use millisecond timestamp
pub millisecond_timestamp: bool,
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/engines/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub mod epoch;
pub use self::authority_round::AuthorityRound;
pub use self::basic_authority::BasicAuthority;
pub use self::epoch::{EpochVerifier, Transition as EpochTransition};
pub use self::instant_seal::InstantSeal;
pub use self::instant_seal::{InstantSeal, InstantSealParams};
pub use self::null_engine::NullEngine;
pub use self::tendermint::Tendermint;

Expand Down
8 changes: 6 additions & 2 deletions ethcore/src/spec/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ use vm::{EnvInfo, CallType, ActionValue, ActionParams, ParamsType};

use builtin::Builtin;
use encoded;
use engines::{EthEngine, NullEngine, InstantSeal, BasicAuthority, AuthorityRound, Tendermint, DEFAULT_BLOCKHASH_CONTRACT};
use engines::{
EthEngine, NullEngine, InstantSeal, InstantSealParams, BasicAuthority,
AuthorityRound, Tendermint, DEFAULT_BLOCKHASH_CONTRACT
};
use error::Error;
use executive::Executive;
use factory::Factories;
Expand Down Expand Up @@ -596,7 +599,8 @@ impl Spec {
match engine_spec {
ethjson::spec::Engine::Null(null) => Arc::new(NullEngine::new(null.params.into(), machine)),
ethjson::spec::Engine::Ethash(ethash) => Arc::new(::ethereum::Ethash::new(spec_params.cache_dir, ethash.params.into(), machine, spec_params.optimization_setting)),
ethjson::spec::Engine::InstantSeal(instant_seal) => Arc::new(InstantSeal::new(instant_seal.params.into(), machine)),
ethjson::spec::Engine::InstantSeal(Some(instant_seal)) => Arc::new(InstantSeal::new(instant_seal.params.into(), machine)),
ethjson::spec::Engine::InstantSeal(None) => Arc::new(InstantSeal::new(InstantSealParams::default(), machine)),
ethjson::spec::Engine::BasicAuthority(basic_authority) => Arc::new(BasicAuthority::new(basic_authority.params.into(), machine)),
ethjson::spec::Engine::AuthorityRound(authority_round) => AuthorityRound::new(authority_round.params.into(), machine)
.expect("Failed to start AuthorityRound consensus engine."),
Expand Down
13 changes: 12 additions & 1 deletion json/src/spec/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub enum Engine {
Null(NullEngine),
/// Instantly sealing engine.
#[serde(rename="instantSeal")]
InstantSeal(InstantSeal),
InstantSeal(Option<InstantSeal>),
/// Ethash engine.
Ethash(Ethash),
/// BasicAuthority engine.
Expand Down Expand Up @@ -71,6 +71,17 @@ mod tests {
_ => panic!(),
};

let s = r#"{
"instantSeal": null
}"#;

let deserialized: Engine = serde_json::from_str(s).unwrap();
match deserialized {
Engine::InstantSeal(_) => {}, // instant seal is unit tested in its own file.
_ => panic!(),
};


let s = r#"{
"Ethash": {
"params": {
Expand Down

0 comments on commit 91e700a

Please sign in to comment.