Skip to content

Commit

Permalink
Ethereum-types and various libs upgrade (openethereum#315)
Browse files Browse the repository at this point in the history
* Upgrade Eth types

ethereum-types -> 0.9.2
rlp -> 0.4.6
keccak-hash -> 0.5.0
parity-crypto -> 0.6.2
ethabi -> 0.12.0
ethabi-derive -> 0.12.0
ethabi-contract -> 0.11.0
ethbloom -> 0.9.1
rand -> 0.7.3
trie-standardmap -> 0.15.2
triehash -> 0.5.0

* backport #10714. Small changes, merge fixes

Co-authored-by: mdben1247 <[email protected]>
  • Loading branch information
rakita and mdben1247 authored Mar 12, 2021
1 parent 3f8e0cf commit a0f406e
Show file tree
Hide file tree
Showing 273 changed files with 3,056 additions and 4,780 deletions.
828 changes: 362 additions & 466 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ ethcore-miner = { path = "crates/concensus/miner" }
ethcore-network = { path = "crates/net/network" }
ethcore-service = { path = "crates/ethcore/service" }
ethcore-sync = { path = "crates/ethcore/sync" }
ethereum-types = "0.4"
ethereum-types = "0.9.2"
ethkey = { path = "crates/accounts/ethkey" }
ethstore = { path = "crates/accounts/ethstore" }
fetch = { path = "crates/net/fetch" }
node-filter = { path = "crates/net/node-filter" }
rlp = { version = "0.3.0", features = ["ethereum"] }
parity-crypto = { version = "0.6.2", features = [ "publickey" ] }
rlp = { version = "0.4.6" }
cli-signer= { path = "crates/util/cli-signer" }
parity-daemonize = "0.3"
parity-local-store = { path = "crates/concensus/miner/local-store" }
Expand All @@ -62,7 +63,7 @@ parity-version = { path = "crates/util/version" }
parity-path = "0.1"
dir = { path = "crates/util/dir" }
panic_hook = { path = "crates/util/panic-hook" }
keccak-hash = "0.1"
keccak-hash = "0.5.0"
migration-rocksdb = { path = "crates/db/migration-rocksdb" }
kvdb = "0.1"
kvdb-rocksdb = "0.1.3"
Expand Down Expand Up @@ -130,6 +131,3 @@ members = [
"bin/evmbin",
"bin/chainspec"
]

[patch.crates-io]
heapsize = { git = "https://github.com/cheme/heapsize.git", branch = "ec-macfix" }
1 change: 1 addition & 0 deletions bin/ethkey/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ docopt = "1.0"
env_logger = "0.5"
ethkey = { path = "../../crates/accounts/ethkey" }
panic_hook = { path = "../../crates/util/panic-hook" }
parity-crypto = { version = "0.6.2", features = [ "publickey" ] }
parity-wordlist="1.3"
rustc-hex = "1.0"
serde = "1.0"
Expand Down
23 changes: 11 additions & 12 deletions bin/ethkey/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extern crate docopt;
extern crate env_logger;
extern crate ethkey;
extern crate panic_hook;
extern crate parity_crypto as crypto;
extern crate parity_wordlist;
extern crate rustc_hex;
extern crate serde;
Expand All @@ -28,11 +29,11 @@ extern crate serde_derive;

use std::{env, fmt, io, num::ParseIntError, process, sync};

use docopt::Docopt;
use ethkey::{
brain_recover, sign, verify_address, verify_public, Brain, BrainPrefix, Error as EthkeyError,
Generator, KeyPair, Prefix, Random,
use crypto::publickey::{
sign, verify_address, verify_public, Error as EthkeyError, Generator, KeyPair, Random,
};
use docopt::Docopt;
use ethkey::{brain_recover, Brain, BrainPrefix, Prefix};
use rustc_hex::{FromHex, FromHexError};

const USAGE: &'static str = r#"
Expand Down Expand Up @@ -202,15 +203,13 @@ where
let result = if args.flag_brain {
let phrase = args.arg_secret_or_phrase;
let phrase_info = validate_phrase(&phrase);
let keypair = Brain::new(phrase)
.generate()
.expect("Brain wallet generator is infallible; qed");
let keypair = Brain::new(phrase).generate();
(keypair, Some(phrase_info))
} else {
let secret = args
.arg_secret_or_phrase
.parse()
.map_err(|_| EthkeyError::InvalidSecret)?;
.map_err(|_| EthkeyError::InvalidSecretKey)?;
(KeyPair::from_secret(secret)?, None)
};
Ok(display(result, display_mode))
Expand All @@ -223,7 +222,7 @@ where
let phrase = format!("recovery phrase: {}", brain.phrase());
(keypair, Some(phrase))
} else {
(Random.generate()?, None)
(Random.generate(), None)
}
} else if args.cmd_prefix {
let prefix = args.arg_prefix.from_hex()?;
Expand Down Expand Up @@ -254,7 +253,7 @@ where
let secret = args
.arg_secret
.parse()
.map_err(|_| EthkeyError::InvalidSecret)?;
.map_err(|_| EthkeyError::InvalidSecretKey)?;
let message = args
.arg_message
.parse()
Expand All @@ -274,7 +273,7 @@ where
let public = args
.arg_public
.parse()
.map_err(|_| EthkeyError::InvalidPublic)?;
.map_err(|_| EthkeyError::InvalidPublicKey)?;
verify_public(&public, &signature, &message)?
} else if args.cmd_address {
let address = args
Expand All @@ -301,7 +300,7 @@ where
while let Some(phrase) = it.next() {
i += 1;

let keypair = Brain::new(phrase.clone()).generate().unwrap();
let keypair = Brain::new(phrase.clone()).generate();
if keypair.address() == address {
return Ok(Some((phrase, keypair)));
}
Expand Down
2 changes: 1 addition & 1 deletion bin/evmbin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ common-types = { path = "../../crates/ethcore/types", features = ["test-helpers"
docopt = "1.0"
env_logger = "0.5"
ethcore = { path = "../../crates/ethcore", features = ["test-helpers", "json-tests", "to-pod-full"] }
ethereum-types = "0.4"
ethereum-types = "0.9.2"
ethjson = { path = "../../crates/ethjson" }
evm = { path = "../../crates/vm/evm" }
panic_hook = { path = "../../crates/util/panic-hook" }
Expand Down
7 changes: 5 additions & 2 deletions bin/evmbin/src/display/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use super::config::Config;
use bytes::ToPretty;
use display;
use ethcore::trace;
use ethereum_types::{H256, U256};
use ethereum_types::{BigEndianHash, H256, U256};
use info as vm;

/// JSON formatting informant.
Expand Down Expand Up @@ -208,7 +208,10 @@ impl trace::VMTracer for Informant {
}

if let Some((pos, val)) = store_diff {
informant.storage.insert(pos.into(), val.into());
informant.storage.insert(
BigEndianHash::from_uint(&pos),
BigEndianHash::from_uint(&val),
);
}

if !informant.subtraces.is_empty() {
Expand Down
7 changes: 5 additions & 2 deletions bin/evmbin/src/display/std_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use super::config::Config;
use bytes::ToPretty;
use display;
use ethcore::{pod_state, trace};
use ethereum_types::{H256, U256};
use ethereum_types::{BigEndianHash, H256, U256};
use info as vm;

pub trait Writer: io::Write + Send + Sized {
Expand Down Expand Up @@ -237,7 +237,10 @@ impl<Trace: Writer, Out: Writer> trace::VMTracer for Informant<Trace, Out> {
let subdepth = self.subdepth;
Self::with_informant_in_depth(self, subdepth, |informant: &mut Informant<Trace, Out>| {
if let Some((pos, val)) = store_written {
informant.storage.insert(pos.into(), val.into());
informant.storage.insert(
BigEndianHash::from_uint(&pos),
BigEndianHash::from_uint(&val),
);
}
});
}
Expand Down
5 changes: 3 additions & 2 deletions bin/evmbin/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub fn run_action<T: Informant>(
Ok(r) => (Ok(r.return_data.to_vec()), Some(r.gas_left)),
Err(err) => (Err(err), None),
};
(result.0, 0.into(), None, result.1, informant.drain())
(result.0, H256::zero(), None, result.1, informant.drain())
},
)
}
Expand Down Expand Up @@ -262,6 +262,7 @@ where
#[cfg(test)]
pub mod tests {
use super::*;
use ethereum_types::Address;
use rustc_hex::FromHex;
use std::sync::Arc;
use tempdir::TempDir;
Expand Down Expand Up @@ -291,7 +292,7 @@ pub mod tests {

let (inf, res) = informant(Config::default());
let mut params = ActionParams::default();
params.code_address = 0x20.into();
params.code_address = Address::from_low_u64_be(0x20);
params.gas = 0xffff.into();

let spec = ::ethcore::ethereum::load(None, include_bytes!("../res/testchain.json"));
Expand Down
5 changes: 3 additions & 2 deletions bin/evmbin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ fn die<T: fmt::Display>(msg: T) -> ! {
mod tests {
use super::{Args, USAGE};
use docopt::Docopt;
use ethereum_types::Address;

fn run<T: AsRef<str>>(args: &[T]) -> Args {
Docopt::new(USAGE)
Expand Down Expand Up @@ -468,8 +469,8 @@ mod tests {
assert_eq!(args.flag_std_out_only, true);
assert_eq!(args.gas(), Ok(1.into()));
assert_eq!(args.gas_price(), Ok(2.into()));
assert_eq!(args.from(), Ok(3.into()));
assert_eq!(args.to(), Ok(4.into()));
assert_eq!(args.from(), Ok(Address::from_low_u64_be(3)));
assert_eq!(args.to(), Ok(Address::from_low_u64_be(4)));
assert_eq!(args.code(), Ok(Some(vec![05])));
assert_eq!(args.data(), Ok(Some(vec![06])));
assert_eq!(args.flag_chain, Some("./testfile".to_owned()));
Expand Down
15 changes: 10 additions & 5 deletions bin/oe/account_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

use std::sync::Arc;

use crypto::publickey;
use dir::Directories;
use ethereum_types::Address;
use ethereum_types::{Address, H160};
use ethkey::Password;

use params::{AccountsConfig, SpecType};
Expand Down Expand Up @@ -70,6 +71,7 @@ mod accounts {
#[cfg(feature = "accounts")]
mod accounts {
use super::*;
use std::str::FromStr;
use upgrade::upgrade_key_location;

pub use accounts::AccountProvider;
Expand Down Expand Up @@ -103,7 +105,8 @@ mod accounts {
| SpecType::Goerli
| SpecType::Sokol
| SpecType::Dev => vec![],
_ => vec!["00a329c0648769a73afac7f9381e08fb43dbea72".into()],
_ => vec![H160::from_str("00a329c0648769a73afac7f9381e08fb43dbea72")
.expect("the string is valid hex; qed")],
},
};

Expand Down Expand Up @@ -216,9 +219,11 @@ mod accounts {
}

fn insert_dev_account(account_provider: &AccountProvider) {
let secret: ethkey::Secret =
"4d5db4107d237df6a3d58ee5f70ae63d73d7658d4026f2eefd2f204c81682cb7".into();
let dev_account = ethkey::KeyPair::from_secret(secret.clone())
let secret = publickey::Secret::from_str(
"4d5db4107d237df6a3d58ee5f70ae63d73d7658d4026f2eefd2f204c81682cb7",
)
.expect("Valid account;qed");
let dev_account = publickey::KeyPair::from_secret(secret.clone())
.expect("Valid secret produces valid key;qed");
if !account_provider.has_account(dev_account.address()) {
match account_provider.insert_account(secret, &Password::from(String::new())) {
Expand Down
4 changes: 2 additions & 2 deletions bin/oe/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
use ansi_term::Colour;
use bytes::Bytes;
use cli::{Args, ArgsError};
use crypto::publickey::{Public, Secret};
use ethcore::{
client::VMType,
miner::{stratum, MinerOptions},
snapshot::SnapshotConfiguration,
verification::queue::VerifierSettings,
};
use ethereum_types::{Address, H256, U256};
use ethkey::{Public, Secret};
use hash::keccak;
use metrics::MetricsConfiguration;
use miner::pool;
Expand Down Expand Up @@ -810,7 +810,7 @@ impl Configuration {
ret.public_address = public.map(|p| format!("{}", p));
ret.use_secret = match self.args.arg_node_key.as_ref().map(|s| {
s.parse::<Secret>()
.or_else(|_| Secret::from_unsafe_slice(&keccak(s)))
.or_else(|_| Secret::import_key(keccak(s).as_bytes()))
.map_err(|e| format!("Invalid key: {:?}", e))
}) {
None => None,
Expand Down
10 changes: 9 additions & 1 deletion bin/oe/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use ethcore::{
client::{BlockId, ClientConfig, DatabaseCompactionProfile, Mode, VMType, VerifierType},
miner::{Penalization, PendingSet},
};
use ethereum_types::{clean_0x, Address, U256};
use ethereum_types::{Address, U256};
use ethkey::Password;
use journaldb::Algorithm;
use miner::pool::PrioritizationStrategy;
Expand All @@ -39,6 +39,14 @@ pub fn to_duration(s: &str) -> Result<Duration, String> {
to_seconds(s).map(Duration::from_secs)
}

fn clean_0x(s: &str) -> &str {
if s.starts_with("0x") {
&s[2..]
} else {
s
}
}

fn to_seconds(s: &str) -> Result<u64, String> {
let bad = |_| {
format!(
Expand Down
1 change: 1 addition & 0 deletions bin/oe/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ extern crate keccak_hash as hash;
extern crate kvdb;
extern crate node_filter;
extern crate parity_bytes as bytes;
extern crate parity_crypto as crypto;
extern crate parity_local_store as local_store;
extern crate parity_path as path;
extern crate parity_rpc;
Expand Down
5 changes: 3 additions & 2 deletions bin/oe/presale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.

use crypto::publickey;
use ethkey::Password;
use ethstore::PresaleWallet;
use helpers::{password_from_file, password_prompt};
Expand Down Expand Up @@ -44,7 +45,7 @@ pub fn execute(cmd: ImportWallet) -> Result<String, String> {
}

#[cfg(feature = "accounts")]
pub fn import_account(cmd: &ImportWallet, kp: ethkey::KeyPair, password: Password) {
pub fn import_account(cmd: &ImportWallet, kp: publickey::KeyPair, password: Password) {
use accounts::{AccountProvider, AccountProviderSettings};
use ethstore::{accounts_dir::RootDiskDirectory, EthStore};

Expand All @@ -57,4 +58,4 @@ pub fn import_account(cmd: &ImportWallet, kp: ethkey::KeyPair, password: Passwor
}

#[cfg(not(feature = "accounts"))]
pub fn import_account(_cmd: &ImportWallet, _kp: ethkey::KeyPair, _password: Password) {}
pub fn import_account(_cmd: &ImportWallet, _kp: publickey::KeyPair, _password: Password) {}
6 changes: 5 additions & 1 deletion bin/oe/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use std::{
any::Any,
str::FromStr,
sync::{atomic, Arc, Weak},
thread,
time::{Duration, Instant},
Expand Down Expand Up @@ -606,7 +607,10 @@ pub fn execute(cmd: RunCmd, logger: Arc<RotatingLogger>) -> Result<RunningClient
fn verification_bad_blocks(spec: &SpecType) -> Vec<H256> {
match *spec {
SpecType::Ropsten => {
vec!["1eac3d16c642411f13c287e29144c6f58fda859407c8f24c38deb168e1040714".into()]
vec![
H256::from_str("1eac3d16c642411f13c287e29144c6f58fda859407c8f24c38deb168e1040714")
.expect("Valid hex string"),
]
}
_ => vec![],
}
Expand Down
3 changes: 2 additions & 1 deletion bin/oe/secretstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.

use account_utils::AccountProvider;
use crypto::publickey::{Public, Secret};
use dir::{default_data_path, helpers::replace_home};
use ethcore::{client::Client, miner::Miner};
use ethereum_types::Address;
use ethkey::{Password, Public, Secret};
use ethkey::Password;
use parity_runtime::Executor;
use std::{collections::BTreeMap, sync::Arc};
use sync::SyncProvider;
Expand Down
3 changes: 2 additions & 1 deletion crates/accounts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ common-types = { path = "../ethcore/types" }
ethkey = { path = "ethkey" }
ethstore = { path = "ethstore" }
log = "0.4"
parity-crypto = { version = "0.6.2", features = [ "publickey" ] }
parking_lot = "0.7"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"

[dev-dependencies]
ethereum-types = "0.4"
ethereum-types = "0.9.2"
tempdir = "0.3"
Loading

0 comments on commit a0f406e

Please sign in to comment.