Additional kovan params

This commit is contained in:
arkpar 2017-03-14 09:54:45 +01:00
parent 456eee4865
commit 5c52c2581b
8 changed files with 15 additions and 8 deletions

View File

@ -30,7 +30,8 @@
"params": { "params": {
"maximumExtraDataSize": "0x20", "maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388", "minGasLimit": "0x1388",
"networkID" : "0x2A" "networkID" : "0x2A",
"validateReceipts" : false
}, },
"genesis": { "genesis": {
"seal": { "seal": {

View File

@ -375,7 +375,7 @@ impl Client {
})?; })?;
// Final Verification // 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); warn!(target: "client", "Stage 4 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e);
return Err(()); return Err(());
} }

View File

@ -53,6 +53,8 @@ pub struct CommonParams {
pub min_gas_limit: U256, pub min_gas_limit: U256,
/// Fork block to check. /// Fork block to check.
pub fork_block: Option<(BlockNumber, H256)>, pub fork_block: Option<(BlockNumber, H256)>,
/// Validate block receipts root.
pub validate_receipts: bool,
} }
impl From<ethjson::spec::Params> for CommonParams { impl From<ethjson::spec::Params> for CommonParams {
@ -65,6 +67,7 @@ impl From<ethjson::spec::Params> for CommonParams {
subprotocol_name: p.subprotocol_name.unwrap_or_else(|| "eth".to_owned()), subprotocol_name: p.subprotocol_name.unwrap_or_else(|| "eth".to_owned()),
min_gas_limit: p.min_gas_limit.into(), 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 }, fork_block: if let (Some(n), Some(h)) = (p.fork_block, p.fork_hash) { Some((n.into(), h.into())) } else { None },
validate_receipts: p.validate_receipts.unwrap_or(true),
} }
} }
} }

View File

@ -31,7 +31,7 @@ impl Verifier for CanonVerifier {
verification::verify_block_family(header, bytes, engine, bc) verification::verify_block_family(header, bytes, engine, bc)
} }
fn verify_block_final(&self, expected: &Header, got: &Header) -> Result<(), Error> { fn verify_block_final(&self, expected: &Header, got: &Header, receipts: bool) -> Result<(), Error> {
verification::verify_block_final(expected, got) verification::verify_block_final(expected, got, receipts)
} }
} }

View File

@ -31,7 +31,7 @@ impl Verifier for NoopVerifier {
Ok(()) 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(()) Ok(())
} }
} }

View File

@ -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, /// 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() { if expected.gas_used() != got.gas_used() {
return Err(From::from(BlockError::InvalidGasUsed(Mismatch { expected: expected.gas_used().clone(), found: got.gas_used().clone() }))) 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() { if expected.state_root() != got.state_root() {
return Err(From::from(BlockError::InvalidStateRoot(Mismatch { expected: expected.state_root().clone(), found: got.state_root().clone() }))) 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() }))) return Err(From::from(BlockError::InvalidReceiptsRoot(Mismatch { expected: expected.receipts_root().clone(), found: got.receipts_root().clone() })))
} }
Ok(()) Ok(())

View File

@ -26,5 +26,5 @@ pub trait Verifier: Send + Sync {
/// Verify a block relative to its parent and uncles. /// Verify a block relative to its parent and uncles.
fn verify_block_family(&self, header: &Header, bytes: &[u8], engine: &Engine, bc: &BlockProvider) -> Result<(), Error>; 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. /// 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>;
} }

View File

@ -49,6 +49,9 @@ pub struct Params {
/// Expected fork block hash. /// Expected fork block hash.
#[serde(rename="forkCanonHash")] #[serde(rename="forkCanonHash")]
pub fork_hash: Option<H256>, pub fork_hash: Option<H256>,
/// See `CommonParams` docs.
#[serde(rename="validateReceipts")]
pub validate_receipts: Option<bool>,
} }
#[cfg(test)] #[cfg(test)]