Backports to beta (#2068)

* Fix several RPCs (#1926)

* Fix up pending receipts details.

* Add support for additional params and registry over RPC.

* Fix tests.

* Add test, additional fix.

Fixes #1932.

* Fix up tests.

* Fix test.

* Fix test.

* DB WAL size limit (#1935)

* Limit WAL size

* Check pruning by db modification date (#1924)

* Cache address hash (#1943)

* ECIES without MAC (#1948)

* Use random IV for ECIES AES

* ECIES encrypt/decrypt for a single message

* Derive IV from shared secret

* Apply settings to column families

* fixed #1933 (#1979)

* Fixed neighbours collection (#1996)

* dapps-hosts configuration

* Disabled counter check

* always process trie death row on commit, add more tracing

* fixed transaction addresses mapping, fixes #1971

* simplified iterator

* v1.3.1

* v1.3.1
This commit is contained in:
Arkadiy Paronyan
2016-09-11 14:04:17 +02:00
committed by GitHub
parent 1ccc90108c
commit 2a82fa0a47
43 changed files with 732 additions and 181 deletions

View File

@@ -107,7 +107,7 @@ impl<C, S: ?Sized, M, EM> EthClient<C, S, M, EM> where
let view = block_view.header_view();
let block = Block {
hash: Some(view.sha3().into()),
size: Some(bytes.len()),
size: Some(bytes.len().into()),
parent_hash: view.parent_hash().into(),
uncles_hash: view.uncles_hash().into(),
author: view.author().into(),
@@ -460,8 +460,8 @@ impl<C, S: ?Sized, M, EM> Eth for EthClient<C, S, M, EM> where
.and_then(|(hash,)| {
let miner = take_weak!(self.miner);
let hash: H256 = hash.into();
match miner.pending_receipts().get(&hash) {
Some(receipt) if self.options.allow_pending_receipt_query => to_value(&Receipt::from(receipt.clone())),
match (miner.pending_receipt(&hash), self.options.allow_pending_receipt_query) {
(Some(receipt), true) => to_value(&Receipt::from(receipt)),
_ => {
let client = take_weak!(self.client);
let receipt = client.transaction_receipt(TransactionID::Hash(hash));

View File

@@ -15,17 +15,18 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Ethcore-specific rpc implementation.
use util::{RotatingLogger};
use util::misc::version_data;
use std::sync::{Arc, Weak};
use std::str::FromStr;
use std::collections::{BTreeMap};
use util::{RotatingLogger, Address};
use util::misc::version_data;
use ethsync::{SyncProvider, ManageNetwork};
use ethcore::miner::MinerService;
use ethcore::client::{MiningBlockChainClient};
use jsonrpc_core::*;
use v1::traits::Ethcore;
use v1::types::{Bytes, U256, Peers};
use v1::types::{Bytes, U256, Peers, H160};
use v1::helpers::{errors, SigningQueue, ConfirmationsQueue, NetworkSettings};
use v1::helpers::params::expect_no_params;
@@ -54,7 +55,7 @@ impl<C, M, S: ?Sized> EthcoreClient<C, M, S> where C: MiningBlockChainClient, M:
logger: Arc<RotatingLogger>,
settings: Arc<NetworkSettings>,
queue: Option<Arc<ConfirmationsQueue>>
) -> Self {
) -> Self {
EthcoreClient {
client: Arc::downgrade(client),
miner: Arc::downgrade(miner),
@@ -150,6 +151,17 @@ impl<C, M, S: ?Sized> Ethcore for EthcoreClient<C, M, S> where M: MinerService +
to_value(&self.settings.name)
}
fn registry_address(&self, params: Params) -> Result<Value, Error> {
try!(self.active());
try!(expect_no_params(params));
let r = take_weak!(self.client)
.additional_params()
.get("registrar")
.and_then(|s| Address::from_str(s).ok())
.map(|s| H160::from(s));
to_value(&r)
}
fn rpc_settings(&self, params: Params) -> Result<Value, Error> {
try!(self.active());
try!(expect_no_params(params));

View File

@@ -22,7 +22,7 @@ use ethcore::error::{Error, CallError};
use ethcore::client::{MiningBlockChainClient, Executed, CallAnalytics};
use ethcore::block::{ClosedBlock, IsBlock};
use ethcore::transaction::SignedTransaction;
use ethcore::receipt::Receipt;
use ethcore::receipt::{Receipt, RichReceipt};
use ethcore::miner::{MinerService, MinerStatus, TransactionImportResult};
/// Test miner service.
@@ -198,6 +198,20 @@ impl MinerService for TestMinerService {
self.pending_transactions.lock().values().cloned().collect()
}
fn pending_receipt(&self, hash: &H256) -> Option<RichReceipt> {
// Not much point implementing this since the logic is complex and the only thing it relies on is pending_receipts, which is already tested.
self.pending_receipts().get(hash).map(|r|
RichReceipt {
transaction_hash: Default::default(),
transaction_index: Default::default(),
cumulative_gas_used: r.gas_used.clone(),
gas_used: r.gas_used.clone(),
contract_address: None,
logs: r.logs.clone(),
}
)
}
fn pending_receipts(&self) -> BTreeMap<H256, Receipt> {
self.pending_receipts.lock().clone()
}

View File

@@ -67,6 +67,9 @@ pub trait Ethcore: Sized + Send + Sync + 'static {
/// Returns error when signer is disabled
fn unsigned_transactions_count(&self, _: Params) -> Result<Value, Error>;
/// Returns the value of the registrar for this network.
fn registry_address(&self, _: Params) -> Result<Value, Error>;
/// Should be used to convert object to io delegate.
fn to_delegate(self) -> IoDelegate<Self> {
let mut delegate = IoDelegate::new(Arc::new(self));
@@ -86,7 +89,7 @@ pub trait Ethcore: Sized + Send + Sync + 'static {
delegate.add_method("ethcore_defaultExtraData", Ethcore::default_extra_data);
delegate.add_method("ethcore_gasPriceStatistics", Ethcore::gas_price_statistics);
delegate.add_method("ethcore_unsignedTransactionsCount", Ethcore::unsigned_transactions_count);
delegate.add_method("ethcore_registryAddress", Ethcore::registry_address);
delegate
}
}

View File

@@ -90,7 +90,7 @@ pub struct Block {
/// Transactions
pub transactions: BlockTransactions,
/// Size in bytes
pub size: Option<usize>,
pub size: Option<U256>,
}
#[cfg(test)]
@@ -132,10 +132,10 @@ mod tests {
seal_fields: vec![Bytes::default(), Bytes::default()],
uncles: vec![],
transactions: BlockTransactions::Hashes(vec![].into()),
size: Some(69usize),
size: Some(69.into()),
};
let serialized = serde_json::to_string(&block).unwrap();
assert_eq!(serialized, r#"{"hash":"0x0000000000000000000000000000000000000000000000000000000000000000","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","sha3Uncles":"0x0000000000000000000000000000000000000000000000000000000000000000","author":"0x0000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","number":"0x00","gasUsed":"0x00","gasLimit":"0x00","extraData":"0x","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","timestamp":"0x00","difficulty":"0x00","totalDifficulty":"0x00","sealFields":["0x","0x"],"uncles":[],"transactions":[],"size":69}"#);
assert_eq!(serialized, r#"{"hash":"0x0000000000000000000000000000000000000000000000000000000000000000","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","sha3Uncles":"0x0000000000000000000000000000000000000000000000000000000000000000","author":"0x0000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","number":"0x00","gasUsed":"0x00","gasLimit":"0x00","extraData":"0x","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","timestamp":"0x00","difficulty":"0x00","totalDifficulty":"0x00","sealFields":["0x","0x"],"uncles":[],"transactions":[],"size":"0x45"}"#);
}
}

View File

@@ -15,7 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use v1::types::{Log, H160, H256, U256};
use ethcore::receipt::{Receipt as EthReceipt, LocalizedReceipt};
use ethcore::receipt::{Receipt as EthReceipt, RichReceipt, LocalizedReceipt};
/// Receipt
#[derive(Debug, Serialize)]
@@ -37,7 +37,7 @@ pub struct Receipt {
pub cumulative_gas_used: U256,
/// Gas used
#[serde(rename="gasUsed")]
pub gas_used: U256,
pub gas_used: Option<U256>,
/// Contract address
#[serde(rename="contractAddress")]
pub contract_address: Option<H160>,
@@ -53,7 +53,22 @@ impl From<LocalizedReceipt> for Receipt {
block_hash: Some(r.block_hash.into()),
block_number: Some(r.block_number.into()),
cumulative_gas_used: r.cumulative_gas_used.into(),
gas_used: r.gas_used.into(),
gas_used: Some(r.gas_used.into()),
contract_address: r.contract_address.map(Into::into),
logs: r.logs.into_iter().map(Into::into).collect(),
}
}
}
impl From<RichReceipt> for Receipt {
fn from(r: RichReceipt) -> Self {
Receipt {
transaction_hash: Some(r.transaction_hash.into()),
transaction_index: Some(r.transaction_index.into()),
block_hash: None,
block_number: None,
cumulative_gas_used: r.cumulative_gas_used.into(),
gas_used: Some(r.gas_used.into()),
contract_address: r.contract_address.map(Into::into),
logs: r.logs.into_iter().map(Into::into).collect(),
}
@@ -68,7 +83,7 @@ impl From<EthReceipt> for Receipt {
block_hash: None,
block_number: None,
cumulative_gas_used: r.gas_used.into(),
gas_used: r.gas_used.into(),
gas_used: None,
contract_address: None,
logs: r.logs.into_iter().map(Into::into).collect(),
}
@@ -91,7 +106,7 @@ mod tests {
block_hash: Some(H256::from_str("ed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5").unwrap()),
block_number: Some(U256::from(0x4510c)),
cumulative_gas_used: U256::from(0x20),
gas_used: U256::from(0x10),
gas_used: Some(U256::from(0x10)),
contract_address: None,
logs: vec![Log {
address: H160::from_str("33990122638b9132ca29c723bdf037f1a891a70c").unwrap(),

View File

@@ -32,14 +32,14 @@ pub struct MemoryDiff {
/// Offset into memory the change begins.
pub off: usize,
/// The changed data.
pub data: Vec<u8>,
pub data: Bytes,
}
impl From<et::MemoryDiff> for MemoryDiff {
fn from(c: et::MemoryDiff) -> Self {
MemoryDiff {
off: c.offset,
data: c.data,
data: c.data.into(),
}
}
}
@@ -118,7 +118,7 @@ impl From<(et::VMOperation, Option<et::VMTrace>)> for VMOperation {
/// A record of a full VM trace for a CALL/CREATE.
pub struct VMTrace {
/// The code to be executed.
pub code: Vec<u8>,
pub code: Bytes,
/// The operations executed.
pub ops: Vec<VMOperation>,
}
@@ -128,7 +128,7 @@ impl From<et::VMTrace> for VMTrace {
let mut subs = c.subs.into_iter();
let mut next_sub = subs.next();
VMTrace {
code: c.code,
code: c.code.into(),
ops: c.operations
.into_iter()
.enumerate()
@@ -485,7 +485,7 @@ impl From<FlatTrace> for Trace {
/// A diff of some chunk of memory.
pub struct TraceResults {
/// The output of the call/create
pub output: Vec<u8>,
pub output: Bytes,
/// The transaction trace.
pub trace: Vec<Trace>,
/// The transaction trace.
@@ -517,13 +517,13 @@ mod tests {
#[test]
fn should_serialize_trace_results() {
let r = TraceResults {
output: vec![0x60],
output: vec![0x60].into(),
trace: vec![],
vm_trace: None,
state_diff: None,
};
let serialized = serde_json::to_string(&r).unwrap();
assert_eq!(serialized, r#"{"output":[96],"trace":[],"vmTrace":null,"stateDiff":null}"#);
assert_eq!(serialized, r#"{"output":"0x60","trace":[],"vmTrace":null,"stateDiff":null}"#);
}
#[test]
@@ -555,7 +555,7 @@ mod tests {
#[test]
fn test_vmtrace_serialize() {
let t = VMTrace {
code: vec![0, 1, 2, 3],
code: vec![0, 1, 2, 3].into(),
ops: vec![
VMOperation {
pc: 0,
@@ -573,15 +573,15 @@ mod tests {
store: None,
}),
sub: Some(VMTrace {
code: vec![0],
code: vec![0].into(),
ops: vec![
VMOperation {
pc: 0,
cost: 0,
ex: Some(VMExecutedOperation {
used: 10,
push: vec![42.into()],
mem: Some(MemoryDiff {off: 42, data: vec![1, 2, 3]}),
push: vec![42.into()].into(),
mem: Some(MemoryDiff {off: 42, data: vec![1, 2, 3].into()}),
store: Some(StorageDiff {key: 69.into(), val: 42.into()}),
}),
sub: None,
@@ -592,7 +592,7 @@ mod tests {
]
};
let serialized = serde_json::to_string(&t).unwrap();
assert_eq!(serialized, r#"{"code":[0,1,2,3],"ops":[{"pc":0,"cost":10,"ex":null,"sub":null},{"pc":1,"cost":11,"ex":{"used":10,"push":["0x45"],"mem":null,"store":null},"sub":{"code":[0],"ops":[{"pc":0,"cost":0,"ex":{"used":10,"push":["0x2a"],"mem":{"off":42,"data":[1,2,3]},"store":{"key":"0x45","val":"0x2a"}},"sub":null}]}}]}"#);
assert_eq!(serialized, r#"{"code":"0x00010203","ops":[{"pc":0,"cost":10,"ex":null,"sub":null},{"pc":1,"cost":11,"ex":{"used":10,"push":["0x45"],"mem":null,"store":null},"sub":{"code":"0x00","ops":[{"pc":0,"cost":0,"ex":{"used":10,"push":["0x2a"],"mem":{"off":42,"data":"0x010203"},"store":{"key":"0x45","val":"0x2a"}},"sub":null}]}}]}"#);
}
#[test]