From 43871e393c99d80f7a9bb6a70a7be3054aeaddba Mon Sep 17 00:00:00 2001 From: Arkadiy Paronyan Date: Tue, 14 Mar 2017 11:41:56 +0100 Subject: [PATCH] Additional kovan params (#4892) --- ethcore/res/ethereum/kovan.json | 3 ++- ethcore/src/client/client.rs | 2 +- ethcore/src/spec/spec.rs | 3 +++ ethcore/src/verification/canon_verifier.rs | 4 ++-- ethcore/src/verification/noop_verifier.rs | 2 +- ethcore/src/verification/verification.rs | 4 ++-- ethcore/src/verification/verifier.rs | 2 +- json/src/spec/params.rs | 3 +++ 8 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ethcore/res/ethereum/kovan.json b/ethcore/res/ethereum/kovan.json index e9c059aaac6..330b00c582c 100644 --- a/ethcore/res/ethereum/kovan.json +++ b/ethcore/res/ethereum/kovan.json @@ -30,7 +30,8 @@ "params": { "maximumExtraDataSize": "0x20", "minGasLimit": "0x1388", - "networkID" : "0x2A" + "networkID" : "0x2A", + "validateReceipts" : false }, "genesis": { "seal": { diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 5ddc837626a..06889a538ea 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -393,7 +393,7 @@ impl Client { })?; // Final Verification - if let Err(e) = self.verifier.verify_block_final(header, locked_block.block().header()) { + if let Err(e) = self.verifier.verify_block_final(header, locked_block.block().header(), self.engine().params().validate_receipts) { warn!(target: "client", "Stage 4 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e); return Err(()); } diff --git a/ethcore/src/spec/spec.rs b/ethcore/src/spec/spec.rs index 078908db4f1..3b7f84acf27 100644 --- a/ethcore/src/spec/spec.rs +++ b/ethcore/src/spec/spec.rs @@ -55,6 +55,8 @@ pub struct CommonParams { pub fork_block: Option<(BlockNumber, H256)>, /// Number of first block where EIP-98 rules begin. pub eip98_transition: BlockNumber, + /// Validate block receipts root. + pub validate_receipts: bool, } impl From for CommonParams { @@ -68,6 +70,7 @@ impl From for CommonParams { min_gas_limit: p.min_gas_limit.into(), fork_block: if let (Some(n), Some(h)) = (p.fork_block, p.fork_hash) { Some((n.into(), h.into())) } else { None }, eip98_transition: p.eip98_transition.map_or(0, Into::into), + validate_receipts: p.validate_receipts.unwrap_or(true), } } } diff --git a/ethcore/src/verification/canon_verifier.rs b/ethcore/src/verification/canon_verifier.rs index 849f7caad53..67d7e0e85b0 100644 --- a/ethcore/src/verification/canon_verifier.rs +++ b/ethcore/src/verification/canon_verifier.rs @@ -31,7 +31,7 @@ impl Verifier for CanonVerifier { verification::verify_block_family(header, bytes, engine, bc) } - fn verify_block_final(&self, expected: &Header, got: &Header) -> Result<(), Error> { - verification::verify_block_final(expected, got) + fn verify_block_final(&self, expected: &Header, got: &Header, receipts: bool) -> Result<(), Error> { + verification::verify_block_final(expected, got, receipts) } } diff --git a/ethcore/src/verification/noop_verifier.rs b/ethcore/src/verification/noop_verifier.rs index 2fcd877f5c9..b60dbed2e1f 100644 --- a/ethcore/src/verification/noop_verifier.rs +++ b/ethcore/src/verification/noop_verifier.rs @@ -31,7 +31,7 @@ impl Verifier for NoopVerifier { Ok(()) } - fn verify_block_final(&self, _expected: &Header, _got: &Header) -> Result<(), Error> { + fn verify_block_final(&self, _expected: &Header, _got: &Header, _receipts: bool) -> Result<(), Error> { Ok(()) } } diff --git a/ethcore/src/verification/verification.rs b/ethcore/src/verification/verification.rs index 34a4ccbd00a..c2c9320661b 100644 --- a/ethcore/src/verification/verification.rs +++ b/ethcore/src/verification/verification.rs @@ -178,7 +178,7 @@ pub fn verify_block_family(header: &Header, bytes: &[u8], engine: &Engine, bc: & } /// Phase 4 verification. Check block information against transaction enactment results, -pub fn verify_block_final(expected: &Header, got: &Header) -> Result<(), Error> { +pub fn verify_block_final(expected: &Header, got: &Header, check_receipts: bool) -> Result<(), Error> { if expected.gas_used() != got.gas_used() { return Err(From::from(BlockError::InvalidGasUsed(Mismatch { expected: expected.gas_used().clone(), found: got.gas_used().clone() }))) } @@ -188,7 +188,7 @@ pub fn verify_block_final(expected: &Header, got: &Header) -> Result<(), Error> if expected.state_root() != got.state_root() { return Err(From::from(BlockError::InvalidStateRoot(Mismatch { expected: expected.state_root().clone(), found: got.state_root().clone() }))) } - if expected.receipts_root() != got.receipts_root() { + if check_receipts && expected.receipts_root() != got.receipts_root() { return Err(From::from(BlockError::InvalidReceiptsRoot(Mismatch { expected: expected.receipts_root().clone(), found: got.receipts_root().clone() }))) } Ok(()) diff --git a/ethcore/src/verification/verifier.rs b/ethcore/src/verification/verifier.rs index e5dabd392fa..9f017300313 100644 --- a/ethcore/src/verification/verifier.rs +++ b/ethcore/src/verification/verifier.rs @@ -26,5 +26,5 @@ pub trait Verifier: Send + Sync { /// Verify a block relative to its parent and uncles. fn verify_block_family(&self, header: &Header, bytes: &[u8], engine: &Engine, bc: &BlockProvider) -> Result<(), Error>; /// Do a final verification check for an enacted header vs its expected counterpart. - fn verify_block_final(&self, expected: &Header, got: &Header) -> Result<(), Error>; + fn verify_block_final(&self, expected: &Header, got: &Header, receipts: bool) -> Result<(), Error>; } diff --git a/json/src/spec/params.rs b/json/src/spec/params.rs index 26cedcf4a16..1b262231621 100644 --- a/json/src/spec/params.rs +++ b/json/src/spec/params.rs @@ -53,6 +53,9 @@ pub struct Params { /// See `CommonParams` docs. #[serde(rename="eip98Transition")] pub eip98_transition: Option, + /// See `CommonParams` docs. + #[serde(rename="validateReceipts")] + pub validate_receipts: Option, } #[cfg(test)]