Updating ethcore and ethjson crates to Rust Edition 2018 (#316)

* Migrating use crate::Type imports to Rust 2018 edition

* import name fixes

* fmt

* removing diff leftover

* catching up with latest developments on dev

* fmt

* removing another diff leftover
This commit is contained in:
Karim Agha 2021-03-12 14:55:49 +01:00 committed by GitHub
parent 48e7d6cee4
commit 29dc10c446
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
81 changed files with 467 additions and 346 deletions

24
Cargo.lock generated
View File

@ -1,5 +1,11 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
[[package]]
name = "adler32"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234"
[[package]] [[package]]
name = "aes" name = "aes"
version = "0.3.2" version = "0.3.2"
@ -438,6 +444,9 @@ name = "common-types"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"ethereum-types", "ethereum-types",
"ethkey",
"hex",
"inflate",
"keccak-hash", "keccak-hash",
"parity-bytes", "parity-bytes",
"parity-crypto", "parity-crypto",
@ -1804,6 +1813,12 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "hex"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]] [[package]]
name = "hex-literal" name = "hex-literal"
version = "0.2.1" version = "0.2.1"
@ -2056,6 +2071,15 @@ dependencies = [
"autocfg 0.1.7", "autocfg 0.1.7",
] ]
[[package]]
name = "inflate"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff"
dependencies = [
"adler32",
]
[[package]] [[package]]
name = "interleaved-ordered" name = "interleaved-ordered"
version = "0.1.1" version = "0.1.1"

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>. // along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
use params::SpecType; use crate::params::SpecType;
use std::num::NonZeroU32; use std::num::NonZeroU32;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
@ -53,9 +53,11 @@ pub fn execute(_cmd: AccountCmd) -> Result<String, String> {
#[cfg(feature = "accounts")] #[cfg(feature = "accounts")]
mod command { mod command {
use super::*; use super::*;
use accounts::{AccountProvider, AccountProviderSettings}; use crate::{
accounts::{AccountProvider, AccountProviderSettings},
helpers::{password_from_file, password_prompt},
};
use ethstore::{accounts_dir::RootDiskDirectory, import_account, import_accounts, EthStore}; use ethstore::{accounts_dir::RootDiskDirectory, import_account, import_accounts, EthStore};
use helpers::{password_from_file, password_prompt};
use std::path::PathBuf; use std::path::PathBuf;
pub fn execute(cmd: AccountCmd) -> Result<String, String> { pub fn execute(cmd: AccountCmd) -> Result<String, String> {

View File

@ -21,7 +21,7 @@ use dir::Directories;
use ethereum_types::{Address, H160}; use ethereum_types::{Address, H160};
use ethkey::Password; use ethkey::Password;
use params::{AccountsConfig, SpecType}; use crate::params::{AccountsConfig, SpecType};
#[cfg(not(feature = "accounts"))] #[cfg(not(feature = "accounts"))]
mod accounts { mod accounts {
@ -71,10 +71,10 @@ mod accounts {
#[cfg(feature = "accounts")] #[cfg(feature = "accounts")]
mod accounts { mod accounts {
use super::*; use super::*;
use crate::upgrade::upgrade_key_location;
use std::str::FromStr; use std::str::FromStr;
use upgrade::upgrade_key_location;
pub use accounts::AccountProvider; pub use crate::accounts::AccountProvider;
/// Pops along with error messages when a password is missing or invalid. /// Pops along with error messages when a password is missing or invalid.
const VERIFY_PASSWORD_HINT: &str = "Make sure valid password is present in files passed using `--password` or in the configuration file."; const VERIFY_PASSWORD_HINT: &str = "Make sure valid password is present in files passed using `--password` or in the configuration file.";
@ -87,7 +87,7 @@ mod accounts {
cfg: AccountsConfig, cfg: AccountsConfig,
passwords: &[Password], passwords: &[Password],
) -> Result<AccountProvider, String> { ) -> Result<AccountProvider, String> {
use accounts::AccountProviderSettings; use crate::accounts::AccountProviderSettings;
use ethstore::{accounts_dir::RootDiskDirectory, EthStore}; use ethstore::{accounts_dir::RootDiskDirectory, EthStore};
let path = dirs.keys_path(data_dir); let path = dirs.keys_path(data_dir);

View File

@ -16,10 +16,18 @@
use std::{fs, io, sync::Arc, time::Instant}; use std::{fs, io, sync::Arc, time::Instant};
use crate::{
bytes::ToPretty,
cache::CacheConfig,
db,
hash::{keccak, KECCAK_NULL_RLP},
helpers::{execute_upgrades, to_client_config},
informant::{FullNodeInformantData, Informant, MillisecondDuration},
params::{fatdb_switch_to_bool, tracing_switch_to_bool, Pruning, SpecType, Switch},
types::data_format::DataFormat,
user_defaults::UserDefaults,
};
use ansi_term::Colour; use ansi_term::Colour;
use bytes::ToPretty;
use cache::CacheConfig;
use db;
use dir::Directories; use dir::Directories;
use ethcore::{ use ethcore::{
client::{ client::{
@ -31,12 +39,6 @@ use ethcore::{
}; };
use ethcore_service::ClientService; use ethcore_service::ClientService;
use ethereum_types::{Address, H256, U256}; use ethereum_types::{Address, H256, U256};
use hash::{keccak, KECCAK_NULL_RLP};
use helpers::{execute_upgrades, to_client_config};
use informant::{FullNodeInformantData, Informant, MillisecondDuration};
use params::{fatdb_switch_to_bool, tracing_switch_to_bool, Pruning, SpecType, Switch};
use types::data_format::DataFormat;
use user_defaults::UserDefaults;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub enum BlockchainCmd { pub enum BlockchainCmd {

View File

@ -14,9 +14,16 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>. // along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
use crate::{
bytes::Bytes,
cli::{Args, ArgsError},
hash::keccak,
metrics::MetricsConfiguration,
miner::pool,
sync::{self, validate_node_url, NetworkConfiguration},
};
use ansi_term::Colour; use ansi_term::Colour;
use bytes::Bytes;
use cli::{Args, ArgsError};
use crypto::publickey::{Public, Secret}; use crypto::publickey::{Public, Secret};
use ethcore::{ use ethcore::{
client::VMType, client::VMType,
@ -25,9 +32,7 @@ use ethcore::{
verification::queue::VerifierSettings, verification::queue::VerifierSettings,
}; };
use ethereum_types::{Address, H256, U256}; use ethereum_types::{Address, H256, U256};
use hash::keccak;
use metrics::MetricsConfiguration;
use miner::pool;
use num_cpus; use num_cpus;
use parity_version::{version, version_data}; use parity_version::{version, version_data};
use std::{ use std::{
@ -40,35 +45,37 @@ use std::{
path::PathBuf, path::PathBuf,
time::Duration, time::Duration,
}; };
use sync::{self, validate_node_url, NetworkConfiguration};
use account::{AccountCmd, ImportAccounts, ListAccounts, NewAccount}; use crate::{
use blockchain::{ account::{AccountCmd, ImportAccounts, ListAccounts, NewAccount},
BlockchainCmd, ExportBlockchain, ExportState, ImportBlockchain, KillBlockchain, ResetBlockchain, blockchain::{
BlockchainCmd, ExportBlockchain, ExportState, ImportBlockchain, KillBlockchain,
ResetBlockchain,
},
cache::CacheConfig,
helpers::{
parity_ipc_path, to_address, to_addresses, to_block_id, to_bootnodes, to_duration, to_mode,
to_pending_set, to_price, to_queue_penalization, to_queue_strategy, to_u256,
},
network::IpFilter,
params::{AccountsConfig, GasPricerConfig, MinerExtras, ResealPolicy, SpecType},
presale::ImportWallet,
rpc::{HttpConfiguration, IpcConfiguration, WsConfiguration},
run::RunCmd,
secretstore::{
Configuration as SecretStoreConfiguration, ContractAddress as SecretStoreContractAddress,
NodeSecretKey,
},
snapshot::{self, SnapshotCommand},
types::data_format::DataFormat,
}; };
use cache::CacheConfig;
use dir::{ use dir::{
self, default_data_path, default_local_path, self, default_data_path, default_local_path,
helpers::{replace_home, replace_home_and_local}, helpers::{replace_home, replace_home_and_local},
Directories, Directories,
}; };
use ethcore_logger::Config as LogConfig; use ethcore_logger::Config as LogConfig;
use helpers::{
parity_ipc_path, to_address, to_addresses, to_block_id, to_bootnodes, to_duration, to_mode,
to_pending_set, to_price, to_queue_penalization, to_queue_strategy, to_u256,
};
use network::IpFilter;
use params::{AccountsConfig, GasPricerConfig, MinerExtras, ResealPolicy, SpecType};
use parity_rpc::NetworkSettings; use parity_rpc::NetworkSettings;
use presale::ImportWallet;
use rpc::{HttpConfiguration, IpcConfiguration, WsConfiguration};
use run::RunCmd;
use secretstore::{
Configuration as SecretStoreConfiguration, ContractAddress as SecretStoreContractAddress,
NodeSecretKey,
};
use snapshot::{self, SnapshotCommand};
use types::data_format::DataFormat;
const DEFAULT_MAX_PEERS: u16 = 50; const DEFAULT_MAX_PEERS: u16 = 50;
const DEFAULT_MIN_PEERS: u16 = 25; const DEFAULT_MIN_PEERS: u16 = 25;
@ -166,7 +173,7 @@ impl Configuration {
let cmd = if self.args.flag_version { let cmd = if self.args.flag_version {
Cmd::Version Cmd::Version
} else if self.args.cmd_signer { } else if self.args.cmd_signer {
let authfile = ::signer::codes_path(&ws_conf.signer_path); let authfile = crate::signer::codes_path(&ws_conf.signer_path);
if self.args.cmd_signer_new_token { if self.args.cmd_signer_new_token {
Cmd::SignerToken(ws_conf, logger_config.clone()) Cmd::SignerToken(ws_conf, logger_config.clone())
@ -1243,23 +1250,25 @@ fn into_secretstore_service_contract_address(
mod tests { mod tests {
use std::{fs::File, io::Write, str::FromStr}; use std::{fs::File, io::Write, str::FromStr};
use account::{AccountCmd, ImportAccounts, ListAccounts, NewAccount}; use crate::{
use blockchain::{BlockchainCmd, ExportBlockchain, ExportState, ImportBlockchain}; account::{AccountCmd, ImportAccounts, ListAccounts, NewAccount},
use cli::Args; blockchain::{BlockchainCmd, ExportBlockchain, ExportState, ImportBlockchain},
cli::Args,
helpers::default_network_config,
miner::pool::PrioritizationStrategy,
params::SpecType,
presale::ImportWallet,
rpc::WsConfiguration,
rpc_apis::ApiSet,
run::RunCmd,
types::{data_format::DataFormat, ids::BlockId},
};
use dir::Directories; use dir::Directories;
use ethcore::{client::VMType, miner::MinerOptions}; use ethcore::{client::VMType, miner::MinerOptions};
use helpers::default_network_config;
use miner::pool::PrioritizationStrategy;
use params::SpecType;
use parity_rpc::NetworkSettings; use parity_rpc::NetworkSettings;
use presale::ImportWallet;
use rpc::WsConfiguration;
use rpc_apis::ApiSet;
use run::RunCmd;
use tempdir::TempDir; use tempdir::TempDir;
use types::{data_format::DataFormat, ids::BlockId};
use network::{AllowIP, IpFilter}; use crate::network::{AllowIP, IpFilter};
extern crate ipnetwork; extern crate ipnetwork;
use self::ipnetwork::IpNetwork; use self::ipnetwork::IpNetwork;

View File

@ -14,8 +14,13 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>. // along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
use cache::CacheConfig; use crate::{
use db::migrate; cache::CacheConfig,
db::migrate,
miner::pool::PrioritizationStrategy,
sync::{self, validate_node_url},
upgrade::{upgrade, upgrade_data_paths},
};
use dir::{helpers::replace_home, DatabaseDirectories}; use dir::{helpers::replace_home, DatabaseDirectories};
use ethcore::{ use ethcore::{
client::{BlockId, ClientConfig, DatabaseCompactionProfile, Mode, VMType, VerifierType}, client::{BlockId, ClientConfig, DatabaseCompactionProfile, Mode, VMType, VerifierType},
@ -24,7 +29,6 @@ use ethcore::{
use ethereum_types::{Address, U256}; use ethereum_types::{Address, U256};
use ethkey::Password; use ethkey::Password;
use journaldb::Algorithm; use journaldb::Algorithm;
use miner::pool::PrioritizationStrategy;
use std::{ use std::{
collections::HashSet, collections::HashSet,
fs::File, fs::File,
@ -32,8 +36,6 @@ use std::{
io::{BufRead, BufReader, Write}, io::{BufRead, BufReader, Write},
time::Duration, time::Duration,
}; };
use sync::{self, validate_node_url};
use upgrade::{upgrade, upgrade_data_paths};
pub fn to_duration(s: &str) -> Result<Duration, String> { pub fn to_duration(s: &str) -> Result<Duration, String> {
to_seconds(s).map(Duration::from_secs) to_seconds(s).map(Duration::from_secs)
@ -223,9 +225,9 @@ pub fn to_bootnodes(bootnodes: &Option<String>) -> Result<Vec<String>, String> {
} }
#[cfg(test)] #[cfg(test)]
pub fn default_network_config() -> ::sync::NetworkConfiguration { pub fn default_network_config() -> crate::sync::NetworkConfiguration {
use super::network::IpFilter; use super::network::IpFilter;
use sync::NetworkConfiguration; use crate::sync::NetworkConfiguration;
NetworkConfiguration { NetworkConfiguration {
config_path: Some(replace_home(&::dir::default_data_path(), "$BASE/network")), config_path: Some(replace_home(&::dir::default_data_path(), "$BASE/network")),
net_config_path: None, net_config_path: None,

View File

@ -29,6 +29,11 @@ use std::{
time::{Duration, Instant}, time::{Duration, Instant},
}; };
use crate::{
io::{IoContext, IoHandler, TimerToken},
sync::{ManageNetwork, SyncProvider},
types::BlockNumber,
};
use atty; use atty;
use ethcore::{ use ethcore::{
client::{ client::{
@ -37,12 +42,9 @@ use ethcore::{
}, },
snapshot::{service::Service as SnapshotService, RestorationStatus, SnapshotService as SS}, snapshot::{service::Service as SnapshotService, RestorationStatus, SnapshotService as SS},
}; };
use io::{IoContext, IoHandler, TimerToken};
use number_prefix::{binary_prefix, Prefixed, Standalone}; use number_prefix::{binary_prefix, Prefixed, Standalone};
use parity_rpc::{informant::RpcStats, is_major_importing_or_waiting}; use parity_rpc::{informant::RpcStats, is_major_importing_or_waiting};
use parking_lot::{Mutex, RwLock}; use parking_lot::{Mutex, RwLock};
use sync::{ManageNetwork, SyncProvider};
use types::BlockNumber;
/// Format byte counts to standard denominations. /// Format byte counts to standard denominations.
pub fn format_bytes(b: usize) -> String { pub fn format_bytes(b: usize) -> String {

View File

@ -114,9 +114,11 @@ mod user_defaults;
use std::{fs::File, io::BufReader, sync::Arc}; use std::{fs::File, io::BufReader, sync::Arc};
use cli::Args; use crate::{
use configuration::{Cmd, Execute}; cli::Args,
use hash::keccak_buffer; configuration::{Cmd, Execute},
hash::keccak_buffer,
};
#[cfg(feature = "memory_profiling")] #[cfg(feature = "memory_profiling")]
use std::alloc::System; use std::alloc::System;

View File

@ -16,14 +16,16 @@
use std::sync::{mpsc, Arc}; use std::sync::{mpsc, Arc};
use crate::{
sync::{self, ConnectionFilter, NetworkConfiguration, Params, SyncConfig},
types::BlockNumber,
};
use ethcore::{client::BlockChainClient, snapshot::SnapshotService}; use ethcore::{client::BlockChainClient, snapshot::SnapshotService};
use std::collections::BTreeSet; use std::collections::BTreeSet;
use sync::{self, ConnectionFilter, NetworkConfiguration, Params, SyncConfig};
use types::BlockNumber;
pub use crate::sync::{EthSync, ManageNetwork, SyncProvider};
pub use ethcore::client::ChainNotify; pub use ethcore::client::ChainNotify;
use ethcore_logger::Config as LogConfig; use ethcore_logger::Config as LogConfig;
pub use sync::{EthSync, ManageNetwork, SyncProvider};
pub type SyncModules = ( pub type SyncModules = (
Arc<dyn SyncProvider>, Arc<dyn SyncProvider>,

View File

@ -16,6 +16,13 @@
use std::{collections::HashSet, fmt, fs, num::NonZeroU32, str, time::Duration}; use std::{collections::HashSet, fmt, fs, num::NonZeroU32, str, time::Duration};
use crate::{
miner::{
gas_price_calibrator::{GasPriceCalibrator, GasPriceCalibratorOptions},
gas_pricer::GasPricer,
},
user_defaults::UserDefaults,
};
use ethcore::{ use ethcore::{
client::Mode, client::Mode,
ethereum, ethereum,
@ -24,13 +31,8 @@ use ethcore::{
use ethereum_types::{Address, U256}; use ethereum_types::{Address, U256};
use fetch::Client as FetchClient; use fetch::Client as FetchClient;
use journaldb::Algorithm; use journaldb::Algorithm;
use miner::{
gas_price_calibrator::{GasPriceCalibrator, GasPriceCalibratorOptions},
gas_pricer::GasPricer,
};
use parity_runtime::Executor; use parity_runtime::Executor;
use parity_version::version_data; use parity_version::version_data;
use user_defaults::UserDefaults;
use crate::configuration; use crate::configuration;
@ -374,8 +376,8 @@ pub fn mode_switch_to_bool(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{tracing_switch_to_bool, Pruning, ResealPolicy, SpecType, Switch}; use super::{tracing_switch_to_bool, Pruning, ResealPolicy, SpecType, Switch};
use crate::user_defaults::UserDefaults;
use journaldb::Algorithm; use journaldb::Algorithm;
use user_defaults::UserDefaults;
#[test] #[test]
fn test_spec_type_parsing() { fn test_spec_type_parsing() {

View File

@ -14,11 +14,14 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>. // along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
use crate::{
helpers::{password_from_file, password_prompt},
params::SpecType,
};
use crypto::publickey; use crypto::publickey;
use ethkey::Password; use ethkey::Password;
use ethstore::PresaleWallet; use ethstore::PresaleWallet;
use helpers::{password_from_file, password_prompt};
use params::SpecType;
use std::num::NonZeroU32; use std::num::NonZeroU32;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
@ -45,6 +48,7 @@ pub fn execute(cmd: ImportWallet) -> Result<String, String> {
} }
#[cfg(feature = "accounts")] #[cfg(feature = "accounts")]
pub fn import_account(cmd: &ImportWallet, kp: publickey::KeyPair, password: Password) { pub fn import_account(cmd: &ImportWallet, kp: publickey::KeyPair, password: Password) {
use accounts::{AccountProvider, AccountProviderSettings}; use accounts::{AccountProvider, AccountProviderSettings};
use ethstore::{accounts_dir::RootDiskDirectory, EthStore}; use ethstore::{accounts_dir::RootDiskDirectory, EthStore};

View File

@ -16,8 +16,11 @@
use std::{collections::HashSet, io, path::PathBuf, sync::Arc}; use std::{collections::HashSet, io, path::PathBuf, sync::Arc};
use crate::{
helpers::parity_ipc_path,
rpc_apis::{self, ApiSet},
};
use dir::{default_data_path, helpers::replace_home}; use dir::{default_data_path, helpers::replace_home};
use helpers::parity_ipc_path;
use jsonrpc_core::MetaIoHandler; use jsonrpc_core::MetaIoHandler;
use parity_rpc::{ use parity_rpc::{
self as rpc, self as rpc,
@ -25,7 +28,6 @@ use parity_rpc::{
DomainsValidation, Metadata, DomainsValidation, Metadata,
}; };
use parity_runtime::Executor; use parity_runtime::Executor;
use rpc_apis::{self, ApiSet};
pub use parity_rpc::{HttpServer, IpcServer, RequestMiddleware}; pub use parity_rpc::{HttpServer, IpcServer, RequestMiddleware};
//pub use parity_rpc::ws::Server as WsServer; //pub use parity_rpc::ws::Server as WsServer;
@ -182,7 +184,7 @@ pub fn new_ws<D: rpc_apis::Dependencies>(
let signer_path; let signer_path;
let path = match conf.support_token_api { let path = match conf.support_token_api {
true => { true => {
signer_path = ::signer::codes_path(&conf.signer_path); signer_path = crate::signer::codes_path(&conf.signer_path);
Some(signer_path.as_path()) Some(signer_path.as_path())
} }
false => None, false => None,

View File

@ -23,12 +23,15 @@ use std::{
pub use parity_rpc::signer::SignerService; pub use parity_rpc::signer::SignerService;
use account_utils::{self, AccountProvider}; use crate::{
account_utils::{self, AccountProvider},
miner::external::ExternalMiner,
sync::{ManageNetwork, SyncProvider},
};
use ethcore::{client::Client, miner::Miner, snapshot::SnapshotService}; use ethcore::{client::Client, miner::Miner, snapshot::SnapshotService};
use ethcore_logger::RotatingLogger; use ethcore_logger::RotatingLogger;
use fetch::Client as FetchClient; use fetch::Client as FetchClient;
use jsonrpc_core::{self as core, MetaIoHandler}; use jsonrpc_core::{self as core, MetaIoHandler};
use miner::external::ExternalMiner;
use parity_rpc::{ use parity_rpc::{
dispatch::FullDispatcher, dispatch::FullDispatcher,
informant::{ActivityNotifier, ClientNotifier}, informant::{ActivityNotifier, ClientNotifier},
@ -36,7 +39,6 @@ use parity_rpc::{
}; };
use parity_runtime::Executor; use parity_runtime::Executor;
use parking_lot::Mutex; use parking_lot::Mutex;
use sync::{ManageNetwork, SyncProvider};
#[derive(Debug, PartialEq, Clone, Eq, Hash)] #[derive(Debug, PartialEq, Clone, Eq, Hash)]
pub enum Api { pub enum Api {

View File

@ -22,10 +22,24 @@ use std::{
time::{Duration, Instant}, time::{Duration, Instant},
}; };
use account_utils; use crate::{
account_utils,
cache::CacheConfig,
db,
helpers::{execute_upgrades, passwords_from_files, to_client_config},
informant::{FullNodeInformantData, Informant},
metrics::{start_prometheus_metrics, MetricsConfiguration},
miner::{external::ExternalMiner, work_notify::WorkPoster},
modules,
params::{
fatdb_switch_to_bool, mode_switch_to_bool, tracing_switch_to_bool, AccountsConfig,
GasPricerConfig, MinerExtras, Pruning, SpecType, Switch,
},
rpc, rpc_apis, secretstore, signer,
sync::{self, SyncConfig},
user_defaults::UserDefaults,
};
use ansi_term::Colour; use ansi_term::Colour;
use cache::CacheConfig;
use db;
use dir::{DatabaseDirectories, Directories}; use dir::{DatabaseDirectories, Directories};
use ethcore::{ use ethcore::{
client::{BlockChainClient, BlockInfo, Client, DatabaseCompactionProfile, Mode, VMType}, client::{BlockChainClient, BlockInfo, Client, DatabaseCompactionProfile, Mode, VMType},
@ -36,30 +50,15 @@ use ethcore::{
use ethcore_logger::{Config as LogConfig, RotatingLogger}; use ethcore_logger::{Config as LogConfig, RotatingLogger};
use ethcore_service::ClientService; use ethcore_service::ClientService;
use ethereum_types::{H256, U64}; use ethereum_types::{H256, U64};
use helpers::{execute_upgrades, passwords_from_files, to_client_config};
use informant::{FullNodeInformantData, Informant};
use journaldb::Algorithm; use journaldb::Algorithm;
use jsonrpc_core; use jsonrpc_core;
use metrics::{start_prometheus_metrics, MetricsConfiguration};
use miner::{external::ExternalMiner, work_notify::WorkPoster};
use modules;
use node_filter::NodeFilter; use node_filter::NodeFilter;
use params::{
fatdb_switch_to_bool, mode_switch_to_bool, tracing_switch_to_bool, AccountsConfig,
GasPricerConfig, MinerExtras, Pruning, SpecType, Switch,
};
use parity_rpc::{ use parity_rpc::{
informant, is_major_importing, FutureOutput, FutureResponse, FutureResult, Metadata, informant, is_major_importing, FutureOutput, FutureResponse, FutureResult, Metadata,
NetworkSettings, Origin, PubSubSession, NetworkSettings, Origin, PubSubSession,
}; };
use parity_runtime::Runtime; use parity_runtime::Runtime;
use parity_version::version; use parity_version::version;
use rpc;
use rpc_apis;
use secretstore;
use signer;
use sync::{self, SyncConfig};
use user_defaults::UserDefaults;
// How often we attempt to take a snapshot: only snapshot on blocknumbers that are multiples of this. // How often we attempt to take a snapshot: only snapshot on blocknumbers that are multiples of this.
const SNAPSHOT_PERIOD: u64 = 20000; const SNAPSHOT_PERIOD: u64 = 20000;
@ -120,8 +119,8 @@ struct FullNodeInfo {
miner: Option<Arc<Miner>>, // TODO: only TXQ needed, just use that after decoupling. miner: Option<Arc<Miner>>, // TODO: only TXQ needed, just use that after decoupling.
} }
impl ::local_store::NodeInfo for FullNodeInfo { impl crate::local_store::NodeInfo for FullNodeInfo {
fn pending_transactions(&self) -> Vec<::types::transaction::PendingTransaction> { fn pending_transactions(&self) -> Vec<crate::types::transaction::PendingTransaction> {
let miner = match self.miner.as_ref() { let miner = match self.miner.as_ref() {
Some(m) => m, Some(m) => m,
None => return Vec::new(), None => return Vec::new(),
@ -131,7 +130,7 @@ impl ::local_store::NodeInfo for FullNodeInfo {
.local_transactions() .local_transactions()
.values() .values()
.filter_map(|status| match *status { .filter_map(|status| match *status {
::miner::pool::local_transactions::Status::Pending(ref tx) => { crate::miner::pool::local_transactions::Status::Pending(ref tx) => {
Some(tx.pending().clone()) Some(tx.pending().clone())
} }
_ => None, _ => None,
@ -387,7 +386,7 @@ pub fn execute(cmd: RunCmd, logger: Arc<RotatingLogger>) -> Result<RunningClient
}, },
}; };
let store = ::local_store::create( let store = crate::local_store::create(
db.key_value().clone(), db.key_value().clone(),
::ethcore_db::COL_NODE_INFO, ::ethcore_db::COL_NODE_INFO,
node_info, node_info,
@ -461,7 +460,7 @@ pub fn execute(cmd: RunCmd, logger: Arc<RotatingLogger>) -> Result<RunningClient
.is_ok() .is_ok()
{ {
let task = let task =
::sync::PriorityTask::PropagateTransactions(Instant::now(), is_ready.clone()); crate::sync::PriorityTask::PropagateTransactions(Instant::now(), is_ready.clone());
// we ignore error cause it means that we are closing // we ignore error cause it means that we are closing
let _ = tx.lock().send(task); let _ = tx.lock().send(task);
} }

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>. // along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
use account_utils::AccountProvider; use crate::{account_utils::AccountProvider, sync::SyncProvider};
use crypto::publickey::{Public, Secret}; use crypto::publickey::{Public, Secret};
use dir::{default_data_path, helpers::replace_home}; use dir::{default_data_path, helpers::replace_home};
use ethcore::{client::Client, miner::Miner}; use ethcore::{client::Client, miner::Miner};
@ -22,7 +22,6 @@ use ethereum_types::Address;
use ethkey::Password; use ethkey::Password;
use parity_runtime::Executor; use parity_runtime::Executor;
use std::{collections::BTreeMap, sync::Arc}; use std::{collections::BTreeMap, sync::Arc};
use sync::SyncProvider;
/// This node secret key. /// This node secret key.
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone)]

View File

@ -19,12 +19,10 @@ use std::{
path::{Path, PathBuf}, path::{Path, PathBuf},
}; };
use crate::{path::restrict_permissions_owner, rpc, rpc_apis};
use ansi_term::Colour::White; use ansi_term::Colour::White;
use ethcore_logger::Config as LogConfig; use ethcore_logger::Config as LogConfig;
use parity_rpc; use parity_rpc;
use path::restrict_permissions_owner;
use rpc;
use rpc_apis;
pub const CODES_FILENAME: &'static str = "authcodes"; pub const CODES_FILENAME: &'static str = "authcodes";

View File

@ -22,6 +22,7 @@ use std::{
time::Duration, time::Duration,
}; };
use crate::{hash::keccak, types::ids::BlockId};
use ethcore::{ use ethcore::{
client::{DatabaseCompactionProfile, Mode, VMType}, client::{DatabaseCompactionProfile, Mode, VMType},
miner::Miner, miner::Miner,
@ -32,15 +33,15 @@ use ethcore::{
}, },
}; };
use ethcore_service::ClientService; use ethcore_service::ClientService;
use hash::keccak;
use types::ids::BlockId;
use cache::CacheConfig; use crate::{
use db; cache::CacheConfig,
db,
helpers::{execute_upgrades, to_client_config},
params::{fatdb_switch_to_bool, tracing_switch_to_bool, Pruning, SpecType, Switch},
user_defaults::UserDefaults,
};
use dir::Directories; use dir::Directories;
use helpers::{execute_upgrades, to_client_config};
use params::{fatdb_switch_to_bool, tracing_switch_to_bool, Pruning, SpecType, Switch};
use user_defaults::UserDefaults;
/// Kinds of snapshot commands. /// Kinds of snapshot commands.
#[derive(Debug, PartialEq, Clone, Copy)] #[derive(Debug, PartialEq, Clone, Copy)]
@ -303,7 +304,7 @@ impl SnapshotCommand {
let cur_size = p.size(); let cur_size = p.size();
if cur_size != last_size { if cur_size != last_size {
last_size = cur_size; last_size = cur_size;
let bytes = ::informant::format_bytes(cur_size as usize); let bytes = crate::informant::format_bytes(cur_size as usize);
info!( info!(
"Snapshot: {} accounts {} blocks {}", "Snapshot: {} accounts {} blocks {}",
p.accounts(), p.accounts(),

View File

@ -2,9 +2,14 @@
description = "Parity Ethereum Common Types" description = "Parity Ethereum Common Types"
name = "common-types" name = "common-types"
version = "0.1.0" version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"] edition = "2018"
authors = [
"Gnosis Ltd <openethereum@gnosis.io>",
"Parity Technologies <admin@parity.io>",
]
[dependencies] [dependencies]
ethkey = { path = "../../accounts/ethkey" }
ethereum-types = "0.9.2" ethereum-types = "0.9.2"
keccak-hash = "0.5.0" keccak-hash = "0.5.0"
parity-bytes = "0.1" parity-bytes = "0.1"
@ -16,6 +21,8 @@ unexpected = { path = "../../util/unexpected" }
serde = "1.0" serde = "1.0"
serde_json = "1.0" serde_json = "1.0"
serde_repr = "0.1" serde_repr = "0.1"
hex = "0.4.3"
inflate = "0.4.5"
[dev-dependencies] [dev-dependencies]
rustc-hex = "1.0" rustc-hex = "1.0"

View File

@ -16,7 +16,7 @@
//! Diff between two accounts. //! Diff between two accounts.
use bytes::Bytes; use crate::bytes::Bytes;
use ethereum_types::{H256, U256}; use ethereum_types::{H256, U256};
use std::{cmp::*, collections::BTreeMap, fmt}; use std::{cmp::*, collections::BTreeMap, fmt};
@ -141,7 +141,7 @@ fn interpreted_hash(u: &H256) -> String {
impl fmt::Display for AccountDiff { impl fmt::Display for AccountDiff {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use bytes::ToPretty; use crate::bytes::ToPretty;
match self.nonce { match self.nonce {
Diff::Born(ref x) => write!(f, " non {}", x)?, Diff::Born(ref x) => write!(f, " non {}", x)?,

View File

@ -31,11 +31,13 @@
//! `ExecutedBlock` is an underlaying data structure used by all structs above to store block //! `ExecutedBlock` is an underlaying data structure used by all structs above to store block
//! related info. //! related info.
use bytes::Bytes; use crate::bytes::Bytes;
use header::Header; use crate::{
header::Header,
transaction::{TypedTransaction, UnverifiedTransaction},
};
use rlp::{Decodable, DecoderError, Rlp, RlpStream}; use rlp::{Decodable, DecoderError, Rlp, RlpStream};
use transaction::{TypedTransaction, UnverifiedTransaction};
/// A block, encoded as it is on the block chain. /// A block, encoded as it is on the block chain.
#[derive(Default, Debug, Clone, PartialEq)] #[derive(Default, Debug, Clone, PartialEq)]

View File

@ -18,9 +18,8 @@
use std::fmt; use std::fmt;
use crate::{security_level::SecurityLevel, BlockNumber};
use ethereum_types::{H256, U256}; use ethereum_types::{H256, U256};
use security_level::SecurityLevel;
use BlockNumber;
/// Information about the blockchain gathered together. /// Information about the blockchain gathered together.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]

View File

@ -23,15 +23,18 @@
//! When the entirety of the object is needed, it's better to upgrade it to a fully //! When the entirety of the object is needed, it's better to upgrade it to a fully
//! decoded object where parts like the hash can be saved. //! decoded object where parts like the hash can be saved.
use block::Block as FullBlock; use crate::{
block::Block as FullBlock,
hash::keccak,
header::Header as FullHeader,
transaction::UnverifiedTransaction,
views::{self, BlockView, BodyView, HeaderView},
BlockNumber,
};
use ethereum_types::{Address, Bloom, H256, U256}; use ethereum_types::{Address, Bloom, H256, U256};
use hash::keccak;
use header::Header as FullHeader;
use parity_util_mem::MallocSizeOf; use parity_util_mem::MallocSizeOf;
use rlp::{self, Rlp, RlpStream}; use rlp::{self, Rlp, RlpStream};
use transaction::UnverifiedTransaction;
use views::{self, BlockView, BodyView, HeaderView};
use BlockNumber;
/// Owning header view. /// Owning header view.
#[derive(Debug, Clone, PartialEq, Eq, MallocSizeOf)] #[derive(Debug, Clone, PartialEq, Eq, MallocSizeOf)]

View File

@ -16,9 +16,8 @@
//! Blockchain filter //! Blockchain filter
use crate::{ids::BlockId, log_entry::LogEntry};
use ethereum_types::{Address, Bloom, BloomInput, H256}; use ethereum_types::{Address, Bloom, BloomInput, H256};
use ids::BlockId;
use log_entry::LogEntry;
/// Blockchain Filter. /// Blockchain Filter.
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
@ -119,10 +118,8 @@ impl Filter {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{filter::Filter, ids::BlockId, log_entry::LogEntry};
use ethereum_types::{Bloom, H160, H256}; use ethereum_types::{Bloom, H160, H256};
use filter::Filter;
use ids::BlockId;
use log_entry::LogEntry;
use std::str::FromStr; use std::str::FromStr;
#[test] #[test]

View File

@ -16,12 +16,14 @@
//! Block header. //! Block header.
use bytes::Bytes; use crate::{
bytes::Bytes,
hash::{keccak, KECCAK_EMPTY_LIST_RLP, KECCAK_NULL_RLP},
BlockNumber,
};
use ethereum_types::{Address, Bloom, H256, U256}; use ethereum_types::{Address, Bloom, H256, U256};
use hash::{keccak, KECCAK_EMPTY_LIST_RLP, KECCAK_NULL_RLP};
use parity_util_mem::MallocSizeOf; use parity_util_mem::MallocSizeOf;
use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}; use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream};
use BlockNumber;
/// Semantic boolean for when a seal/signature is included. /// Semantic boolean for when a seal/signature is included.
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
@ -307,8 +309,8 @@ impl Header {
} }
/// Encode the header, getting a type-safe wrapper around the RLP. /// Encode the header, getting a type-safe wrapper around the RLP.
pub fn encoded(&self) -> ::encoded::Header { pub fn encoded(&self) -> crate::encoded::Header {
::encoded::Header::new(self.rlp(Seal::With)) crate::encoded::Header::new(self.rlp(Seal::With))
} }
/// Get the RLP representation of this Header. /// Get the RLP representation of this Header.

View File

@ -16,8 +16,8 @@
//! Unique identifiers. //! Unique identifiers.
use crate::BlockNumber;
use ethereum_types::H256; use ethereum_types::H256;
use BlockNumber;
/// Uniquely identifies block. /// Uniquely identifies block.
#[derive(Debug, PartialEq, Copy, Clone, Hash, Eq)] #[derive(Debug, PartialEq, Copy, Clone, Hash, Eq)]

View File

@ -34,20 +34,15 @@
#![allow(missing_docs)] #![allow(missing_docs)]
#![warn(unused_extern_crates)] #![warn(unused_extern_crates)]
extern crate ethereum_types; pub use keccak_hash as hash;
extern crate keccak_hash as hash; pub use parity_bytes as bytes;
extern crate parity_bytes as bytes; pub use parity_crypto as crypto;
extern crate parity_crypto as crypto;
extern crate parity_util_mem;
extern crate rlp;
extern crate serde_repr;
extern crate unexpected;
#[macro_use] #[macro_use]
extern crate rlp_derive; extern crate rlp_derive;
#[cfg(test)] #[cfg(test)]
extern crate rustc_hex; pub use rustc_hex;
#[macro_use] #[macro_use]
pub mod views; pub mod views;

View File

@ -16,13 +16,11 @@
//! Log entry type definition. //! Log entry type definition.
use bytes::Bytes; use crate::{bytes::Bytes, BlockNumber};
use ethereum_types::{Address, Bloom, BloomInput, H256}; use ethereum_types::{Address, Bloom, BloomInput, H256};
use parity_util_mem::MallocSizeOf; use parity_util_mem::MallocSizeOf;
use std::ops::Deref; use std::ops::Deref;
use BlockNumber;
/// A record of execution for a `LOG` operation. /// A record of execution for a `LOG` operation.
#[derive(Default, Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable, MallocSizeOf)] #[derive(Default, Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable, MallocSizeOf)]
pub struct LogEntry { pub struct LogEntry {

View File

@ -22,8 +22,10 @@ use parity_util_mem::MallocSizeOf;
use rlp::{DecoderError, Rlp, RlpStream}; use rlp::{DecoderError, Rlp, RlpStream};
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use log_entry::{LocalizedLogEntry, LogEntry}; use crate::{
use BlockNumber; log_entry::{LocalizedLogEntry, LogEntry},
BlockNumber,
};
/// Transaction outcome store in the receipt. /// Transaction outcome store in the receipt.
#[derive(Debug, Clone, PartialEq, Eq, MallocSizeOf)] #[derive(Debug, Clone, PartialEq, Eq, MallocSizeOf)]
@ -296,8 +298,8 @@ pub struct LocalizedReceipt {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{LegacyReceipt, TransactionOutcome, TypedReceipt, TypedTxId}; use super::{LegacyReceipt, TransactionOutcome, TypedReceipt, TypedTxId};
use crate::log_entry::LogEntry;
use ethereum_types::{H160, H256}; use ethereum_types::{H160, H256};
use log_entry::LogEntry;
use std::str::FromStr; use std::str::FromStr;
#[test] #[test]

View File

@ -16,7 +16,7 @@
//! Indication of how secure the chain is. //! Indication of how secure the chain is.
use BlockNumber; use crate::BlockNumber;
/// Indication of how secure the chain is. /// Indication of how secure the chain is.
#[derive(Debug, PartialEq, Copy, Clone, Hash, Eq)] #[derive(Debug, PartialEq, Copy, Clone, Hash, Eq)]

View File

@ -16,7 +16,7 @@
//! Snapshot manifest type definition //! Snapshot manifest type definition
use bytes::Bytes; use crate::bytes::Bytes;
use ethereum_types::H256; use ethereum_types::H256;
use rlp::{DecoderError, Rlp, RlpStream}; use rlp::{DecoderError, Rlp, RlpStream};

View File

@ -16,7 +16,7 @@
//! State diff module. //! State diff module.
use account_diff::*; use crate::account_diff::*;
use ethereum_types::Address; use ethereum_types::Address;
use std::{collections::BTreeMap, fmt, ops::*}; use std::{collections::BTreeMap, fmt, ops::*};

View File

@ -16,8 +16,8 @@
//! Trace filter related types //! Trace filter related types
use crate::ids::BlockId;
use ethereum_types::Address; use ethereum_types::Address;
use ids::BlockId;
use std::ops::Range; use std::ops::Range;
/// Easy to use trace filter. /// Easy to use trace filter.

View File

@ -16,6 +16,7 @@
use std::{error, fmt}; use std::{error, fmt};
use crate::crypto;
use ethereum_types::U256; use ethereum_types::U256;
use rlp; use rlp;
use unexpected::OutOfBounds; use unexpected::OutOfBounds;

View File

@ -16,10 +16,14 @@
//! Transaction data structure. //! Transaction data structure.
use crypto::publickey::{self, public_to_address, recover, Public, Secret, Signature}; use crate::{
crypto::publickey::{self, public_to_address, recover, Public, Secret, Signature},
hash::keccak,
transaction::error,
};
use ethereum_types::{Address, BigEndianHash, H160, H256, U256}; use ethereum_types::{Address, BigEndianHash, H160, H256, U256};
use hash::keccak;
use parity_util_mem::MallocSizeOf; use parity_util_mem::MallocSizeOf;
use rlp::{self, DecoderError, Rlp, RlpStream}; use rlp::{self, DecoderError, Rlp, RlpStream};
use std::ops::Deref; use std::ops::Deref;
@ -28,8 +32,6 @@ pub type AccessList = Vec<AccessListItem>;
use super::TypedTxId; use super::TypedTxId;
use transaction::error;
type Bytes = Vec<u8>; type Bytes = Vec<u8>;
type BlockNumber = u64; type BlockNumber = u64;
@ -134,7 +136,7 @@ pub struct Transaction {
pub gas: U256, pub gas: U256,
/// Action, can be either call or contract create. /// Action, can be either call or contract create.
pub action: Action, pub action: Action,
/// Transfered value. /// Transfered value.s
pub value: U256, pub value: U256,
/// Transaction data. /// Transaction data.
pub data: Bytes, pub data: Bytes,
@ -430,7 +432,6 @@ impl TypedTransaction {
/// Legacy EIP-86 compatible empty signature. /// Legacy EIP-86 compatible empty signature.
/// This method is used in json tests as well as /// This method is used in json tests as well as
/// signature verification tests. /// signature verification tests.
#[cfg(any(test, feature = "test-helpers"))]
pub fn null_sign(self, chain_id: u64) -> SignedTransaction { pub fn null_sign(self, chain_id: u64) -> SignedTransaction {
SignedTransaction { SignedTransaction {
transaction: UnverifiedTransaction { transaction: UnverifiedTransaction {
@ -566,11 +567,11 @@ impl TypedTransaction {
pub struct SignatureComponents { pub struct SignatureComponents {
/// The V field of the signature; the LS bit described which half of the curve our point falls /// The V field of the signature; the LS bit described which half of the curve our point falls
/// in. It can be 0 or 1. /// in. It can be 0 or 1.
standard_v: u8, pub standard_v: u8,
/// The R field of the signature; helps describe the point on the curve. /// The R field of the signature; helps describe the point on the curve.
r: U256, pub r: U256,
/// The S field of the signature; helps describe the point on the curve. /// The S field of the signature; helps describe the point on the curve.
s: U256, pub s: U256,
} }
impl SignatureComponents { impl SignatureComponents {
@ -594,13 +595,13 @@ impl SignatureComponents {
#[derive(Debug, Clone, Eq, PartialEq, MallocSizeOf)] #[derive(Debug, Clone, Eq, PartialEq, MallocSizeOf)]
pub struct UnverifiedTransaction { pub struct UnverifiedTransaction {
/// Plain Transaction. /// Plain Transaction.
unsigned: TypedTransaction, pub unsigned: TypedTransaction,
/// Transaction signature /// Transaction signature
signature: SignatureComponents, pub signature: SignatureComponents,
/// chain_id recover from signature in legacy transaction. For TypedTransaction it is probably separate field. /// chain_id recover from signature in legacy transaction. For TypedTransaction it is probably separate field.
chain_id: Option<u64>, pub chain_id: Option<u64>,
/// Hash of the transaction /// Hash of the transaction
hash: H256, pub hash: H256,
} }
impl Deref for UnverifiedTransaction { impl Deref for UnverifiedTransaction {
@ -628,7 +629,7 @@ impl UnverifiedTransaction {
} }
/// Used to compute hash of created transactions. /// Used to compute hash of created transactions.
fn compute_hash(mut self) -> UnverifiedTransaction { pub fn compute_hash(mut self) -> UnverifiedTransaction {
let hash = keccak(&*self.encode()); let hash = keccak(&*self.encode());
self.hash = hash; self.hash = hash;
self self
@ -874,8 +875,8 @@ impl From<SignedTransaction> for PendingTransaction {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::hash::keccak;
use ethereum_types::{H160, U256}; use ethereum_types::{H160, U256};
use hash::keccak;
use std::str::FromStr; use std::str::FromStr;
#[test] #[test]

View File

@ -17,12 +17,15 @@
//! View onto block rlp. //! View onto block rlp.
use super::ViewRlp; use super::ViewRlp;
use bytes::Bytes; use crate::{
bytes::Bytes,
hash::keccak,
header::Header,
transaction::{LocalizedTransaction, TypedTransaction, UnverifiedTransaction},
views::{HeaderView, TypedTransactionView},
};
use ethereum_types::H256; use ethereum_types::H256;
use hash::keccak;
use header::Header;
use transaction::{LocalizedTransaction, TypedTransaction, UnverifiedTransaction};
use views::{HeaderView, TypedTransactionView};
/// View onto block rlp. /// View onto block rlp.
pub struct BlockView<'a> { pub struct BlockView<'a> {

View File

@ -17,13 +17,15 @@
//! View onto block body rlp. //! View onto block body rlp.
use super::ViewRlp; use super::ViewRlp;
use bytes::Bytes; use crate::{
bytes::Bytes,
hash::keccak,
header::Header,
transaction::{LocalizedTransaction, TypedTransaction, UnverifiedTransaction},
views::{HeaderView, TypedTransactionView},
BlockNumber,
};
use ethereum_types::H256; use ethereum_types::H256;
use hash::keccak;
use header::Header;
use transaction::{LocalizedTransaction, TypedTransaction, UnverifiedTransaction};
use views::{HeaderView, TypedTransactionView};
use BlockNumber;
/// View onto block rlp. /// View onto block rlp.
pub struct BodyView<'a> { pub struct BodyView<'a> {
@ -184,10 +186,9 @@ impl<'a> BodyView<'a> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::BodyView; use super::BodyView;
use bytes::Bytes; use crate::{bytes::Bytes, views::BlockView};
use rlp::RlpStream; use rlp::RlpStream;
use rustc_hex::FromHex; use rustc_hex::FromHex;
use views::BlockView;
fn block_to_body(block: &[u8]) -> Bytes { fn block_to_body(block: &[u8]) -> Bytes {
let mut body = RlpStream::new_list(2); let mut body = RlpStream::new_list(2);

View File

@ -17,11 +17,9 @@
//! View onto block header rlp //! View onto block header rlp
use super::ViewRlp; use super::ViewRlp;
use bytes::Bytes; use crate::{bytes::Bytes, hash::keccak, BlockNumber};
use ethereum_types::{Address, Bloom, H256, U256}; use ethereum_types::{Address, Bloom, H256, U256};
use hash::keccak;
use rlp::{self}; use rlp::{self};
use BlockNumber;
/// View onto block header rlp. /// View onto block header rlp.
pub struct HeaderView<'a> { pub struct HeaderView<'a> {

View File

@ -16,12 +16,14 @@
//! View onto transaction rlp //! View onto transaction rlp
use crate::transaction::{signature, TypedTxId}; use crate::{
bytes::Bytes,
hash::keccak,
transaction::{signature, TypedTxId},
views::ViewRlp,
};
use super::ViewRlp;
use bytes::Bytes;
use ethereum_types::{H256, U256}; use ethereum_types::{H256, U256};
use hash::keccak;
use rlp::Rlp; use rlp::Rlp;
/// View onto transaction rlp. Assumption is this is part of block. /// View onto transaction rlp. Assumption is this is part of block.

View File

@ -2,7 +2,11 @@
description = "Parity Ethereum JSON Deserialization" description = "Parity Ethereum JSON Deserialization"
name = "ethjson" name = "ethjson"
version = "0.1.0" version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"] edition = "2018"
authors = [
"Gnosis Ltd <openethereum@gnosis.io>",
"Parity Technologies <admin@parity.io>"
]
[dependencies] [dependencies]
common-types = { path = "../ethcore/types", features = ["test-helpers"] } common-types = { path = "../ethcore/types", features = ["test-helpers"] }

View File

@ -16,9 +16,8 @@
//! Blockchain test account deserializer. //! Blockchain test account deserializer.
use bytes::Bytes; use crate::{bytes::Bytes, uint::Uint};
use std::collections::BTreeMap; use std::collections::BTreeMap;
use uint::Uint;
/// Blockchain test account deserializer. /// Blockchain test account deserializer.
#[derive(Debug, PartialEq, Deserialize, Clone)] #[derive(Debug, PartialEq, Deserialize, Clone)]
@ -35,7 +34,7 @@ pub struct Account {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use blockchain::account::Account; use crate::blockchain::account::Account;
use serde_json; use serde_json;
#[test] #[test]

View File

@ -16,8 +16,10 @@
//! Blockchain test block deserializer. //! Blockchain test block deserializer.
use blockchain::{header::Header, transaction::Transaction}; use crate::{
use bytes::Bytes; blockchain::{header::Header, transaction::Transaction},
bytes::Bytes,
};
/// Blockchain test block deserializer. /// Blockchain test block deserializer.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
@ -39,7 +41,7 @@ impl Block {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use blockchain::block::Block; use crate::blockchain::block::Block;
use serde_json; use serde_json;
#[test] #[test]

View File

@ -16,10 +16,12 @@
//! Blockchain deserialization. //! Blockchain deserialization.
use blockchain::{block::Block, header::Header, state::State}; use crate::{
use bytes::Bytes; blockchain::{block::Block, header::Header, state::State},
use hash::H256; bytes::Bytes,
use spec::{Ethereum, ForkSpec, Genesis, Seal}; hash::H256,
spec::{Ethereum, ForkSpec, Genesis, Seal},
};
/// Json Block test possible engine kind. /// Json Block test possible engine kind.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
@ -93,7 +95,7 @@ impl BlockChain {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use blockchain::blockchain::BlockChain; use crate::blockchain::blockchain::BlockChain;
use serde_json; use serde_json;
#[test] #[test]

View File

@ -16,9 +16,11 @@
//! Blockchain test header deserializer. //! Blockchain test header deserializer.
use bytes::Bytes; use crate::{
use hash::{Address, Bloom, H256, H64}; bytes::Bytes,
use uint::Uint; hash::{Address, Bloom, H256, H64},
uint::Uint,
};
/// Blockchain test header deserializer. /// Blockchain test header deserializer.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
@ -64,7 +66,7 @@ pub struct Header {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use blockchain::header::Header; use crate::blockchain::header::Header;
use serde_json; use serde_json;
#[test] #[test]

View File

@ -16,7 +16,7 @@
//! Blockchain test deserializer. //! Blockchain test deserializer.
use blockchain::blockchain::BlockChain; use crate::blockchain::blockchain::BlockChain;
use serde_json::{self, Error}; use serde_json::{self, Error};
use std::{collections::BTreeMap, io::Read}; use std::{collections::BTreeMap, io::Read};

View File

@ -16,9 +16,8 @@
//! Blockchain test transaction deserialization. //! Blockchain test transaction deserialization.
use bytes::Bytes; use crate::{bytes::Bytes, uint::Uint};
use ethereum_types::{H160, H256}; use ethereum_types::{H160, H256};
use uint::Uint;
/// Blockchain test transaction deserialization. /// Blockchain test transaction deserialization.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
@ -39,11 +38,11 @@ pub struct Transaction {
pub hash: Option<H256>, pub hash: Option<H256>,
} }
pub type AccessList = Vec<AccessListItem>;
#[derive(Debug, PartialEq, Deserialize, Clone)] #[derive(Debug, PartialEq, Deserialize, Clone)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct AccessListItem { pub struct AccessListItem {
pub address: H160, pub address: H160,
pub storage_keys: Vec<H256>, pub storage_keys: Vec<H256>,
} }
pub type AccessList = Vec<AccessListItem>;

View File

@ -102,7 +102,7 @@ impl<'a> Visitor<'a> for BytesVisitor {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use bytes::Bytes; use crate::bytes::Bytes;
use serde_json; use serde_json;
#[test] #[test]

View File

@ -112,8 +112,8 @@ impl_hash!(Bloom, Hash2048);
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use crate::hash::H256;
use ethereum_types; use ethereum_types;
use hash::H256;
use serde_json; use serde_json;
use std::str::FromStr; use std::str::FromStr;

View File

@ -14,9 +14,9 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>. // along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
extern crate common_types as types; pub use common_types as types;
extern crate ethereum_types; pub use parity_crypto as crypto;
extern crate parity_crypto as crypto;
extern crate rustc_hex; extern crate rustc_hex;
extern crate serde; extern crate serde;
extern crate serde_json; extern crate serde_json;

View File

@ -1,4 +1,4 @@
use blockchain::block::Block; use crate::blockchain::block::Block;
use serde_json::{self, Error}; use serde_json::{self, Error};
use std::{collections::BTreeMap, io::Read}; use std::{collections::BTreeMap, io::Read};

View File

@ -94,9 +94,8 @@ impl<T> Into<Option<T>> for MaybeEmpty<T> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{hash::H256, maybe::MaybeEmpty};
use ethereum_types; use ethereum_types;
use hash::H256;
use maybe::MaybeEmpty;
use serde_json; use serde_json;
use std::str::FromStr; use std::str::FromStr;

View File

@ -18,9 +18,7 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use bytes::Bytes; use crate::{bytes::Bytes, spec::builtin::BuiltinCompat, uint::Uint};
use spec::builtin::BuiltinCompat;
use uint::Uint;
/// Spec account. /// Spec account.
#[derive(Clone, Debug, PartialEq, Deserialize)] #[derive(Clone, Debug, PartialEq, Deserialize)]
@ -53,12 +51,10 @@ impl Account {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use bytes::Bytes; use crate::{bytes::Bytes, spec::account::Account, uint::Uint};
use ethereum_types::U256; use ethereum_types::U256;
use serde_json; use serde_json;
use spec::account::Account;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use uint::Uint;
#[test] #[test]
fn account_balance_missing_not_empty() { fn account_balance_missing_not_empty() {

View File

@ -17,9 +17,7 @@
//! Authority params deserialization. //! Authority params deserialization.
use super::{BlockReward, ValidatorSet}; use super::{BlockReward, ValidatorSet};
use bytes::Bytes; use crate::{bytes::Bytes, hash::Address, uint::Uint};
use hash::Address;
use uint::Uint;
/// Authority params deserialization. /// Authority params deserialization.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
@ -73,12 +71,14 @@ mod tests {
use std::collections::BTreeMap; use std::collections::BTreeMap;
use super::BlockReward; use super::BlockReward;
use crate::{
hash::Address,
spec::{authority_round::AuthorityRound, validator_set::ValidatorSet},
uint::Uint,
};
use ethereum_types::{H160, U256}; use ethereum_types::{H160, U256};
use hash::Address;
use serde_json; use serde_json;
use spec::{authority_round::AuthorityRound, validator_set::ValidatorSet};
use std::str::FromStr; use std::str::FromStr;
use uint::Uint;
#[test] #[test]
fn authority_round_deserialization() { fn authority_round_deserialization() {

View File

@ -17,7 +17,7 @@
//! Authority params deserialization. //! Authority params deserialization.
use super::ValidatorSet; use super::ValidatorSet;
use uint::Uint; use crate::uint::Uint;
/// Authority params deserialization. /// Authority params deserialization.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
@ -40,12 +40,14 @@ pub struct BasicAuthority {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{
hash::Address,
spec::{basic_authority::BasicAuthority, validator_set::ValidatorSet},
uint::Uint,
};
use ethereum_types::{H160, U256}; use ethereum_types::{H160, U256};
use hash::Address;
use serde_json; use serde_json;
use spec::{basic_authority::BasicAuthority, validator_set::ValidatorSet};
use std::str::FromStr; use std::str::FromStr;
use uint::Uint;
#[test] #[test]
fn basic_authority_deserialization() { fn basic_authority_deserialization() {

View File

@ -16,8 +16,8 @@
//! Spec builtin deserialization. //! Spec builtin deserialization.
use crate::uint::Uint;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use uint::Uint;
/// Linear pricing. /// Linear pricing.
#[derive(Debug, PartialEq, Deserialize, Clone)] #[derive(Debug, PartialEq, Deserialize, Clone)]

View File

@ -40,8 +40,8 @@ pub enum Engine {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::spec::Engine;
use serde_json; use serde_json;
use spec::Engine;
#[test] #[test]
fn engine_deserialization() { fn engine_deserialization() {

View File

@ -16,10 +16,12 @@
//! Ethash params deserialization. //! Ethash params deserialization.
use bytes::Bytes; use crate::{
use hash::Address; bytes::Bytes,
hash::Address,
uint::{self, Uint},
};
use std::collections::BTreeMap; use std::collections::BTreeMap;
use uint::{self, Uint};
/// Deserializable doppelganger of block rewards for EthashParams /// Deserializable doppelganger of block rewards for EthashParams
#[derive(Clone, Debug, PartialEq, Deserialize)] #[derive(Clone, Debug, PartialEq, Deserialize)]
@ -105,12 +107,14 @@ pub struct Ethash {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{
hash::Address,
spec::ethash::{BlockReward, Ethash, EthashParams},
uint::Uint,
};
use ethereum_types::{H160, U256}; use ethereum_types::{H160, U256};
use hash::Address;
use serde_json; use serde_json;
use spec::ethash::{BlockReward, Ethash, EthashParams};
use std::str::FromStr; use std::str::FromStr;
use uint::Uint;
#[test] #[test]
fn ethash_deserialization() { fn ethash_deserialization() {

View File

@ -16,10 +16,12 @@
//! Spec genesis deserialization. //! Spec genesis deserialization.
use bytes::Bytes; use crate::{
use hash::{Address, H256}; bytes::Bytes,
use spec::Seal; hash::{Address, H256},
use uint::{self, Uint}; spec::Seal,
uint::{self, Uint},
};
/// Spec genesis. /// Spec genesis.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
@ -53,13 +55,15 @@ pub struct Genesis {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use bytes::Bytes; use crate::{
bytes::Bytes,
hash::{Address, H256, H64},
spec::{genesis::Genesis, Ethereum, Seal},
uint::Uint,
};
use ethereum_types::{H160, H256 as Eth256, H64 as Eth64, U256}; use ethereum_types::{H160, H256 as Eth256, H64 as Eth64, U256};
use hash::{Address, H256, H64};
use serde_json; use serde_json;
use spec::{genesis::Genesis, Ethereum, Seal};
use std::str::FromStr; use std::str::FromStr;
use uint::Uint;
#[test] #[test]
fn genesis_deserialization() { fn genesis_deserialization() {

View File

@ -16,7 +16,7 @@
//! Null engine params deserialization. //! Null engine params deserialization.
use uint::Uint; use crate::uint::Uint;
/// Authority params deserialization. /// Authority params deserialization.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
@ -40,9 +40,9 @@ pub struct NullEngine {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::uint::Uint;
use ethereum_types::U256; use ethereum_types::U256;
use serde_json; use serde_json;
use uint::Uint;
#[test] #[test]
fn null_engine_deserialization() { fn null_engine_deserialization() {

View File

@ -16,9 +16,11 @@
//! Spec params deserialization. //! Spec params deserialization.
use bytes::Bytes; use crate::{
use hash::{Address, H256}; bytes::Bytes,
use uint::{self, Uint}; hash::{Address, H256},
uint::{self, Uint},
};
/// Spec params. /// Spec params.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
@ -146,10 +148,9 @@ pub struct Params {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{spec::params::Params, uint::Uint};
use ethereum_types::U256; use ethereum_types::U256;
use serde_json; use serde_json;
use spec::params::Params;
use uint::Uint;
#[test] #[test]
fn params_deserialization() { fn params_deserialization() {

View File

@ -16,9 +16,7 @@
//! Spec seal deserialization. //! Spec seal deserialization.
use bytes::Bytes; use crate::{bytes::Bytes, hash::*, uint::Uint};
use hash::*;
use uint::Uint;
/// Ethereum seal. /// Ethereum seal.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
@ -70,13 +68,15 @@ pub enum Seal {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use bytes::Bytes; use crate::{
bytes::Bytes,
hash::*,
spec::{AuthorityRoundSeal, Ethereum, Seal, TendermintSeal},
uint::Uint,
};
use ethereum_types::{H256 as Eth256, H520 as Eth520, H64 as Eth64, U256}; use ethereum_types::{H256 as Eth256, H520 as Eth520, H64 as Eth64, U256};
use hash::*;
use serde_json; use serde_json;
use spec::{AuthorityRoundSeal, Ethereum, Seal, TendermintSeal};
use std::str::FromStr; use std::str::FromStr;
use uint::Uint;
#[test] #[test]
fn seal_deserialization() { fn seal_deserialization() {

View File

@ -16,8 +16,8 @@
//! Spec deserialization. //! Spec deserialization.
use crate::spec::{Engine, Genesis, Params, State};
use serde_json::{self, Error}; use serde_json::{self, Error};
use spec::{Engine, Genesis, Params, State};
use std::io::Read; use std::io::Read;
/// Fork spec definition /// Fork spec definition
@ -73,8 +73,8 @@ impl Spec {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::spec::spec::Spec;
use serde_json; use serde_json;
use spec::spec::Spec;
#[test] #[test]
fn should_error_on_unknown_fields() { fn should_error_on_unknown_fields() {

View File

@ -16,9 +16,11 @@
//! Blockchain test state deserializer. //! Blockchain test state deserializer.
use bytes::Bytes; use crate::{
use hash::Address; bytes::Bytes,
use spec::{Account, Builtin}; hash::Address,
spec::{Account, Builtin},
};
use std::collections::BTreeMap; use std::collections::BTreeMap;
/// Blockchain test state deserializer. /// Blockchain test state deserializer.

View File

@ -16,9 +16,8 @@
//! Validator set deserialization. //! Validator set deserialization.
use hash::Address; use crate::{hash::Address, uint::Uint};
use std::collections::BTreeMap; use std::collections::BTreeMap;
use uint::Uint;
/// Different ways of specifying validators. /// Different ways of specifying validators.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
@ -37,12 +36,10 @@ pub enum ValidatorSet {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{hash::Address, spec::validator_set::ValidatorSet, uint::Uint};
use ethereum_types::{H160, U256}; use ethereum_types::{H160, U256};
use hash::Address;
use serde_json; use serde_json;
use spec::validator_set::ValidatorSet;
use std::str::FromStr; use std::str::FromStr;
use uint::Uint;
#[test] #[test]
fn validator_set_deserialization() { fn validator_set_deserialization() {

View File

@ -15,8 +15,11 @@
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>. // along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
//! State test log deserialization. //! State test log deserialization.
use bytes::Bytes; use crate::{
use hash::{Address, Bloom, H256}; bytes::Bytes,
hash::{Address, Bloom, H256},
};
use common_types::log_entry::LogEntry;
/// State test log deserialization. /// State test log deserialization.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
@ -33,8 +36,8 @@ pub struct Log {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::Log;
use serde_json; use serde_json;
use state::Log;
#[test] #[test]
fn log_deserialization() { fn log_deserialization() {
@ -50,3 +53,13 @@ mod tests {
// TODO: validate all fields // TODO: validate all fields
} }
} }
impl From<Log> for LogEntry {
fn from(l: Log) -> Self {
LogEntry {
address: l.address.into(),
topics: l.topics.into_iter().map(Into::into).collect(),
data: l.data.into(),
}
}
}

View File

@ -22,5 +22,4 @@ pub mod test;
pub mod transaction; pub mod transaction;
pub use self::{log::Log, state::State, test::Test, transaction::Transaction}; pub use self::{log::Log, state::State, test::Test, transaction::Transaction};
pub use blockchain::State as AccountState; pub use crate::{blockchain::State as AccountState, vm::Env};
pub use vm::Env;

View File

@ -16,9 +16,11 @@
//! State test deserialization. //! State test deserialization.
use bytes::Bytes; use crate::{
use hash::H256; bytes::Bytes,
use state::{AccountState, Env, Log, Transaction}; hash::H256,
state::{AccountState, Env, Log, Transaction},
};
/// State test deserialization. /// State test deserialization.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
@ -45,8 +47,8 @@ pub struct State {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::State;
use serde_json; use serde_json;
use state::State;
#[test] #[test]
fn state_deserialization() { fn state_deserialization() {

View File

@ -16,16 +16,22 @@
//! General test deserialization. //! General test deserialization.
use bytes::Bytes; use crate::{
use crypto::publickey::Secret; bytes::Bytes,
use hash::{Address, H256}; crypto::publickey::Secret,
use maybe::MaybeEmpty; hash::{Address, H256},
maybe::MaybeEmpty,
spec::ForkSpec,
state::{AccountState, Env},
uint::Uint,
};
use common_types::transaction::{
AccessListTx, Action, SignedTransaction, Transaction, TypedTransaction,
};
use serde_json::{self, Error}; use serde_json::{self, Error};
use spec::ForkSpec;
use state::{AccountState, Env};
use std::{collections::BTreeMap, io::Read}; use std::{collections::BTreeMap, io::Read};
use types::transaction::{AccessListTx, Action, SignedTransaction, Transaction, TypedTransaction};
use uint::Uint;
use crate::blockchain::transaction::AccessList; use crate::blockchain::transaction::AccessList;

View File

@ -16,10 +16,12 @@
//! State test transaction deserialization. //! State test transaction deserialization.
use bytes::Bytes; use crate::{
use hash::{Address, H256}; bytes::Bytes,
use maybe::MaybeEmpty; hash::{Address, H256},
use uint::Uint; maybe::MaybeEmpty,
uint::Uint,
};
/// State test transaction deserialization. /// State test transaction deserialization.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
@ -44,8 +46,8 @@ pub struct Transaction {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::Transaction;
use serde_json; use serde_json;
use state::Transaction;
#[test] #[test]
fn transaction_deserialization() { fn transaction_deserialization() {

View File

@ -16,10 +16,9 @@
//! Additional test structures deserialization. //! Additional test structures deserialization.
use hash::H256; use crate::{hash::H256, uint::Uint};
use serde_json::{self, Error}; use serde_json::{self, Error};
use std::{collections::BTreeMap, io::Read, path::PathBuf}; use std::{collections::BTreeMap, io::Read, path::PathBuf};
use uint::Uint;
/// Blockchain test header deserializer. /// Blockchain test header deserializer.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]

View File

@ -16,9 +16,9 @@
//! TransactionTest test deserializer. //! TransactionTest test deserializer.
use crate::transaction::TransactionTest;
use serde_json::{self, Error}; use serde_json::{self, Error};
use std::{collections::BTreeMap, io::Read}; use std::{collections::BTreeMap, io::Read};
use transaction::TransactionTest;
/// TransactionTest test deserializer. /// TransactionTest test deserializer.
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]

View File

@ -16,10 +16,12 @@
//! Transaction test transaction deserialization. //! Transaction test transaction deserialization.
use bytes::Bytes; use crate::{bytes::Bytes, hash::Address, maybe::MaybeEmpty, uint::Uint};
use hash::Address; use common_types::transaction::{
use maybe::MaybeEmpty; signature, Action, SignatureComponents, Transaction as CoreTransaction, TypedTransaction,
use uint::Uint; UnverifiedTransaction,
};
use ethereum_types::H256;
/// Transaction test transaction deserialization. /// Transaction test transaction deserialization.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
@ -45,10 +47,37 @@ pub struct Transaction {
pub v: Uint, pub v: Uint,
} }
impl From<Transaction> for UnverifiedTransaction {
fn from(t: Transaction) -> Self {
let to: Option<Address> = t.to.into();
UnverifiedTransaction {
unsigned: TypedTransaction::Legacy(CoreTransaction {
nonce: t.nonce.into(),
gas_price: t.gas_price.into(),
gas: t.gas_limit.into(),
action: match to {
Some(to) => Action::Call(to.into()),
None => Action::Create,
},
value: t.value.into(),
data: t.data.into(),
}),
chain_id: signature::extract_chain_id_from_legacy_v(t.v.into()),
signature: SignatureComponents {
r: t.r.into(),
s: t.s.into(),
standard_v: signature::extract_standard_v(t.v.into()),
},
hash: H256::zero(),
}
.compute_hash()
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::Transaction;
use serde_json; use serde_json;
use transaction::Transaction;
#[test] #[test]
fn transaction_deserialization() { fn transaction_deserialization() {

View File

@ -16,9 +16,11 @@
//! Transaction test deserialization. //! Transaction test deserialization.
use bytes::Bytes; use crate::{
use hash::{Address, H256}; bytes::Bytes,
use spec::ForkSpec; hash::{Address, H256},
spec::ForkSpec,
};
use std::collections::BTreeMap; use std::collections::BTreeMap;
/// Transaction test deserialization. /// Transaction test deserialization.
@ -42,8 +44,8 @@ pub struct PostState {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::TransactionTest;
use serde_json; use serde_json;
use transaction::TransactionTest;
#[test] #[test]
fn transaction_deserialization() { fn transaction_deserialization() {

View File

@ -16,7 +16,7 @@
//! Trie test input deserialization. //! Trie test input deserialization.
use bytes::Bytes; use crate::bytes::Bytes;
use serde::{ use serde::{
de::{Error as ErrorTrait, MapAccess, SeqAccess, Visitor}, de::{Error as ErrorTrait, MapAccess, SeqAccess, Visitor},
Deserialize, Deserializer, Deserialize, Deserializer,
@ -135,7 +135,7 @@ impl<'a> Visitor<'a> for InputVisitor {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::Input; use super::Input;
use bytes::Bytes; use crate::bytes::Bytes;
use serde_json; use serde_json;
use std::collections::BTreeMap; use std::collections::BTreeMap;

View File

@ -16,9 +16,9 @@
//! TransactionTest test deserializer. //! TransactionTest test deserializer.
use crate::trie::Trie;
use serde_json::{self, Error}; use serde_json::{self, Error};
use std::{collections::BTreeMap, io::Read}; use std::{collections::BTreeMap, io::Read};
use trie::Trie;
/// TransactionTest test deserializer. /// TransactionTest test deserializer.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]

View File

@ -16,8 +16,7 @@
//! Trie test deserialization. //! Trie test deserialization.
use hash::H256; use crate::{hash::H256, trie::Input};
use trie::Input;
/// Trie test deserialization. /// Trie test deserialization.
#[derive(Debug, Deserialize, PartialEq)] #[derive(Debug, Deserialize, PartialEq)]

View File

@ -148,9 +148,9 @@ where
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use crate::uint::Uint;
use ethereum_types::U256; use ethereum_types::U256;
use serde_json; use serde_json;
use uint::Uint;
#[test] #[test]
fn uint_deserialization() { fn uint_deserialization() {

View File

@ -16,10 +16,7 @@
//! Vm call deserialization. //! Vm call deserialization.
use bytes::Bytes; use crate::{bytes::Bytes, hash::Address, maybe::MaybeEmpty, uint::Uint};
use hash::Address;
use maybe::MaybeEmpty;
use uint::Uint;
/// Vm call deserialization. /// Vm call deserialization.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
@ -37,13 +34,11 @@ pub struct Call {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{hash::Address, maybe::MaybeEmpty, uint::Uint, vm::Call};
use ethereum_types::{H160 as Hash160, U256}; use ethereum_types::{H160 as Hash160, U256};
use hash::Address;
use maybe::MaybeEmpty;
use serde_json; use serde_json;
use std::str::FromStr; use std::str::FromStr;
use uint::Uint;
use vm::Call;
#[test] #[test]
fn call_deserialization_empty_dest() { fn call_deserialization_empty_dest() {

View File

@ -15,8 +15,7 @@
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>. // along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
//! Vm environment. //! Vm environment.
use hash::Address; use crate::{hash::Address, uint::Uint};
use uint::Uint;
/// Vm environment. /// Vm environment.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
@ -40,8 +39,8 @@ pub struct Env {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::Env;
use serde_json; use serde_json;
use vm::Env;
#[test] #[test]
fn env_deserialization() { fn env_deserialization() {

View File

@ -16,9 +16,9 @@
//! Vm test deserializer. //! Vm test deserializer.
use crate::vm::Vm;
use serde_json::{self, Error}; use serde_json::{self, Error};
use std::{collections::BTreeMap, io::Read}; use std::{collections::BTreeMap, io::Read};
use vm::Vm;
/// Vm test deserializer. /// Vm test deserializer.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]

View File

@ -15,9 +15,7 @@
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>. // along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
//! Executed transaction. //! Executed transaction.
use bytes::Bytes; use crate::{bytes::Bytes, hash::Address, uint::Uint};
use hash::Address;
use uint::Uint;
/// Executed transaction. /// Executed transaction.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
@ -44,8 +42,8 @@ pub struct Transaction {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::Transaction;
use serde_json; use serde_json;
use vm::Transaction;
#[test] #[test]
fn transaction_deserialization() { fn transaction_deserialization() {

View File

@ -16,11 +16,13 @@
//! Vm execution env. //! Vm execution env.
use blockchain::State; use crate::{
use bytes::Bytes; blockchain::State,
use hash::H256; bytes::Bytes,
use uint::Uint; hash::H256,
use vm::{Call, Env, Transaction}; uint::Uint,
vm::{Call, Env, Transaction},
};
/// Represents vm execution environment before and after execution of transaction. /// Represents vm execution environment before and after execution of transaction.
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]
@ -58,8 +60,8 @@ impl Vm {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::Vm;
use serde_json; use serde_json;
use vm::Vm;
#[test] #[test]
fn vm_deserialization() { fn vm_deserialization() {