[stable] Backports (#8352)

* Update musicoin spec in line with gmc v2.6.2 (#8242)

* Supress TemporaryInvalid verification failures. (#8256)

* Include suicided accounts in state diff (#8297)

* Include suicided accounts in state diff

* Shorten form match -> if let

* Test suicide trace diff in State

* replace_home for password_files, reserved_peers and log_file (#8324)

* replace_home for password_files, reserved_peers and log_file

* typo: arg_log_file is Option

* Bump version in util/version
This commit is contained in:
Tomasz Drwięga 2018-04-10 12:35:08 +02:00 committed by Rando
parent e6273039c8
commit fdacb9b649
5 changed files with 71 additions and 22 deletions

View File

@ -10,9 +10,9 @@
"homesteadTransition":"0x118c30", "homesteadTransition":"0x118c30",
"eip100bTransition":"0x21e88e", "eip100bTransition":"0x21e88e",
"eip150Transition":"0x21e88e", "eip150Transition":"0x21e88e",
"eip160Transition":"0x7fffffffffffff", "eip160Transition":"0x21e88e",
"eip161abcTransition":"0x7fffffffffffff", "eip161abcTransition":"0x21e88e",
"eip161dTransition":"0x7fffffffffffff", "eip161dTransition":"0x21e88e",
"eip649Transition":"0x21e88e", "eip649Transition":"0x21e88e",
"blockReward":"0x1105a0185b50a80000", "blockReward":"0x1105a0185b50a80000",
"mcip3Transition":"0x124f81", "mcip3Transition":"0x124f81",
@ -40,8 +40,7 @@
"eip211Transition":"0x21e88e", "eip211Transition":"0x21e88e",
"eip214Transition":"0x21e88e", "eip214Transition":"0x21e88e",
"eip658Transition":"0x21e88e", "eip658Transition":"0x21e88e",
"maxCodeSize":"0x6000", "maxCodeSize":"0x6000"
"maxCodeSizeTransition": "0x7fffffffffffff"
}, },
"genesis":{ "genesis":{
"seal":{ "seal":{

View File

@ -833,16 +833,26 @@ impl<B: Backend> State<B> {
})) }))
} }
fn query_pod(&mut self, query: &PodState) -> trie::Result<()> { // Return a list of all touched addresses in cache.
for (address, pod_account) in query.get() { fn touched_addresses(&self) -> Vec<Address> {
assert!(self.checkpoints.borrow().is_empty());
self.cache.borrow().iter().map(|(add, _)| *add).collect()
}
fn query_pod(&mut self, query: &PodState, touched_addresses: &[Address]) -> trie::Result<()> {
let pod = query.get();
for address in touched_addresses {
if !self.ensure_cached(address, RequireCache::Code, true, |a| a.is_some())? { if !self.ensure_cached(address, RequireCache::Code, true, |a| a.is_some())? {
continue continue
} }
// needs to be split into two parts for the refcell code here if let Some(pod_account) = pod.get(address) {
// to work. // needs to be split into two parts for the refcell code here
for key in pod_account.storage.keys() { // to work.
self.storage_at(address, key)?; for key in pod_account.storage.keys() {
self.storage_at(address, key)?;
}
} }
} }
@ -852,9 +862,10 @@ impl<B: Backend> State<B> {
/// Returns a `StateDiff` describing the difference from `orig` to `self`. /// Returns a `StateDiff` describing the difference from `orig` to `self`.
/// Consumes self. /// Consumes self.
pub fn diff_from<X: Backend>(&self, orig: State<X>) -> trie::Result<StateDiff> { pub fn diff_from<X: Backend>(&self, orig: State<X>) -> trie::Result<StateDiff> {
let addresses_post = self.touched_addresses();
let pod_state_post = self.to_pod(); let pod_state_post = self.to_pod();
let mut state_pre = orig; let mut state_pre = orig;
state_pre.query_pod(&pod_state_post)?; state_pre.query_pod(&pod_state_post, &addresses_post)?;
Ok(pod_state::diff_pod(&state_pre.to_pod(), &pod_state_post)) Ok(pod_state::diff_pod(&state_pre.to_pod(), &pod_state_post))
} }
@ -2182,4 +2193,37 @@ mod tests {
assert!(state.exists(&d).unwrap()); assert!(state.exists(&d).unwrap());
assert!(!state.exists(&e).unwrap()); assert!(!state.exists(&e).unwrap());
} }
#[test]
fn should_trace_diff_suicided_accounts() {
use pod_account;
let a = 10.into();
let db = get_temp_state_db();
let (root, db) = {
let mut state = State::new(db, U256::from(0), Default::default());
state.add_balance(&a, &100.into(), CleanupMode::ForceCreate).unwrap();
state.commit().unwrap();
state.drop()
};
let mut state = State::from_existing(db, root, U256::from(0u8), Default::default()).unwrap();
let original = state.clone();
state.kill_account(&a);
assert_eq!(original.touched_addresses(), vec![]);
assert_eq!(state.touched_addresses(), vec![a]);
let diff = state.diff_from(original).unwrap();
let diff_map = diff.get();
assert_eq!(diff_map.len(), 1);
assert!(diff_map.get(&a).is_some());
assert_eq!(diff_map.get(&a),
pod_account::diff_pod(Some(&PodAccount {
balance: U256::from(100),
nonce: U256::zero(),
code: Some(Default::default()),
storage: Default::default()
}), None).as_ref());
}
} }

View File

@ -70,7 +70,7 @@ pub mod blocks {
use super::{Kind, BlockLike}; use super::{Kind, BlockLike};
use engines::EthEngine; use engines::EthEngine;
use error::Error; use error::{Error, BlockError};
use header::Header; use header::Header;
use verification::{PreverifiedBlock, verify_block_basic, verify_block_unordered}; use verification::{PreverifiedBlock, verify_block_basic, verify_block_unordered};
@ -90,6 +90,10 @@ pub mod blocks {
fn create(input: Self::Input, engine: &EthEngine) -> Result<Self::Unverified, Error> { fn create(input: Self::Input, engine: &EthEngine) -> Result<Self::Unverified, Error> {
match verify_block_basic(&input.header, &input.bytes, engine) { match verify_block_basic(&input.header, &input.bytes, engine) {
Ok(()) => Ok(input), Ok(()) => Ok(input),
Err(Error::Block(BlockError::TemporarilyInvalid(oob))) => {
debug!(target: "client", "Block received too early {}: {:?}", input.hash(), oob);
Err(BlockError::TemporarilyInvalid(oob).into())
},
Err(e) => { Err(e) => {
warn!(target: "client", "Stage 1 block verification failed for {}: {:?}", input.hash(), e); warn!(target: "client", "Stage 1 block verification failed for {}: {:?}", input.hash(), e);
Err(e) Err(e)

View File

@ -145,7 +145,7 @@ impl Configuration {
if self.args.cmd_signer_new_token { if self.args.cmd_signer_new_token {
Cmd::SignerToken(ws_conf, ui_conf, logger_config.clone()) Cmd::SignerToken(ws_conf, ui_conf, logger_config.clone())
} else if self.args.cmd_signer_sign { } else if self.args.cmd_signer_sign {
let pwfile = self.args.arg_password.first().map(|pwfile| { let pwfile = self.accounts_config()?.password_files.first().map(|pwfile| {
PathBuf::from(pwfile) PathBuf::from(pwfile)
}); });
Cmd::SignerSign { Cmd::SignerSign {
@ -182,7 +182,7 @@ impl Configuration {
iterations: self.args.arg_keys_iterations, iterations: self.args.arg_keys_iterations,
path: dirs.keys, path: dirs.keys,
spec: spec, spec: spec,
password_file: self.args.arg_password.first().map(|x| x.to_owned()), password_file: self.accounts_config()?.password_files.first().map(|x| x.to_owned()),
}; };
AccountCmd::New(new_acc) AccountCmd::New(new_acc)
} else if self.args.cmd_account_list { } else if self.args.cmd_account_list {
@ -216,8 +216,8 @@ impl Configuration {
iterations: self.args.arg_keys_iterations, iterations: self.args.arg_keys_iterations,
path: dirs.keys, path: dirs.keys,
spec: spec, spec: spec,
wallet_path: self.args.arg_wallet_import_path.unwrap().clone(), wallet_path: self.args.arg_wallet_import_path.clone().unwrap(),
password_file: self.args.arg_password.first().map(|x| x.to_owned()), password_file: self.accounts_config()?.password_files.first().map(|x| x.to_owned()),
}; };
Cmd::ImportPresaleWallet(presale_cmd) Cmd::ImportPresaleWallet(presale_cmd)
} else if self.args.cmd_import { } else if self.args.cmd_import {
@ -440,7 +440,7 @@ impl Configuration {
LogConfig { LogConfig {
mode: self.args.arg_logging.clone(), mode: self.args.arg_logging.clone(),
color: !self.args.flag_no_color && !cfg!(windows), color: !self.args.flag_no_color && !cfg!(windows),
file: self.args.arg_log_file.clone(), file: self.args.arg_log_file.as_ref().map(|log_file| replace_home(&self.directories().base, log_file)),
} }
} }
@ -489,7 +489,7 @@ impl Configuration {
iterations: self.args.arg_keys_iterations, iterations: self.args.arg_keys_iterations,
refresh_time: self.args.arg_accounts_refresh, refresh_time: self.args.arg_accounts_refresh,
testnet: self.args.flag_testnet, testnet: self.args.flag_testnet,
password_files: self.args.arg_password.clone(), password_files: self.args.arg_password.iter().map(|s| replace_home(&self.directories().base, s)).collect(),
unlocked_accounts: to_addresses(&self.args.arg_unlock)?, unlocked_accounts: to_addresses(&self.args.arg_unlock)?,
enable_hardware_wallets: !self.args.flag_no_hardware_wallets, enable_hardware_wallets: !self.args.flag_no_hardware_wallets,
enable_fast_unlock: self.args.flag_fast_unlock, enable_fast_unlock: self.args.flag_fast_unlock,
@ -704,8 +704,10 @@ impl Configuration {
match self.args.arg_reserved_peers { match self.args.arg_reserved_peers {
Some(ref path) => { Some(ref path) => {
let path = replace_home(&self.directories().base, path);
let mut buffer = String::new(); let mut buffer = String::new();
let mut node_file = File::open(path).map_err(|e| format!("Error opening reserved nodes file: {}", e))?; let mut node_file = File::open(&path).map_err(|e| format!("Error opening reserved nodes file: {}", e))?;
node_file.read_to_string(&mut buffer).map_err(|_| "Error reading reserved node file")?; node_file.read_to_string(&mut buffer).map_err(|_| "Error reading reserved node file")?;
let lines = buffer.lines().map(|s| s.trim().to_owned()).filter(|s| !s.is_empty() && !s.starts_with("#")).collect::<Vec<_>>(); let lines = buffer.lines().map(|s| s.trim().to_owned()).filter(|s| !s.is_empty() && !s.starts_with("#")).collect::<Vec<_>>();

View File

@ -3,7 +3,7 @@
[package] [package]
name = "parity-version" name = "parity-version"
# NOTE: this value is used for Parity version string. # NOTE: this value is used for Parity version string.
version = "1.9.5" version = "1.9.6"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs" build = "build.rs"
@ -13,7 +13,7 @@ build = "build.rs"
track = "stable" track = "stable"
# Indicates a critical release in this track (i.e. consensus issue) # Indicates a critical release in this track (i.e. consensus issue)
critical = true critical = false
# Latest supported fork blocks for various networks. Used ONLY by auto-updater. # Latest supported fork blocks for various networks. Used ONLY by auto-updater.
[package.metadata.forks] [package.metadata.forks]