[dependencies]: unify rustc-hex (#11506)

* [dependency]: unify `rustc-hex`

* [private tx]: fix upgrade to `rustc hex 2.1.0`
This commit is contained in:
Niklas Adolfsson
2020-02-21 15:10:00 +01:00
committed by GitHub
parent bec867be03
commit 2018f5b0ab
52 changed files with 355 additions and 357 deletions

View File

@@ -30,6 +30,6 @@ triehash-ethereum = { version = "0.2", path = "../../util/triehash-ethereum" }
[dev-dependencies]
env_logger = "0.5"
parity-crypto = { version = "0.5.0", features = ["publickey"] }
rustc-hex = "1.0"
rustc-hex = "2.1.0"
tempdir = "0.3"
kvdb-memorydb = "0.4.0"

View File

@@ -36,9 +36,9 @@ call-contract = { package = "ethcore-call-contract", path = "../../call-contract
engine = { path = "../../engine", features = ["test-helpers"] }
env_logger = "0.6.2"
ethcore = { path = "../..", features = ["test-helpers"] }
parity-crypto = { version = "0.5.0", features = ["publickey"] }
rustc-hex = "2.1.0"
keccak-hash = "0.4.0"
rustc-hex = "1.0"
parity-crypto = { version = "0.5.0", features = ["publickey"] }
spec = { path = "../../spec" }
[features]

View File

@@ -17,9 +17,8 @@ parking_lot = "0.10.0"
memory-cache = { path = "../../util/memory-cache" }
[dev-dependencies]
rustc-hex = "1.0"
criterion = "0.3"
hex-literal = "0.2.0"
hex-literal = "0.2.1"
[features]
evm-debug = []

View File

@@ -18,26 +18,29 @@
#[macro_use]
extern crate criterion;
#[macro_use]
extern crate hex_literal;
extern crate bit_set;
extern crate ethereum_types;
extern crate parking_lot;
extern crate parity_util_mem as mem;
extern crate vm;
extern crate evm;
extern crate keccak_hash as hash;
extern crate memory_cache;
extern crate parity_bytes as bytes;
extern crate rustc_hex;
extern crate parity_util_mem as mem;
extern crate parking_lot;
extern crate vm;
use criterion::{Criterion, Bencher, black_box};
use std::str::FromStr;
use std::sync::Arc;
use criterion::{Criterion, Bencher, black_box};
use bytes::Bytes;
use ethereum_types::{U256, Address};
use vm::{ActionParams, Result, GasLeft, Ext};
use vm::tests::FakeExt;
use evm::Factory;
use rustc_hex::FromHex;
criterion_group!(
basic,
@@ -91,9 +94,7 @@ fn simple_loop_log0(gas: U256, b: &mut Bencher) {
let mut ext = FakeExt::new();
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
let code = black_box(
"62ffffff5b600190036000600fa0600357".from_hex().unwrap()
);
let code = black_box(hex!("62ffffff5b600190036000600fa0600357").to_vec());
b.iter(|| {
let mut params = ActionParams::default();
@@ -109,7 +110,7 @@ fn simple_loop_log0(gas: U256, b: &mut Bencher) {
fn mem_gas_calculation_same_usize(b: &mut Criterion) {
b.bench_function("mem_gas_calculation_same_usize", |b| {
mem_gas_calculation_same(U256::from(::std::usize::MAX), b);
mem_gas_calculation_same(U256::from(std::usize::MAX), b);
});
}
@@ -127,7 +128,7 @@ fn mem_gas_calculation_same(gas: U256, b: &mut Bencher) {
b.iter(|| {
let code = black_box(
"6110006001556001546000555b610fff805560016000540380600055600c57".from_hex().unwrap()
hex!("6110006001556001546000555b610fff805560016000540380600055600c57").to_vec()
);
let mut params = ActionParams::default();
@@ -143,7 +144,7 @@ fn mem_gas_calculation_same(gas: U256, b: &mut Bencher) {
fn mem_gas_calculation_increasing_usize(b: &mut Criterion) {
b.bench_function("mem_gas_calculation_increasing_usize", |b| {
mem_gas_calculation_increasing(U256::from(::std::usize::MAX), b);
mem_gas_calculation_increasing(U256::from(std::usize::MAX), b);
});
}
@@ -161,7 +162,7 @@ fn mem_gas_calculation_increasing(gas: U256, b: &mut Bencher) {
b.iter(|| {
let code = black_box(
"6110006001556001546000555b610fff60005401805560016000540380600055600c57".from_hex().unwrap()
hex!("6110006001556001546000555b610fff60005401805560016000540380600055600c57").to_vec()
);
let mut params = ActionParams::default();
@@ -184,7 +185,7 @@ fn blockhash_mulmod_small(b: &mut Criterion) {
b.iter(|| {
let code = black_box(
"6080604052348015600f57600080fd5b5060005a90505b60c881111560de5760017effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095060017effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095060017effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095060017effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095060017effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8009505a90506016565b506035806100ed6000396000f3fe6080604052600080fdfea165627a7a72305820bde4a0ac6d0fac28fc879244baf8a6a0eda514bc95fb7ecbcaaebf2556e2687c0029".from_hex().unwrap()
hex!("6080604052348015600f57600080fd5b5060005a90505b60c881111560de5760017effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095060017effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095060017effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095060017effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095060017effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8009505a90506016565b506035806100ed6000396000f3fe6080604052600080fdfea165627a7a72305820bde4a0ac6d0fac28fc879244baf8a6a0eda514bc95fb7ecbcaaebf2556e2687c0029").to_vec()
);
let mut params = ActionParams::default();
@@ -208,7 +209,7 @@ fn blockhash_mulmod_large(b: &mut Criterion) {
b.iter(|| {
let code = black_box(
"608060405234801561001057600080fd5b5060005a90505b60c8811115610177577efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff17efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff08009507efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff17efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff08009507efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff17efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff08009507efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff17efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff08009507efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff17efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff08009505a9050610017565b506035806101866000396000f3fe6080604052600080fdfea165627a7a72305820dcaec306f67bb96f3044fff25c9af2ec66f01d0954d0656964f046f42f2780670029".from_hex().unwrap()
hex!("608060405234801561001057600080fd5b5060005a90505b60c8811115610177577efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff17efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff08009507efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff17efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff08009507efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff17efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff08009507efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff17efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff08009507efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff17efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff08009505a9050610017565b506035806101866000396000f3fe6080604052600080fdfea165627a7a72305820dcaec306f67bb96f3044fff25c9af2ec66f01d0954d0656964f046f42f2780670029").to_vec()
);
let mut params = ActionParams::default();
@@ -248,56 +249,56 @@ fn run_code(b: &mut Bencher, code: Bytes) {
/// Compute mulmod(U256::MAX, U256::MAX, 1) 500 times.
fn mulmod1_500(b: &mut Criterion) {
b.bench_function("mulmod modulo 1, 500 times", |b| {
run_code(b, "6101f45b6001900360017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095080600357".from_hex().unwrap());
run_code(b, hex!("6101f45b6001900360017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095080600357").to_vec());
});
}
/// Compute mulmod(U256::MAX, U256::MAX, 1) 1000 times.
fn mulmod1_1000(b: &mut Criterion) {
b.bench_function("mulmod modulo 1, 1000 times", |b| {
run_code(b, "6103e85b6001900360017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095080600357".from_hex().unwrap());
run_code(b, hex!("6103e85b6001900360017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095080600357").to_vec());
});
}
/// Compute mulmod(U256::MAX, U256::MAX, 5) 500 times.
fn mulmod5_500(b: &mut Criterion) {
b.bench_function("mulmod modulo 5, 500 times", |b| {
run_code(b, "6101f45b6001900360057fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095080600357".from_hex().unwrap());
run_code(b, hex!("6101f45b6001900360057fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095080600357").to_vec());
});
}
/// Compute mulmod(U256::MAX, U256::MAX, 5) 1000 times.
fn mulmod5_1000(b: &mut Criterion) {
b.bench_function("mulmod modulo 5, 1000 times", |b| {
run_code(b, "6103e85b6001900360057fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095080600357".from_hex().unwrap());
run_code(b, hex!("6103e85b6001900360057fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095080600357").to_vec());
});
}
/// Compute mulmod(U256::MAX, U256::MAX, 11) 500 times.
fn mulmod11_500(b: &mut Criterion) {
b.bench_function("mulmod modulo 11, 500 times", |b| {
run_code(b, "6101f45b60019003600b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095080600357".from_hex().unwrap());
run_code(b, hex!("6101f45b60019003600b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095080600357").to_vec());
});
}
/// Compute mulmod(U256::MAX, U256::MAX, 11) 1000 times.
fn mulmod11_1000(b: &mut Criterion) {
b.bench_function("mulmod modulo 11, 1000 times", |b| {
run_code(b, "6103e85b60019003600b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095080600357".from_hex().unwrap());
run_code(b, hex!("6103e85b60019003600b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095080600357").to_vec());
});
}
/// Compute mulmod(U256::MAX, U256::MAX, 0x58bca9711298bc76cd73f173352c8bc1d1640f977c1ec9a849dfde6fdbfbd591) 500 times.
fn mulmod_big_500(b: &mut Criterion) {
b.bench_function("mulmod modulo random 256-bit number, 500 times", |b| {
run_code(b, "6101f45b600190037f58bca9711298bc76cd73f173352c8bc1d1640f977c1ec9a849dfde6fdbfbd5917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095080600357".from_hex().unwrap());
run_code(b, hex!("6101f45b600190037f58bca9711298bc76cd73f173352c8bc1d1640f977c1ec9a849dfde6fdbfbd5917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095080600357").to_vec());
});
}
/// Compute mulmod(U256::MAX, U256::MAX, 0x58bca9711298bc76cd73f173352c8bc1d1640f977c1ec9a849dfde6fdbfbd591) 1000 times.
fn mulmod_big_1000(b: &mut Criterion) {
b.bench_function("mulmod modulo random 256-bit number, 1000 times", |b| {
run_code(b, "6103e85b600190037f58bca9711298bc76cd73f173352c8bc1d1640f977c1ec9a849dfde6fdbfbd5917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095080600357".from_hex().unwrap());
run_code(b, hex!("6103e85b600190037f58bca9711298bc76cd73f173352c8bc1d1640f977c1ec9a849dfde6fdbfbd5917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80095080600357").to_vec());
});
}
@@ -321,97 +322,97 @@ fn mulmod_big_1000(b: &mut Criterion) {
/// ```
fn mulmod500(b: &mut Criterion) {
b.bench_function("mulmod randomly generated ints, 500 times", |b| {
run_code(b, "6101f45b600190037f5ed6db9489224124a1a4110ec8bec8b01369c8b549a4b8c4388a1796dc35a9377fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca095080600357".from_hex().unwrap());
run_code(b, hex!("6101f45b600190037f5ed6db9489224124a1a4110ec8bec8b01369c8b549a4b8c4388a1796dc35a9377fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca095080600357").to_vec());
});
}
/// Compute mulmod(a, b, c) for random 256-bit a, b and c. Iterate 1000 times.
fn mulmod1000(b: &mut Criterion) {
b.bench_function("mulmod randomly generated ints, 1000 times", |b| {
run_code(b, "6103e85b600190037f5ed6db9489224124a1a4110ec8bec8b01369c8b549a4b8c4388a1796dc35a9377fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca095080600357".from_hex().unwrap());
run_code(b, hex!("6103e85b600190037f5ed6db9489224124a1a4110ec8bec8b01369c8b549a4b8c4388a1796dc35a9377fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca095080600357").to_vec());
});
}
/// Compute addmod(a, b, c) for random 256-bit a, b and c. Iterate 500 times.
fn addmod500(b: &mut Criterion) {
b.bench_function("addmod randomly generated ints, 500 times", |b| {
run_code(b, "6101f45b600190037f5ed6db9489224124a1a4110ec8bec8b01369c8b549a4b8c4388a1796dc35a9377fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca085080600357".from_hex().unwrap());
run_code(b, hex!("6101f45b600190037f5ed6db9489224124a1a4110ec8bec8b01369c8b549a4b8c4388a1796dc35a9377fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca085080600357").to_vec());
});
}
/// Compute addmod(a, b, c) for random 256-bit a, b and c. Iterate 1000 times.
fn addmod1000(b: &mut Criterion) {
b.bench_function("addmod randomly generated ints, 1000 times", |b| {
run_code(b, "6103e85b600190037f5ed6db9489224124a1a4110ec8bec8b01369c8b549a4b8c4388a1796dc35a9377fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca085080600357".from_hex().unwrap());
run_code(b, hex!("6103e85b600190037f5ed6db9489224124a1a4110ec8bec8b01369c8b549a4b8c4388a1796dc35a9377fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca085080600357").to_vec());
});
}
/// Compute mul(a, b) for random 256-bit a and b. Iterate 500 times.
fn mul500(b: &mut Criterion) {
b.bench_function("mul randomly generated ints, 500 times", |b| {
run_code(b, "6101f45b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca025080600357".from_hex().unwrap());
run_code(b, hex!("6101f45b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca025080600357").to_vec());
});
}
/// Compute mul(a, b) for random 256-bit a and b. Iterate 1000 times.
fn mul1000(b: &mut Criterion) {
b.bench_function("mul randomly generated ints, 1000 times", |b| {
run_code(b, "6103e85b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca025080600357".from_hex().unwrap());
run_code(b, hex!("6103e85b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca025080600357").to_vec());
});
}
/// Compute div(a, b) for random 256-bit a and b. Iterate 500 times.
fn div500(b: &mut Criterion) {
b.bench_function("div randomly generated ints, 500 times", |b| {
run_code(b, "6101f45b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca045080600357".from_hex().unwrap());
run_code(b, hex!("6101f45b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca045080600357").to_vec());
});
}
/// Compute div(a, b) for random 256-bit a and b. Iterate 1000 times.
fn div1000(b: &mut Criterion) {
b.bench_function("div randomly generated ints, 1000 times", |b| {
run_code(b, "6103e85b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca045080600357".from_hex().unwrap());
run_code(b, hex!("6103e85b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca045080600357").to_vec());
});
}
/// Compute sdiv(a, b) for random 256-bit a and b. Iterate 500 times.
fn sdiv500(b: &mut Criterion) {
b.bench_function("sdiv randomly generated ints, 500 times", |b| {
run_code(b, "6101f45b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca055080600357".from_hex().unwrap());
run_code(b, hex!("6101f45b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca055080600357").to_vec());
});
}
/// Compute sdiv(a, b) for random 256-bit a and b. Iterate 1000 times.
fn sdiv1000(b: &mut Criterion) {
b.bench_function("sdiv randomly generated ints, 1000 times", |b| {
run_code(b, "6103e85b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca055080600357".from_hex().unwrap());
run_code(b, hex!("6103e85b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca055080600357").to_vec());
});
}
/// Compute mod(a, b) for random 256-bit a and b. Iterate 500 times.
fn mod500(b: &mut Criterion) {
b.bench_function("mod randomly generated ints, 500 times", |b| {
run_code(b, "6101f45b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca065080600357".from_hex().unwrap());
run_code(b, hex!("6101f45b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca065080600357").to_vec());
});
}
/// Compute mod(a, b) for random 256-bit a and b. Iterate 1000 times.
fn mod1000(b: &mut Criterion) {
b.bench_function("mod randomly generated ints, 1000 times", |b| {
run_code(b, "6103e85b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca065080600357".from_hex().unwrap());
run_code(b, hex!("6103e85b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca065080600357").to_vec());
});
}
/// Compute smod(a, b) for random 256-bit a and b. Iterate 500 times.
fn smod500(b: &mut Criterion) {
b.bench_function("smod randomly generated ints, 500 times", |b| {
run_code(b, "6101f45b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca075080600357".from_hex().unwrap());
run_code(b, hex!("6101f45b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca075080600357").to_vec());
});
}
/// Compute smod(a, b) for random 256-bit a and b. Iterate 1000 times.
fn smod1000(b: &mut Criterion) {
b.bench_function("smod randomly generated ints, 1000 times", |b| {
run_code(b, "6103e85b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca075080600357".from_hex().unwrap());
run_code(b, hex!("6103e85b600190037fb8e0a2b6b1587398c28bf9e9d34ea24ba34df308eec2acedca363b2fce2c25db7fcc2de1f8ec6cc9a24ed2c48b856637f9e45f0a5feee21a196aa42a290ef454ca075080600357").to_vec());
});
}

View File

@@ -31,7 +31,6 @@ use hash::keccak;
use bytes::Bytes;
use ethereum_types::{U256, U512, H256, Address, BigEndianHash};
use vm::{
self, ActionParams, ParamsType, ActionValue, ActionType, MessageCallResult,
ContractCreateResult, CreateContractAddress, ReturnData, GasLeft, Schedule,
@@ -556,11 +555,11 @@ impl<Cost: CostType> Interpreter<Cost> {
let contract_code = self.mem.read_slice(init_off, init_size);
let create_result = ext.create(
&create_gas.as_u256(),
&endowment,
contract_code,
&self.params.code_version,
address_scheme,
&create_gas.as_u256(),
&endowment,
contract_code,
&self.params.code_version,
address_scheme,
true,
);
return match create_result {
@@ -1221,7 +1220,6 @@ fn address_to_u256(value: Address) -> U256 {
#[cfg(test)]
mod tests {
use std::sync::Arc;
use rustc_hex::FromHex;
use factory::Factory;
use vm::{self, Exec, ActionParams, ActionValue};
use vm::tests::{FakeExt, test_finalize};
@@ -1233,7 +1231,7 @@ mod tests {
#[test]
fn should_not_fail_on_tracing_mem() {
let code = "7feeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff006000527faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020526000620f120660406000601773945304eb96065b2a98b57a48a06ae28d285a71b56101f4f1600055".from_hex().unwrap();
let code = hex!("7feeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff006000527faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020526000620f120660406000601773945304eb96065b2a98b57a48a06ae28d285a71b56101f4f1600055").to_vec();
let mut params = ActionParams::default();
params.address = Address::from_low_u64_be(5);
@@ -1256,7 +1254,7 @@ mod tests {
#[test]
fn should_not_overflow_returndata() {
let code = "6001600160000360003e00".from_hex().unwrap();
let code = hex!("6001600160000360003e00").to_vec();
let mut params = ActionParams::default();
params.address = Address::from_low_u64_be(5);

View File

@@ -101,9 +101,8 @@ impl Default for SharedCache {
#[test]
fn test_find_jump_destinations() {
use rustc_hex::FromHex;
// given
let code = "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5b01600055".from_hex().unwrap();
let code = hex!("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5b01600055");
// when
let valid_jump_destinations = SharedCache::find_jump_destinations(&code);

View File

@@ -32,8 +32,7 @@ extern crate lazy_static;
extern crate log;
#[cfg(test)]
extern crate rustc_hex;
#[cfg(test)]
#[macro_use]
extern crate hex_literal;
pub mod evm;

View File

@@ -28,7 +28,7 @@ parity-crypto = { version = "0.5.0", features = ["publickey"] }
evm = { path = "../evm" }
keccak-hash = "0.4.0"
pod = { path = "../pod" }
rustc-hex = "1.0"
hex-literal = "0.2.1"
spec = { path = "../spec" }
trie-db = "0.20.0"
ethtrie = { package = "patricia-trie-ethereum", path = "../../util/patricia-trie-ethereum" }

View File

@@ -266,17 +266,13 @@ mod tests {
use account_state::{Account, CleanupMode};
use common_types::transaction::*;
use ethereum_types::{H256, U256, Address, BigEndianHash};
use ethcore::test_helpers::{get_temp_state, get_temp_state_db};
use hex_literal::hex;
use keccak_hash::{keccak, KECCAK_NULL_RLP};
use parity_crypto::publickey::Secret;
use ethereum_types::{H256, U256, Address, BigEndianHash};
use ethcore::{
test_helpers::{get_temp_state, get_temp_state_db}
};
use ethtrie;
use machine::Machine;
use pod::{self, PodAccount, PodState};
use rustc_hex::FromHex;
use spec;
use pod::{PodAccount, PodState};
use ::trace::{FlatTrace, TraceError, trace};
use trie_db::{TrieFactory, TrieSpec};
use vm::EnvInfo;
@@ -307,7 +303,7 @@ mod tests {
gas: 100_000.into(),
action: Action::Create,
value: 100.into(),
data: FromHex::from_hex("601080600c6000396000f3006000355415600957005b60203560003555").unwrap(),
data: hex!("601080600c6000396000f3006000355415600957005b60203560003555").to_vec(),
}.sign(&secret(), None);
state.add_balance(&t.sender(), &(100.into()), CleanupMode::NoEmpty).unwrap();
@@ -366,7 +362,7 @@ mod tests {
gas: 100_000.into(),
action: Action::Create,
value: 100.into(),
data: FromHex::from_hex("5b600056").unwrap(),
data: hex!("5b600056").to_vec(),
}.sign(&secret(), None);
state.add_balance(&t.sender(), &(100.into()), CleanupMode::NoEmpty).unwrap();
@@ -406,7 +402,7 @@ mod tests {
data: vec![],
}.sign(&secret(), None);
state.init_code(&Address::from_low_u64_be(0xa), FromHex::from_hex("6000").unwrap()).unwrap();
state.init_code(&Address::from_low_u64_be(0xa), hex!("6000").to_vec()).unwrap();
state.add_balance(&t.sender(), &(100.into()), CleanupMode::NoEmpty).unwrap();
let result = state.apply(&info, &machine, &t, true).unwrap();
let expected_trace = vec![FlatTrace {
@@ -530,7 +526,7 @@ mod tests {
data: vec![],
}.sign(&secret(), None);
state.init_code(&Address::from_low_u64_be(0xa), FromHex::from_hex("600060006000600060006001610be0f1").unwrap()).unwrap();
state.init_code(&Address::from_low_u64_be(0xa), hex!("600060006000600060006001610be0f1").to_vec()).unwrap();
let result = state.apply(&info, &machine, &t, true).unwrap();
let expected_trace = vec![FlatTrace {
@@ -572,8 +568,8 @@ mod tests {
data: vec![],
}.sign(&secret(), None);
state.init_code(&Address::from_low_u64_be(0xa), FromHex::from_hex("60006000600060006000600b611000f2").unwrap()).unwrap();
state.init_code(&Address::from_low_u64_be(0xb), FromHex::from_hex("6000").unwrap()).unwrap();
state.init_code(&Address::from_low_u64_be(0xa), hex!("60006000600060006000600b611000f2").to_vec()).unwrap();
state.init_code(&Address::from_low_u64_be(0xb), hex!("6000").to_vec()).unwrap();
let result = state.apply(&info, &machine, &t, true).unwrap();
let expected_trace = vec![FlatTrace {
@@ -631,8 +627,8 @@ mod tests {
data: vec![],
}.sign(&secret(), None);
state.init_code(&Address::from_low_u64_be(0xa), FromHex::from_hex("6000600060006000600b618000f4").unwrap()).unwrap();
state.init_code(&Address::from_low_u64_be(0xb), FromHex::from_hex("60056000526001601ff3").unwrap()).unwrap();
state.init_code(&Address::from_low_u64_be(0xa), hex!("6000600060006000600b618000f4").to_vec()).unwrap();
state.init_code(&Address::from_low_u64_be(0xb), hex!("60056000526001601ff3").to_vec()).unwrap();
let result = state.apply(&info, &machine, &t, true).unwrap();
let expected_trace = vec![FlatTrace {
@@ -689,7 +685,7 @@ mod tests {
data: vec![],
}.sign(&secret(), None);
state.init_code(&Address::from_low_u64_be(0xa), FromHex::from_hex("5b600056").unwrap()).unwrap();
state.init_code(&Address::from_low_u64_be(0xa), hex!("5b600056").to_vec()).unwrap();
state.add_balance(&t.sender(), &(100.into()), CleanupMode::NoEmpty).unwrap();
let result = state.apply(&info, &machine, &t, true).unwrap();
let expected_trace = vec![FlatTrace {
@@ -728,8 +724,8 @@ mod tests {
data: vec![],
}.sign(&secret(), None);
state.init_code(&Address::from_low_u64_be(0xa), FromHex::from_hex("60006000600060006000600b602b5a03f1").unwrap()).unwrap();
state.init_code(&Address::from_low_u64_be(0xb), FromHex::from_hex("6000").unwrap()).unwrap();
state.init_code(&Address::from_low_u64_be(0xa), hex!("60006000600060006000600b602b5a03f1").to_vec()).unwrap();
state.init_code(&Address::from_low_u64_be(0xb), hex!("6000").to_vec()).unwrap();
state.add_balance(&t.sender(), &(100.into()), CleanupMode::NoEmpty).unwrap();
let result = state.apply(&info, &machine, &t, true).unwrap();
@@ -787,7 +783,7 @@ mod tests {
data: vec![],
}.sign(&secret(), None);
state.init_code(&Address::from_low_u64_be(0xa), FromHex::from_hex("60006000600060006045600b6000f1").unwrap()).unwrap();
state.init_code(&Address::from_low_u64_be(0xa), hex!("60006000600060006045600b6000f1").to_vec()).unwrap();
state.add_balance(&t.sender(), &(100.into()), CleanupMode::NoEmpty).unwrap();
let result = state.apply(&info, &machine, &t, true).unwrap();
let expected_trace = vec![FlatTrace {
@@ -841,7 +837,7 @@ mod tests {
data: vec![],
}.sign(&secret(), None);
state.init_code(&Address::from_low_u64_be(0xa), FromHex::from_hex("600060006000600060ff600b6000f1").unwrap()).unwrap(); // not enough funds.
state.init_code(&Address::from_low_u64_be(0xa), hex!("600060006000600060ff600b6000f1").to_vec()).unwrap(); // not enough funds.
state.add_balance(&t.sender(), &(100.into()), CleanupMode::NoEmpty).unwrap();
let result = state.apply(&info, &machine, &t, true).unwrap();
let expected_trace = vec![FlatTrace {
@@ -883,8 +879,8 @@ mod tests {
data: vec![],//600480600b6000396000f35b600056
}.sign(&secret(), None);
state.init_code(&Address::from_low_u64_be(0xa), FromHex::from_hex("60006000600060006000600b602b5a03f1").unwrap()).unwrap();
state.init_code(&Address::from_low_u64_be(0xb), FromHex::from_hex("5b600056").unwrap()).unwrap();
state.init_code(&Address::from_low_u64_be(0xa), hex!("60006000600060006000600b602b5a03f1").to_vec()).unwrap();
state.init_code(&Address::from_low_u64_be(0xb), hex!("5b600056").to_vec()).unwrap();
state.add_balance(&t.sender(), &(100.into()), CleanupMode::NoEmpty).unwrap();
let result = state.apply(&info, &machine, &t, true).unwrap();
let expected_trace = vec![FlatTrace {
@@ -938,9 +934,9 @@ mod tests {
data: vec![],
}.sign(&secret(), None);
state.init_code(&Address::from_low_u64_be(0xa), FromHex::from_hex("60006000600060006000600b602b5a03f1").unwrap()).unwrap();
state.init_code(&Address::from_low_u64_be(0xb), FromHex::from_hex("60006000600060006000600c602b5a03f1").unwrap()).unwrap();
state.init_code(&Address::from_low_u64_be(0xc), FromHex::from_hex("6000").unwrap()).unwrap();
state.init_code(&Address::from_low_u64_be(0xa), hex!("60006000600060006000600b602b5a03f1").to_vec()).unwrap();
state.init_code(&Address::from_low_u64_be(0xb), hex!("60006000600060006000600c602b5a03f1").to_vec()).unwrap();
state.init_code(&Address::from_low_u64_be(0xc), hex!("6000").to_vec()).unwrap();
state.add_balance(&t.sender(), &(100.into()), CleanupMode::NoEmpty).unwrap();
let result = state.apply(&info, &machine, &t, true).unwrap();
let expected_trace = vec![FlatTrace {
@@ -1012,9 +1008,9 @@ mod tests {
data: vec![],//600480600b6000396000f35b600056
}.sign(&secret(), None);
state.init_code(&Address::from_low_u64_be(0xa), FromHex::from_hex("60006000600060006000600b602b5a03f1").unwrap()).unwrap();
state.init_code(&Address::from_low_u64_be(0xb), FromHex::from_hex("60006000600060006000600c602b5a03f1505b601256").unwrap()).unwrap();
state.init_code(&Address::from_low_u64_be(0xc), FromHex::from_hex("6000").unwrap()).unwrap();
state.init_code(&Address::from_low_u64_be(0xa), hex!("60006000600060006000600b602b5a03f1").to_vec()).unwrap();
state.init_code(&Address::from_low_u64_be(0xb), hex!("60006000600060006000600c602b5a03f1505b601256").to_vec()).unwrap();
state.init_code(&Address::from_low_u64_be(0xc), hex!("6000").to_vec()).unwrap();
state.add_balance(&t.sender(), &(100.into()), CleanupMode::NoEmpty).unwrap();
let result = state.apply(&info, &machine, &t, true).unwrap();
@@ -1084,7 +1080,7 @@ mod tests {
data: vec![],
}.sign(&secret(), None);
state.init_code(&Address::from_low_u64_be(0xa), FromHex::from_hex("73000000000000000000000000000000000000000bff").unwrap()).unwrap();
state.init_code(&Address::from_low_u64_be(0xa), hex!("73000000000000000000000000000000000000000bff").to_vec()).unwrap();
state.add_balance(&Address::from_low_u64_be(0xa), &50.into(), CleanupMode::NoEmpty).unwrap();
state.add_balance(&t.sender(), &100.into(), CleanupMode::NoEmpty).unwrap();
let result = state.apply(&info, &machine, &t, true).unwrap();

View File

@@ -44,7 +44,7 @@ ethcore = { path = "../", features = ["test-helpers"] }
ethcore-io = { path = "../../util/io" }
ethjson = { path = "../../json" }
parity-crypto = { version = "0.5.0", features = ["publickey"] }
rustc-hex = "1.0"
hex-literal = "0.2.1"
spec = { path = "../spec" }
tempdir = "0.3"
trace = { path = "../trace" }

View File

@@ -1223,16 +1223,15 @@ mod tests {
collections::HashSet,
};
use rustc_hex::FromHex;
use ethereum_types::{H256, U256, U512, Address, BigEndianHash};
use account_state::CleanupMode;
use common_types::{
errors::ExecutionError,
transaction::{Action, Transaction},
};
use parity_crypto::publickey::{Generator, Random};
use ethereum_types::{H256, U256, U512, Address, BigEndianHash};
use evm::{Factory, evm_test, evm_test_ignore};
use hex_literal::hex;
use parity_crypto::publickey::{Generator, Random};
use vm::{ActionParams, ActionValue, EnvInfo, CreateContractAddress};
use ::trace::{
trace,
@@ -1309,7 +1308,7 @@ mod tests {
params.address = address.clone();
params.sender = sender.clone();
params.gas = U256::from(100_000);
params.code = Some(Arc::new("3331600055".from_hex().unwrap()));
params.code = Some(Arc::new(hex!("3331600055").to_vec()));
params.value = ActionValue::Transfer(U256::from(0x7));
let mut state = get_temp_state_with_factory(factory);
state.add_balance(&sender, &U256::from(0x100u64), CleanupMode::NoEmpty).unwrap();
@@ -1356,7 +1355,8 @@ mod tests {
// 60 00 - push 0
// f3 - return
let code = "7c601080600c6000396000f3006000355415600957005b60203560003555600052601d60036017f0600055".from_hex().unwrap();
let code =
hex!("7c601080600c6000396000f3006000355415600957005b60203560003555600052601d60036017f0600055").to_vec();
let sender = Address::from_str("cd1722f3947def4cf144679da39c4c32bdc35681").unwrap();
let address = contract_address(CreateContractAddress::FromSenderAndNonce, &sender, &U256::zero(), &[]).0;
@@ -1399,7 +1399,7 @@ mod tests {
// 61 ffff - push fff gas
// f1 - CALL
let code = "60006000600060006001600361fffff1".from_hex().unwrap();
let code = hex!("60006000600060006001600361fffff1").to_vec();
let sender = Address::from_str("4444444444444444444444444444444444444444").unwrap();
let address = Address::from_str("5555555555555555555555555555555555555555").unwrap();
@@ -1481,7 +1481,7 @@ mod tests {
// 60 00 - push 0
// f3 - return
let code = "7c601080600c6000396000f3006000355415600957005b60203560003555600052601d60036017f0600055".from_hex().unwrap();
let code = hex!("7c601080600c6000396000f3006000355415600957005b60203560003555600052601d60036017f0600055").to_vec();
let sender = Address::from_str("cd1722f3947def4cf144679da39c4c32bdc35681").unwrap();
let address = contract_address(CreateContractAddress::FromSenderAndNonce, &sender, &U256::zero(), &[]).0;
@@ -1600,7 +1600,7 @@ mod tests {
// 60 00
// fd - revert
let code = "6460016000fd6000526005601b6017f0600055".from_hex().unwrap();
let code = hex!("6460016000fd6000526005601b6017f0600055").to_vec();
let sender = Address::from_str("cd1722f3947def4cf144679da39c4c32bdc35681").unwrap();
let address = contract_address(CreateContractAddress::FromSenderAndNonce, &sender, &U256::zero(), &[]).0;
@@ -1673,7 +1673,7 @@ mod tests {
// 60 00 - push 0
// f3 - return
let code = "601080600c6000396000f3006000355415600957005b60203560003555".from_hex().unwrap();
let code = hex!("601080600c6000396000f3006000355415600957005b60203560003555").to_vec();
let sender = Address::from_str("cd1722f3947def4cf144679da39c4c32bdc35681").unwrap();
let address = contract_address(CreateContractAddress::FromSenderAndNonce, &sender, &U256::zero(), &[]).0;
@@ -1762,7 +1762,7 @@ mod tests {
// 60 00 - push 0
// f3 - return
let code = "7c601080600c6000396000f3006000355415600957005b60203560003555600052601d600360e6f0600055".from_hex().unwrap();
let code = hex!("7c601080600c6000396000f3006000355415600957005b60203560003555600052601d600360e6f0600055").to_vec();
let sender = Address::from_str("cd1722f3947def4cf144679da39c4c32bdc35681").unwrap();
let address = contract_address(CreateContractAddress::FromSenderAndNonce, &sender, &U256::zero(), &[]).0;
@@ -1815,7 +1815,7 @@ mod tests {
// 60 00 - push 0
// f3 - return
let code = "7c601080600c6000396000f3006000355415600957005b60203560003555600052601d60036017f0".from_hex().unwrap();
let code = hex!("7c601080600c6000396000f3006000355415600957005b60203560003555600052601d60036017f0").to_vec();
let sender = Address::from_str("cd1722f3947def4cf144679da39c4c32bdc35681").unwrap();
let address = contract_address(CreateContractAddress::FromSenderAndNonce, &sender, &U256::zero(), &[]).0;
@@ -1858,7 +1858,7 @@ mod tests {
// 58 - get PC
// 55 - sstore
let code_a = "6000600060006000601873945304eb96065b2a98b57a48a06ae28d285a71b56103e8f15855".from_hex().unwrap();
let code_a = hex!("6000600060006000601873945304eb96065b2a98b57a48a06ae28d285a71b56103e8f15855").to_vec();
// 60 00 - push 0
// 60 00 - push 0
@@ -1872,7 +1872,7 @@ mod tests {
// 01 - add
// 58 - get PC
// 55 - sstore
let code_b = "60006000600060006017730f572e5295c57f15886f9b263e2f6d2d6c7b5ec66101f4f16001015855".from_hex().unwrap();
let code_b = hex!("60006000600060006017730f572e5295c57f15886f9b263e2f6d2d6c7b5ec66101f4f16001015855").to_vec();
let address_a = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
let address_b = Address::from_str("945304eb96065b2a98b57a48a06ae28d285a71b5" ).unwrap();
@@ -1933,7 +1933,7 @@ mod tests {
// 60 01 - push 1
// 55 - sstore
let sender = Address::from_str("cd1722f3947def4cf144679da39c4c32bdc35681").unwrap();
let code = "600160005401600055600060006000600060003060e05a03f1600155".from_hex().unwrap();
let code = hex!("600160005401600055600060006000600060003060e05a03f1600155").to_vec();
let address = contract_address(CreateContractAddress::FromSenderAndNonce, &sender, &U256::zero(), &[]).0;
let mut params = ActionParams::default();
params.address = address.clone();
@@ -1964,7 +1964,7 @@ mod tests {
let t = Transaction {
action: Action::Create,
value: U256::from(17),
data: "3331600055".from_hex().unwrap(),
data: hex!("3331600055").to_vec(),
gas: U256::from(100_000),
gas_price: U256::zero(),
nonce: U256::zero()
@@ -2003,7 +2003,7 @@ mod tests {
let t = Transaction {
action: Action::Create,
value: U256::from(17),
data: "3331600055".from_hex().unwrap(),
data: hex!("3331600055").to_vec(),
gas: U256::from(100_000),
gas_price: U256::zero(),
nonce: U256::one()
@@ -2036,7 +2036,7 @@ mod tests {
let t = Transaction {
action: Action::Create,
value: U256::from(17),
data: "3331600055".from_hex().unwrap(),
data: hex!("3331600055").to_vec(),
gas: U256::from(80_001),
gas_price: U256::zero(),
nonce: U256::zero()
@@ -2071,7 +2071,7 @@ mod tests {
let t = Transaction {
action: Action::Create,
value: U256::from(18),
data: "3331600055".from_hex().unwrap(),
data: hex!("3331600055").to_vec(),
gas: U256::from(100_000),
gas_price: U256::one(),
nonce: U256::zero()
@@ -2100,7 +2100,7 @@ mod tests {
evm_test!{test_keccak: test_keccak_int}
fn test_keccak(factory: Factory) {
let code = "6064640fffffffff20600055".from_hex().unwrap();
let code = hex!("6064640fffffffff20600055").to_vec();
let sender = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
let address = contract_address(CreateContractAddress::FromSenderAndNonce, &sender, &U256::zero(), &[]).0;
@@ -2136,8 +2136,8 @@ mod tests {
let contract_address = Address::from_str("cd1722f3947def4cf144679da39c4c32bdc35681").unwrap();
let sender = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
// EIP-140 test case
let code = "6c726576657274656420646174616000557f726576657274206d657373616765000000000000000000000000000000000000600052600e6000fd".from_hex().unwrap();
let returns = "726576657274206d657373616765".from_hex().unwrap();
let code = hex!("6c726576657274656420646174616000557f726576657274206d657373616765000000000000000000000000000000000000600052600e6000fd").to_vec();
let returns = hex!("726576657274206d657373616765").to_vec();
let mut state = get_temp_state_with_factory(factory.clone());
state.add_balance(&sender, &U256::from_str("152d02c7e14af68000000").unwrap(), CleanupMode::NoEmpty).unwrap();
state.commit().unwrap();
@@ -2177,13 +2177,13 @@ mod tests {
let mut state = get_temp_state_with_factory(factory.clone());
state.new_contract(&x1, U256::zero(), U256::from(1), U256::zero()).unwrap();
state.init_code(&x1, "600160005560006000556001600055".from_hex().unwrap()).unwrap();
state.init_code(&x1, hex!("600160005560006000556001600055").to_vec()).unwrap();
state.new_contract(&x2, U256::zero(), U256::from(1), U256::zero()).unwrap();
state.init_code(&x2, "600060005560016000556000600055".from_hex().unwrap()).unwrap();
state.init_code(&x2, hex!("600060005560016000556000600055").to_vec()).unwrap();
state.new_contract(&y1, U256::zero(), U256::from(1), U256::zero()).unwrap();
state.init_code(&y1, "600060006000600061100062fffffff4".from_hex().unwrap()).unwrap();
state.init_code(&y1, hex!("600060006000600061100062fffffff4").to_vec()).unwrap();
state.new_contract(&y2, U256::zero(), U256::from(1), U256::zero()).unwrap();
state.init_code(&y2, "600060006000600061100162fffffff4".from_hex().unwrap()).unwrap();
state.init_code(&y2, hex!("600060006000600061100162fffffff4").to_vec()).unwrap();
let info = EnvInfo::default();
let machine = new_constantinople_test_machine();
@@ -2194,7 +2194,7 @@ mod tests {
let (FinalizationResult { gas_left, .. }, refund, gas) = {
let gas = U256::from(0xffffffffffu64);
let mut params = ActionParams::default();
params.code = Some(Arc::new("6001600055600060006000600061200163fffffffff4".from_hex().unwrap()));
params.code = Some(Arc::new(hex!("6001600055600060006000600061200163fffffffff4").to_vec()));
params.gas = gas;
let mut substate = Substate::new();
let mut ex = Executive::new(&mut state, &info, &machine, &schedule);
@@ -2212,7 +2212,7 @@ mod tests {
let (FinalizationResult { gas_left, .. }, refund, gas) = {
let gas = U256::from(0xffffffffffu64);
let mut params = ActionParams::default();
params.code = Some(Arc::new("6001600055600060006000600061200263fffffffff4".from_hex().unwrap()));
params.code = Some(Arc::new(hex!("6001600055600060006000600061200263fffffffff4").to_vec()));
params.gas = gas;
let mut substate = Substate::new();
let mut ex = Executive::new(&mut state, &info, &machine, &schedule);
@@ -2228,9 +2228,7 @@ mod tests {
fn wasm_sample_code() -> Arc<Vec<u8>> {
Arc::new(
"0061736d01000000010d0360027f7f0060017f0060000002270303656e7603726574000003656e760673656e646572000103656e76066d656d6f727902010110030201020404017000000501000708010463616c6c00020901000ac10101be0102057f017e4100410028020441c0006b22043602042004412c6a41106a220041003602002004412c6a41086a22014200370200200441186a41106a22024100360200200441186a41086a220342003703002004420037022c2004410036021c20044100360218200441186a1001200020022802002202360200200120032903002205370200200441106a2002360200200441086a200537030020042004290318220537022c200420053703002004411410004100200441c0006a3602040b0b0a010041040b0410c00000"
.from_hex()
.unwrap()
hex!("0061736d01000000010d0360027f7f0060017f0060000002270303656e7603726574000003656e760673656e646572000103656e76066d656d6f727902010110030201020404017000000501000708010463616c6c00020901000ac10101be0102057f017e4100410028020441c0006b22043602042004412c6a41106a220041003602002004412c6a41086a22014200370200200441186a41106a22024100360200200441186a41086a220342003703002004420037022c2004410036021c20044100360218200441186a1001200020022802002202360200200120032903002205370200200441106a2002360200200441086a200537030020042004290318220537022c200420053703002004411410004100200441c0006a3602040b0b0a010041040b0410c00000").to_vec()
)
}

View File

@@ -407,8 +407,8 @@ fn round_block_gas_limit(gas_limit: U256, lower_limit: U256, upper_limit: U256)
mod tests {
use std::str::FromStr;
use common_types::header::Header;
use hex_literal::hex;
use super::*;
use spec;
fn get_default_ethash_extensions() -> EthashExtensions {
EthashExtensions {
@@ -421,8 +421,8 @@ mod tests {
#[test]
fn should_disallow_unsigned_transactions() {
let rlp = "ea80843b9aca0083015f90948921ebb5f79e9e3920abe571004d0b1d5119c154865af3107a400080038080";
let transaction: UnverifiedTransaction = ::rlp::decode(&::rustc_hex::FromHex::from_hex(rlp).unwrap()).unwrap();
let rlp = hex!("ea80843b9aca0083015f90948921ebb5f79e9e3920abe571004d0b1d5119c154865af3107a400080038080").to_vec();
let transaction: UnverifiedTransaction = rlp::decode(&rlp).unwrap();
assert_eq!(
transaction::Error::from(transaction.verify_unordered().unwrap_err()),
transaction::Error::InvalidSignature("invalid EC signature".into()),

View File

@@ -19,7 +19,7 @@ kvdb = "0.4.0"
log = "0.4"
parity-bytes = "0.1.0"
rlp = "0.4"
rustc-hex = "1.0"
rustc-hex = "2.1.0"
serde = { version = "1.0", features = ["derive"] }
trie-db = "0.20.0"
triehash = { package = "triehash-ethereum", version = "0.2", path = "../../util/triehash-ethereum" }

View File

@@ -53,7 +53,7 @@ pub struct PodAccount {
fn opt_bytes_to_hex<S>(opt_bytes: &Option<Bytes>, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer
{
let readable = opt_bytes.as_ref().map(|b| b.to_hex()).unwrap_or_default();
let readable: String = opt_bytes.as_ref().map(|b| b.to_hex()).unwrap_or_default();
serializer.collect_str(&format_args!("0x{}", readable))
}

View File

@@ -38,7 +38,7 @@ patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" }
registrar = { path = "../../util/registrar" }
rlp = "0.4.0"
rlp-derive = "0.1"
rustc-hex = "1.0"
rustc-hex = "2.1.0"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"

View File

@@ -105,13 +105,13 @@ fn private_contract() {
query_tx.nonce = 1.into();
let query_tx = query_tx.sign(&key1.secret(), chain_id);
let result = pm.private_call(BlockId::Latest, &query_tx).unwrap();
assert_eq!(&result.output[..], &("0000000000000000000000000000000000000000000000000000000000000000".from_hex().unwrap()[..]));
assert_eq!(&result.output[..], &("0000000000000000000000000000000000000000000000000000000000000000".from_hex::<Vec<u8>>().unwrap()[..]));
assert_eq!(pm.get_validators(BlockId::Latest, &address).unwrap(), validators);
trace!("Modifying private state");
let mut private_tx = Transaction::default();
private_tx.action = Action::Call(address.clone());
private_tx.data = "bc64b76d2a00000000000000000000000000000000000000000000000000000000000000".from_hex().unwrap(); //setX(42)
private_tx.data = "bc64b76d2a00000000000000000000000000000000000000000000000000000000000000".from_hex::<Vec<u8>>().unwrap(); //setX(42)
private_tx.gas = 120000.into();
private_tx.nonce = 1.into();
let private_tx = private_tx.sign(&key1.secret(), None);
@@ -132,7 +132,7 @@ fn private_contract() {
query_tx.nonce = 2.into();
let query_tx = query_tx.sign(&key1.secret(), chain_id);
let result = pm.private_call(BlockId::Latest, &query_tx).unwrap();
assert_eq!(&result.output[..], &("2a00000000000000000000000000000000000000000000000000000000000000".from_hex().unwrap()[..]));
assert_eq!(&result.output[..], &("2a00000000000000000000000000000000000000000000000000000000000000".from_hex::<Vec<u8>>().unwrap()[..]));
assert_eq!(pm.get_validators(BlockId::Latest, &address).unwrap(), validators);
// Now try modification with just one signature
@@ -159,7 +159,7 @@ fn private_contract() {
query_tx.nonce = 3.into();
let query_tx = query_tx.sign(&key1.secret(), chain_id);
let result = pm.private_call(BlockId::Latest, &query_tx).unwrap();
assert_eq!(result.output, "2a00000000000000000000000000000000000000000000000000000000000000".from_hex().unwrap());
assert_eq!(result.output, "2a00000000000000000000000000000000000000000000000000000000000000".from_hex::<Vec<u8>>().unwrap());
}
#[test]
@@ -241,7 +241,7 @@ fn call_other_private_contract() {
trace!("Creating private contract B");
// Build constructor data
let mut deploy_data = "6060604052341561000f57600080fd5b6040516020806101c583398101604052808051906020019091905050806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505061014a8061007b6000396000f300606060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680635197c7aa14610046575b600080fd5b341561005157600080fd5b61005961006f565b6040518082815260200191505060405180910390f35b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630c55699c6000604051602001526040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15156100fe57600080fd5b6102c65a03f1151561010f57600080fd5b505050604051805190509050905600a165627a7a723058207f8994e02725b47d76ec73e5c54a338d27b306dd1c830276bff2d75fcd1a5c920029000000000000000000000000".to_string();
deploy_data.push_str(&address_a.as_bytes().to_vec().to_hex());
deploy_data.push_str(&address_a.as_bytes().to_hex::<String>());
let private_contract_b_test = deploy_data.from_hex().unwrap();
let mut private_create_tx2 = Transaction::default();
private_create_tx2.action = Action::Create;
@@ -283,5 +283,5 @@ fn call_other_private_contract() {
query_tx.nonce = 3.into();
let query_tx = query_tx.sign(&key1.secret(), chain_id);
let result = pm.private_call(BlockId::Latest, &query_tx).unwrap();
assert_eq!(&result.output[..], &("2a00000000000000000000000000000000000000000000000000000000000000".from_hex().unwrap()[..]));
assert_eq!(&result.output[..], &("2a00000000000000000000000000000000000000000000000000000000000000".from_hex::<Vec<u8>>().unwrap()[..]));
}

View File

@@ -43,5 +43,5 @@ ethcore-io = { path = "../../util/io", features = ["mio"] }
kvdb-memorydb = "0.4.0"
machine = { path = "../machine" }
rand_xorshift = "0.2"
rustc-hex = "1.0"
rustc-hex = "2.1.0"
spec = { path = "../spec" }

View File

@@ -14,7 +14,7 @@ vm = { path = "../../vm" }
wasm = { path = "../" }
clap = "2.24"
env_logger = "0.5"
rustc-hex = "1.0"
rustc-hex = "2.1.0"
[features]
default = ["ethereum-types/std"]

View File

@@ -73,9 +73,9 @@ impl fmt::Display for Fail {
write!(
f,
"Expected to return result: 0x{} ({} bytes), but got 0x{} ({} bytes)",
expected.to_hex(),
expected.to_hex::<String>(),
expected.len(),
actual.to_hex(),
actual.to_hex::<String>(),
actual.len()
),
@@ -95,17 +95,17 @@ impl fmt::Display for Fail {
write!(
f,
"Storage key {} value mismatch, expected {}, got: {}",
key.as_bytes().to_vec().to_hex(),
expected.as_bytes().to_vec().to_hex(),
actual.as_bytes().to_vec().to_hex(),
key.as_bytes().to_hex::<String>(),
expected.as_bytes().to_hex::<String>(),
actual.as_bytes().to_hex::<String>(),
),
StorageMismatch { ref key, ref expected, actual: None} =>
write!(
f,
"No expected storage value for key {} found, expected {}",
key.as_bytes().to_vec().to_hex(),
expected.as_bytes().to_vec().to_hex(),
key.as_bytes().to_hex::<String>(),
expected.as_bytes().to_hex::<String>(),
),
Nonconformity(SpecNonconformity::Address) =>