From b0c15497e110f3c9d70be067b6294188e682e8a8 Mon Sep 17 00:00:00 2001 From: Arkadiy Paronyan Date: Sat, 14 Oct 2017 21:59:26 +0200 Subject: [PATCH] Fixed kovan chain validation (#6758) * Fixed kovan chain validation * Fork detection * Fixed typo --- ethcore/res/ethereum/kovan.json | 7 +++++-- ethcore/src/machine.rs | 4 +++- ethcore/src/spec/spec.rs | 5 ++++- json/src/spec/params.rs | 3 +++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ethcore/res/ethereum/kovan.json b/ethcore/res/ethereum/kovan.json index bd27d3b14..325b7cdf6 100644 --- a/ethcore/res/ethereum/kovan.json +++ b/ethcore/res/ethereum/kovan.json @@ -30,11 +30,14 @@ "params": { "gasLimitBoundDivisor": "0x400", "registrar" : "0xfAb104398BBefbd47752E7702D9fE23047E1Bca3", - "maximumExtraDataSize": "0x20", + "maximumExtraDataSize": "0x20", "minGasLimit": "0x1388", "networkID" : "0x2A", + "forkBlock": 4297256, + "forkCanonHash": "0x0a66d93c2f727dca618fabaf70c39b37018c73d78b939d8b11efbbd09034778f", "validateReceiptsTransition" : 1000000, - "eip155Transition": 1000000 + "eip155Transition": 1000000, + "validateChainIdTransition": 1000000 }, "genesis": { "seal": { diff --git a/ethcore/src/machine.rs b/ethcore/src/machine.rs index b1354b17b..2536384e6 100644 --- a/ethcore/src/machine.rs +++ b/ethcore/src/machine.rs @@ -351,7 +351,9 @@ impl EthereumMachine { None => true, }; - let chain_id = if header.number() >= self.params().eip155_transition { + let chain_id = if header.number() < self.params().validate_chain_id_transition { + t.chain_id() + } else if header.number() >= self.params().eip155_transition { Some(self.params().chain_id) } else { None diff --git a/ethcore/src/spec/spec.rs b/ethcore/src/spec/spec.rs index e643e1210..a1696c47b 100644 --- a/ethcore/src/spec/spec.rs +++ b/ethcore/src/spec/spec.rs @@ -85,6 +85,8 @@ pub struct CommonParams { pub eip155_transition: BlockNumber, /// Validate block receipts root. pub validate_receipts_transition: BlockNumber, + /// Validate transaction chain id. + pub validate_chain_id_transition: BlockNumber, /// Number of first block where EIP-86 (Metropolis) rules begin. pub eip86_transition: BlockNumber, /// Number of first block where EIP-140 (Metropolis: REVERT opcode) rules begin. @@ -153,7 +155,7 @@ impl CommonParams { self.validate_receipts_transition != 0 && self.eip86_transition != 0 && self.eip140_transition != 0 && self.eip210_transition != 0 && self.eip211_transition != 0 && self.eip214_transition != 0 && - self.dust_protection_transition != 0 + self.validate_chain_id_transition != 0 && self.dust_protection_transition != 0 } } @@ -178,6 +180,7 @@ impl From for CommonParams { eip98_transition: p.eip98_transition.map_or(0, Into::into), eip155_transition: p.eip155_transition.map_or(0, Into::into), validate_receipts_transition: p.validate_receipts_transition.map_or(0, Into::into), + validate_chain_id_transition: p.validate_chain_id_transition.map_or(0, Into::into), eip86_transition: p.eip86_transition.map_or( BlockNumber::max_value(), Into::into, diff --git a/json/src/spec/params.rs b/json/src/spec/params.rs index 1bb6abeb3..f62626899 100644 --- a/json/src/spec/params.rs +++ b/json/src/spec/params.rs @@ -58,6 +58,9 @@ pub struct Params { #[serde(rename="eip155Transition")] pub eip155_transition: Option, /// See `CommonParams` docs. + #[serde(rename="validateChainIdTransition")] + pub validate_chain_id_transition: Option, + /// See `CommonParams` docs. #[serde(rename="validateReceiptsTransition")] pub validate_receipts_transition: Option, /// See `CommonParams` docs.