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

Commit 6b286a5

Browse files
debrisAndronik Ordian
authored andcommitted
make instantSeal engine backwards compatible, closes #9696 (#9700)
1 parent c8ae675 commit 6b286a5

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

ethcore/src/engines/instant_seal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use engines::{Engine, Seal};
1818
use parity_machine::{Machine, Transactions, TotalScoredHeader};
1919

2020
/// `InstantSeal` params.
21-
#[derive(Debug, PartialEq)]
21+
#[derive(Default, Debug, PartialEq)]
2222
pub struct InstantSealParams {
2323
/// Whether to use millisecond timestamp
2424
pub millisecond_timestamp: bool,

ethcore/src/engines/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub mod epoch;
3232
pub use self::authority_round::AuthorityRound;
3333
pub use self::basic_authority::BasicAuthority;
3434
pub use self::epoch::{EpochVerifier, Transition as EpochTransition};
35-
pub use self::instant_seal::InstantSeal;
35+
pub use self::instant_seal::{InstantSeal, InstantSealParams};
3636
pub use self::null_engine::NullEngine;
3737
pub use self::tendermint::Tendermint;
3838

ethcore/src/spec/spec.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ use vm::{EnvInfo, CallType, ActionValue, ActionParams, ParamsType};
3333

3434
use builtin::Builtin;
3535
use encoded;
36-
use engines::{EthEngine, NullEngine, InstantSeal, BasicAuthority, AuthorityRound, Tendermint, DEFAULT_BLOCKHASH_CONTRACT};
36+
use engines::{
37+
EthEngine, NullEngine, InstantSeal, InstantSealParams, BasicAuthority,
38+
AuthorityRound, Tendermint, DEFAULT_BLOCKHASH_CONTRACT
39+
};
3740
use error::Error;
3841
use executive::Executive;
3942
use factory::Factories;
@@ -596,7 +599,8 @@ impl Spec {
596599
match engine_spec {
597600
ethjson::spec::Engine::Null(null) => Arc::new(NullEngine::new(null.params.into(), machine)),
598601
ethjson::spec::Engine::Ethash(ethash) => Arc::new(::ethereum::Ethash::new(spec_params.cache_dir, ethash.params.into(), machine, spec_params.optimization_setting)),
599-
ethjson::spec::Engine::InstantSeal(instant_seal) => Arc::new(InstantSeal::new(instant_seal.params.into(), machine)),
602+
ethjson::spec::Engine::InstantSeal(Some(instant_seal)) => Arc::new(InstantSeal::new(instant_seal.params.into(), machine)),
603+
ethjson::spec::Engine::InstantSeal(None) => Arc::new(InstantSeal::new(InstantSealParams::default(), machine)),
600604
ethjson::spec::Engine::BasicAuthority(basic_authority) => Arc::new(BasicAuthority::new(basic_authority.params.into(), machine)),
601605
ethjson::spec::Engine::AuthorityRound(authority_round) => AuthorityRound::new(authority_round.params.into(), machine)
602606
.expect("Failed to start AuthorityRound consensus engine."),

json/src/spec/engine.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub enum Engine {
2626
Null(NullEngine),
2727
/// Instantly sealing engine.
2828
#[serde(rename="instantSeal")]
29-
InstantSeal(InstantSeal),
29+
InstantSeal(Option<InstantSeal>),
3030
/// Ethash engine.
3131
Ethash(Ethash),
3232
/// BasicAuthority engine.
@@ -71,6 +71,17 @@ mod tests {
7171
_ => panic!(),
7272
};
7373

74+
let s = r#"{
75+
"instantSeal": null
76+
}"#;
77+
78+
let deserialized: Engine = serde_json::from_str(s).unwrap();
79+
match deserialized {
80+
Engine::InstantSeal(_) => {}, // instant seal is unit tested in its own file.
81+
_ => panic!(),
82+
};
83+
84+
7485
let s = r#"{
7586
"Ethash": {
7687
"params": {

0 commit comments

Comments
 (0)