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/extract-state-db
Browse files Browse the repository at this point in the history
* master:
  Move more code into state-account (#10840)
  Remove compiler warning (#10865)
  [ethash] use static_assertions crate (#10860)
  • Loading branch information
dvdplm committed Jul 8, 2019
2 parents cd9167e + 44cc442 commit d51cede
Show file tree
Hide file tree
Showing 21 changed files with 62 additions and 63 deletions.
37 changes: 22 additions & 15 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions ethash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ log = "0.4"
memmap = "0.6"
parking_lot = "0.8"
primal = "0.2.3"
static_assertions = "0.3.3"

[dev-dependencies]
criterion = "0.2"
Expand Down
2 changes: 2 additions & 0 deletions ethash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ extern crate primal;
extern crate crunchy;
#[macro_use]
extern crate log;
#[macro_use]
extern crate static_assertions;

#[cfg(test)]
extern crate rustc_hex;
Expand Down
29 changes: 1 addition & 28 deletions ethash/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,34 +69,7 @@ pub type NodeBytes = [u8; NODE_BYTES];
pub type NodeWords = [u32; NODE_WORDS];
pub type NodeDwords = [u64; NODE_DWORDS];

macro_rules! static_assert_size_eq {
(@inner $a:ty, $b:ty, $($rest:ty),*) => {
fn first() {
static_assert_size_eq!($a, $b);
}

fn second() {
static_assert_size_eq!($b, $($rest),*);
}
};
(@inner $a:ty, $b:ty) => {
unsafe {
let val: $b = ::std::mem::uninitialized();
let _: $a = ::std::mem::transmute(val);
}
};
($($rest:ty),*) => {
static_assert_size_eq!(size_eq: $($rest),*);
};
($name:ident : $($rest:ty),*) => {
#[allow(dead_code)]
fn $name() {
static_assert_size_eq!(@inner $($rest),*);
}
};
}

static_assert_size_eq!(Node, NodeBytes, NodeWords, NodeDwords);
assert_eq_size!(node; Node, NodeBytes, NodeWords, NodeDwords);

#[repr(C)]
pub union Node {
Expand Down
2 changes: 1 addition & 1 deletion ethcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ethereum-types = "0.6.0"
ethjson = { path = "../json" }
ethkey = { path = "../accounts/ethkey" }
evm = { path = "evm" }
factories = { path = "factories" }
trie-vm-factories = { path = "trie-vm-factories" }
futures = "0.1"
hash-db = "0.12.4"
parity-util-mem = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion ethcore/account-state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ derive_more = "0.15.0"
ethereum-types = "0.6.0"
ethtrie = { package = "patricia-trie-ethereum", path = "../../util/patricia-trie-ethereum" }
evm = { path = "../evm" }
factories = { path = "../factories" }
trie-vm-factories = { path = "../trie-vm-factories" }
hash-db = "0.12.4"
journaldb = { path = "../../util/journaldb" }
keccak-hash = "0.2.0"
Expand Down
2 changes: 1 addition & 1 deletion ethcore/account-state/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use common_types::{
};
use ethereum_types::{Address, H256, U256};
use ethtrie::{TrieDB, Result as TrieResult};
use factories::{Factories, VmFactory};
use trie_vm_factories::{Factories, VmFactory};
use hash_db::HashDB;
use keccak_hash::{KECCAK_EMPTY, KECCAK_NULL_RLP};
use keccak_hasher::KeccakHasher;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/account-state/src/substate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ impl Substate {

#[cfg(test)]
mod tests {
use ethereum_types::Address;
use common_types::log_entry::LogEntry;
use ethereum_types::Address;
use super::Substate;

#[test]
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use ethereum_types::{H256, U256, Address, Bloom};

use engines::Engine;
use error::{Error, BlockError};
use factories::Factories;
use trie_vm_factories::Factories;
use state_db::StateDB;
use account_state::State;
use trace::Tracing;
Expand Down Expand Up @@ -551,7 +551,7 @@ mod tests {
use engines::Engine;
use vm::LastHashes;
use error::Error;
use factories::Factories;
use trie_vm_factories::Factories;
use state_db::StateDB;
use ethereum_types::Address;
use std::sync::Arc;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ use error::{
Error as EthcoreError, EthcoreResult,
};
use executive::{Executive, Executed, TransactOptions, contract_address};
use factories::{Factories, VmFactory};
use trie_vm_factories::{Factories, VmFactory};
use miner::{Miner, MinerService};
use snapshot::{self, io as snapshot_io, SnapshotClient};
use spec::Spec;
Expand Down
6 changes: 3 additions & 3 deletions ethcore/src/client/evm_test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
use std::fmt;
use std::sync::Arc;
use ethereum_types::{H256, U256, H160};
use {factories, journaldb, trie, kvdb_memorydb};
use {trie_vm_factories, journaldb, trie, kvdb_memorydb};
use kvdb::{self, KeyValueDB};
use {state_db, client, executive, trace, db, spec};
use pod::PodState;
use types::{log_entry, receipt, transaction};
use factories::Factories;
use trie_vm_factories::Factories;
use evm::{VMType, FinalizationResult};
use vm::{self, ActionParams};
use ethtrie;
Expand Down Expand Up @@ -150,7 +150,7 @@ impl<'a> EvmTestClient<'a> {

fn factories(trie_spec: trie::TrieSpec) -> Factories {
Factories {
vm: factories::VmFactory::new(VMType::Interpreter, 5 * 1024),
vm: trie_vm_factories::VmFactory::new(VMType::Interpreter, 5 * 1024),
trie: trie::TrieFactory::new(trie_spec),
accountdb: Default::default(),
}
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/executive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use vm::{
self, EnvInfo, CreateContractAddress, ReturnData, CleanDustMode, ActionParams,
ActionValue, Schedule, TrapError, ResumeCall, ResumeCreate
};
use factories::VmFactory;
use trie_vm_factories::VmFactory;
use externalities::*;
use trace::{self, Tracer, VMTracer};
use types::transaction::{Action, SignedTransaction};
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/executive_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use account_state::{
state::State,
};
use ethereum_types::H256;
use factories::Factories;
use trie_vm_factories::Factories;
use bytes::Bytes;
use keccak_hasher::KeccakHasher;
use kvdb::DBValue;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ extern crate ethcore_miner;
extern crate ethereum_types;
extern crate ethjson;
extern crate ethkey;
extern crate factories;
extern crate trie_vm_factories;
extern crate futures;
extern crate hash_db;
extern crate itertools;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/spec/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use engines::{
};
use error::Error;
use executive::Executive;
use factories::Factories;
use trie_vm_factories::Factories;
use machine::Machine;
use pod::PodState;
use spec::Genesis;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use types::views::BlockView;

use block::{OpenBlock, Drain};
use client::{Client, ClientConfig, ChainInfo, ImportBlock, ChainNotify, ChainMessageType, PrepareOpenBlock};
use factories::Factories;
use trie_vm_factories::Factories;
use miner::Miner;
use spec::Spec;
use account_state::*;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ fn transaction_proof() {
let proof = client.prove_transaction(transaction.clone(), BlockId::Latest).unwrap().1;
let backend = backend::ProofCheck::new(&proof);

let mut factories = ::factories::Factories::default();
let mut factories = ::trie_vm_factories::Factories::default();
factories.accountdb = ::account_db::Factory::Plain; // raw state values, no mangled keys.
let root = *client.best_block_header().state_root();

Expand Down
7 changes: 4 additions & 3 deletions ethcore/trace/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@
//! Trace database.
use std::collections::HashMap;
use std::sync::Arc;
use parity_util_mem::MallocSizeOfExt;

use common_types::BlockNumber;
use ethcore_blockchain::{BlockChainDB, DatabaseExtras};
use ethcore_db::{
self as db,
cache_manager::CacheManager,
Key, Writable, Readable, CacheUpdatePolicy,
};
use ethereum_types::{H256, H264};
use kvdb::DBTransaction;
use parity_util_mem::MallocSizeOfExt;
use parking_lot::RwLock;
use common_types::BlockNumber;
use ethcore_blockchain::{BlockChainDB, DatabaseExtras};

use crate::{
LocalizedTrace, Config, Filter, Database as TraceDatabase, ImportRequest,
Expand Down
15 changes: 15 additions & 0 deletions ethcore/trie-vm-factories/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
description = "Collection of factories for VM and Tries"
name = "trie-vm-factories"
version = "0.1.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2018"

[dependencies]
trie-db = "0.12.4"
ethtrie = { package = "patricia-trie-ethereum", path = "../../util/patricia-trie-ethereum" }
account-db = { path = "../account-db" }
evm = { path = "../evm" }
vm = { path = "../vm" }
wasm = { path = "../wasm" }
keccak-hasher = { path = "../../util/keccak-hasher" }
File renamed without changes.
2 changes: 1 addition & 1 deletion rpc/src/v1/helpers/engine_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl ethcore::engines::EngineSigner for EngineSigner {
fn sign(&self, message: ethkey::Message) -> Result<ethkey::Signature, ethkey::Error> {
match self.accounts.sign(self.address, Some(self.password.clone()), message) {
Ok(ok) => Ok(ok),
Err(e) => Err(ethkey::Error::InvalidSecret),
Err(_) => Err(ethkey::Error::InvalidSecret),
}
}

Expand Down

0 comments on commit d51cede

Please sign in to comment.