Upgrade ethereum types (#10670)
* cargo upgrade "ethereum-types" --all --allow-prerelease * [ethash] fix compilation errors * [ethkey] fix compilation errors * [journaldb] fix compilation errors * [dir] fix compilation errors * [ethabi] update to 0.7 * wip * [eip-712] fix compilation errors * [ethjson] fix compilation errors * [Cargo.toml] add TODO to remove patches * [ethstore] fix compilation errors * use patched keccak-hash with new primitive-types * wip * [ethcore-network-devp2p] fix compilation errors * [vm] fix compilation errors * [common-types, evm, wasm] fix compilation errors * [ethcore-db] Require AsRef instead of Deref for keys * [ethcore-blockchain] fix some compilation errors * [blooms-db] fix compilation errors Thanks a lot @dvdplm :) * we don't need no rlp ethereum feature * [ethcore] fix some compilation errors * [parity-ipfs-api] fix compilation error * [ethcore-light] fix compilation errors * [Cargo.lock] update parity-common * [ethcore-private-tx] fix some compilation errors * wip * [ethcore-private-tx] fix compilation errors * [parity-updater] fix compilation errors * [parity-rpc] fix compilation errors * [parity-bin] fix other compilation errors * update to new ethereum-types * update keccak-hash * [fastmap] fix compilation in tests * [blooms-db] fix compilation in tests * [common-types] fix compilation in tests * [triehash-ethereum] fix compilation in tests * [ethkey] fix compilation in tests * [pwasm-run-test] fix compilation errors * [wasm] fix compilation errors * [ethjson] fix compilation in tests * [eip-712] fix compilation in tests * [ethcore-blockchain] fix compilation in tests * [ethstore] fix compilation in tests * [ethstore-accounts] fix compilation in tests * [parity-hash-fetch] fix compilation in tests * [parity-whisper] fix compilation in tests * [ethcore-miner] fix compilation in tests * [ethcore-network-devp2p] fix compilation in tests * [*] upgrade rand to 0.6 * [evm] get rid of num-bigint conversions * [ethcore] downgrade trie-standardmap and criterion * [ethcore] fix some warnings * [ethcore] fix compilation in tests * [evmbin] fix compilation in tests * [updater] fix compilation in tests * [ethash] fix compilation in tests * [ethcore-secretstore] fix compilation in tests * [ethcore-sync] fix compilation in tests * [parity-rpc] fix compilation in tests * [ethcore] finally fix compilation in tests FUCK YEAH!!! * [ethstore] lazy_static is unused * [ethcore] fix test * fix up bad merge * [Cargo.toml] remove unused patches * [*] replace some git dependencies with crates.io * [Cargo.toml] remove unused lazy_static * [*] clean up * [ethcore] fix transaction_filter_deprecated test * [private-tx] fix serialization tests * fix more serialization tests * [ethkey] fix smoky test * [rpc] fix tests, please? * [ethcore] remove commented out code * Apply suggestions from code review Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * [ethstore] remove unused dev-dependency * [ethcore] remove resolved TODO * [*] resolve keccak-hash TODO * [*] s/Address::default()/Address::zero() * [rpc] remove Subscribers::new_test * [rpc] remove EthPubSubClient::new_test * [ethcore] use trie-standardmap from crates.io * [dir] fix db_root_path * [ethcore] simplify snapshot::tests::helpers::fill_storage * Apply suggestions from code review Co-Authored-By: David <dvdplm@gmail.com> * [ethcore-secretstore] resolve TODO in serialization * [ethcore-network-devp2p] resolve TODO in save_key * [Cargo.lock] update triehash * [*] use ethabi from crates.io * [ethkey] use secp256k1 from master branch * [Cargo.lock] update eth-secp256k1
This commit is contained in:
@@ -520,7 +520,7 @@ impl BlockCollection {
|
||||
(None, receipt_root)
|
||||
}
|
||||
} else {
|
||||
(None, H256::new())
|
||||
(None, H256::zero())
|
||||
};
|
||||
|
||||
self.parents.insert(*info.header.parent_hash(), hash);
|
||||
|
||||
@@ -113,7 +113,7 @@ use ethcore::snapshot::{RestorationStatus};
|
||||
use sync_io::SyncIo;
|
||||
use super::{WarpSync, SyncConfig};
|
||||
use block_sync::{BlockDownloader, DownloadAction};
|
||||
use rand::Rng;
|
||||
use rand::{Rng, seq::SliceRandom};
|
||||
use snapshot::{Snapshot};
|
||||
use api::{EthProtocolInfo as PeerInfoDigest, WARP_SYNC_PROTOCOL_ID, PriorityTask};
|
||||
use private_tx::PrivateTxHandler;
|
||||
@@ -360,12 +360,13 @@ impl PeerInfo {
|
||||
#[cfg(not(test))]
|
||||
pub mod random {
|
||||
use rand;
|
||||
pub fn new() -> rand::ThreadRng { rand::thread_rng() }
|
||||
pub fn new() -> rand::rngs::ThreadRng { rand::thread_rng() }
|
||||
}
|
||||
#[cfg(test)]
|
||||
pub mod random {
|
||||
use rand::{self, SeedableRng};
|
||||
pub fn new() -> rand::XorShiftRng { rand::XorShiftRng::from_seed([0, 1, 2, 3]) }
|
||||
use rand::SeedableRng;
|
||||
const RNG_SEED: [u8; 16] = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16];
|
||||
pub fn new() -> rand_xorshift::XorShiftRng { rand_xorshift::XorShiftRng::from_seed(RNG_SEED) }
|
||||
}
|
||||
|
||||
pub type RlpResponseResult = Result<Option<(PacketId, RlpStream)>, PacketDecodeError>;
|
||||
@@ -559,7 +560,7 @@ impl ChainSync {
|
||||
let mut count = (peers.len() as f64).powf(0.5).round() as usize;
|
||||
count = cmp::min(count, MAX_PEERS_PROPAGATION);
|
||||
count = cmp::max(count, MIN_PEERS_PROPAGATION);
|
||||
random::new().shuffle(&mut peers);
|
||||
peers.shuffle(&mut random::new());
|
||||
peers.truncate(count);
|
||||
peers
|
||||
}
|
||||
@@ -908,7 +909,7 @@ impl ChainSync {
|
||||
self.active_peers.len(), peers.len(), self.peers.len()
|
||||
);
|
||||
|
||||
random::new().shuffle(&mut peers); // TODO (#646): sort by rating
|
||||
peers.shuffle(&mut random::new()); // TODO (#646): sort by rating
|
||||
// prefer peers with higher protocol version
|
||||
peers.sort_by(|&(_, ref v1), &(_, ref v2)| v1.cmp(v2));
|
||||
|
||||
@@ -1154,7 +1155,7 @@ impl ChainSync {
|
||||
if warp_protocol {
|
||||
let manifest = io.snapshot_service().manifest();
|
||||
let block_number = manifest.as_ref().map_or(0, |m| m.block_number);
|
||||
let manifest_hash = manifest.map_or(H256::new(), |m| keccak(m.into_rlp()));
|
||||
let manifest_hash = manifest.map_or(H256::zero(), |m| keccak(m.into_rlp()));
|
||||
packet.append(&manifest_hash);
|
||||
packet.append(&block_number);
|
||||
if private_tx_protocol {
|
||||
@@ -1398,7 +1399,7 @@ pub mod tests {
|
||||
let mut rlp = RlpStream::new_list(5);
|
||||
for _ in 0..5 {
|
||||
let mut hash_d_rlp = RlpStream::new_list(2);
|
||||
let hash: H256 = H256::from(0u64);
|
||||
let hash: H256 = H256::zero();
|
||||
let diff: U256 = U256::from(1u64);
|
||||
hash_d_rlp.append(&hash);
|
||||
hash_d_rlp.append(&diff);
|
||||
|
||||
@@ -22,7 +22,7 @@ use ethereum_types::H256;
|
||||
use fastmap::H256FastSet;
|
||||
use network::client_version::ClientCapabilities;
|
||||
use network::PeerId;
|
||||
use rand::Rng;
|
||||
use rand::RngCore;
|
||||
use rlp::{Encodable, RlpStream};
|
||||
use sync_io::SyncIo;
|
||||
use types::transaction::SignedTransaction;
|
||||
|
||||
@@ -377,6 +377,7 @@ mod test {
|
||||
use super::{*, super::tests::*};
|
||||
use blocks::SyncHeader;
|
||||
use ethcore::client::{BlockChainClient, EachBlockWith, TestBlockChainClient};
|
||||
use std::str::FromStr;
|
||||
|
||||
#[test]
|
||||
fn return_block_headers() {
|
||||
@@ -412,7 +413,7 @@ mod test {
|
||||
let ss = TestSnapshotService::new();
|
||||
let io = TestIo::new(&mut client, &ss, &queue, None);
|
||||
|
||||
let unknown: H256 = H256::new();
|
||||
let unknown: H256 = H256::zero();
|
||||
let result = SyncSupplier::return_block_headers(&io, &Rlp::new(&make_hash_req(&unknown, 1, 0, false)), 0);
|
||||
assert!(to_header_vec(result).is_empty());
|
||||
let result = SyncSupplier::return_block_headers(&io, &Rlp::new(&make_hash_req(&unknown, 1, 0, true)), 0);
|
||||
@@ -483,14 +484,14 @@ mod test {
|
||||
fn return_nodes() {
|
||||
let mut client = TestBlockChainClient::new();
|
||||
let queue = RwLock::new(VecDeque::new());
|
||||
let sync = dummy_sync_with_peer(H256::new(), &client);
|
||||
let sync = dummy_sync_with_peer(H256::zero(), &client);
|
||||
let ss = TestSnapshotService::new();
|
||||
let mut io = TestIo::new(&mut client, &ss, &queue, None);
|
||||
|
||||
let mut node_list = RlpStream::new_list(3);
|
||||
node_list.append(&H256::from("0000000000000000000000000000000000000000000000005555555555555555"));
|
||||
node_list.append(&H256::from("ffffffffffffffffffffffffffffffffffffffffffffaaaaaaaaaaaaaaaaaaaa"));
|
||||
node_list.append(&H256::from("aff0000000000000000000000000000000000000000000000000000000000000"));
|
||||
node_list.append(&H256::from_str("0000000000000000000000000000000000000000000000005555555555555555").unwrap());
|
||||
node_list.append(&H256::from_str("ffffffffffffffffffffffffffffffffffffffffffffaaaaaaaaaaaaaaaaaaaa").unwrap());
|
||||
node_list.append(&H256::from_str("aff0000000000000000000000000000000000000000000000000000000000000").unwrap());
|
||||
|
||||
let node_request = node_list.out();
|
||||
// it returns rlp ONLY for hashes started with "f"
|
||||
@@ -527,15 +528,15 @@ mod test {
|
||||
fn return_receipts() {
|
||||
let mut client = TestBlockChainClient::new();
|
||||
let queue = RwLock::new(VecDeque::new());
|
||||
let sync = dummy_sync_with_peer(H256::new(), &client);
|
||||
let sync = dummy_sync_with_peer(H256::zero(), &client);
|
||||
let ss = TestSnapshotService::new();
|
||||
let mut io = TestIo::new(&mut client, &ss, &queue, None);
|
||||
|
||||
let mut receipt_list = RlpStream::new_list(4);
|
||||
receipt_list.append(&H256::from("0000000000000000000000000000000000000000000000005555555555555555"));
|
||||
receipt_list.append(&H256::from("ff00000000000000000000000000000000000000000000000000000000000000"));
|
||||
receipt_list.append(&H256::from("fff0000000000000000000000000000000000000000000000000000000000000"));
|
||||
receipt_list.append(&H256::from("aff0000000000000000000000000000000000000000000000000000000000000"));
|
||||
receipt_list.append(&H256::from_str("0000000000000000000000000000000000000000000000005555555555555555").unwrap());
|
||||
receipt_list.append(&H256::from_str("ff00000000000000000000000000000000000000000000000000000000000000").unwrap());
|
||||
receipt_list.append(&H256::from_str("fff0000000000000000000000000000000000000000000000000000000000000").unwrap());
|
||||
receipt_list.append(&H256::from_str("aff0000000000000000000000000000000000000000000000000000000000000").unwrap());
|
||||
|
||||
let receipts_request = receipt_list.out();
|
||||
// it returns rlp ONLY for hashes started with "f"
|
||||
|
||||
@@ -45,6 +45,7 @@ extern crate ethcore_light as light;
|
||||
#[cfg(test)] extern crate ethcore_private_tx;
|
||||
#[cfg(test)] extern crate kvdb_memorydb;
|
||||
#[cfg(test)] extern crate rustc_hex;
|
||||
#[cfg(test)] extern crate rand_xorshift;
|
||||
|
||||
#[macro_use]
|
||||
extern crate enum_primitive;
|
||||
|
||||
@@ -50,7 +50,7 @@ use light::request::{self, CompleteHeadersRequest as HeadersRequest};
|
||||
use network::PeerId;
|
||||
use ethereum_types::{H256, U256};
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use rand::{Rng, OsRng};
|
||||
use rand::{rngs::OsRng, seq::SliceRandom};
|
||||
use futures::sync::mpsc;
|
||||
|
||||
use self::sync_round::{AbortReason, SyncRound, ResponseContext};
|
||||
@@ -637,7 +637,7 @@ impl<L: AsLightClient> LightSync<L> {
|
||||
// naive request dispatcher: just give to any peer which says it will
|
||||
// give us responses. but only one request per peer per state transition.
|
||||
let dispatcher = move |req: HeadersRequest| {
|
||||
rng.shuffle(&mut peer_ids);
|
||||
peer_ids.shuffle(&mut *rng);
|
||||
|
||||
let request = {
|
||||
let mut builder = request::Builder::default();
|
||||
|
||||
@@ -33,11 +33,11 @@ pub struct NoopPrivateTxHandler;
|
||||
|
||||
impl PrivateTxHandler for NoopPrivateTxHandler {
|
||||
fn import_private_transaction(&self, _rlp: &[u8]) -> Result<H256, String> {
|
||||
Ok(H256::default())
|
||||
Ok(H256::zero())
|
||||
}
|
||||
|
||||
fn import_signed_private_transaction(&self, _rlp: &[u8]) -> Result<H256, String> {
|
||||
Ok(H256::default())
|
||||
Ok(H256::zero())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,11 +53,11 @@ pub struct SimplePrivateTxHandler {
|
||||
impl PrivateTxHandler for SimplePrivateTxHandler {
|
||||
fn import_private_transaction(&self, rlp: &[u8]) -> Result<H256, String> {
|
||||
self.txs.lock().push(rlp.to_vec());
|
||||
Ok(H256::default())
|
||||
Ok(H256::zero())
|
||||
}
|
||||
|
||||
fn import_signed_private_transaction(&self, rlp: &[u8]) -> Result<H256, String> {
|
||||
self.signed_txs.lock().push(rlp.to_vec());
|
||||
Ok(H256::default())
|
||||
Ok(H256::zero())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,15 +188,15 @@ mod test {
|
||||
}
|
||||
|
||||
fn test_manifest() -> (ManifestData, H256, Vec<Bytes>, Vec<Bytes>) {
|
||||
let state_chunks: Vec<Bytes> = (0..20).map(|_| H256::random().to_vec()).collect();
|
||||
let block_chunks: Vec<Bytes> = (0..20).map(|_| H256::random().to_vec()).collect();
|
||||
let state_chunks: Vec<Bytes> = (0..20).map(|_| H256::random().as_bytes().to_vec()).collect();
|
||||
let block_chunks: Vec<Bytes> = (0..20).map(|_| H256::random().as_bytes().to_vec()).collect();
|
||||
let manifest = ManifestData {
|
||||
version: 2,
|
||||
state_hashes: state_chunks.iter().map(|data| keccak(data)).collect(),
|
||||
block_hashes: block_chunks.iter().map(|data| keccak(data)).collect(),
|
||||
state_root: H256::new(),
|
||||
state_root: H256::zero(),
|
||||
block_number: 42,
|
||||
block_hash: H256::new(),
|
||||
block_hash: H256::zero(),
|
||||
};
|
||||
let mhash = keccak(manifest.clone().into_rlp());
|
||||
(manifest, mhash, state_chunks, block_chunks)
|
||||
@@ -219,7 +219,7 @@ mod test {
|
||||
let (manifest, mhash, state_chunks, block_chunks) = test_manifest();
|
||||
snapshot.reset_to(&manifest, &mhash);
|
||||
assert_eq!(snapshot.done_chunks(), 0);
|
||||
assert!(snapshot.validate_chunk(&H256::random().to_vec()).is_err());
|
||||
assert!(snapshot.validate_chunk(&H256::random().as_bytes().to_vec()).is_err());
|
||||
|
||||
let requested: Vec<H256> = (0..40).map(|_| snapshot.needed_chunk().unwrap()).collect();
|
||||
assert!(snapshot.needed_chunk().is_none());
|
||||
|
||||
@@ -32,7 +32,7 @@ fn new_tx(secret: &Secret, nonce: U256, chain_id: u64) -> PendingTransaction {
|
||||
nonce: nonce.into(),
|
||||
gas_price: 0.into(),
|
||||
gas: 21000.into(),
|
||||
action: Action::Call(Address::default()),
|
||||
action: Action::Call(Address::zero()),
|
||||
value: 0.into(),
|
||||
data: Vec::new(),
|
||||
}.sign(secret, Some(chain_id));
|
||||
@@ -41,8 +41,8 @@ fn new_tx(secret: &Secret, nonce: U256, chain_id: u64) -> PendingTransaction {
|
||||
|
||||
#[test]
|
||||
fn authority_round() {
|
||||
let s0 = KeyPair::from_secret_slice(&keccak("1")).unwrap();
|
||||
let s1 = KeyPair::from_secret_slice(&keccak("0")).unwrap();
|
||||
let s0 = KeyPair::from_secret_slice(keccak("1").as_bytes()).unwrap();
|
||||
let s1 = KeyPair::from_secret_slice(keccak("0").as_bytes()).unwrap();
|
||||
|
||||
let chain_id = Spec::new_test_round().chain_id();
|
||||
let mut net = TestNet::with_spec(2, SyncConfig::default(), Spec::new_test_round);
|
||||
|
||||
@@ -41,8 +41,8 @@ fn seal_spec() -> Spec {
|
||||
#[test]
|
||||
fn send_private_transaction() {
|
||||
// Setup two clients
|
||||
let s0 = KeyPair::from_secret_slice(&keccak("1")).unwrap();
|
||||
let s1 = KeyPair::from_secret_slice(&keccak("0")).unwrap();
|
||||
let s0 = KeyPair::from_secret_slice(keccak("1").as_bytes()).unwrap();
|
||||
let s1 = KeyPair::from_secret_slice(keccak("0").as_bytes()).unwrap();
|
||||
|
||||
let signer = Arc::new(ethcore_private_tx::KeyPairSigner(vec![s0.clone(), s1.clone()]));
|
||||
|
||||
|
||||
@@ -49,13 +49,13 @@ impl TestSnapshotService {
|
||||
pub fn new_with_snapshot(num_chunks: usize, block_hash: H256, block_number: BlockNumber) -> TestSnapshotService {
|
||||
let num_state_chunks = num_chunks / 2;
|
||||
let num_block_chunks = num_chunks - num_state_chunks;
|
||||
let state_chunks: Vec<Bytes> = (0..num_state_chunks).map(|_| H256::random().to_vec()).collect();
|
||||
let block_chunks: Vec<Bytes> = (0..num_block_chunks).map(|_| H256::random().to_vec()).collect();
|
||||
let state_chunks: Vec<Bytes> = (0..num_state_chunks).map(|_| H256::random().as_bytes().to_vec()).collect();
|
||||
let block_chunks: Vec<Bytes> = (0..num_block_chunks).map(|_| H256::random().as_bytes().to_vec()).collect();
|
||||
let manifest = ManifestData {
|
||||
version: 2,
|
||||
state_hashes: state_chunks.iter().map(|data| keccak(data)).collect(),
|
||||
block_hashes: block_chunks.iter().map(|data| keccak(data)).collect(),
|
||||
state_root: H256::new(),
|
||||
state_root: H256::zero(),
|
||||
block_number: block_number,
|
||||
block_hash: block_hash,
|
||||
};
|
||||
@@ -145,7 +145,7 @@ fn snapshot_sync() {
|
||||
let mut config = SyncConfig::default();
|
||||
config.warp_sync = WarpSync::Enabled;
|
||||
let mut net = TestNet::new_with_config(5, config);
|
||||
let snapshot_service = Arc::new(TestSnapshotService::new_with_snapshot(16, H256::new(), 500000));
|
||||
let snapshot_service = Arc::new(TestSnapshotService::new_with_snapshot(16, H256::zero(), 500000));
|
||||
for i in 0..4 {
|
||||
net.peer_mut(i).snapshot_service = snapshot_service.clone();
|
||||
net.peer(i).chain.add_blocks(1, EachBlockWith::Nothing);
|
||||
|
||||
@@ -91,15 +91,15 @@ impl TransactionsStats {
|
||||
mod tests {
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use super::{Stats, TransactionsStats};
|
||||
use super::{Stats, TransactionsStats, NodeId, H256};
|
||||
|
||||
#[test]
|
||||
fn should_keep_track_of_propagations() {
|
||||
// given
|
||||
let mut stats = TransactionsStats::default();
|
||||
let hash = 5.into();
|
||||
let enodeid1 = 2.into();
|
||||
let enodeid2 = 5.into();
|
||||
let hash = H256::from_low_u64_be(5);
|
||||
let enodeid1 = NodeId::from_low_u64_be(2);
|
||||
let enodeid2 = NodeId::from_low_u64_be(5);
|
||||
|
||||
// when
|
||||
stats.propagated(&hash, Some(enodeid1), 5);
|
||||
@@ -121,8 +121,8 @@ mod tests {
|
||||
fn should_remove_hash_from_tracking() {
|
||||
// given
|
||||
let mut stats = TransactionsStats::default();
|
||||
let hash = 5.into();
|
||||
let enodeid1 = 5.into();
|
||||
let hash = H256::from_low_u64_be(5);
|
||||
let enodeid1 = NodeId::from_low_u64_be(5);
|
||||
stats.propagated(&hash, Some(enodeid1), 10);
|
||||
|
||||
// when
|
||||
|
||||
Reference in New Issue
Block a user