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:
parent
48e7d6cee4
commit
29dc10c446
24
Cargo.lock
generated
24
Cargo.lock
generated
@ -1,5 +1,11 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# 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]]
|
||||
name = "aes"
|
||||
version = "0.3.2"
|
||||
@ -438,6 +444,9 @@ name = "common-types"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ethereum-types",
|
||||
"ethkey",
|
||||
"hex",
|
||||
"inflate",
|
||||
"keccak-hash",
|
||||
"parity-bytes",
|
||||
"parity-crypto",
|
||||
@ -1804,6 +1813,12 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hex"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||
|
||||
[[package]]
|
||||
name = "hex-literal"
|
||||
version = "0.2.1"
|
||||
@ -2056,6 +2071,15 @@ dependencies = [
|
||||
"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]]
|
||||
name = "interleaved-ordered"
|
||||
version = "0.1.1"
|
||||
|
@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use params::SpecType;
|
||||
use crate::params::SpecType;
|
||||
use std::num::NonZeroU32;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
@ -53,9 +53,11 @@ pub fn execute(_cmd: AccountCmd) -> Result<String, String> {
|
||||
#[cfg(feature = "accounts")]
|
||||
mod command {
|
||||
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 helpers::{password_from_file, password_prompt};
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub fn execute(cmd: AccountCmd) -> Result<String, String> {
|
||||
|
@ -21,7 +21,7 @@ use dir::Directories;
|
||||
use ethereum_types::{Address, H160};
|
||||
use ethkey::Password;
|
||||
|
||||
use params::{AccountsConfig, SpecType};
|
||||
use crate::params::{AccountsConfig, SpecType};
|
||||
|
||||
#[cfg(not(feature = "accounts"))]
|
||||
mod accounts {
|
||||
@ -71,10 +71,10 @@ mod accounts {
|
||||
#[cfg(feature = "accounts")]
|
||||
mod accounts {
|
||||
use super::*;
|
||||
use crate::upgrade::upgrade_key_location;
|
||||
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.
|
||||
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,
|
||||
passwords: &[Password],
|
||||
) -> Result<AccountProvider, String> {
|
||||
use accounts::AccountProviderSettings;
|
||||
use crate::accounts::AccountProviderSettings;
|
||||
use ethstore::{accounts_dir::RootDiskDirectory, EthStore};
|
||||
|
||||
let path = dirs.keys_path(data_dir);
|
||||
|
@ -16,10 +16,18 @@
|
||||
|
||||
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 bytes::ToPretty;
|
||||
use cache::CacheConfig;
|
||||
use db;
|
||||
use dir::Directories;
|
||||
use ethcore::{
|
||||
client::{
|
||||
@ -31,12 +39,6 @@ use ethcore::{
|
||||
};
|
||||
use ethcore_service::ClientService;
|
||||
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)]
|
||||
pub enum BlockchainCmd {
|
||||
|
@ -14,9 +14,16 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// 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 bytes::Bytes;
|
||||
use cli::{Args, ArgsError};
|
||||
|
||||
use crypto::publickey::{Public, Secret};
|
||||
use ethcore::{
|
||||
client::VMType,
|
||||
@ -25,9 +32,7 @@ use ethcore::{
|
||||
verification::queue::VerifierSettings,
|
||||
};
|
||||
use ethereum_types::{Address, H256, U256};
|
||||
use hash::keccak;
|
||||
use metrics::MetricsConfiguration;
|
||||
use miner::pool;
|
||||
|
||||
use num_cpus;
|
||||
use parity_version::{version, version_data};
|
||||
use std::{
|
||||
@ -40,35 +45,37 @@ use std::{
|
||||
path::PathBuf,
|
||||
time::Duration,
|
||||
};
|
||||
use sync::{self, validate_node_url, NetworkConfiguration};
|
||||
|
||||
use account::{AccountCmd, ImportAccounts, ListAccounts, NewAccount};
|
||||
use blockchain::{
|
||||
BlockchainCmd, ExportBlockchain, ExportState, ImportBlockchain, KillBlockchain, ResetBlockchain,
|
||||
use crate::{
|
||||
account::{AccountCmd, ImportAccounts, ListAccounts, NewAccount},
|
||||
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::{
|
||||
self, default_data_path, default_local_path,
|
||||
helpers::{replace_home, replace_home_and_local},
|
||||
Directories,
|
||||
};
|
||||
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 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_MIN_PEERS: u16 = 25;
|
||||
@ -166,7 +173,7 @@ impl Configuration {
|
||||
let cmd = if self.args.flag_version {
|
||||
Cmd::Version
|
||||
} 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 {
|
||||
Cmd::SignerToken(ws_conf, logger_config.clone())
|
||||
@ -1243,23 +1250,25 @@ fn into_secretstore_service_contract_address(
|
||||
mod tests {
|
||||
use std::{fs::File, io::Write, str::FromStr};
|
||||
|
||||
use account::{AccountCmd, ImportAccounts, ListAccounts, NewAccount};
|
||||
use blockchain::{BlockchainCmd, ExportBlockchain, ExportState, ImportBlockchain};
|
||||
use cli::Args;
|
||||
use crate::{
|
||||
account::{AccountCmd, ImportAccounts, ListAccounts, NewAccount},
|
||||
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 ethcore::{client::VMType, miner::MinerOptions};
|
||||
use helpers::default_network_config;
|
||||
use miner::pool::PrioritizationStrategy;
|
||||
use params::SpecType;
|
||||
use parity_rpc::NetworkSettings;
|
||||
use presale::ImportWallet;
|
||||
use rpc::WsConfiguration;
|
||||
use rpc_apis::ApiSet;
|
||||
use run::RunCmd;
|
||||
use tempdir::TempDir;
|
||||
use types::{data_format::DataFormat, ids::BlockId};
|
||||
|
||||
use network::{AllowIP, IpFilter};
|
||||
use crate::network::{AllowIP, IpFilter};
|
||||
|
||||
extern crate ipnetwork;
|
||||
use self::ipnetwork::IpNetwork;
|
||||
|
@ -14,8 +14,13 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use cache::CacheConfig;
|
||||
use db::migrate;
|
||||
use crate::{
|
||||
cache::CacheConfig,
|
||||
db::migrate,
|
||||
miner::pool::PrioritizationStrategy,
|
||||
sync::{self, validate_node_url},
|
||||
upgrade::{upgrade, upgrade_data_paths},
|
||||
};
|
||||
use dir::{helpers::replace_home, DatabaseDirectories};
|
||||
use ethcore::{
|
||||
client::{BlockId, ClientConfig, DatabaseCompactionProfile, Mode, VMType, VerifierType},
|
||||
@ -24,7 +29,6 @@ use ethcore::{
|
||||
use ethereum_types::{Address, U256};
|
||||
use ethkey::Password;
|
||||
use journaldb::Algorithm;
|
||||
use miner::pool::PrioritizationStrategy;
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
fs::File,
|
||||
@ -32,8 +36,6 @@ use std::{
|
||||
io::{BufRead, BufReader, Write},
|
||||
time::Duration,
|
||||
};
|
||||
use sync::{self, validate_node_url};
|
||||
use upgrade::{upgrade, upgrade_data_paths};
|
||||
|
||||
pub fn to_duration(s: &str) -> Result<Duration, String> {
|
||||
to_seconds(s).map(Duration::from_secs)
|
||||
@ -223,9 +225,9 @@ pub fn to_bootnodes(bootnodes: &Option<String>) -> Result<Vec<String>, String> {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn default_network_config() -> ::sync::NetworkConfiguration {
|
||||
pub fn default_network_config() -> crate::sync::NetworkConfiguration {
|
||||
use super::network::IpFilter;
|
||||
use sync::NetworkConfiguration;
|
||||
use crate::sync::NetworkConfiguration;
|
||||
NetworkConfiguration {
|
||||
config_path: Some(replace_home(&::dir::default_data_path(), "$BASE/network")),
|
||||
net_config_path: None,
|
||||
|
@ -29,6 +29,11 @@ use std::{
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
io::{IoContext, IoHandler, TimerToken},
|
||||
sync::{ManageNetwork, SyncProvider},
|
||||
types::BlockNumber,
|
||||
};
|
||||
use atty;
|
||||
use ethcore::{
|
||||
client::{
|
||||
@ -37,12 +42,9 @@ use ethcore::{
|
||||
},
|
||||
snapshot::{service::Service as SnapshotService, RestorationStatus, SnapshotService as SS},
|
||||
};
|
||||
use io::{IoContext, IoHandler, TimerToken};
|
||||
use number_prefix::{binary_prefix, Prefixed, Standalone};
|
||||
use parity_rpc::{informant::RpcStats, is_major_importing_or_waiting};
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use sync::{ManageNetwork, SyncProvider};
|
||||
use types::BlockNumber;
|
||||
|
||||
/// Format byte counts to standard denominations.
|
||||
pub fn format_bytes(b: usize) -> String {
|
||||
|
@ -114,9 +114,11 @@ mod user_defaults;
|
||||
|
||||
use std::{fs::File, io::BufReader, sync::Arc};
|
||||
|
||||
use cli::Args;
|
||||
use configuration::{Cmd, Execute};
|
||||
use hash::keccak_buffer;
|
||||
use crate::{
|
||||
cli::Args,
|
||||
configuration::{Cmd, Execute},
|
||||
hash::keccak_buffer,
|
||||
};
|
||||
|
||||
#[cfg(feature = "memory_profiling")]
|
||||
use std::alloc::System;
|
||||
|
@ -16,14 +16,16 @@
|
||||
|
||||
use std::sync::{mpsc, Arc};
|
||||
|
||||
use crate::{
|
||||
sync::{self, ConnectionFilter, NetworkConfiguration, Params, SyncConfig},
|
||||
types::BlockNumber,
|
||||
};
|
||||
use ethcore::{client::BlockChainClient, snapshot::SnapshotService};
|
||||
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;
|
||||
use ethcore_logger::Config as LogConfig;
|
||||
pub use sync::{EthSync, ManageNetwork, SyncProvider};
|
||||
|
||||
pub type SyncModules = (
|
||||
Arc<dyn SyncProvider>,
|
||||
|
@ -16,6 +16,13 @@
|
||||
|
||||
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::{
|
||||
client::Mode,
|
||||
ethereum,
|
||||
@ -24,13 +31,8 @@ use ethcore::{
|
||||
use ethereum_types::{Address, U256};
|
||||
use fetch::Client as FetchClient;
|
||||
use journaldb::Algorithm;
|
||||
use miner::{
|
||||
gas_price_calibrator::{GasPriceCalibrator, GasPriceCalibratorOptions},
|
||||
gas_pricer::GasPricer,
|
||||
};
|
||||
use parity_runtime::Executor;
|
||||
use parity_version::version_data;
|
||||
use user_defaults::UserDefaults;
|
||||
|
||||
use crate::configuration;
|
||||
|
||||
@ -374,8 +376,8 @@ pub fn mode_switch_to_bool(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{tracing_switch_to_bool, Pruning, ResealPolicy, SpecType, Switch};
|
||||
use crate::user_defaults::UserDefaults;
|
||||
use journaldb::Algorithm;
|
||||
use user_defaults::UserDefaults;
|
||||
|
||||
#[test]
|
||||
fn test_spec_type_parsing() {
|
||||
|
@ -14,11 +14,14 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// 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 ethkey::Password;
|
||||
use ethstore::PresaleWallet;
|
||||
use helpers::{password_from_file, password_prompt};
|
||||
use params::SpecType;
|
||||
use std::num::NonZeroU32;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
@ -45,6 +48,7 @@ pub fn execute(cmd: ImportWallet) -> Result<String, String> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "accounts")]
|
||||
|
||||
pub fn import_account(cmd: &ImportWallet, kp: publickey::KeyPair, password: Password) {
|
||||
use accounts::{AccountProvider, AccountProviderSettings};
|
||||
use ethstore::{accounts_dir::RootDiskDirectory, EthStore};
|
||||
|
@ -16,8 +16,11 @@
|
||||
|
||||
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 helpers::parity_ipc_path;
|
||||
use jsonrpc_core::MetaIoHandler;
|
||||
use parity_rpc::{
|
||||
self as rpc,
|
||||
@ -25,7 +28,6 @@ use parity_rpc::{
|
||||
DomainsValidation, Metadata,
|
||||
};
|
||||
use parity_runtime::Executor;
|
||||
use rpc_apis::{self, ApiSet};
|
||||
|
||||
pub use parity_rpc::{HttpServer, IpcServer, RequestMiddleware};
|
||||
//pub use parity_rpc::ws::Server as WsServer;
|
||||
@ -182,7 +184,7 @@ pub fn new_ws<D: rpc_apis::Dependencies>(
|
||||
let signer_path;
|
||||
let path = match conf.support_token_api {
|
||||
true => {
|
||||
signer_path = ::signer::codes_path(&conf.signer_path);
|
||||
signer_path = crate::signer::codes_path(&conf.signer_path);
|
||||
Some(signer_path.as_path())
|
||||
}
|
||||
false => None,
|
||||
|
@ -23,12 +23,15 @@ use std::{
|
||||
|
||||
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_logger::RotatingLogger;
|
||||
use fetch::Client as FetchClient;
|
||||
use jsonrpc_core::{self as core, MetaIoHandler};
|
||||
use miner::external::ExternalMiner;
|
||||
use parity_rpc::{
|
||||
dispatch::FullDispatcher,
|
||||
informant::{ActivityNotifier, ClientNotifier},
|
||||
@ -36,7 +39,6 @@ use parity_rpc::{
|
||||
};
|
||||
use parity_runtime::Executor;
|
||||
use parking_lot::Mutex;
|
||||
use sync::{ManageNetwork, SyncProvider};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Eq, Hash)]
|
||||
pub enum Api {
|
||||
|
@ -22,10 +22,24 @@ use std::{
|
||||
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 cache::CacheConfig;
|
||||
use db;
|
||||
use dir::{DatabaseDirectories, Directories};
|
||||
use ethcore::{
|
||||
client::{BlockChainClient, BlockInfo, Client, DatabaseCompactionProfile, Mode, VMType},
|
||||
@ -36,30 +50,15 @@ use ethcore::{
|
||||
use ethcore_logger::{Config as LogConfig, RotatingLogger};
|
||||
use ethcore_service::ClientService;
|
||||
use ethereum_types::{H256, U64};
|
||||
use helpers::{execute_upgrades, passwords_from_files, to_client_config};
|
||||
use informant::{FullNodeInformantData, Informant};
|
||||
use journaldb::Algorithm;
|
||||
use jsonrpc_core;
|
||||
use metrics::{start_prometheus_metrics, MetricsConfiguration};
|
||||
use miner::{external::ExternalMiner, work_notify::WorkPoster};
|
||||
use modules;
|
||||
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::{
|
||||
informant, is_major_importing, FutureOutput, FutureResponse, FutureResult, Metadata,
|
||||
NetworkSettings, Origin, PubSubSession,
|
||||
};
|
||||
use parity_runtime::Runtime;
|
||||
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.
|
||||
const SNAPSHOT_PERIOD: u64 = 20000;
|
||||
@ -120,8 +119,8 @@ struct FullNodeInfo {
|
||||
miner: Option<Arc<Miner>>, // TODO: only TXQ needed, just use that after decoupling.
|
||||
}
|
||||
|
||||
impl ::local_store::NodeInfo for FullNodeInfo {
|
||||
fn pending_transactions(&self) -> Vec<::types::transaction::PendingTransaction> {
|
||||
impl crate::local_store::NodeInfo for FullNodeInfo {
|
||||
fn pending_transactions(&self) -> Vec<crate::types::transaction::PendingTransaction> {
|
||||
let miner = match self.miner.as_ref() {
|
||||
Some(m) => m,
|
||||
None => return Vec::new(),
|
||||
@ -131,7 +130,7 @@ impl ::local_store::NodeInfo for FullNodeInfo {
|
||||
.local_transactions()
|
||||
.values()
|
||||
.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())
|
||||
}
|
||||
_ => 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(),
|
||||
::ethcore_db::COL_NODE_INFO,
|
||||
node_info,
|
||||
@ -461,7 +460,7 @@ pub fn execute(cmd: RunCmd, logger: Arc<RotatingLogger>) -> Result<RunningClient
|
||||
.is_ok()
|
||||
{
|
||||
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
|
||||
let _ = tx.lock().send(task);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use account_utils::AccountProvider;
|
||||
use crate::{account_utils::AccountProvider, sync::SyncProvider};
|
||||
use crypto::publickey::{Public, Secret};
|
||||
use dir::{default_data_path, helpers::replace_home};
|
||||
use ethcore::{client::Client, miner::Miner};
|
||||
@ -22,7 +22,6 @@ use ethereum_types::Address;
|
||||
use ethkey::Password;
|
||||
use parity_runtime::Executor;
|
||||
use std::{collections::BTreeMap, sync::Arc};
|
||||
use sync::SyncProvider;
|
||||
|
||||
/// This node secret key.
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
|
@ -19,12 +19,10 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use crate::{path::restrict_permissions_owner, rpc, rpc_apis};
|
||||
use ansi_term::Colour::White;
|
||||
use ethcore_logger::Config as LogConfig;
|
||||
use parity_rpc;
|
||||
use path::restrict_permissions_owner;
|
||||
use rpc;
|
||||
use rpc_apis;
|
||||
|
||||
pub const CODES_FILENAME: &'static str = "authcodes";
|
||||
|
||||
|
@ -22,6 +22,7 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use crate::{hash::keccak, types::ids::BlockId};
|
||||
use ethcore::{
|
||||
client::{DatabaseCompactionProfile, Mode, VMType},
|
||||
miner::Miner,
|
||||
@ -32,15 +33,15 @@ use ethcore::{
|
||||
},
|
||||
};
|
||||
use ethcore_service::ClientService;
|
||||
use hash::keccak;
|
||||
use types::ids::BlockId;
|
||||
|
||||
use cache::CacheConfig;
|
||||
use db;
|
||||
use crate::{
|
||||
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 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.
|
||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
||||
@ -303,7 +304,7 @@ impl SnapshotCommand {
|
||||
let cur_size = p.size();
|
||||
if cur_size != last_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!(
|
||||
"Snapshot: {} accounts {} blocks {}",
|
||||
p.accounts(),
|
||||
|
@ -2,9 +2,14 @@
|
||||
description = "Parity Ethereum Common Types"
|
||||
name = "common-types"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
authors = [
|
||||
"Gnosis Ltd <openethereum@gnosis.io>",
|
||||
"Parity Technologies <admin@parity.io>",
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
ethkey = { path = "../../accounts/ethkey" }
|
||||
ethereum-types = "0.9.2"
|
||||
keccak-hash = "0.5.0"
|
||||
parity-bytes = "0.1"
|
||||
@ -16,6 +21,8 @@ unexpected = { path = "../../util/unexpected" }
|
||||
serde = "1.0"
|
||||
serde_json = "1.0"
|
||||
serde_repr = "0.1"
|
||||
hex = "0.4.3"
|
||||
inflate = "0.4.5"
|
||||
|
||||
[dev-dependencies]
|
||||
rustc-hex = "1.0"
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
//! Diff between two accounts.
|
||||
|
||||
use bytes::Bytes;
|
||||
use crate::bytes::Bytes;
|
||||
use ethereum_types::{H256, U256};
|
||||
use std::{cmp::*, collections::BTreeMap, fmt};
|
||||
|
||||
@ -141,7 +141,7 @@ fn interpreted_hash(u: &H256) -> String {
|
||||
|
||||
impl fmt::Display for AccountDiff {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use bytes::ToPretty;
|
||||
use crate::bytes::ToPretty;
|
||||
|
||||
match self.nonce {
|
||||
Diff::Born(ref x) => write!(f, " non {}", x)?,
|
||||
|
@ -31,11 +31,13 @@
|
||||
//! `ExecutedBlock` is an underlaying data structure used by all structs above to store block
|
||||
//! 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 transaction::{TypedTransaction, UnverifiedTransaction};
|
||||
|
||||
/// A block, encoded as it is on the block chain.
|
||||
#[derive(Default, Debug, Clone, PartialEq)]
|
||||
|
@ -18,9 +18,8 @@
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use crate::{security_level::SecurityLevel, BlockNumber};
|
||||
use ethereum_types::{H256, U256};
|
||||
use security_level::SecurityLevel;
|
||||
use BlockNumber;
|
||||
|
||||
/// Information about the blockchain gathered together.
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -23,15 +23,18 @@
|
||||
//! 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.
|
||||
|
||||
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 hash::keccak;
|
||||
use header::Header as FullHeader;
|
||||
use parity_util_mem::MallocSizeOf;
|
||||
use rlp::{self, Rlp, RlpStream};
|
||||
use transaction::UnverifiedTransaction;
|
||||
use views::{self, BlockView, BodyView, HeaderView};
|
||||
use BlockNumber;
|
||||
|
||||
/// Owning header view.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, MallocSizeOf)]
|
||||
|
@ -16,9 +16,8 @@
|
||||
|
||||
//! Blockchain filter
|
||||
|
||||
use crate::{ids::BlockId, log_entry::LogEntry};
|
||||
use ethereum_types::{Address, Bloom, BloomInput, H256};
|
||||
use ids::BlockId;
|
||||
use log_entry::LogEntry;
|
||||
|
||||
/// Blockchain Filter.
|
||||
#[derive(Debug, PartialEq)]
|
||||
@ -119,10 +118,8 @@ impl Filter {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{filter::Filter, ids::BlockId, log_entry::LogEntry};
|
||||
use ethereum_types::{Bloom, H160, H256};
|
||||
use filter::Filter;
|
||||
use ids::BlockId;
|
||||
use log_entry::LogEntry;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[test]
|
||||
|
@ -16,12 +16,14 @@
|
||||
|
||||
//! 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 hash::{keccak, KECCAK_EMPTY_LIST_RLP, KECCAK_NULL_RLP};
|
||||
use parity_util_mem::MallocSizeOf;
|
||||
use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream};
|
||||
use BlockNumber;
|
||||
|
||||
/// Semantic boolean for when a seal/signature is included.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
@ -307,8 +309,8 @@ impl Header {
|
||||
}
|
||||
|
||||
/// Encode the header, getting a type-safe wrapper around the RLP.
|
||||
pub fn encoded(&self) -> ::encoded::Header {
|
||||
::encoded::Header::new(self.rlp(Seal::With))
|
||||
pub fn encoded(&self) -> crate::encoded::Header {
|
||||
crate::encoded::Header::new(self.rlp(Seal::With))
|
||||
}
|
||||
|
||||
/// Get the RLP representation of this Header.
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
//! Unique identifiers.
|
||||
|
||||
use crate::BlockNumber;
|
||||
use ethereum_types::H256;
|
||||
use BlockNumber;
|
||||
|
||||
/// Uniquely identifies block.
|
||||
#[derive(Debug, PartialEq, Copy, Clone, Hash, Eq)]
|
||||
|
@ -34,20 +34,15 @@
|
||||
#![allow(missing_docs)]
|
||||
#![warn(unused_extern_crates)]
|
||||
|
||||
extern crate ethereum_types;
|
||||
extern crate keccak_hash as hash;
|
||||
extern crate parity_bytes as bytes;
|
||||
extern crate parity_crypto as crypto;
|
||||
extern crate parity_util_mem;
|
||||
extern crate rlp;
|
||||
extern crate serde_repr;
|
||||
extern crate unexpected;
|
||||
pub use keccak_hash as hash;
|
||||
pub use parity_bytes as bytes;
|
||||
pub use parity_crypto as crypto;
|
||||
|
||||
#[macro_use]
|
||||
extern crate rlp_derive;
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate rustc_hex;
|
||||
pub use rustc_hex;
|
||||
|
||||
#[macro_use]
|
||||
pub mod views;
|
||||
|
@ -16,13 +16,11 @@
|
||||
|
||||
//! Log entry type definition.
|
||||
|
||||
use bytes::Bytes;
|
||||
use crate::{bytes::Bytes, BlockNumber};
|
||||
use ethereum_types::{Address, Bloom, BloomInput, H256};
|
||||
use parity_util_mem::MallocSizeOf;
|
||||
use std::ops::Deref;
|
||||
|
||||
use BlockNumber;
|
||||
|
||||
/// A record of execution for a `LOG` operation.
|
||||
#[derive(Default, Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable, MallocSizeOf)]
|
||||
pub struct LogEntry {
|
||||
|
@ -22,8 +22,10 @@ use parity_util_mem::MallocSizeOf;
|
||||
use rlp::{DecoderError, Rlp, RlpStream};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
use log_entry::{LocalizedLogEntry, LogEntry};
|
||||
use BlockNumber;
|
||||
use crate::{
|
||||
log_entry::{LocalizedLogEntry, LogEntry},
|
||||
BlockNumber,
|
||||
};
|
||||
|
||||
/// Transaction outcome store in the receipt.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, MallocSizeOf)]
|
||||
@ -296,8 +298,8 @@ pub struct LocalizedReceipt {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{LegacyReceipt, TransactionOutcome, TypedReceipt, TypedTxId};
|
||||
use crate::log_entry::LogEntry;
|
||||
use ethereum_types::{H160, H256};
|
||||
use log_entry::LogEntry;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[test]
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
//! Indication of how secure the chain is.
|
||||
|
||||
use BlockNumber;
|
||||
use crate::BlockNumber;
|
||||
|
||||
/// Indication of how secure the chain is.
|
||||
#[derive(Debug, PartialEq, Copy, Clone, Hash, Eq)]
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
//! Snapshot manifest type definition
|
||||
|
||||
use bytes::Bytes;
|
||||
use crate::bytes::Bytes;
|
||||
use ethereum_types::H256;
|
||||
use rlp::{DecoderError, Rlp, RlpStream};
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
//! State diff module.
|
||||
|
||||
use account_diff::*;
|
||||
use crate::account_diff::*;
|
||||
use ethereum_types::Address;
|
||||
use std::{collections::BTreeMap, fmt, ops::*};
|
||||
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
//! Trace filter related types
|
||||
|
||||
use crate::ids::BlockId;
|
||||
use ethereum_types::Address;
|
||||
use ids::BlockId;
|
||||
use std::ops::Range;
|
||||
|
||||
/// Easy to use trace filter.
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
use std::{error, fmt};
|
||||
|
||||
use crate::crypto;
|
||||
use ethereum_types::U256;
|
||||
use rlp;
|
||||
use unexpected::OutOfBounds;
|
||||
|
@ -16,10 +16,14 @@
|
||||
|
||||
//! 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 hash::keccak;
|
||||
use parity_util_mem::MallocSizeOf;
|
||||
|
||||
use rlp::{self, DecoderError, Rlp, RlpStream};
|
||||
use std::ops::Deref;
|
||||
|
||||
@ -28,8 +32,6 @@ pub type AccessList = Vec<AccessListItem>;
|
||||
|
||||
use super::TypedTxId;
|
||||
|
||||
use transaction::error;
|
||||
|
||||
type Bytes = Vec<u8>;
|
||||
type BlockNumber = u64;
|
||||
|
||||
@ -134,7 +136,7 @@ pub struct Transaction {
|
||||
pub gas: U256,
|
||||
/// Action, can be either call or contract create.
|
||||
pub action: Action,
|
||||
/// Transfered value.
|
||||
/// Transfered value.s
|
||||
pub value: U256,
|
||||
/// Transaction data.
|
||||
pub data: Bytes,
|
||||
@ -430,7 +432,6 @@ impl TypedTransaction {
|
||||
/// Legacy EIP-86 compatible empty signature.
|
||||
/// This method is used in json tests as well as
|
||||
/// signature verification tests.
|
||||
#[cfg(any(test, feature = "test-helpers"))]
|
||||
pub fn null_sign(self, chain_id: u64) -> SignedTransaction {
|
||||
SignedTransaction {
|
||||
transaction: UnverifiedTransaction {
|
||||
@ -566,11 +567,11 @@ impl TypedTransaction {
|
||||
pub struct SignatureComponents {
|
||||
/// 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.
|
||||
standard_v: u8,
|
||||
pub standard_v: u8,
|
||||
/// 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.
|
||||
s: U256,
|
||||
pub s: U256,
|
||||
}
|
||||
|
||||
impl SignatureComponents {
|
||||
@ -594,13 +595,13 @@ impl SignatureComponents {
|
||||
#[derive(Debug, Clone, Eq, PartialEq, MallocSizeOf)]
|
||||
pub struct UnverifiedTransaction {
|
||||
/// Plain Transaction.
|
||||
unsigned: TypedTransaction,
|
||||
pub unsigned: TypedTransaction,
|
||||
/// Transaction signature
|
||||
signature: SignatureComponents,
|
||||
pub signature: SignatureComponents,
|
||||
/// 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: H256,
|
||||
pub hash: H256,
|
||||
}
|
||||
|
||||
impl Deref for UnverifiedTransaction {
|
||||
@ -628,7 +629,7 @@ impl UnverifiedTransaction {
|
||||
}
|
||||
|
||||
/// 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());
|
||||
self.hash = hash;
|
||||
self
|
||||
@ -874,8 +875,8 @@ impl From<SignedTransaction> for PendingTransaction {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::hash::keccak;
|
||||
use ethereum_types::{H160, U256};
|
||||
use hash::keccak;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[test]
|
||||
|
@ -17,12 +17,15 @@
|
||||
//! View onto block rlp.
|
||||
|
||||
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 hash::keccak;
|
||||
use header::Header;
|
||||
use transaction::{LocalizedTransaction, TypedTransaction, UnverifiedTransaction};
|
||||
use views::{HeaderView, TypedTransactionView};
|
||||
|
||||
/// View onto block rlp.
|
||||
pub struct BlockView<'a> {
|
||||
|
@ -17,13 +17,15 @@
|
||||
//! View onto block body rlp.
|
||||
|
||||
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 hash::keccak;
|
||||
use header::Header;
|
||||
use transaction::{LocalizedTransaction, TypedTransaction, UnverifiedTransaction};
|
||||
use views::{HeaderView, TypedTransactionView};
|
||||
use BlockNumber;
|
||||
|
||||
/// View onto block rlp.
|
||||
pub struct BodyView<'a> {
|
||||
@ -184,10 +186,9 @@ impl<'a> BodyView<'a> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::BodyView;
|
||||
use bytes::Bytes;
|
||||
use crate::{bytes::Bytes, views::BlockView};
|
||||
use rlp::RlpStream;
|
||||
use rustc_hex::FromHex;
|
||||
use views::BlockView;
|
||||
|
||||
fn block_to_body(block: &[u8]) -> Bytes {
|
||||
let mut body = RlpStream::new_list(2);
|
||||
|
@ -17,11 +17,9 @@
|
||||
//! View onto block header rlp
|
||||
|
||||
use super::ViewRlp;
|
||||
use bytes::Bytes;
|
||||
use crate::{bytes::Bytes, hash::keccak, BlockNumber};
|
||||
use ethereum_types::{Address, Bloom, H256, U256};
|
||||
use hash::keccak;
|
||||
use rlp::{self};
|
||||
use BlockNumber;
|
||||
|
||||
/// View onto block header rlp.
|
||||
pub struct HeaderView<'a> {
|
||||
|
@ -16,12 +16,14 @@
|
||||
|
||||
//! 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 hash::keccak;
|
||||
use rlp::Rlp;
|
||||
|
||||
/// View onto transaction rlp. Assumption is this is part of block.
|
||||
|
@ -2,7 +2,11 @@
|
||||
description = "Parity Ethereum JSON Deserialization"
|
||||
name = "ethjson"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
authors = [
|
||||
"Gnosis Ltd <openethereum@gnosis.io>",
|
||||
"Parity Technologies <admin@parity.io>"
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
common-types = { path = "../ethcore/types", features = ["test-helpers"] }
|
||||
|
@ -16,9 +16,8 @@
|
||||
|
||||
//! Blockchain test account deserializer.
|
||||
|
||||
use bytes::Bytes;
|
||||
use crate::{bytes::Bytes, uint::Uint};
|
||||
use std::collections::BTreeMap;
|
||||
use uint::Uint;
|
||||
|
||||
/// Blockchain test account deserializer.
|
||||
#[derive(Debug, PartialEq, Deserialize, Clone)]
|
||||
@ -35,7 +34,7 @@ pub struct Account {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use blockchain::account::Account;
|
||||
use crate::blockchain::account::Account;
|
||||
use serde_json;
|
||||
|
||||
#[test]
|
||||
|
@ -16,8 +16,10 @@
|
||||
|
||||
//! Blockchain test block deserializer.
|
||||
|
||||
use blockchain::{header::Header, transaction::Transaction};
|
||||
use bytes::Bytes;
|
||||
use crate::{
|
||||
blockchain::{header::Header, transaction::Transaction},
|
||||
bytes::Bytes,
|
||||
};
|
||||
|
||||
/// Blockchain test block deserializer.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@ -39,7 +41,7 @@ impl Block {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use blockchain::block::Block;
|
||||
use crate::blockchain::block::Block;
|
||||
use serde_json;
|
||||
|
||||
#[test]
|
||||
|
@ -16,10 +16,12 @@
|
||||
|
||||
//! Blockchain deserialization.
|
||||
|
||||
use blockchain::{block::Block, header::Header, state::State};
|
||||
use bytes::Bytes;
|
||||
use hash::H256;
|
||||
use spec::{Ethereum, ForkSpec, Genesis, Seal};
|
||||
use crate::{
|
||||
blockchain::{block::Block, header::Header, state::State},
|
||||
bytes::Bytes,
|
||||
hash::H256,
|
||||
spec::{Ethereum, ForkSpec, Genesis, Seal},
|
||||
};
|
||||
|
||||
/// Json Block test possible engine kind.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@ -93,7 +95,7 @@ impl BlockChain {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use blockchain::blockchain::BlockChain;
|
||||
use crate::blockchain::blockchain::BlockChain;
|
||||
use serde_json;
|
||||
|
||||
#[test]
|
||||
|
@ -16,9 +16,11 @@
|
||||
|
||||
//! Blockchain test header deserializer.
|
||||
|
||||
use bytes::Bytes;
|
||||
use hash::{Address, Bloom, H256, H64};
|
||||
use uint::Uint;
|
||||
use crate::{
|
||||
bytes::Bytes,
|
||||
hash::{Address, Bloom, H256, H64},
|
||||
uint::Uint,
|
||||
};
|
||||
|
||||
/// Blockchain test header deserializer.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@ -64,7 +66,7 @@ pub struct Header {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use blockchain::header::Header;
|
||||
use crate::blockchain::header::Header;
|
||||
use serde_json;
|
||||
|
||||
#[test]
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
//! Blockchain test deserializer.
|
||||
|
||||
use blockchain::blockchain::BlockChain;
|
||||
use crate::blockchain::blockchain::BlockChain;
|
||||
use serde_json::{self, Error};
|
||||
use std::{collections::BTreeMap, io::Read};
|
||||
|
||||
|
@ -16,9 +16,8 @@
|
||||
|
||||
//! Blockchain test transaction deserialization.
|
||||
|
||||
use bytes::Bytes;
|
||||
use crate::{bytes::Bytes, uint::Uint};
|
||||
use ethereum_types::{H160, H256};
|
||||
use uint::Uint;
|
||||
|
||||
/// Blockchain test transaction deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@ -39,11 +38,11 @@ pub struct Transaction {
|
||||
pub hash: Option<H256>,
|
||||
}
|
||||
|
||||
pub type AccessList = Vec<AccessListItem>;
|
||||
|
||||
#[derive(Debug, PartialEq, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AccessListItem {
|
||||
pub address: H160,
|
||||
pub storage_keys: Vec<H256>,
|
||||
}
|
||||
|
||||
pub type AccessList = Vec<AccessListItem>;
|
||||
|
@ -102,7 +102,7 @@ impl<'a> Visitor<'a> for BytesVisitor {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use bytes::Bytes;
|
||||
use crate::bytes::Bytes;
|
||||
use serde_json;
|
||||
|
||||
#[test]
|
||||
|
@ -112,8 +112,8 @@ impl_hash!(Bloom, Hash2048);
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::hash::H256;
|
||||
use ethereum_types;
|
||||
use hash::H256;
|
||||
use serde_json;
|
||||
use std::str::FromStr;
|
||||
|
||||
|
@ -14,9 +14,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
extern crate common_types as types;
|
||||
extern crate ethereum_types;
|
||||
extern crate parity_crypto as crypto;
|
||||
pub use common_types as types;
|
||||
pub use parity_crypto as crypto;
|
||||
|
||||
extern crate rustc_hex;
|
||||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use blockchain::block::Block;
|
||||
use crate::blockchain::block::Block;
|
||||
use serde_json::{self, Error};
|
||||
use std::{collections::BTreeMap, io::Read};
|
||||
|
||||
|
@ -94,9 +94,8 @@ impl<T> Into<Option<T>> for MaybeEmpty<T> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{hash::H256, maybe::MaybeEmpty};
|
||||
use ethereum_types;
|
||||
use hash::H256;
|
||||
use maybe::MaybeEmpty;
|
||||
use serde_json;
|
||||
use std::str::FromStr;
|
||||
|
||||
|
@ -18,9 +18,7 @@
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use bytes::Bytes;
|
||||
use spec::builtin::BuiltinCompat;
|
||||
use uint::Uint;
|
||||
use crate::{bytes::Bytes, spec::builtin::BuiltinCompat, uint::Uint};
|
||||
|
||||
/// Spec account.
|
||||
#[derive(Clone, Debug, PartialEq, Deserialize)]
|
||||
@ -53,12 +51,10 @@ impl Account {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use bytes::Bytes;
|
||||
use crate::{bytes::Bytes, spec::account::Account, uint::Uint};
|
||||
use ethereum_types::U256;
|
||||
use serde_json;
|
||||
use spec::account::Account;
|
||||
use std::collections::BTreeMap;
|
||||
use uint::Uint;
|
||||
|
||||
#[test]
|
||||
fn account_balance_missing_not_empty() {
|
||||
|
@ -17,9 +17,7 @@
|
||||
//! Authority params deserialization.
|
||||
|
||||
use super::{BlockReward, ValidatorSet};
|
||||
use bytes::Bytes;
|
||||
use hash::Address;
|
||||
use uint::Uint;
|
||||
use crate::{bytes::Bytes, hash::Address, uint::Uint};
|
||||
|
||||
/// Authority params deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@ -73,12 +71,14 @@ mod tests {
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use super::BlockReward;
|
||||
use crate::{
|
||||
hash::Address,
|
||||
spec::{authority_round::AuthorityRound, validator_set::ValidatorSet},
|
||||
uint::Uint,
|
||||
};
|
||||
use ethereum_types::{H160, U256};
|
||||
use hash::Address;
|
||||
use serde_json;
|
||||
use spec::{authority_round::AuthorityRound, validator_set::ValidatorSet};
|
||||
use std::str::FromStr;
|
||||
use uint::Uint;
|
||||
|
||||
#[test]
|
||||
fn authority_round_deserialization() {
|
||||
|
@ -17,7 +17,7 @@
|
||||
//! Authority params deserialization.
|
||||
|
||||
use super::ValidatorSet;
|
||||
use uint::Uint;
|
||||
use crate::uint::Uint;
|
||||
|
||||
/// Authority params deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@ -40,12 +40,14 @@ pub struct BasicAuthority {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
hash::Address,
|
||||
spec::{basic_authority::BasicAuthority, validator_set::ValidatorSet},
|
||||
uint::Uint,
|
||||
};
|
||||
use ethereum_types::{H160, U256};
|
||||
use hash::Address;
|
||||
use serde_json;
|
||||
use spec::{basic_authority::BasicAuthority, validator_set::ValidatorSet};
|
||||
use std::str::FromStr;
|
||||
use uint::Uint;
|
||||
|
||||
#[test]
|
||||
fn basic_authority_deserialization() {
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
//! Spec builtin deserialization.
|
||||
|
||||
use crate::uint::Uint;
|
||||
use std::collections::BTreeMap;
|
||||
use uint::Uint;
|
||||
|
||||
/// Linear pricing.
|
||||
#[derive(Debug, PartialEq, Deserialize, Clone)]
|
||||
|
@ -40,8 +40,8 @@ pub enum Engine {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::spec::Engine;
|
||||
use serde_json;
|
||||
use spec::Engine;
|
||||
|
||||
#[test]
|
||||
fn engine_deserialization() {
|
||||
|
@ -16,10 +16,12 @@
|
||||
|
||||
//! Ethash params deserialization.
|
||||
|
||||
use bytes::Bytes;
|
||||
use hash::Address;
|
||||
use crate::{
|
||||
bytes::Bytes,
|
||||
hash::Address,
|
||||
uint::{self, Uint},
|
||||
};
|
||||
use std::collections::BTreeMap;
|
||||
use uint::{self, Uint};
|
||||
|
||||
/// Deserializable doppelganger of block rewards for EthashParams
|
||||
#[derive(Clone, Debug, PartialEq, Deserialize)]
|
||||
@ -105,12 +107,14 @@ pub struct Ethash {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
hash::Address,
|
||||
spec::ethash::{BlockReward, Ethash, EthashParams},
|
||||
uint::Uint,
|
||||
};
|
||||
use ethereum_types::{H160, U256};
|
||||
use hash::Address;
|
||||
use serde_json;
|
||||
use spec::ethash::{BlockReward, Ethash, EthashParams};
|
||||
use std::str::FromStr;
|
||||
use uint::Uint;
|
||||
|
||||
#[test]
|
||||
fn ethash_deserialization() {
|
||||
|
@ -16,10 +16,12 @@
|
||||
|
||||
//! Spec genesis deserialization.
|
||||
|
||||
use bytes::Bytes;
|
||||
use hash::{Address, H256};
|
||||
use spec::Seal;
|
||||
use uint::{self, Uint};
|
||||
use crate::{
|
||||
bytes::Bytes,
|
||||
hash::{Address, H256},
|
||||
spec::Seal,
|
||||
uint::{self, Uint},
|
||||
};
|
||||
|
||||
/// Spec genesis.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@ -53,13 +55,15 @@ pub struct Genesis {
|
||||
|
||||
#[cfg(test)]
|
||||
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 hash::{Address, H256, H64};
|
||||
use serde_json;
|
||||
use spec::{genesis::Genesis, Ethereum, Seal};
|
||||
use std::str::FromStr;
|
||||
use uint::Uint;
|
||||
|
||||
#[test]
|
||||
fn genesis_deserialization() {
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
//! Null engine params deserialization.
|
||||
|
||||
use uint::Uint;
|
||||
use crate::uint::Uint;
|
||||
|
||||
/// Authority params deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@ -40,9 +40,9 @@ pub struct NullEngine {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::uint::Uint;
|
||||
use ethereum_types::U256;
|
||||
use serde_json;
|
||||
use uint::Uint;
|
||||
|
||||
#[test]
|
||||
fn null_engine_deserialization() {
|
||||
|
@ -16,9 +16,11 @@
|
||||
|
||||
//! Spec params deserialization.
|
||||
|
||||
use bytes::Bytes;
|
||||
use hash::{Address, H256};
|
||||
use uint::{self, Uint};
|
||||
use crate::{
|
||||
bytes::Bytes,
|
||||
hash::{Address, H256},
|
||||
uint::{self, Uint},
|
||||
};
|
||||
|
||||
/// Spec params.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@ -146,10 +148,9 @@ pub struct Params {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{spec::params::Params, uint::Uint};
|
||||
use ethereum_types::U256;
|
||||
use serde_json;
|
||||
use spec::params::Params;
|
||||
use uint::Uint;
|
||||
|
||||
#[test]
|
||||
fn params_deserialization() {
|
||||
|
@ -16,9 +16,7 @@
|
||||
|
||||
//! Spec seal deserialization.
|
||||
|
||||
use bytes::Bytes;
|
||||
use hash::*;
|
||||
use uint::Uint;
|
||||
use crate::{bytes::Bytes, hash::*, uint::Uint};
|
||||
|
||||
/// Ethereum seal.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@ -70,13 +68,15 @@ pub enum Seal {
|
||||
|
||||
#[cfg(test)]
|
||||
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 hash::*;
|
||||
use serde_json;
|
||||
use spec::{AuthorityRoundSeal, Ethereum, Seal, TendermintSeal};
|
||||
use std::str::FromStr;
|
||||
use uint::Uint;
|
||||
|
||||
#[test]
|
||||
fn seal_deserialization() {
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
//! Spec deserialization.
|
||||
|
||||
use crate::spec::{Engine, Genesis, Params, State};
|
||||
use serde_json::{self, Error};
|
||||
use spec::{Engine, Genesis, Params, State};
|
||||
use std::io::Read;
|
||||
|
||||
/// Fork spec definition
|
||||
@ -73,8 +73,8 @@ impl Spec {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::spec::spec::Spec;
|
||||
use serde_json;
|
||||
use spec::spec::Spec;
|
||||
|
||||
#[test]
|
||||
fn should_error_on_unknown_fields() {
|
||||
|
@ -16,9 +16,11 @@
|
||||
|
||||
//! Blockchain test state deserializer.
|
||||
|
||||
use bytes::Bytes;
|
||||
use hash::Address;
|
||||
use spec::{Account, Builtin};
|
||||
use crate::{
|
||||
bytes::Bytes,
|
||||
hash::Address,
|
||||
spec::{Account, Builtin},
|
||||
};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
/// Blockchain test state deserializer.
|
||||
|
@ -16,9 +16,8 @@
|
||||
|
||||
//! Validator set deserialization.
|
||||
|
||||
use hash::Address;
|
||||
use crate::{hash::Address, uint::Uint};
|
||||
use std::collections::BTreeMap;
|
||||
use uint::Uint;
|
||||
|
||||
/// Different ways of specifying validators.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@ -37,12 +36,10 @@ pub enum ValidatorSet {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{hash::Address, spec::validator_set::ValidatorSet, uint::Uint};
|
||||
use ethereum_types::{H160, U256};
|
||||
use hash::Address;
|
||||
use serde_json;
|
||||
use spec::validator_set::ValidatorSet;
|
||||
use std::str::FromStr;
|
||||
use uint::Uint;
|
||||
|
||||
#[test]
|
||||
fn validator_set_deserialization() {
|
||||
|
@ -15,8 +15,11 @@
|
||||
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! State test log deserialization.
|
||||
use bytes::Bytes;
|
||||
use hash::{Address, Bloom, H256};
|
||||
use crate::{
|
||||
bytes::Bytes,
|
||||
hash::{Address, Bloom, H256},
|
||||
};
|
||||
use common_types::log_entry::LogEntry;
|
||||
|
||||
/// State test log deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@ -33,8 +36,8 @@ pub struct Log {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Log;
|
||||
use serde_json;
|
||||
use state::Log;
|
||||
|
||||
#[test]
|
||||
fn log_deserialization() {
|
||||
@ -50,3 +53,13 @@ mod tests {
|
||||
// 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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,5 +22,4 @@ pub mod test;
|
||||
pub mod transaction;
|
||||
|
||||
pub use self::{log::Log, state::State, test::Test, transaction::Transaction};
|
||||
pub use blockchain::State as AccountState;
|
||||
pub use vm::Env;
|
||||
pub use crate::{blockchain::State as AccountState, vm::Env};
|
||||
|
@ -16,9 +16,11 @@
|
||||
|
||||
//! State test deserialization.
|
||||
|
||||
use bytes::Bytes;
|
||||
use hash::H256;
|
||||
use state::{AccountState, Env, Log, Transaction};
|
||||
use crate::{
|
||||
bytes::Bytes,
|
||||
hash::H256,
|
||||
state::{AccountState, Env, Log, Transaction},
|
||||
};
|
||||
|
||||
/// State test deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@ -45,8 +47,8 @@ pub struct State {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::State;
|
||||
use serde_json;
|
||||
use state::State;
|
||||
|
||||
#[test]
|
||||
fn state_deserialization() {
|
||||
|
@ -16,16 +16,22 @@
|
||||
|
||||
//! General test deserialization.
|
||||
|
||||
use bytes::Bytes;
|
||||
use crypto::publickey::Secret;
|
||||
use hash::{Address, H256};
|
||||
use maybe::MaybeEmpty;
|
||||
use crate::{
|
||||
bytes::Bytes,
|
||||
crypto::publickey::Secret,
|
||||
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 spec::ForkSpec;
|
||||
use state::{AccountState, Env};
|
||||
use std::{collections::BTreeMap, io::Read};
|
||||
use types::transaction::{AccessListTx, Action, SignedTransaction, Transaction, TypedTransaction};
|
||||
use uint::Uint;
|
||||
|
||||
use crate::blockchain::transaction::AccessList;
|
||||
|
||||
|
@ -16,10 +16,12 @@
|
||||
|
||||
//! State test transaction deserialization.
|
||||
|
||||
use bytes::Bytes;
|
||||
use hash::{Address, H256};
|
||||
use maybe::MaybeEmpty;
|
||||
use uint::Uint;
|
||||
use crate::{
|
||||
bytes::Bytes,
|
||||
hash::{Address, H256},
|
||||
maybe::MaybeEmpty,
|
||||
uint::Uint,
|
||||
};
|
||||
|
||||
/// State test transaction deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@ -44,8 +46,8 @@ pub struct Transaction {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Transaction;
|
||||
use serde_json;
|
||||
use state::Transaction;
|
||||
|
||||
#[test]
|
||||
fn transaction_deserialization() {
|
||||
|
@ -16,10 +16,9 @@
|
||||
|
||||
//! Additional test structures deserialization.
|
||||
|
||||
use hash::H256;
|
||||
use crate::{hash::H256, uint::Uint};
|
||||
use serde_json::{self, Error};
|
||||
use std::{collections::BTreeMap, io::Read, path::PathBuf};
|
||||
use uint::Uint;
|
||||
|
||||
/// Blockchain test header deserializer.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
|
@ -16,9 +16,9 @@
|
||||
|
||||
//! TransactionTest test deserializer.
|
||||
|
||||
use crate::transaction::TransactionTest;
|
||||
use serde_json::{self, Error};
|
||||
use std::{collections::BTreeMap, io::Read};
|
||||
use transaction::TransactionTest;
|
||||
|
||||
/// TransactionTest test deserializer.
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
@ -16,10 +16,12 @@
|
||||
|
||||
//! Transaction test transaction deserialization.
|
||||
|
||||
use bytes::Bytes;
|
||||
use hash::Address;
|
||||
use maybe::MaybeEmpty;
|
||||
use uint::Uint;
|
||||
use crate::{bytes::Bytes, hash::Address, maybe::MaybeEmpty, uint::Uint};
|
||||
use common_types::transaction::{
|
||||
signature, Action, SignatureComponents, Transaction as CoreTransaction, TypedTransaction,
|
||||
UnverifiedTransaction,
|
||||
};
|
||||
use ethereum_types::H256;
|
||||
|
||||
/// Transaction test transaction deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@ -45,10 +47,37 @@ pub struct Transaction {
|
||||
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)]
|
||||
mod tests {
|
||||
use super::Transaction;
|
||||
use serde_json;
|
||||
use transaction::Transaction;
|
||||
|
||||
#[test]
|
||||
fn transaction_deserialization() {
|
||||
|
@ -16,9 +16,11 @@
|
||||
|
||||
//! Transaction test deserialization.
|
||||
|
||||
use bytes::Bytes;
|
||||
use hash::{Address, H256};
|
||||
use spec::ForkSpec;
|
||||
use crate::{
|
||||
bytes::Bytes,
|
||||
hash::{Address, H256},
|
||||
spec::ForkSpec,
|
||||
};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
/// Transaction test deserialization.
|
||||
@ -42,8 +44,8 @@ pub struct PostState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::TransactionTest;
|
||||
use serde_json;
|
||||
use transaction::TransactionTest;
|
||||
|
||||
#[test]
|
||||
fn transaction_deserialization() {
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
//! Trie test input deserialization.
|
||||
|
||||
use bytes::Bytes;
|
||||
use crate::bytes::Bytes;
|
||||
use serde::{
|
||||
de::{Error as ErrorTrait, MapAccess, SeqAccess, Visitor},
|
||||
Deserialize, Deserializer,
|
||||
@ -135,7 +135,7 @@ impl<'a> Visitor<'a> for InputVisitor {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Input;
|
||||
use bytes::Bytes;
|
||||
use crate::bytes::Bytes;
|
||||
use serde_json;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
|
@ -16,9 +16,9 @@
|
||||
|
||||
//! TransactionTest test deserializer.
|
||||
|
||||
use crate::trie::Trie;
|
||||
use serde_json::{self, Error};
|
||||
use std::{collections::BTreeMap, io::Read};
|
||||
use trie::Trie;
|
||||
|
||||
/// TransactionTest test deserializer.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
|
@ -16,8 +16,7 @@
|
||||
|
||||
//! Trie test deserialization.
|
||||
|
||||
use hash::H256;
|
||||
use trie::Input;
|
||||
use crate::{hash::H256, trie::Input};
|
||||
|
||||
/// Trie test deserialization.
|
||||
#[derive(Debug, Deserialize, PartialEq)]
|
||||
|
@ -148,9 +148,9 @@ where
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::uint::Uint;
|
||||
use ethereum_types::U256;
|
||||
use serde_json;
|
||||
use uint::Uint;
|
||||
|
||||
#[test]
|
||||
fn uint_deserialization() {
|
||||
|
@ -16,10 +16,7 @@
|
||||
|
||||
//! Vm call deserialization.
|
||||
|
||||
use bytes::Bytes;
|
||||
use hash::Address;
|
||||
use maybe::MaybeEmpty;
|
||||
use uint::Uint;
|
||||
use crate::{bytes::Bytes, hash::Address, maybe::MaybeEmpty, uint::Uint};
|
||||
|
||||
/// Vm call deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@ -37,13 +34,11 @@ pub struct Call {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{hash::Address, maybe::MaybeEmpty, uint::Uint, vm::Call};
|
||||
use ethereum_types::{H160 as Hash160, U256};
|
||||
use hash::Address;
|
||||
use maybe::MaybeEmpty;
|
||||
|
||||
use serde_json;
|
||||
use std::str::FromStr;
|
||||
use uint::Uint;
|
||||
use vm::Call;
|
||||
|
||||
#[test]
|
||||
fn call_deserialization_empty_dest() {
|
||||
|
@ -15,8 +15,7 @@
|
||||
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Vm environment.
|
||||
use hash::Address;
|
||||
use uint::Uint;
|
||||
use crate::{hash::Address, uint::Uint};
|
||||
|
||||
/// Vm environment.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@ -40,8 +39,8 @@ pub struct Env {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Env;
|
||||
use serde_json;
|
||||
use vm::Env;
|
||||
|
||||
#[test]
|
||||
fn env_deserialization() {
|
||||
|
@ -16,9 +16,9 @@
|
||||
|
||||
//! Vm test deserializer.
|
||||
|
||||
use crate::vm::Vm;
|
||||
use serde_json::{self, Error};
|
||||
use std::{collections::BTreeMap, io::Read};
|
||||
use vm::Vm;
|
||||
|
||||
/// Vm test deserializer.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
|
@ -15,9 +15,7 @@
|
||||
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Executed transaction.
|
||||
use bytes::Bytes;
|
||||
use hash::Address;
|
||||
use uint::Uint;
|
||||
use crate::{bytes::Bytes, hash::Address, uint::Uint};
|
||||
|
||||
/// Executed transaction.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@ -44,8 +42,8 @@ pub struct Transaction {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Transaction;
|
||||
use serde_json;
|
||||
use vm::Transaction;
|
||||
|
||||
#[test]
|
||||
fn transaction_deserialization() {
|
||||
|
@ -16,11 +16,13 @@
|
||||
|
||||
//! Vm execution env.
|
||||
|
||||
use blockchain::State;
|
||||
use bytes::Bytes;
|
||||
use hash::H256;
|
||||
use uint::Uint;
|
||||
use vm::{Call, Env, Transaction};
|
||||
use crate::{
|
||||
blockchain::State,
|
||||
bytes::Bytes,
|
||||
hash::H256,
|
||||
uint::Uint,
|
||||
vm::{Call, Env, Transaction},
|
||||
};
|
||||
|
||||
/// Represents vm execution environment before and after execution of transaction.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@ -58,8 +60,8 @@ impl Vm {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Vm;
|
||||
use serde_json;
|
||||
use vm::Vm;
|
||||
|
||||
#[test]
|
||||
fn vm_deserialization() {
|
||||
|
Loading…
Reference in New Issue
Block a user