Deprecate account management (#10213)
* Extract accounts from ethcore. * Fix ethcore. * Get rid of AccountProvider in test_helpers * Fix rest of the code. * Re-use EngineSigner, fix tests. * Simplify EngineSigner to always have an Address. * Fix RPC tests. * Add deprecation notice to RPCs. * Feature to disable accounts. * extract accounts in RPC * Run with accounts in tests. * Fix RPC compilation and tests. * Fix compilation of the binary. * Fix compilation of the binary. * Fix compilation with accounts enabled. * Fix tests. * Update submodule. * Remove android. * Use derive for Default * Don't build secretstore by default. * Add link to issue. * Refresh Cargo.lock. * Fix miner tests. * Update rpc/Cargo.toml Co-Authored-By: tomusdrw <tomusdrw@users.noreply.github.com> * Fix private tests.
This commit is contained in:
committed by
Afri Schoedon
parent
8fa56add47
commit
d5c19f8719
@@ -9,13 +9,13 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
|
||||
[dependencies]
|
||||
common-types = { path = "../types" }
|
||||
env_logger = "0.5"
|
||||
ethcore = { path = ".." }
|
||||
ethcore-io = { path = "../../util/io" }
|
||||
ethcore-light = { path = "../light" }
|
||||
ethcore-network = { path = "../../util/network" }
|
||||
ethcore-network-devp2p = { path = "../../util/network-devp2p" }
|
||||
ethereum-types = "0.4"
|
||||
ethkey = { path = "../../accounts/ethkey" }
|
||||
ethstore = { path = "../../accounts/ethstore" }
|
||||
fastmap = { path = "../../util/fastmap" }
|
||||
hashdb = "0.3.0"
|
||||
@@ -34,9 +34,8 @@ triehash-ethereum = {version = "0.2", path = "../../util/triehash-ethereum" }
|
||||
|
||||
[dev-dependencies]
|
||||
env_logger = "0.5"
|
||||
ethcore-io = { path = "../../util/io", features = ["mio"] }
|
||||
ethkey = { path = "../../accounts/ethkey" }
|
||||
kvdb-memorydb = "0.1"
|
||||
ethcore-private-tx = { path = "../private-tx" }
|
||||
ethcore = { path = "..", features = ["test-helpers"] }
|
||||
ethcore-io = { path = "../../util/io", features = ["mio"] }
|
||||
ethcore-private-tx = { path = "../private-tx" }
|
||||
kvdb-memorydb = "0.1"
|
||||
rustc-hex = "1.0"
|
||||
|
||||
@@ -28,7 +28,7 @@ use network::{NetworkProtocolHandler, NetworkContext, PeerId, ProtocolId,
|
||||
use types::pruning_info::PruningInfo;
|
||||
use ethereum_types::{H256, H512, U256};
|
||||
use io::{TimerToken};
|
||||
use ethstore::ethkey::Secret;
|
||||
use ethkey::Secret;
|
||||
use ethcore::client::{BlockChainClient, ChainNotify, NewBlocks, ChainMessageType};
|
||||
use ethcore::snapshot::SnapshotService;
|
||||
use types::BlockNumber;
|
||||
|
||||
@@ -27,6 +27,7 @@ extern crate ethcore_io as io;
|
||||
extern crate ethcore_network as network;
|
||||
extern crate ethcore_network_devp2p as devp2p;
|
||||
extern crate ethereum_types;
|
||||
extern crate ethkey;
|
||||
extern crate ethstore;
|
||||
extern crate fastmap;
|
||||
extern crate keccak_hash as hash;
|
||||
@@ -40,7 +41,6 @@ extern crate ethcore_light as light;
|
||||
|
||||
#[cfg(test)] extern crate env_logger;
|
||||
#[cfg(test)] extern crate ethcore_private_tx;
|
||||
#[cfg(test)] extern crate ethkey;
|
||||
#[cfg(test)] extern crate kvdb_memorydb;
|
||||
#[cfg(test)] extern crate rustc_hex;
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ use hash::keccak;
|
||||
use ethereum_types::{U256, Address};
|
||||
use io::{IoHandler, IoChannel};
|
||||
use ethcore::client::{ChainInfo, ClientIoMessage};
|
||||
use ethcore::engines;
|
||||
use ethcore::spec::Spec;
|
||||
use ethcore::miner::MinerService;
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use ethcore::miner::{self, MinerService};
|
||||
use ethkey::{KeyPair, Secret};
|
||||
use types::transaction::{Action, PendingTransaction, Transaction};
|
||||
use super::helpers::*;
|
||||
@@ -43,17 +43,14 @@ fn new_tx(secret: &Secret, nonce: U256, chain_id: u64) -> PendingTransaction {
|
||||
fn authority_round() {
|
||||
let s0 = KeyPair::from_secret_slice(&keccak("1")).unwrap();
|
||||
let s1 = KeyPair::from_secret_slice(&keccak("0")).unwrap();
|
||||
let ap = Arc::new(AccountProvider::transient_provider());
|
||||
ap.insert_account(s0.secret().clone(), &"".into()).unwrap();
|
||||
ap.insert_account(s1.secret().clone(), &"".into()).unwrap();
|
||||
|
||||
let chain_id = Spec::new_test_round().chain_id();
|
||||
let mut net = TestNet::with_spec_and_accounts(2, SyncConfig::default(), Spec::new_test_round, Some(ap));
|
||||
let mut net = TestNet::with_spec(2, SyncConfig::default(), Spec::new_test_round);
|
||||
let io_handler0: Arc<IoHandler<ClientIoMessage>> = Arc::new(TestIoHandler::new(net.peer(0).chain.clone()));
|
||||
let io_handler1: Arc<IoHandler<ClientIoMessage>> = Arc::new(TestIoHandler::new(net.peer(1).chain.clone()));
|
||||
// Push transaction to both clients. Only one of them gets lucky to produce a block.
|
||||
net.peer(0).miner.set_author(s0.address(), Some("".into())).unwrap();
|
||||
net.peer(1).miner.set_author(s1.address(), Some("".into())).unwrap();
|
||||
net.peer(0).miner.set_author(miner::Author::Sealer(engines::signer::from_keypair(s0.clone())));
|
||||
net.peer(1).miner.set_author(miner::Author::Sealer(engines::signer::from_keypair(s1.clone())));
|
||||
net.peer(0).chain.engine().register_client(Arc::downgrade(&net.peer(0).chain) as _);
|
||||
net.peer(1).chain.engine().register_client(Arc::downgrade(&net.peer(1).chain) as _);
|
||||
net.peer(0).chain.set_io_channel(IoChannel::to_handler(Arc::downgrade(&io_handler1)));
|
||||
|
||||
@@ -25,7 +25,6 @@ use ethcore::client::{TestBlockChainClient, BlockChainClient, Client as EthcoreC
|
||||
ClientConfig, ChainNotify, NewBlocks, ChainMessageType, ClientIoMessage};
|
||||
use ethcore::snapshot::SnapshotService;
|
||||
use ethcore::spec::Spec;
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use ethcore::miner::Miner;
|
||||
use ethcore::test_helpers;
|
||||
use sync_io::SyncIo;
|
||||
@@ -367,11 +366,10 @@ impl TestNet<EthPeer<TestBlockChainClient>> {
|
||||
}
|
||||
|
||||
impl TestNet<EthPeer<EthcoreClient>> {
|
||||
pub fn with_spec_and_accounts<F>(
|
||||
pub fn with_spec<F>(
|
||||
n: usize,
|
||||
config: SyncConfig,
|
||||
spec_factory: F,
|
||||
accounts: Option<Arc<AccountProvider>>
|
||||
) -> Self
|
||||
where F: Fn() -> Spec
|
||||
{
|
||||
@@ -381,14 +379,14 @@ impl TestNet<EthPeer<EthcoreClient>> {
|
||||
disconnect_events: Vec::new(),
|
||||
};
|
||||
for _ in 0..n {
|
||||
net.add_peer_with_private_config(config.clone(), spec_factory(), accounts.clone());
|
||||
net.add_peer_with_private_config(config.clone(), spec_factory());
|
||||
}
|
||||
net
|
||||
}
|
||||
|
||||
pub fn add_peer_with_private_config(&mut self, config: SyncConfig, spec: Spec, accounts: Option<Arc<AccountProvider>>) {
|
||||
pub fn add_peer_with_private_config(&mut self, config: SyncConfig, spec: Spec) {
|
||||
let channel = IoChannel::disconnected();
|
||||
let miner = Arc::new(Miner::new_for_tests(&spec, accounts.clone()));
|
||||
let miner = Arc::new(Miner::new_for_tests(&spec, None));
|
||||
let client = EthcoreClient::new(
|
||||
ClientConfig::default(),
|
||||
&spec,
|
||||
|
||||
@@ -17,16 +17,17 @@
|
||||
use std::sync::Arc;
|
||||
use hash::keccak;
|
||||
use io::{IoHandler, IoChannel};
|
||||
use ethcore::client::{BlockChainClient, BlockId, ClientIoMessage};
|
||||
use ethcore::spec::Spec;
|
||||
use ethcore::miner::MinerService;
|
||||
use ethcore::CreateContractAddress;
|
||||
use types::transaction::{Transaction, Action};
|
||||
use types::ids::BlockId;
|
||||
use ethcore::CreateContractAddress;
|
||||
use ethcore::client::{ClientIoMessage, BlockChainClient};
|
||||
use ethcore::executive::{contract_address};
|
||||
use ethcore::engines;
|
||||
use ethcore::miner::{self, MinerService};
|
||||
use ethcore::spec::Spec;
|
||||
use ethcore::test_helpers::{push_block_with_transactions};
|
||||
use ethcore_private_tx::{Provider, ProviderConfig, NoopEncryptor, Importer, SignedPrivateTransaction, StoringKeyProvider};
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use ethkey::{KeyPair};
|
||||
use ethkey::KeyPair;
|
||||
use tests::helpers::{TestNet, TestIoHandler};
|
||||
use rustc_hex::FromHex;
|
||||
use rlp::Rlp;
|
||||
@@ -42,18 +43,17 @@ fn send_private_transaction() {
|
||||
// Setup two clients
|
||||
let s0 = KeyPair::from_secret_slice(&keccak("1")).unwrap();
|
||||
let s1 = KeyPair::from_secret_slice(&keccak("0")).unwrap();
|
||||
let ap = Arc::new(AccountProvider::transient_provider());
|
||||
ap.insert_account(s0.secret().clone(), &"".into()).unwrap();
|
||||
ap.insert_account(s1.secret().clone(), &"".into()).unwrap();
|
||||
|
||||
let mut net = TestNet::with_spec_and_accounts(2, SyncConfig::default(), seal_spec, Some(ap.clone()));
|
||||
let signer = Arc::new(ethcore_private_tx::KeyPairSigner(vec![s0.clone(), s1.clone()]));
|
||||
|
||||
let mut net = TestNet::with_spec(2, SyncConfig::default(), seal_spec);
|
||||
let client0 = net.peer(0).chain.clone();
|
||||
let client1 = net.peer(1).chain.clone();
|
||||
let io_handler0: Arc<IoHandler<ClientIoMessage>> = Arc::new(TestIoHandler::new(net.peer(0).chain.clone()));
|
||||
let io_handler1: Arc<IoHandler<ClientIoMessage>> = Arc::new(TestIoHandler::new(net.peer(1).chain.clone()));
|
||||
|
||||
net.peer(0).miner.set_author(s0.address(), Some("".into())).unwrap();
|
||||
net.peer(1).miner.set_author(s1.address(), Some("".into())).unwrap();
|
||||
net.peer(0).miner.set_author(miner::Author::Sealer(engines::signer::from_keypair(s0.clone())));
|
||||
net.peer(1).miner.set_author(miner::Author::Sealer(engines::signer::from_keypair(s1.clone())));
|
||||
net.peer(0).chain.engine().register_client(Arc::downgrade(&net.peer(0).chain) as _);
|
||||
net.peer(1).chain.engine().register_client(Arc::downgrade(&net.peer(1).chain) as _);
|
||||
net.peer(0).chain.set_io_channel(IoChannel::to_handler(Arc::downgrade(&io_handler0)));
|
||||
@@ -69,13 +69,11 @@ fn send_private_transaction() {
|
||||
let validator_config = ProviderConfig{
|
||||
validator_accounts: vec![s1.address()],
|
||||
signer_account: None,
|
||||
passwords: vec!["".into()],
|
||||
};
|
||||
|
||||
let signer_config = ProviderConfig{
|
||||
validator_accounts: Vec::new(),
|
||||
signer_account: Some(s0.address()),
|
||||
passwords: vec!["".into()],
|
||||
};
|
||||
|
||||
let private_keys = Arc::new(StoringKeyProvider::default());
|
||||
@@ -83,7 +81,7 @@ fn send_private_transaction() {
|
||||
let pm0 = Arc::new(Provider::new(
|
||||
client0.clone(),
|
||||
net.peer(0).miner.clone(),
|
||||
ap.clone(),
|
||||
signer.clone(),
|
||||
Box::new(NoopEncryptor::default()),
|
||||
signer_config,
|
||||
IoChannel::to_handler(Arc::downgrade(&io_handler0)),
|
||||
@@ -94,7 +92,7 @@ fn send_private_transaction() {
|
||||
let pm1 = Arc::new(Provider::new(
|
||||
client1.clone(),
|
||||
net.peer(1).miner.clone(),
|
||||
ap.clone(),
|
||||
signer.clone(),
|
||||
Box::new(NoopEncryptor::default()),
|
||||
validator_config,
|
||||
IoChannel::to_handler(Arc::downgrade(&io_handler1)),
|
||||
|
||||
Reference in New Issue
Block a user