Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into dp/chore/debug-synching-UnlinkedAncientBlo…
Browse files Browse the repository at this point in the history
…ckChain

* master:
  cargo update -p smallvec (#10822)
  replace memzero with zeroize crate (#10816)
  Don't repeat the logic from Default impl (#10813)
  removed additional_params method (#10818)
  Add Constantinople eips to the dev (instant_seal) config (#10809)
  removed redundant fmt::Display implementations (#10806)
  • Loading branch information
dvdplm committed Jul 1, 2019
2 parents f577c8f + f6a3908 commit 658f7ef
Show file tree
Hide file tree
Showing 24 changed files with 101 additions and 214 deletions.
47 changes: 33 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion accounts/ethkey/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" }
ethereum-types = "0.6.0"
lazy_static = "1.0"
log = "0.4"
parity-util-mem = "0.1"
parity-wordlist = "1.2"
quick-error = "1.2.2"
rand = "0.6"
rustc-hex = "1.0"
serde = "1.0"
serde_derive = "1.0"
tiny-keccak = "1.4"
zeroize = "0.9.1"
2 changes: 1 addition & 1 deletion accounts/ethkey/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
extern crate edit_distance;
extern crate parity_crypto;
extern crate ethereum_types;
extern crate parity_util_mem;
extern crate parity_wordlist;
#[macro_use]
extern crate quick_error;
Expand All @@ -28,6 +27,7 @@ extern crate rustc_hex;
extern crate secp256k1;
extern crate serde;
extern crate tiny_keccak;
extern crate zeroize;

#[macro_use]
extern crate lazy_static;
Expand Down
18 changes: 12 additions & 6 deletions accounts/ethkey/src/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,23 @@ use rustc_hex::ToHex;
use secp256k1::constants::{SECRET_KEY_SIZE as SECP256K1_SECRET_KEY_SIZE};
use secp256k1::key;
use ethereum_types::H256;
use parity_util_mem::Memzero;
use zeroize::Zeroize;
use {Error, SECP256K1};

#[derive(Clone, PartialEq, Eq)]
pub struct Secret {
inner: Memzero<H256>,
inner: H256,
}

impl Drop for Secret {
fn drop(&mut self) {
self.inner.0.zeroize()
}
}

impl ToHex for Secret {
fn to_hex(&self) -> String {
format!("{:x}", *self.inner)
format!("{:x}", self.inner)
}
}

Expand Down Expand Up @@ -61,12 +67,12 @@ impl Secret {
}
let mut h = H256::zero();
h.as_bytes_mut().copy_from_slice(&key[0..32]);
Some(Secret { inner: Memzero::from(h) })
Some(Secret { inner: h })
}

/// Creates zero key, which is invalid for crypto operations, but valid for math operation.
pub fn zero() -> Self {
Secret { inner: Memzero::from(H256::zero()) }
Secret { inner: H256::zero() }
}

/// Imports and validates the key.
Expand Down Expand Up @@ -214,7 +220,7 @@ impl FromStr for Secret {

impl From<[u8; 32]> for Secret {
fn from(k: [u8; 32]) -> Self {
Secret { inner: Memzero::from(H256(k)) }
Secret { inner: H256(k) }
}
}

Expand Down
3 changes: 3 additions & 0 deletions ethcore/res/instant_seal.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"eip211Transition": "0x0",
"eip214Transition": "0x0",
"eip658Transition": "0x0",
"eip145Transition": "0x0",
"eip1014Transition": "0x0",
"eip1052Transition": "0x0",
"wasmActivationTransition": "0x0"
},
"genesis": {
Expand Down
7 changes: 1 addition & 6 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

use std::cmp;
use std::collections::{HashSet, BTreeMap, VecDeque};
use std::str::FromStr;
use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering as AtomicOrdering};
use std::sync::{Arc, Weak};
use std::time::{Instant, Duration};
Expand Down Expand Up @@ -753,7 +752,7 @@ impl Client {

let importer = Importer::new(&config, engine.clone(), message_channel.clone(), miner)?;

let registrar_address = engine.additional_params().get("registrar").and_then(|s| Address::from_str(s).ok());
let registrar_address = engine.machine().params().registrar;
if let Some(ref addr) = registrar_address {
trace!(target: "client", "Found registrar at {}", addr);
}
Expand Down Expand Up @@ -1982,10 +1981,6 @@ impl BlockChainClient for Client {
self.importer.block_queue.clear();
}

fn additional_params(&self) -> BTreeMap<String, String> {
self.engine.additional_params().into_iter().collect()
}

fn logs(&self, filter: Filter) -> Result<Vec<LocalizedLogEntry>, BlockId> {
let chain = self.chain.read();

Expand Down
4 changes: 0 additions & 4 deletions ethcore/src/client/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -841,10 +841,6 @@ impl BlockChainClient for TestBlockChainClient {
fn clear_queue(&self) {
}

fn additional_params(&self) -> BTreeMap<String, String> {
Default::default()
}

fn filter_traces(&self, _filter: TraceFilter) -> Option<Vec<LocalizedTrace>> {
self.traces.read().clone()
}
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/client/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,6 @@ pub trait BlockChainClient : Sync + Send + AccountData + BlockChain + CallContra
/// Clear block queue and abort all import activity.
fn clear_queue(&self);

/// Get the registrar address, if it exists.
fn additional_params(&self) -> BTreeMap<String, String>;

/// Returns logs matching given filter. If one of the filtering block cannot be found, returns the block id that caused the error.
fn logs(&self, filter: Filter) -> Result<Vec<LocalizedLogEntry>, BlockId>;

Expand Down
7 changes: 1 addition & 6 deletions ethcore/src/engines/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub use types::engines::ForkChoice;
pub use types::engines::epoch::{self, Transition as EpochTransition};

use std::sync::{Weak, Arc};
use std::collections::{BTreeMap, HashMap};
use std::collections::BTreeMap;
use std::{fmt, error};

use builtin::Builtin;
Expand Down Expand Up @@ -543,11 +543,6 @@ pub trait Engine: Sync + Send {
self.machine().verify_transaction_basic(t, header)
}

/// Additional information.
fn additional_params(&self) -> HashMap<String, String> {
self.machine().additional_params()
}

/// Performs pre-validation of RLP decoded transaction before other processing
fn decode_transaction(&self, transaction: &[u8]) -> Result<UnverifiedTransaction, transaction::Error> {
self.machine().decode_transaction(transaction)
Expand Down
9 changes: 1 addition & 8 deletions ethcore/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

//! Ethereum-like state machine definition.

use std::collections::{BTreeMap, HashMap};
use std::collections::BTreeMap;
use std::cmp;
use std::sync::Arc;

Expand Down Expand Up @@ -385,13 +385,6 @@ impl Machine {
Ok(())
}

/// Additional params.
pub fn additional_params(&self) -> HashMap<String, String> {
hash_map![
"registrar".to_owned() => format!("{:x}", self.params.registrar)
]
}

/// Performs pre-validation of RLP decoded transaction before other processing
pub fn decode_transaction(&self, transaction: &[u8]) -> Result<UnverifiedTransaction, transaction::Error> {
let rlp = Rlp::new(&transaction);
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/spec/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub struct CommonParams {
/// Gas limit bound divisor (how much gas limit can change per block)
pub gas_limit_bound_divisor: U256,
/// Registrar contract address.
pub registrar: Address,
pub registrar: Option<Address>,
/// Node permission managing contract address.
pub node_permission_contract: Option<Address>,
/// Maximum contract code size that can be deployed.
Expand Down Expand Up @@ -315,7 +315,7 @@ impl From<ethjson::spec::Params> for CommonParams {
nonce_cap_increment: p.nonce_cap_increment.map_or(64, Into::into),
remove_dust_contracts: p.remove_dust_contracts.unwrap_or(false),
gas_limit_bound_divisor: p.gas_limit_bound_divisor.into(),
registrar: p.registrar.map_or_else(Address::zero, Into::into),
registrar: p.registrar.map(Into::into),
node_permission_contract: p.node_permission_contract.map(Into::into),
max_code_size: p.max_code_size.map_or(u64::max_value(), Into::into),
max_transaction_size: p.max_transaction_size.map_or(MAX_TRANSACTION_SIZE, Into::into),
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2678,7 +2678,7 @@ mod tests {
state.kill_account(&a);

let diff = state.diff_from(original).unwrap();
let diff_map = diff.get();
let diff_map = diff.raw;
assert_eq!(diff_map.len(), 1);
assert!(diff_map.get(&a).is_some());
assert_eq!(diff_map.get(&a),
Expand Down Expand Up @@ -2709,7 +2709,7 @@ mod tests {
state.set_storage(&a, BigEndianHash::from_uint(&U256::from(1u64)), BigEndianHash::from_uint(&U256::from(100u64))).unwrap();

let diff = state.diff_from(original).unwrap();
let diff_map = diff.get();
let diff_map = diff.raw;
assert_eq!(diff_map.len(), 1);
assert!(diff_map.get(&a).is_some());
assert_eq!(diff_map.get(&a),
Expand Down
7 changes: 2 additions & 5 deletions ethcore/src/tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,8 @@ fn should_return_registrar() {
Arc::new(Miner::new_for_tests(&spec, None)),
IoChannel::disconnected(),
).unwrap();
let params = client.additional_params();
let address = &params["registrar"];

assert_eq!(address.len(), 40);
assert!(U256::from_str(address).is_ok());
let address = client.registrar_address();
assert_eq!(address, Some("52dff57a8a1532e6afb3dc07e2af58bb9eb05b3d".parse().unwrap()));
}

#[test]
Expand Down
Loading

0 comments on commit 658f7ef

Please sign in to comment.