Backports to 1.11.8-stable (#9144)
* parity-version: bump stable to 1.11.8 * ci: update version strings for snaps * Be more graceful on Aura difficulty validation (#9164) * Be more graceful on Aura difficulty validation * test: rejects_step_backwards * test: proposer_switching * test: rejects_future_block * test: reports_skipped * test: verify_empty_seal_steps * parity: fix UserDefaults json parser (#9189) * parity: fix UserDefaults json parser * parity: use serde_derive for UserDefaults * parity: support deserialization of old UserDefault json format * parity: make UserDefaults serde backwards compatible * parity: tabify indentation in UserDefaults * Fix bugfix hard fork logic (#9138) * Fix bugfix hard fork logic * Remove dustProtectionTransition from bugfix category EIP-168 is not enabled by default * Remove unnecessary 'static * Disable per-sender limit for local transactions. (#9148) * Disable per-sender limit for local transactions. * Add a missing new line. * rpc: fix is_major_importing sync state condition (#9112) * rpc: fix is_major_importing sync state condition * rpc: fix informant printout when waiting for peers * fix verification in ethcore-sync collect_blocks (#9135) * docker: update hub dockerfile (#9173) * update Dockerfile for hub update to Ubuntu Xenial 16.04 fix cmake version * docker: fix tab indentation in hub dockerfile * ethcore: update to parity-wasm 0.31 * rpc: fix broken merge
This commit is contained in:
@@ -1149,9 +1149,10 @@ impl Engine<EthereumMachine> for AuthorityRound {
|
||||
|
||||
// If empty step messages are enabled we will validate the messages in the seal, missing messages are not
|
||||
// reported as there's no way to tell whether the empty step message was never sent or simply not included.
|
||||
if header.number() >= self.empty_steps_transition {
|
||||
let validate_empty_steps = || -> Result<(), Error> {
|
||||
let empty_steps_len = if header.number() >= self.empty_steps_transition {
|
||||
let validate_empty_steps = || -> Result<usize, Error> {
|
||||
let empty_steps = header_empty_steps(header)?;
|
||||
let empty_steps_len = empty_steps.len();
|
||||
for empty_step in empty_steps {
|
||||
if empty_step.step <= parent_step || empty_step.step >= step {
|
||||
Err(EngineError::InsufficientProof(
|
||||
@@ -1168,16 +1169,27 @@ impl Engine<EthereumMachine> for AuthorityRound {
|
||||
format!("invalid empty step proof: {:?}", empty_step)))?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
Ok(empty_steps_len)
|
||||
};
|
||||
|
||||
if let err @ Err(_) = validate_empty_steps() {
|
||||
self.validators.report_benign(header.author(), set_number, header.number());
|
||||
return err;
|
||||
match validate_empty_steps() {
|
||||
Ok(len) => len,
|
||||
Err(err) => {
|
||||
self.validators.report_benign(header.author(), set_number, header.number());
|
||||
return Err(err);
|
||||
},
|
||||
}
|
||||
|
||||
} else {
|
||||
self.report_skipped(header, step, parent_step, &*validators, set_number);
|
||||
|
||||
0
|
||||
};
|
||||
|
||||
if header.number() >= self.validate_score_transition {
|
||||
let expected_difficulty = calculate_score(parent_step.into(), step.into(), empty_steps_len.into());
|
||||
if header.difficulty() != &expected_difficulty {
|
||||
return Err(From::from(BlockError::InvalidDifficulty(Mismatch { expected: expected_difficulty, found: header.difficulty().clone() })));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -1408,7 +1420,7 @@ mod tests {
|
||||
use engines::{Seal, Engine, EngineError, EthEngine};
|
||||
use engines::validator_set::TestSet;
|
||||
use error::{Error, ErrorKind};
|
||||
use super::{AuthorityRoundParams, AuthorityRound, EmptyStep, SealedEmptyStep};
|
||||
use super::{AuthorityRoundParams, AuthorityRound, EmptyStep, SealedEmptyStep, calculate_score};
|
||||
|
||||
#[test]
|
||||
fn has_valid_metadata() {
|
||||
@@ -1514,12 +1526,15 @@ mod tests {
|
||||
|
||||
let engine = Spec::new_test_round().engine;
|
||||
|
||||
let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap();
|
||||
// Two validators.
|
||||
// Spec starts with step 2.
|
||||
header.set_difficulty(calculate_score(U256::from(0), U256::from(2), U256::zero()));
|
||||
let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap();
|
||||
header.set_seal(vec![encode(&2usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]);
|
||||
assert!(engine.verify_block_family(&header, &parent_header).is_ok());
|
||||
assert!(engine.verify_block_external(&header).is_err());
|
||||
header.set_difficulty(calculate_score(U256::from(0), U256::from(1), U256::zero()));
|
||||
let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap();
|
||||
header.set_seal(vec![encode(&1usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]);
|
||||
assert!(engine.verify_block_family(&header, &parent_header).is_ok());
|
||||
assert!(engine.verify_block_external(&header).is_ok());
|
||||
@@ -1540,9 +1555,10 @@ mod tests {
|
||||
|
||||
let engine = Spec::new_test_round().engine;
|
||||
|
||||
let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap();
|
||||
// Two validators.
|
||||
// Spec starts with step 2.
|
||||
header.set_difficulty(calculate_score(U256::from(0), U256::from(1), U256::zero()));
|
||||
let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap();
|
||||
header.set_seal(vec![encode(&1usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]);
|
||||
assert!(engine.verify_block_family(&header, &parent_header).is_ok());
|
||||
assert!(engine.verify_block_external(&header).is_ok());
|
||||
@@ -1569,8 +1585,10 @@ mod tests {
|
||||
// Two validators.
|
||||
// Spec starts with step 2.
|
||||
header.set_seal(vec![encode(&5usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]);
|
||||
header.set_difficulty(calculate_score(U256::from(4), U256::from(5), U256::zero()));
|
||||
assert!(engine.verify_block_family(&header, &parent_header).is_ok());
|
||||
header.set_seal(vec![encode(&3usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]);
|
||||
header.set_difficulty(calculate_score(U256::from(4), U256::from(3), U256::zero()));
|
||||
assert!(engine.verify_block_family(&header, &parent_header).is_err());
|
||||
}
|
||||
|
||||
@@ -1604,6 +1622,7 @@ mod tests {
|
||||
parent_header.set_seal(vec![encode(&1usize).into_vec()]);
|
||||
parent_header.set_gas_limit("222222".parse::<U256>().unwrap());
|
||||
let mut header: Header = Header::default();
|
||||
header.set_difficulty(calculate_score(U256::from(1), U256::from(3), U256::zero()));
|
||||
header.set_gas_limit("222222".parse::<U256>().unwrap());
|
||||
header.set_seal(vec![encode(&3usize).into_vec()]);
|
||||
|
||||
@@ -1963,16 +1982,15 @@ mod tests {
|
||||
let empty_step3 = sealed_empty_step(engine, 3, &parent_header.hash());
|
||||
|
||||
let empty_steps = vec![empty_step2, empty_step3];
|
||||
header.set_difficulty(calculate_score(U256::from(0), U256::from(4), U256::from(2)));
|
||||
let signature = tap.sign(addr1, Some("1".into()), header.bare_hash()).unwrap();
|
||||
header.set_seal(vec![
|
||||
encode(&4usize).into_vec(),
|
||||
encode(&(&*signature as &[u8])).into_vec(),
|
||||
::rlp::encode_list(&empty_steps).into_vec(),
|
||||
]);
|
||||
|
||||
assert!(match engine.verify_block_family(&header, &parent_header) {
|
||||
Ok(_) => true,
|
||||
_ => false,
|
||||
});
|
||||
assert!(engine.verify_block_family(&header, &parent_header).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1026,10 +1026,12 @@ impl miner::MinerService for Miner {
|
||||
|
||||
// refuse to seal the first block of the chain if it contains hard forks
|
||||
// which should be on by default.
|
||||
if block.block().header().number() == 1 && self.engine.params().contains_bugfix_hard_fork() {
|
||||
warn!("Your chain specification contains one or more hard forks which are required to be \
|
||||
on by default. Please remove these forks and start your chain again.");
|
||||
return;
|
||||
if block.block().header().number() == 1 {
|
||||
if let Some(name) = self.engine.params().nonzero_bugfix_hard_fork() {
|
||||
warn!("Your chain specification contains one or more hard forks which are required to be \
|
||||
on by default. Please remove these forks and start your chain again: {}.", name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
match self.engine.seals_internally() {
|
||||
|
||||
@@ -57,7 +57,7 @@ fn fmt_err<F: ::std::fmt::Display>(f: F) -> String {
|
||||
|
||||
/// Parameters common to ethereum-like blockchains.
|
||||
/// NOTE: when adding bugfix hard-fork parameters,
|
||||
/// add to `contains_bugfix_hard_fork`
|
||||
/// add to `nonzero_bugfix_hard_fork`
|
||||
///
|
||||
/// we define a "bugfix" hard fork as any hard fork which
|
||||
/// you would put on-by-default in a new chain.
|
||||
@@ -166,13 +166,21 @@ impl CommonParams {
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether these params contain any bug-fix hard forks.
|
||||
pub fn contains_bugfix_hard_fork(&self) -> bool {
|
||||
self.eip98_transition != 0 && self.eip155_transition != 0 &&
|
||||
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.validate_chain_id_transition != 0 && self.dust_protection_transition != 0
|
||||
/// Return Some if the current parameters contain a bugfix hard fork not on block 0.
|
||||
pub fn nonzero_bugfix_hard_fork(&self) -> Option<&str> {
|
||||
if self.eip155_transition != 0 {
|
||||
return Some("eip155Transition");
|
||||
}
|
||||
|
||||
if self.validate_receipts_transition != 0 {
|
||||
return Some("validateReceiptsTransition");
|
||||
}
|
||||
|
||||
if self.validate_chain_id_transition != 0 {
|
||||
return Some("validateChainIdTransition");
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
byteorder = "1.0"
|
||||
ethereum-types = "0.3"
|
||||
log = "0.3"
|
||||
parity-wasm = "0.27"
|
||||
parity-wasm = "0.31"
|
||||
libc = "0.2"
|
||||
pwasm-utils = "0.1"
|
||||
pwasm-utils = "0.2.2"
|
||||
vm = { path = "../vm" }
|
||||
ethcore-logger = { path = "../../logger" }
|
||||
wasmi = { version = "0.2" }
|
||||
|
||||
@@ -25,7 +25,7 @@ fn gas_rules(wasm_costs: &vm::WasmCosts) -> rules::Set {
|
||||
rules::Set::new(
|
||||
wasm_costs.regular,
|
||||
{
|
||||
let mut vals = ::std::collections::HashMap::with_capacity(8);
|
||||
let mut vals = ::std::collections::BTreeMap::new();
|
||||
vals.insert(rules::InstructionType::Load, rules::Metering::Fixed(wasm_costs.mem as u32));
|
||||
vals.insert(rules::InstructionType::Store, rules::Metering::Fixed(wasm_costs.mem as u32));
|
||||
vals.insert(rules::InstructionType::Div, rules::Metering::Fixed(wasm_costs.div as u32));
|
||||
|
||||
Reference in New Issue
Block a user