From 73f08b376f3523214cf7cf83a555039e1a8c2ac4 Mon Sep 17 00:00:00 2001 From: Seun LanLege Date: Wed, 17 Oct 2018 00:47:11 +0100 Subject: [PATCH] prevent zero networkID (#9763) * prevent zero networkID, closes #8345 Signed-off-by: Seun LanLege * updated networkID of olymic chain spec Signed-off-by: Seun LanLege --- ethcore/res/ethereum/olympic.json | 2 +- json/src/spec/params.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ethcore/res/ethereum/olympic.json b/ethcore/res/ethereum/olympic.json index 274e8c23a..f0e4c1045 100644 --- a/ethcore/res/ethereum/olympic.json +++ b/ethcore/res/ethereum/olympic.json @@ -17,7 +17,7 @@ "accountStartNonce": "0x00", "maximumExtraDataSize": "0x0400", "minGasLimit": "125000", - "networkID" : "0x0", + "networkID" : "0xf0", "eip150Transition": "0x7fffffffffffffff", "eip160Transition": "0x7fffffffffffffff", "eip161abcTransition": "0x7fffffffffffffff", diff --git a/json/src/spec/params.rs b/json/src/spec/params.rs index ea0a55d49..74f872154 100644 --- a/json/src/spec/params.rs +++ b/json/src/spec/params.rs @@ -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")] @@ -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(); + } }