Skip to content

Commit

Permalink
fix Unity bug openethereum#1
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisicen committed Apr 18, 2022
1 parent 9e11a33 commit af94ba7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
5 changes: 1 addition & 4 deletions crates/ethcore/src/engines/unity/mod.rs
Expand Up @@ -753,7 +753,7 @@ impl Unity {
machine: EthereumMachine,
optimize_for: T,
) -> Result<Arc<Self>, Error> {
debug!("unity params: {:?}, {:?}, {:?}, {:?}, {:?}, {:?}",
debug!("unity params: {:?}, {:?}, {:?}, {:?}, {:?}",
our_params.minimum_difficulty,
our_params.block_reward,
our_params.two_thirds_majority_transition,
Expand Down Expand Up @@ -2207,7 +2207,6 @@ mod tests {
durations: [StepDurationInfo {
transition_step: 0,
transition_timestamp: 0,
step_duration: 1,
}]
.to_vec()
.into_iter()
Expand Down Expand Up @@ -2368,7 +2367,6 @@ mod tests {
fn should_collect_block_reward_transitions() {
let config = r#"{
"params": {
"stepDuration": "5",
"validators": {
"list" : ["0x1000000000000000000000000000000000000001"]
},
Expand Down Expand Up @@ -2419,7 +2417,6 @@ mod tests {
fn should_reject_out_of_order_block_reward_transition() {
let config = r#"{
"params": {
"stepDuration": "5",
"validators": {
"list" : ["0x1000000000000000000000000000000000000001"]
},
Expand Down
7 changes: 6 additions & 1 deletion crates/ethcore/src/spec/spec.rs
Expand Up @@ -727,7 +727,12 @@ impl Spec {
.expect("Failed to start AuthorityRound consensus engine.")
},
ethjson::spec::Engine::Unity(unity) => {
Unity::new(unity.params.into(), machine)
Unity::new(
spec_params.cache_dir,
unity.params.into(),
machine,
spec_params.optimization_setting,
)
.expect("Failed to start Unity consensus engine.")
}
};
Expand Down
13 changes: 1 addition & 12 deletions crates/ethjson/src/spec/unity.rs
Expand Up @@ -23,7 +23,6 @@
//!
//! ```ignore
//! "params": {
//! "stepDuration": "5",
//! "validators": {
//! "multi": {
//! "0": {
Expand Down Expand Up @@ -113,7 +112,7 @@ mod tests {
use crate::{
hash::Address,
spec::{
unity::Unity, step_duration::StepDuration,
unity::Unity,
validator_set::ValidatorSet,
},
uint::Uint,
Expand All @@ -126,7 +125,6 @@ mod tests {
fn authority_round_deserialization() {
let s = r#"{
"params": {
"stepDuration": "0x02",
"validators": {
"list" : ["0xc6d9d2cd449a754c494264e1809c50e34d64562b"]
},
Expand All @@ -146,10 +144,6 @@ mod tests {
}"#;

let deserialized: Unity = serde_json::from_str(s).unwrap();
assert_eq!(
deserialized.params.step_duration,
StepDuration::Single(Uint(U256::from(2)))
);
assert_eq!(
deserialized.params.validators,
ValidatorSet::List(vec![Address(
Expand Down Expand Up @@ -200,7 +194,6 @@ mod tests {
fn authority_round_deserialization_multi_block() {
let s = r#"{
"params": {
"stepDuration": "0x02",
"validators": {
"contract" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b"
},
Expand All @@ -212,10 +205,6 @@ mod tests {
}"#;

let deserialized: Unity = serde_json::from_str(s).unwrap();
assert_eq!(
deserialized.params.step_duration,
StepDuration::Single(Uint(U256::from(0x02)))
);
assert_eq!(
deserialized.params.validators,
ValidatorSet::Contract(Address(
Expand Down

0 comments on commit af94ba7

Please sign in to comment.