Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Beta backports to 2.0.4 (#9452)
Browse files Browse the repository at this point in the history
* parity-version: bump beta to 2.0.4

* [light/jsonrpc] Provide the actual account for `eth_coinbase` RPC and unify error handeling for light and full client (#9383)

* Provide the actual `account` for eth_coinbase

The previous implementation always provided the `zero address` on
`eth_coinbase` RPC. Now, instead the actual address is returned on
success or an error when no account(s) is found!

* full client `eth_coinbase` return err

In the full-client return an error when no account is found instead of
returning the `zero address`

* Remove needless blocks on single import

* Remove needless `static` lifetime on const

* Fix `rpc_eth_author` test

* parity: print correct keys path on startup (#9501)

* aura: don't report skipped primaries when empty steps are enabled (#9435)

* Only check warp syncing for eth_getWorks (#9484)

* Only check warp syncing for eth_getWorks

* Use SyncStatus::is_snapshot_syncing

* Fix Snapshot restoration failure on Windows (#9491)

* Close Blooms DB files before DB restoration

* PR Grumbles I

* PR Grumble

* Grumble
  • Loading branch information
5chdn authored Sep 10, 2018
1 parent a0a2bed commit e2e1d22
Show file tree
Hide file tree
Showing 13 changed files with 183 additions and 71 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description = "Parity Ethereum client"
name = "parity-ethereum"
# NOTE Make sure to update util/version/Cargo.toml as well
version = "2.0.3"
version = "2.0.4"
license = "GPL-3.0"
authors = ["Parity Technologies <admin@parity.io>"]

Expand Down
16 changes: 16 additions & 0 deletions ethcore/src/blockchain/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use encoded;
use engines::epoch::{Transition as EpochTransition, PendingTransition as PendingEpochTransition};
use engines::ForkChoice;
use ethereum_types::{H256, Bloom, BloomRef, U256};
use error::Error as EthcoreError;
use header::*;
use heapsize::HeapSizeOf;
use itertools::Itertools;
Expand All @@ -60,6 +61,21 @@ pub trait BlockChainDB: Send + Sync {

/// Trace blooms database.
fn trace_blooms(&self) -> &blooms_db::Database;

/// Restore the DB from the given path
fn restore(&self, new_db: &str) -> Result<(), EthcoreError> {
// First, close the Blooms databases
self.blooms().close()?;
self.trace_blooms().close()?;

// Restore the key_value DB
self.key_value().restore(new_db)?;

// Re-open the Blooms databases
self.blooms().reopen()?;
self.trace_blooms().reopen()?;
Ok(())
}
}

/// Generic database handler. This trait contains one function `open`. When called, it opens database with a
Expand Down
4 changes: 1 addition & 3 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1296,9 +1296,7 @@ impl snapshot::DatabaseRestore for Client {
let mut tracedb = self.tracedb.write();
self.importer.miner.clear();
let db = self.db.write();
db.key_value().restore(new_db)?;
db.blooms().reopen()?;
db.trace_blooms().reopen()?;
db.restore(new_db)?;

let cache_size = state_db.cache_size();
*state_db = StateDB::new(journaldb::new(db.key_value().clone(), self.pruning, ::db::COL_STATE), cache_size);
Expand Down
6 changes: 4 additions & 2 deletions ethcore/src/engines/authority_round/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -984,8 +984,10 @@ impl Engine<EthereumMachine> for AuthorityRound {
self.clear_empty_steps(parent_step);

// report any skipped primaries between the parent block and
// the block we're sealing
self.report_skipped(header, step, u64::from(parent_step) as usize, &*validators, set_number);
// the block we're sealing, unless we have empty steps enabled
if header.number() < self.empty_steps_transition {
self.report_skipped(header, step, u64::from(parent_step) as usize, &*validators, set_number);
}

let mut fields = vec![
encode(&step).into_vec(),
Expand Down
8 changes: 4 additions & 4 deletions parity/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ fn execute_light_impl(cmd: RunCmd, logger: Arc<RotatingLogger>) -> Result<Runnin
cmd.dirs.create_dirs(cmd.acc_conf.unlocked_accounts.len() == 0, cmd.secretstore_conf.enabled)?;

//print out running parity environment
print_running_environment(&spec.name, &cmd.dirs, &db_dirs);
print_running_environment(&spec.data_dir, &cmd.dirs, &db_dirs);

info!("Running in experimental {} mode.", Colour::Blue.bold().paint("Light Client"));

Expand Down Expand Up @@ -402,7 +402,7 @@ fn execute_impl<Cr, Rr>(cmd: RunCmd, logger: Arc<RotatingLogger>, on_client_rq:
}

//print out running parity environment
print_running_environment(&spec.name, &cmd.dirs, &db_dirs);
print_running_environment(&spec.data_dir, &cmd.dirs, &db_dirs);

// display info about used pruning algorithm
info!("State DB configuration: {}{}{}",
Expand Down Expand Up @@ -926,9 +926,9 @@ fn daemonize(_pid_file: String) -> Result<(), String> {
Err("daemon is no supported on windows".into())
}

fn print_running_environment(spec_name: &String, dirs: &Directories, db_dirs: &DatabaseDirectories) {
fn print_running_environment(data_dir: &str, dirs: &Directories, db_dirs: &DatabaseDirectories) {
info!("Starting {}", Colour::White.bold().paint(version()));
info!("Keys path {}", Colour::White.bold().paint(dirs.keys_path(spec_name).to_string_lossy().into_owned()));
info!("Keys path {}", Colour::White.bold().paint(dirs.keys_path(data_dir).to_string_lossy().into_owned()));
info!("DB path {}", Colour::White.bold().paint(db_dirs.db_root_path().to_string_lossy().into_owned()));
}

Expand Down
18 changes: 11 additions & 7 deletions rpc/src/v1/impls/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use ethcore::log_entry::LogEntry;
use ethcore::miner::{self, MinerService};
use ethcore::snapshot::SnapshotService;
use ethcore::encoded;
use sync::{SyncProvider};
use sync::SyncProvider;
use miner::external::ExternalMinerService;
use transaction::{SignedTransaction, LocalizedTransaction};

Expand All @@ -52,7 +52,7 @@ use v1::types::{
};
use v1::metadata::Metadata;

const EXTRA_INFO_PROOF: &'static str = "Object exists in blockchain (fetched earlier), extra_info is always available if object exists; qed";
const EXTRA_INFO_PROOF: &str = "Object exists in blockchain (fetched earlier), extra_info is always available if object exists; qed";

/// Eth RPC options
pub struct EthClientOptions {
Expand Down Expand Up @@ -502,12 +502,16 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
}

fn author(&self) -> Result<RpcH160> {
let mut miner = self.miner.authoring_params().author;
let miner = self.miner.authoring_params().author;
if miner == 0.into() {
miner = self.accounts.accounts().ok().and_then(|a| a.get(0).cloned()).unwrap_or_default();
self.accounts.accounts()
.ok()
.and_then(|a| a.first().cloned())
.map(From::from)
.ok_or_else(|| errors::account("No accounts were found", ""))
} else {
Ok(RpcH160::from(miner))
}

Ok(RpcH160::from(miner))
}

fn is_mining(&self) -> Result<bool> {
Expand Down Expand Up @@ -737,7 +741,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
let queue_info = self.client.queue_info();
let total_queue_size = queue_info.total_queue_size();

if is_major_importing(Some(sync_status.state), queue_info) || total_queue_size > MAX_QUEUE_SIZE_TO_MINE_ON {
if sync_status.is_snapshot_syncing() || total_queue_size > MAX_QUEUE_SIZE_TO_MINE_ON {
trace!(target: "miner", "Syncing. Cannot give any work.");
return Err(errors::no_work());
}
Expand Down
6 changes: 5 additions & 1 deletion rpc/src/v1/impls/light/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,11 @@ impl<T: LightChainClient + 'static> Eth for EthClient<T> {
}

fn author(&self) -> Result<RpcH160> {
Ok(Default::default())
self.accounts.accounts()
.ok()
.and_then(|a| a.first().cloned())
.map(From::from)
.ok_or_else(|| errors::account("No accounts were found", ""))
}

fn is_mining(&self) -> Result<bool> {
Expand Down
12 changes: 7 additions & 5 deletions rpc/src/v1/tests/mocked/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,25 +350,27 @@ fn rpc_eth_author() {
let make_res = |addr| r#"{"jsonrpc":"2.0","result":""#.to_owned() + &format!("0x{:x}", addr) + r#"","id":1}"#;
let tester = EthTester::default();

let req = r#"{
let request = r#"{
"jsonrpc": "2.0",
"method": "eth_coinbase",
"params": [],
"id": 1
}"#;

// No accounts - returns zero
assert_eq!(tester.io.handle_request_sync(req), Some(make_res(Address::zero())));
let response = r#"{"jsonrpc":"2.0","error":{"code":-32023,"message":"No accounts were found","data":"\"\""},"id":1}"#;

// No accounts - returns an error indicating that no accounts were found
assert_eq!(tester.io.handle_request_sync(request), Some(response.to_string()));

// Account set - return first account
let addr = tester.accounts_provider.new_account(&"123".into()).unwrap();
assert_eq!(tester.io.handle_request_sync(req), Some(make_res(addr)));
assert_eq!(tester.io.handle_request_sync(request), Some(make_res(addr)));

for i in 0..20 {
let addr = tester.accounts_provider.new_account(&format!("{}", i).into()).unwrap();
tester.miner.set_author(addr.clone(), None).unwrap();

assert_eq!(tester.io.handle_request_sync(req), Some(make_res(addr)));
assert_eq!(tester.io.handle_request_sync(request), Some(make_res(addr)));
}
}

Expand Down
Loading

0 comments on commit e2e1d22

Please sign in to comment.