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

Commit

Permalink
prevent zero networkID (#9763)
Browse files Browse the repository at this point in the history
* prevent zero networkID, closes #8345

Signed-off-by: Seun LanLege <seunlanlege@gmail.com>

* updated networkID of olymic chain spec

Signed-off-by: Seun LanLege <seunlanlege@gmail.com>
  • Loading branch information
seunlanlege authored and sorpaas committed Oct 16, 2018
1 parent ed34d1f commit 73f08b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ethcore/res/ethereum/olympic.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x0400",
"minGasLimit": "125000",
"networkID" : "0x0",
"networkID" : "0xf0",
"eip150Transition": "0x7fffffffffffffff",
"eip160Transition": "0x7fffffffffffffff",
"eip161abcTransition": "0x7fffffffffffffff",
Expand Down
17 changes: 17 additions & 0 deletions json/src/spec/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub struct Params {

/// Network id.
#[serde(rename="networkID")]
#[serde(deserialize_with="uint::validate_non_zero")]
pub network_id: Uint,
/// Chain id.
#[serde(rename="chainID")]
Expand Down Expand Up @@ -208,4 +209,20 @@ mod tests {

let _deserialized: Params = serde_json::from_str(s).unwrap();
}

#[test]
#[should_panic(expected = "a non-zero value")]
fn test_non_zero_network_id() {
let s = r#"{
"maximumExtraDataSize": "0x20",
"networkID" : "0x0",
"subprotocolName" : "exp",
"minGasLimit": "0x1388",
"accountStartNonce": "0x01",
"gasLimitBoundDivisor": "0x20",
"maxCodeSize": "0x1000"
}"#;

let _deserialized: Params = serde_json::from_str(s).unwrap();
}
}

0 comments on commit 73f08b3

Please sign in to comment.