From c99e0216a080e0fac419bebe5b9550e40599b847 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 27 Mar 2018 18:35:39 +0200 Subject: [PATCH 01/98] added eth_getAccount --- ethcore/src/client/client.rs | 10 +++++++++- ethcore/src/client/test_client.rs | 11 ++++++++++- ethcore/src/client/traits.rs | 9 ++++++++- ethcore/src/state/mod.rs | 17 +++++++++++++++++ rpc/src/v1/impls/eth.rs | 22 +++++++++++++++++++++- rpc/src/v1/impls/light/eth.rs | 6 ++++++ rpc/src/v1/traits/eth.rs | 6 +++++- rpc/src/v1/types/account_info.rs | 17 +++++++++++++++++ rpc/src/v1/types/mod.rs | 2 +- 9 files changed, 94 insertions(+), 6 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 127f0f9eb5f..5f5f04be3b6 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -1324,7 +1324,15 @@ impl Balance for Client { } } -impl AccountData for Client {} +impl AccountData for Client { + fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { + match state { + StateOrBlock::State(s) => s.account(address).ok(), + StateOrBlock::Block(id) => self.state_at(id).and_then(|s| s.account(address).ok()), + } + } + +} impl ChainInfo for Client { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index c3d8c127b08..1df8307250c 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -457,7 +457,16 @@ impl Balance for TestBlockChainClient { } } -impl AccountData for TestBlockChainClient {} +impl AccountData for TestBlockChainClient { + fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { + match state { + StateOrBlock::Block(BlockId::Latest) | StateOrBlock::State(_) => None, + _ => None, + } + } + + +} impl ChainInfo for TestBlockChainClient { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index ebe70dcd82c..eb75f6eec51 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -110,7 +110,14 @@ pub trait Balance { } /// Provides methods to access account info -pub trait AccountData: Nonce + Balance {} +pub trait AccountData: Nonce + Balance { + /// Get address balance at the given block's state. + /// + /// May not return None if given BlockId::Latest. + /// Returns None if and only if the block's root hash has been pruned from the DB. + fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)>; + +} /// Provides `chain_info` method pub trait ChainInfo { diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index f34f1219daf..4a9169ff003 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -526,6 +526,23 @@ impl State { self.ensure_cached(a, RequireCache::CodeSize, false, |a| a.map_or(false, |a| a.code_hash() != KECCAK_EMPTY || *a.nonce() != self.account_start_nonce)) } + /// Get the balance of account `a`. + pub fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)> { + self.ensure_cached(a, RequireCache::None, true, |a| { + a.as_ref().map_or( + (U256::zero(), self.account_start_nonce, KECCAK_EMPTY, KECCAK_NULL_RLP), + |account| { + ( + *account.balance(), + *account.nonce(), + account.code_hash(), + *account.storage_root().unwrap_or(&H256::zero()), + ) + }, + ) + }) + } + /// Get the balance of account `a`. pub fn balance(&self, a: &Address) -> TrieResult { diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index d912c13dd6d..4c5c0db708b 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -46,7 +46,7 @@ use v1::helpers::block_import::is_major_importing; use v1::traits::Eth; use v1::types::{ RichBlock, Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, SyncInfo, - Transaction, CallRequest, Index, Filter, Log, Receipt, Work, + Transaction, CallRequest, Index, Filter, Log, Receipt, Work,EthAccount, H64 as RpcH64, H256 as RpcH256, H160 as RpcH160, U256 as RpcU256, block_number_to_id, }; use v1::metadata::Metadata; @@ -545,6 +545,26 @@ impl Eth for EthClient< Box::new(future::done(res)) } + fn account(&self, address: RpcH160, num: Trailing) -> BoxFuture { + let address = address.into(); + + let num = num.unwrap_or_default(); + + try_bf!(check_known(&*self.client, num.clone())); + let res = match self.client.account(&address, self.get_state(num)) { + Some(a) => Ok(EthAccount { + address : address.into(), + balance : a.0.into(), + nonce : a.1.into(), + code_hash : a.2.into(), + storage_hash : a.3.into(), + }), + None => Err(errors::state_pruned()), + }; + + Box::new(future::done(res)) + } + fn storage_at(&self, address: RpcH160, pos: RpcU256, num: Trailing) -> BoxFuture { let address: Address = RpcH160::into(address); let position: U256 = RpcU256::into(pos); diff --git a/rpc/src/v1/impls/light/eth.rs b/rpc/src/v1/impls/light/eth.rs index 34b89ac9f6b..d6ef2220f40 100644 --- a/rpc/src/v1/impls/light/eth.rs +++ b/rpc/src/v1/impls/light/eth.rs @@ -470,6 +470,12 @@ impl Eth for EthClient { })) } + + fn account(&self, address: RpcH160, num: Trailing) -> BoxFuture { + Box::new(future::err(errors::unimplemented(None))) + } + + fn compilers(&self) -> Result> { Err(errors::deprecated("Compilation functionality is deprecated.".to_string())) } diff --git a/rpc/src/v1/traits/eth.rs b/rpc/src/v1/traits/eth.rs index a11b8680635..291280a1751 100644 --- a/rpc/src/v1/traits/eth.rs +++ b/rpc/src/v1/traits/eth.rs @@ -18,7 +18,7 @@ use jsonrpc_core::{Result, BoxFuture}; use jsonrpc_macros::Trailing; -use v1::types::{RichBlock, BlockNumber, Bytes, CallRequest, Filter, FilterChanges, Index}; +use v1::types::{RichBlock, BlockNumber, Bytes, CallRequest, Filter, FilterChanges, Index, EthAccount}; use v1::types::{Log, Receipt, SyncStatus, Transaction, Work}; use v1::types::{H64, H160, H256, U256}; @@ -63,6 +63,10 @@ build_rpc_trait! { #[rpc(name = "eth_getBalance")] fn balance(&self, H160, Trailing) -> BoxFuture; + /// Returns balance of the given account. + #[rpc(name = "eth_getAccount")] + fn account(&self, H160, Trailing) -> BoxFuture; + /// Returns content of the storage at given address. #[rpc(name = "eth_getStorageAt")] fn storage_at(&self, H160, U256, Trailing) -> BoxFuture; diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index 5a0e2952a18..1d89dab20df 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -13,6 +13,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +use v1::types::{ H160, H256, U256}; /// Account information. #[derive(Debug, Default, Clone, PartialEq, Serialize)] @@ -21,6 +22,22 @@ pub struct AccountInfo { pub name: String, } +/// Account information. +#[derive(Debug, Default, Clone, PartialEq, Serialize)] +pub struct EthAccount{ + #[serde(rename="address")] + pub address: H160, + #[serde(rename="balance")] + pub balance: U256, + #[serde(rename="nonce")] + pub nonce: U256, + #[serde(rename="codeHash")] + pub code_hash: H256, + #[serde(rename="storageHash")] + pub storage_hash: H256, + +} + /// Extended account information (used by `parity_allAccountInfo`). #[derive(Debug, Default, Clone, PartialEq, Serialize)] pub struct ExtAccountInfo { diff --git a/rpc/src/v1/types/mod.rs b/rpc/src/v1/types/mod.rs index eb8c0dc226c..6b5e2403178 100644 --- a/rpc/src/v1/types/mod.rs +++ b/rpc/src/v1/types/mod.rs @@ -46,7 +46,7 @@ mod private_receipt; pub mod pubsub; -pub use self::account_info::{AccountInfo, ExtAccountInfo, HwAccountInfo}; +pub use self::account_info::{AccountInfo, ExtAccountInfo, HwAccountInfo, EthAccount}; pub use self::bytes::Bytes; pub use self::block::{RichBlock, Block, BlockTransactions, Header, RichHeader, Rich}; pub use self::block_number::{BlockNumber, LightBlockNumber, block_number_to_id}; From f6d95f8b524144a155fe62e66d09b53b13ce6300 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Mar 2018 09:06:37 +0200 Subject: [PATCH 02/98] changed to getProof --- ethcore/src/client/client.rs | 10 +--------- ethcore/src/client/test_client.rs | 11 +---------- ethcore/src/client/traits.rs | 9 +-------- ethcore/src/state/mod.rs | 17 ---------------- rpc/src/v1/impls/eth.rs | 33 +++++++++++++++++++++---------- rpc/src/v1/impls/light/eth.rs | 2 +- rpc/src/v1/traits/eth.rs | 4 ++-- rpc/src/v1/types/account_info.rs | 6 +++++- 8 files changed, 34 insertions(+), 58 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 5f5f04be3b6..127f0f9eb5f 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -1324,15 +1324,7 @@ impl Balance for Client { } } -impl AccountData for Client { - fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { - match state { - StateOrBlock::State(s) => s.account(address).ok(), - StateOrBlock::Block(id) => self.state_at(id).and_then(|s| s.account(address).ok()), - } - } - -} +impl AccountData for Client {} impl ChainInfo for Client { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index 1df8307250c..c3d8c127b08 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -457,16 +457,7 @@ impl Balance for TestBlockChainClient { } } -impl AccountData for TestBlockChainClient { - fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { - match state { - StateOrBlock::Block(BlockId::Latest) | StateOrBlock::State(_) => None, - _ => None, - } - } - - -} +impl AccountData for TestBlockChainClient {} impl ChainInfo for TestBlockChainClient { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index eb75f6eec51..ebe70dcd82c 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -110,14 +110,7 @@ pub trait Balance { } /// Provides methods to access account info -pub trait AccountData: Nonce + Balance { - /// Get address balance at the given block's state. - /// - /// May not return None if given BlockId::Latest. - /// Returns None if and only if the block's root hash has been pruned from the DB. - fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)>; - -} +pub trait AccountData: Nonce + Balance {} /// Provides `chain_info` method pub trait ChainInfo { diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index 4a9169ff003..f34f1219daf 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -526,23 +526,6 @@ impl State { self.ensure_cached(a, RequireCache::CodeSize, false, |a| a.map_or(false, |a| a.code_hash() != KECCAK_EMPTY || *a.nonce() != self.account_start_nonce)) } - /// Get the balance of account `a`. - pub fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)> { - self.ensure_cached(a, RequireCache::None, true, |a| { - a.as_ref().map_or( - (U256::zero(), self.account_start_nonce, KECCAK_EMPTY, KECCAK_NULL_RLP), - |account| { - ( - *account.balance(), - *account.nonce(), - account.code_hash(), - *account.storage_root().unwrap_or(&H256::zero()), - ) - }, - ) - }) - } - /// Get the balance of account `a`. pub fn balance(&self, a: &Address) -> TrieResult { diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 4c5c0db708b..9a5bf2011a1 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -35,6 +35,7 @@ use ethcore::encoded; use sync::SyncProvider; use miner::external::ExternalMinerService; use transaction::{SignedTransaction, LocalizedTransaction}; +use hash::keccak; use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_core::futures::future; @@ -545,23 +546,35 @@ impl Eth for EthClient< Box::new(future::done(res)) } - fn account(&self, address: RpcH160, num: Trailing) -> BoxFuture { - let address = address.into(); + fn proof(&self, _address: RpcH160, values:Vec, num: Trailing) -> BoxFuture { + let a : H160 = _address.clone().into(); + let key1 = keccak(a); let num = num.unwrap_or_default(); + let id = match num { + BlockNumber::Num(n) => BlockId::Number(n), + BlockNumber::Earliest => BlockId::Earliest, + BlockNumber::Latest => BlockId::Latest, + BlockNumber::Pending => { + warn!("`Pending` is deprecated and may be removed in future versions. Falling back to `Latest`"); + BlockId::Latest + } + }; + try_bf!(check_known(&*self.client, num.clone())); - let res = match self.client.account(&address, self.get_state(num)) { - Some(a) => Ok(EthAccount { - address : address.into(), - balance : a.0.into(), - nonce : a.1.into(), - code_hash : a.2.into(), - storage_hash : a.3.into(), + let res = match self.client.prove_account(key1, id) { + Some(p) => Ok(EthAccount { + address : _address.into(), + balance : p.1.balance.into(), + nonce : p.1.nonce.into(), + code_hash : p.1.code_hash.into(), + storage_hash : p.1.storage_root.into(), + account_proof: Some(p.0.iter().map(|b| Bytes::new(b.clone())).collect::>()), + storage_proof: None }), None => Err(errors::state_pruned()), }; - Box::new(future::done(res)) } diff --git a/rpc/src/v1/impls/light/eth.rs b/rpc/src/v1/impls/light/eth.rs index d6ef2220f40..407c30691a8 100644 --- a/rpc/src/v1/impls/light/eth.rs +++ b/rpc/src/v1/impls/light/eth.rs @@ -471,7 +471,7 @@ impl Eth for EthClient { } - fn account(&self, address: RpcH160, num: Trailing) -> BoxFuture { + fn proof(&self, address: RpcH160, values:Vec, num: Trailing) -> BoxFuture { Box::new(future::err(errors::unimplemented(None))) } diff --git a/rpc/src/v1/traits/eth.rs b/rpc/src/v1/traits/eth.rs index 291280a1751..2378d119990 100644 --- a/rpc/src/v1/traits/eth.rs +++ b/rpc/src/v1/traits/eth.rs @@ -64,8 +64,8 @@ build_rpc_trait! { fn balance(&self, H160, Trailing) -> BoxFuture; /// Returns balance of the given account. - #[rpc(name = "eth_getAccount")] - fn account(&self, H160, Trailing) -> BoxFuture; + #[rpc(name = "eth_getProof")] + fn proof(&self, H160, Vec, Trailing) -> BoxFuture; /// Returns content of the storage at given address. #[rpc(name = "eth_getStorageAt")] diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index 1d89dab20df..72cbd6d496a 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -use v1::types::{ H160, H256, U256}; +use v1::types::{ H160, H256, U256, Bytes}; /// Account information. #[derive(Debug, Default, Clone, PartialEq, Serialize)] @@ -35,6 +35,10 @@ pub struct EthAccount{ pub code_hash: H256, #[serde(rename="storageHash")] pub storage_hash: H256, + #[serde(rename="accountProof")] + pub account_proof: Option>, + #[serde(rename="storageProof")] + pub storage_proof: Option)>>, } From d13364dc840d6916ebda563fdd8eb9550a83d116 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Mar 2018 19:40:20 +0200 Subject: [PATCH 03/98] implemented storage_proof --- ethcore/src/state/account.rs | 2 +- rpc/src/v1/impls/eth.rs | 12 ++++++++++-- rpc/src/v1/types/account_info.rs | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ethcore/src/state/account.rs b/ethcore/src/state/account.rs index 160152fc70b..1a53d5e4cd6 100644 --- a/ethcore/src/state/account.rs +++ b/ethcore/src/state/account.rs @@ -581,7 +581,7 @@ impl Account { /// this will only work correctly under a secure trie. pub fn prove_storage(&self, db: &HashDB, storage_key: H256) -> TrieResult<(Vec, H256)> { let mut recorder = Recorder::new(); - + let trie = TrieDB::new(db, &self.storage_root)?; let item: U256 = { let panicky_decoder = |bytes:&[u8]| ::rlp::decode(bytes).expect("decoding db value failed"); diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 9a5bf2011a1..6c00048df09 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -561,7 +561,6 @@ impl Eth for EthClient< } }; - try_bf!(check_known(&*self.client, num.clone())); let res = match self.client.prove_account(key1, id) { Some(p) => Ok(EthAccount { @@ -571,10 +570,19 @@ impl Eth for EthClient< code_hash : p.1.code_hash.into(), storage_hash : p.1.storage_root.into(), account_proof: Some(p.0.iter().map(|b| Bytes::new(b.clone())).collect::>()), - storage_proof: None + storage_proof: Some( + values.iter().map(|storageIndex| { + let key2 : H256 = storageIndex.clone().into(); + match self.client.prove_storage(key1, keccak(key2), id) { + Some(sp) => ( storageIndex.clone(), sp.1.into(), sp.0.iter().map(|b| Bytes::new(b.clone())).collect::>()), + None => ( storageIndex.clone(), 0.into(), Vec::new()) + } + }).collect::)>>() + ) }), None => Err(errors::state_pruned()), }; + Box::new(future::done(res)) } diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index 72cbd6d496a..48ceb3140d0 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -38,7 +38,7 @@ pub struct EthAccount{ #[serde(rename="accountProof")] pub account_proof: Option>, #[serde(rename="storageProof")] - pub storage_proof: Option)>>, + pub storage_proof: Option)>>, } From 767847bc47d9bedbdb5cbb73a83b6ec1254d911a Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Mar 2018 20:00:37 +0200 Subject: [PATCH 04/98] better formatting of storage proof --- rpc/src/v1/impls/eth.rs | 16 ++++++++++++---- rpc/src/v1/types/account_info.rs | 12 +++++++++++- rpc/src/v1/types/mod.rs | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 6c00048df09..4ce353d0614 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -47,7 +47,7 @@ use v1::helpers::block_import::is_major_importing; use v1::traits::Eth; use v1::types::{ RichBlock, Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, SyncInfo, - Transaction, CallRequest, Index, Filter, Log, Receipt, Work,EthAccount, + Transaction, CallRequest, Index, Filter, Log, Receipt, Work, EthAccount, StorageProof, H64 as RpcH64, H256 as RpcH256, H160 as RpcH160, U256 as RpcU256, block_number_to_id, }; use v1::metadata::Metadata; @@ -574,10 +574,18 @@ impl Eth for EthClient< values.iter().map(|storageIndex| { let key2 : H256 = storageIndex.clone().into(); match self.client.prove_storage(key1, keccak(key2), id) { - Some(sp) => ( storageIndex.clone(), sp.1.into(), sp.0.iter().map(|b| Bytes::new(b.clone())).collect::>()), - None => ( storageIndex.clone(), 0.into(), Vec::new()) + Some(sp) => StorageProof { + key : key2.into(), + value: sp.1.into(), + proof: sp.0.iter().map(|b| Bytes::new(b.clone())).collect::>() + }, + None => StorageProof { + key : key2.into(), + value : 0.into(), + proof : Vec::new() + } } - }).collect::)>>() + }).collect::>() ) }), None => Err(errors::state_pruned()), diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index 48ceb3140d0..8e12b54a689 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -21,6 +21,16 @@ pub struct AccountInfo { /// Account name pub name: String, } +#[derive(Debug, Default, Clone, PartialEq, Serialize)] +pub struct StorageProof{ + #[serde(rename="key")] + pub key: U256, + #[serde(rename="value")] + pub value: U256, + #[serde(rename="proof")] + pub proof: Vec + +} /// Account information. #[derive(Debug, Default, Clone, PartialEq, Serialize)] @@ -38,7 +48,7 @@ pub struct EthAccount{ #[serde(rename="accountProof")] pub account_proof: Option>, #[serde(rename="storageProof")] - pub storage_proof: Option)>>, + pub storage_proof: Option>, } diff --git a/rpc/src/v1/types/mod.rs b/rpc/src/v1/types/mod.rs index 6b5e2403178..fb822d0e43d 100644 --- a/rpc/src/v1/types/mod.rs +++ b/rpc/src/v1/types/mod.rs @@ -46,7 +46,7 @@ mod private_receipt; pub mod pubsub; -pub use self::account_info::{AccountInfo, ExtAccountInfo, HwAccountInfo, EthAccount}; +pub use self::account_info::{AccountInfo, ExtAccountInfo, HwAccountInfo, EthAccount, StorageProof}; pub use self::bytes::Bytes; pub use self::block::{RichBlock, Block, BlockTransactions, Header, RichHeader, Rich}; pub use self::block_number::{BlockNumber, LightBlockNumber, block_number_to_id}; From 35e522c76b133aef44173d16cdb29580ae67e137 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 19 Jun 2018 11:44:35 +0200 Subject: [PATCH 05/98] fixed imports;2C --- rpc/src/v1/impls/eth.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 4ce353d0614..9aaf018538e 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -453,7 +453,7 @@ fn check_known(client: &C, number: BlockNumber) -> Result<()> where C: BlockC const MAX_QUEUE_SIZE_TO_MINE_ON: usize = 4; // because uncles go back 6. impl Eth for EthClient where - C: miner::BlockChainClient + BlockChainClient + StateClient + Call + EngineInfo + 'static, + C: miner::BlockChainClient + StateClient + ProvingBlockChainClient + Call + EngineInfo + 'static, SN: SnapshotService + 'static, S: SyncProvider + 'static, M: MinerService + 'static, From 7a62f08ba3f72142fb45ff3f86b3c91a91376ad3 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:31:42 +0200 Subject: [PATCH 06/98] removed spaces --- ethcore/src/state/account.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethcore/src/state/account.rs b/ethcore/src/state/account.rs index 1a53d5e4cd6..160152fc70b 100644 --- a/ethcore/src/state/account.rs +++ b/ethcore/src/state/account.rs @@ -581,7 +581,7 @@ impl Account { /// this will only work correctly under a secure trie. pub fn prove_storage(&self, db: &HashDB, storage_key: H256) -> TrieResult<(Vec, H256)> { let mut recorder = Recorder::new(); - + let trie = TrieDB::new(db, &self.storage_root)?; let item: U256 = { let panicky_decoder = |bytes:&[u8]| ::rlp::decode(bytes).expect("decoding db value failed"); From 388947f4cb2a0b2001a233ddd99605d17df6400e Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:37:25 +0200 Subject: [PATCH 07/98] fixed whitespace --- docker/slockit/Dockerfile | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 docker/slockit/Dockerfile diff --git a/docker/slockit/Dockerfile b/docker/slockit/Dockerfile new file mode 100644 index 00000000000..b5f8178290a --- /dev/null +++ b/docker/slockit/Dockerfile @@ -0,0 +1,65 @@ +FROM ubuntu:14.04 +MAINTAINER Parity Technologies +WORKDIR /build +#ENV for build TAG +ARG BUILD_TAG +ENV BUILD_TAG ${BUILD_TAG:-master} +RUN echo "Build tag:" $BUILD_TAG +# install tools and dependencies +RUN apt-get update && \ + apt-get install -y --force-yes --no-install-recommends \ + # make + build-essential \ + # add-apt-repository + software-properties-common \ + make \ + curl \ + wget \ + git \ + g++ \ + gcc \ + libc6 \ + libc6-dev \ + binutils \ + file \ + openssl \ + libssl-dev \ + libudev-dev \ + pkg-config \ + dpkg-dev \ + libudev-dev &&\ +# install rustup + curl https://sh.rustup.rs -sSf | sh -s -- -y && \ +# rustup directory + PATH=/root/.cargo/bin:$PATH && \ +# show backtraces + RUST_BACKTRACE=1 && \ +# build parity +cd /build&&git clone https://github.com/slockit/parity -b in3 && \ + cd parity && \ + git pull&& \ + cargo build --verbose --release --features final && \ + #ls /build/parity/target/release/parity && \ + strip /build/parity/target/release/parity && \ + file /build/parity/target/release/parity&&mkdir -p /parity&& cp /build/parity/target/release/parity /parity&&\ +#cleanup Docker image + rm -rf /root/.cargo&&rm -rf /root/.multirust&&rm -rf /root/.rustup&&rm -rf /build&&\ + apt-get purge -y \ + # make + build-essential \ + # add-apt-repository + software-properties-common \ + make \ + curl \ + wget \ + git \ + g++ \ + gcc \ + binutils \ + file \ + pkg-config \ + dpkg-dev &&\ + rm -rf /var/lib/apt/lists/* +# setup ENTRYPOINT +EXPOSE 8080 8545 8180 +ENTRYPOINT ["/parity/parity"] From f4090a9856f0aea2943be395e85069bac895dfc0 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:43:10 +0200 Subject: [PATCH 08/98] fixed docker --- docker/slockit/Dockerfile | 65 --------------------------------------- rpc/src/v1/impls/eth.rs | 2 +- 2 files changed, 1 insertion(+), 66 deletions(-) delete mode 100644 docker/slockit/Dockerfile diff --git a/docker/slockit/Dockerfile b/docker/slockit/Dockerfile deleted file mode 100644 index b5f8178290a..00000000000 --- a/docker/slockit/Dockerfile +++ /dev/null @@ -1,65 +0,0 @@ -FROM ubuntu:14.04 -MAINTAINER Parity Technologies -WORKDIR /build -#ENV for build TAG -ARG BUILD_TAG -ENV BUILD_TAG ${BUILD_TAG:-master} -RUN echo "Build tag:" $BUILD_TAG -# install tools and dependencies -RUN apt-get update && \ - apt-get install -y --force-yes --no-install-recommends \ - # make - build-essential \ - # add-apt-repository - software-properties-common \ - make \ - curl \ - wget \ - git \ - g++ \ - gcc \ - libc6 \ - libc6-dev \ - binutils \ - file \ - openssl \ - libssl-dev \ - libudev-dev \ - pkg-config \ - dpkg-dev \ - libudev-dev &&\ -# install rustup - curl https://sh.rustup.rs -sSf | sh -s -- -y && \ -# rustup directory - PATH=/root/.cargo/bin:$PATH && \ -# show backtraces - RUST_BACKTRACE=1 && \ -# build parity -cd /build&&git clone https://github.com/slockit/parity -b in3 && \ - cd parity && \ - git pull&& \ - cargo build --verbose --release --features final && \ - #ls /build/parity/target/release/parity && \ - strip /build/parity/target/release/parity && \ - file /build/parity/target/release/parity&&mkdir -p /parity&& cp /build/parity/target/release/parity /parity&&\ -#cleanup Docker image - rm -rf /root/.cargo&&rm -rf /root/.multirust&&rm -rf /root/.rustup&&rm -rf /build&&\ - apt-get purge -y \ - # make - build-essential \ - # add-apt-repository - software-properties-common \ - make \ - curl \ - wget \ - git \ - g++ \ - gcc \ - binutils \ - file \ - pkg-config \ - dpkg-dev &&\ - rm -rf /var/lib/apt/lists/* -# setup ENTRYPOINT -EXPOSE 8080 8545 8180 -ENTRYPOINT ["/parity/parity"] diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 9aaf018538e..f73d656c816 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -569,7 +569,7 @@ impl Eth for EthClient< nonce : p.1.nonce.into(), code_hash : p.1.code_hash.into(), storage_hash : p.1.storage_root.into(), - account_proof: Some(p.0.iter().map(|b| Bytes::new(b.clone())).collect::>()), + account_proof: Some(p.0.iter().map(|b| Bytes::new(b.clone())).collect::>()), storage_proof: Some( values.iter().map(|storageIndex| { let key2 : H256 = storageIndex.clone().into(); From 2ba439685da340b612a59ddb3fe919bb50ac303e Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:55:43 +0200 Subject: [PATCH 09/98] added doc --- rpc/src/v1/types/account_info.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index 8e12b54a689..e5d90abd605 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -21,6 +21,7 @@ pub struct AccountInfo { /// Account name pub name: String, } +/// Datastructure with proof for one single storage-entry #[derive(Debug, Default, Clone, PartialEq, Serialize)] pub struct StorageProof{ #[serde(rename="key")] @@ -29,7 +30,6 @@ pub struct StorageProof{ pub value: U256, #[serde(rename="proof")] pub proof: Vec - } /// Account information. From bbfbaa5d8d2d4c5456501cbcd85dc24052848c73 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 20 Sep 2018 16:47:36 +0200 Subject: [PATCH 10/98] fixed Compile-error --- rpc/src/v1/impls/eth.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index f73d656c816..462abe90363 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -26,7 +26,7 @@ use parking_lot::Mutex; use ethash::{self, SeedHashCompute}; use ethcore::account_provider::AccountProvider; -use ethcore::client::{BlockChainClient, BlockId, TransactionId, UncleId, StateOrBlock, StateClient, StateInfo, Call, EngineInfo}; +use ethcore::client::{BlockChainClient, BlockId, TransactionId, UncleId, StateOrBlock, StateClient, StateInfo, Call, EngineInfo, ProvingBlockChainClient}; use ethcore::filter::Filter as EthcoreFilter; use ethcore::header::{BlockNumber as EthBlockNumber}; use ethcore::miner::{self, MinerService}; From 2621b4a57f176128fcc83ba66fcf2a2e41b686b5 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 21 Sep 2018 09:35:06 +0200 Subject: [PATCH 11/98] expose more ports --- scripts/docker/alpine/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/docker/alpine/Dockerfile b/scripts/docker/alpine/Dockerfile index 47b37372ebf..1af07ebdeaa 100644 --- a/scripts/docker/alpine/Dockerfile +++ b/scripts/docker/alpine/Dockerfile @@ -33,7 +33,7 @@ RUN addgroup -g 1000 parity \ USER parity -EXPOSE 8080 8545 8180 +EXPOSE 5001 8080 8082 8083 8545 8546 8180 30303/tcp 30303/udp WORKDIR /home/parity From 080ce05a6b839dd72f0df6abd3bfce0cba2b46dc Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 27 Mar 2018 18:35:39 +0200 Subject: [PATCH 12/98] added eth_getAccount --- ethcore/src/client/client.rs | 10 +++++++++- ethcore/src/client/test_client.rs | 11 ++++++++++- ethcore/src/client/traits.rs | 9 ++++++++- ethcore/src/state/mod.rs | 17 +++++++++++++++++ rpc/src/v1/impls/light/eth.rs | 4 ++-- rpc/src/v1/types/account_info.rs | 16 ++++++++++++++++ 6 files changed, 62 insertions(+), 5 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 127f0f9eb5f..5f5f04be3b6 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -1324,7 +1324,15 @@ impl Balance for Client { } } -impl AccountData for Client {} +impl AccountData for Client { + fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { + match state { + StateOrBlock::State(s) => s.account(address).ok(), + StateOrBlock::Block(id) => self.state_at(id).and_then(|s| s.account(address).ok()), + } + } + +} impl ChainInfo for Client { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index c3d8c127b08..1df8307250c 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -457,7 +457,16 @@ impl Balance for TestBlockChainClient { } } -impl AccountData for TestBlockChainClient {} +impl AccountData for TestBlockChainClient { + fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { + match state { + StateOrBlock::Block(BlockId::Latest) | StateOrBlock::State(_) => None, + _ => None, + } + } + + +} impl ChainInfo for TestBlockChainClient { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index ebe70dcd82c..eb75f6eec51 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -110,7 +110,14 @@ pub trait Balance { } /// Provides methods to access account info -pub trait AccountData: Nonce + Balance {} +pub trait AccountData: Nonce + Balance { + /// Get address balance at the given block's state. + /// + /// May not return None if given BlockId::Latest. + /// Returns None if and only if the block's root hash has been pruned from the DB. + fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)>; + +} /// Provides `chain_info` method pub trait ChainInfo { diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index f34f1219daf..4a9169ff003 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -526,6 +526,23 @@ impl State { self.ensure_cached(a, RequireCache::CodeSize, false, |a| a.map_or(false, |a| a.code_hash() != KECCAK_EMPTY || *a.nonce() != self.account_start_nonce)) } + /// Get the balance of account `a`. + pub fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)> { + self.ensure_cached(a, RequireCache::None, true, |a| { + a.as_ref().map_or( + (U256::zero(), self.account_start_nonce, KECCAK_EMPTY, KECCAK_NULL_RLP), + |account| { + ( + *account.balance(), + *account.nonce(), + account.code_hash(), + *account.storage_root().unwrap_or(&H256::zero()), + ) + }, + ) + }) + } + /// Get the balance of account `a`. pub fn balance(&self, a: &Address) -> TrieResult { diff --git a/rpc/src/v1/impls/light/eth.rs b/rpc/src/v1/impls/light/eth.rs index 407c30691a8..a2633acfff6 100644 --- a/rpc/src/v1/impls/light/eth.rs +++ b/rpc/src/v1/impls/light/eth.rs @@ -46,8 +46,8 @@ use v1::helpers::{SyncPollFilter, PollManager}; use v1::helpers::light_fetch::{self, LightFetch}; use v1::traits::Eth; use v1::types::{ - RichBlock, Block, BlockTransactions, BlockNumber, LightBlockNumber, Bytes, SyncStatus, SyncInfo, - Transaction, CallRequest, Index, Filter, Log, Receipt, Work, + RichBlock, Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, SyncInfo, + Transaction, CallRequest, Index, Filter, Log, Receipt, Work,EthAccount, H64 as RpcH64, H256 as RpcH256, H160 as RpcH160, U256 as RpcU256, }; use v1::metadata::Metadata; diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index e5d90abd605..f61106d0951 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -52,6 +52,22 @@ pub struct EthAccount{ } +/// Account information. +#[derive(Debug, Default, Clone, PartialEq, Serialize)] +pub struct EthAccount{ + #[serde(rename="address")] + pub address: H160, + #[serde(rename="balance")] + pub balance: U256, + #[serde(rename="nonce")] + pub nonce: U256, + #[serde(rename="codeHash")] + pub code_hash: H256, + #[serde(rename="storageHash")] + pub storage_hash: H256, + +} + /// Extended account information (used by `parity_allAccountInfo`). #[derive(Debug, Default, Clone, PartialEq, Serialize)] pub struct ExtAccountInfo { From 4f9f285b974a1eb61486e90646975904913417d4 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Mar 2018 09:06:37 +0200 Subject: [PATCH 13/98] changed to getProof --- ethcore/src/client/client.rs | 10 +--------- ethcore/src/client/test_client.rs | 11 +---------- ethcore/src/client/traits.rs | 9 +-------- ethcore/src/state/mod.rs | 17 ----------------- rpc/src/v1/impls/eth.rs | 1 - rpc/src/v1/types/account_info.rs | 4 ++++ 6 files changed, 7 insertions(+), 45 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 5f5f04be3b6..127f0f9eb5f 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -1324,15 +1324,7 @@ impl Balance for Client { } } -impl AccountData for Client { - fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { - match state { - StateOrBlock::State(s) => s.account(address).ok(), - StateOrBlock::Block(id) => self.state_at(id).and_then(|s| s.account(address).ok()), - } - } - -} +impl AccountData for Client {} impl ChainInfo for Client { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index 1df8307250c..c3d8c127b08 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -457,16 +457,7 @@ impl Balance for TestBlockChainClient { } } -impl AccountData for TestBlockChainClient { - fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { - match state { - StateOrBlock::Block(BlockId::Latest) | StateOrBlock::State(_) => None, - _ => None, - } - } - - -} +impl AccountData for TestBlockChainClient {} impl ChainInfo for TestBlockChainClient { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index eb75f6eec51..ebe70dcd82c 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -110,14 +110,7 @@ pub trait Balance { } /// Provides methods to access account info -pub trait AccountData: Nonce + Balance { - /// Get address balance at the given block's state. - /// - /// May not return None if given BlockId::Latest. - /// Returns None if and only if the block's root hash has been pruned from the DB. - fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)>; - -} +pub trait AccountData: Nonce + Balance {} /// Provides `chain_info` method pub trait ChainInfo { diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index 4a9169ff003..f34f1219daf 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -526,23 +526,6 @@ impl State { self.ensure_cached(a, RequireCache::CodeSize, false, |a| a.map_or(false, |a| a.code_hash() != KECCAK_EMPTY || *a.nonce() != self.account_start_nonce)) } - /// Get the balance of account `a`. - pub fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)> { - self.ensure_cached(a, RequireCache::None, true, |a| { - a.as_ref().map_or( - (U256::zero(), self.account_start_nonce, KECCAK_EMPTY, KECCAK_NULL_RLP), - |account| { - ( - *account.balance(), - *account.nonce(), - account.code_hash(), - *account.storage_root().unwrap_or(&H256::zero()), - ) - }, - ) - }) - } - /// Get the balance of account `a`. pub fn balance(&self, a: &Address) -> TrieResult { diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 462abe90363..05b4b780e30 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -590,7 +590,6 @@ impl Eth for EthClient< }), None => Err(errors::state_pruned()), }; - Box::new(future::done(res)) } diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index f61106d0951..88d6c0793bd 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -65,6 +65,10 @@ pub struct EthAccount{ pub code_hash: H256, #[serde(rename="storageHash")] pub storage_hash: H256, + #[serde(rename="accountProof")] + pub account_proof: Option>, + #[serde(rename="storageProof")] + pub storage_proof: Option)>>, } From a66db7f731e6f54f1351945a5e693a6beea22e44 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Mar 2018 19:40:20 +0200 Subject: [PATCH 14/98] implemented storage_proof --- ethcore/src/state/account.rs | 2 +- rpc/src/v1/impls/eth.rs | 1 + rpc/src/v1/types/account_info.rs | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ethcore/src/state/account.rs b/ethcore/src/state/account.rs index 160152fc70b..1a53d5e4cd6 100644 --- a/ethcore/src/state/account.rs +++ b/ethcore/src/state/account.rs @@ -581,7 +581,7 @@ impl Account { /// this will only work correctly under a secure trie. pub fn prove_storage(&self, db: &HashDB, storage_key: H256) -> TrieResult<(Vec, H256)> { let mut recorder = Recorder::new(); - + let trie = TrieDB::new(db, &self.storage_root)?; let item: U256 = { let panicky_decoder = |bytes:&[u8]| ::rlp::decode(bytes).expect("decoding db value failed"); diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 05b4b780e30..462abe90363 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -590,6 +590,7 @@ impl Eth for EthClient< }), None => Err(errors::state_pruned()), }; + Box::new(future::done(res)) } diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index 88d6c0793bd..081c3d60277 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -68,7 +68,7 @@ pub struct EthAccount{ #[serde(rename="accountProof")] pub account_proof: Option>, #[serde(rename="storageProof")] - pub storage_proof: Option)>>, + pub storage_proof: Option)>>, } From f5f3e1cef9662002c1acd2aa02c9db02adbaa65e Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Mar 2018 20:00:37 +0200 Subject: [PATCH 15/98] better formatting of storage proof --- rpc/src/v1/types/account_info.rs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index 081c3d60277..8f455cdd46d 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -52,25 +52,6 @@ pub struct EthAccount{ } -/// Account information. -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct EthAccount{ - #[serde(rename="address")] - pub address: H160, - #[serde(rename="balance")] - pub balance: U256, - #[serde(rename="nonce")] - pub nonce: U256, - #[serde(rename="codeHash")] - pub code_hash: H256, - #[serde(rename="storageHash")] - pub storage_hash: H256, - #[serde(rename="accountProof")] - pub account_proof: Option>, - #[serde(rename="storageProof")] - pub storage_proof: Option)>>, - -} /// Extended account information (used by `parity_allAccountInfo`). #[derive(Debug, Default, Clone, PartialEq, Serialize)] From ad50c152d2b594a340d2426fefa7c42306e45b61 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 19 Jun 2018 09:37:51 +0200 Subject: [PATCH 16/98] fixed docker --- docker/hub/Dockerfile | 82 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 docker/hub/Dockerfile diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile new file mode 100644 index 00000000000..661542472d1 --- /dev/null +++ b/docker/hub/Dockerfile @@ -0,0 +1,82 @@ +FROM ubuntu:14.04 +MAINTAINER Parity Technologies +WORKDIR /build +#ENV for build TAG +ARG BUILD_TAG +ENV BUILD_TAG ${BUILD_TAG:-master} +RUN echo "Build tag:" $BUILD_TAG +# install tools and dependencies +RUN apt-get update && \ + apt-get install -y --force-yes --no-install-recommends \ + # make + build-essential \ + # add-apt-repository + software-properties-common \ + make \ + curl \ + wget \ + git \ + g++ \ + gcc \ + libc6 \ + libc6-dev \ + binutils \ + file \ + openssl \ + libssl-dev \ + libudev-dev \ + pkg-config \ + dpkg-dev \ + # evmjit dependencies + zlib1g-dev \ + libedit-dev \ + libudev-dev &&\ +# cmake and llvm ppa's. then update ppa's + add-apt-repository -y "ppa:george-edison55/cmake-3.x" && \ + add-apt-repository "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.7 main" && \ + apt-get update && \ + apt-get install -y --force-yes cmake llvm-3.7-dev && \ +# install evmjit + git clone https://github.com/debris/evmjit && \ + cd evmjit && \ + mkdir build && cd build && \ + cmake .. && make && make install && cd && \ +# install rustup + curl https://sh.rustup.rs -sSf | sh -s -- -y && \ +# rustup directory + PATH=/root/.cargo/bin:$PATH && \ +# show backtraces + RUST_BACKTRACE=1 && \ +# build parity +cd /build&&git clone https://github.com/slockit/parity -b in3 && \ + cd parity && \ + git pull&& \ + cargo build --verbose --release --features final && \ + #ls /build/parity/target/release/parity && \ + strip /build/parity/target/release/parity && \ + file /build/parity/target/release/parity&&mkdir -p /parity&& cp /build/parity/target/release/parity /parity&&\ +#cleanup Docker image + rm -rf /root/.cargo&&rm -rf /root/.multirust&&rm -rf /root/.rustup&&rm -rf /build&&\ + apt-get purge -y \ + # make + build-essential \ + # add-apt-repository + software-properties-common \ + make \ + curl \ + wget \ + git \ + g++ \ + gcc \ + binutils \ + file \ + pkg-config \ + dpkg-dev \ + # evmjit dependencies + zlib1g-dev \ + libedit-dev \ + cmake llvm-3.7-dev&&\ + rm -rf /var/lib/apt/lists/* +# setup ENTRYPOINT +EXPOSE 8080 8545 8180 +ENTRYPOINT ["/parity/parity"] From 2f1f536b3c7dd9271875e37b9818847560fc156c Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:27:07 +0200 Subject: [PATCH 17/98] removed slockit-changes --- docker/hub/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index 661542472d1..d1e06e4a242 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -48,9 +48,9 @@ RUN apt-get update && \ # show backtraces RUST_BACKTRACE=1 && \ # build parity -cd /build&&git clone https://github.com/slockit/parity -b in3 && \ +cd /build&&git clone https://github.com/paritytech/parity && \ cd parity && \ - git pull&& \ +git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From f024622240009b3b2008fe75cafad5ee2d43a842 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:29:09 +0200 Subject: [PATCH 18/98] fixed Dockerfile --- docker/hub/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index d1e06e4a242..a8557e936d8 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -50,7 +50,8 @@ RUN apt-get update && \ # build parity cd /build&&git clone https://github.com/paritytech/parity && \ cd parity && \ -git checkout $BUILD_TAG && \ + git pull&& \ + git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From c119551f5ad8d36a2c77afffbbcc5f8900f2d612 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:29:52 +0200 Subject: [PATCH 19/98] intend --- docker/hub/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index a8557e936d8..2bc26d5d953 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -50,8 +50,8 @@ RUN apt-get update && \ # build parity cd /build&&git clone https://github.com/paritytech/parity && \ cd parity && \ - git pull&& \ - git checkout $BUILD_TAG && \ + git pull&& \ + git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From 7a26db8ec9b3d0ddf701f6b789f648bac083f065 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:30:31 +0200 Subject: [PATCH 20/98] spaces --- docker/hub/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index 2bc26d5d953..69cf8aac798 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -50,8 +50,8 @@ RUN apt-get update && \ # build parity cd /build&&git clone https://github.com/paritytech/parity && \ cd parity && \ - git pull&& \ - git checkout $BUILD_TAG && \ + git pull&& \ + git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From 0fa44561df1805100b62288779a87efa61d7212d Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:31:42 +0200 Subject: [PATCH 21/98] removed spaces --- ethcore/src/state/account.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethcore/src/state/account.rs b/ethcore/src/state/account.rs index 1a53d5e4cd6..160152fc70b 100644 --- a/ethcore/src/state/account.rs +++ b/ethcore/src/state/account.rs @@ -581,7 +581,7 @@ impl Account { /// this will only work correctly under a secure trie. pub fn prove_storage(&self, db: &HashDB, storage_key: H256) -> TrieResult<(Vec, H256)> { let mut recorder = Recorder::new(); - + let trie = TrieDB::new(db, &self.storage_root)?; let item: U256 = { let panicky_decoder = |bytes:&[u8]| ::rlp::decode(bytes).expect("decoding db value failed"); From ddd2db55c9735ef77e861286cef0f4828a9c0072 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:37:25 +0200 Subject: [PATCH 22/98] fixed whitespace --- docker/slockit/Dockerfile | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 docker/slockit/Dockerfile diff --git a/docker/slockit/Dockerfile b/docker/slockit/Dockerfile new file mode 100644 index 00000000000..b5f8178290a --- /dev/null +++ b/docker/slockit/Dockerfile @@ -0,0 +1,65 @@ +FROM ubuntu:14.04 +MAINTAINER Parity Technologies +WORKDIR /build +#ENV for build TAG +ARG BUILD_TAG +ENV BUILD_TAG ${BUILD_TAG:-master} +RUN echo "Build tag:" $BUILD_TAG +# install tools and dependencies +RUN apt-get update && \ + apt-get install -y --force-yes --no-install-recommends \ + # make + build-essential \ + # add-apt-repository + software-properties-common \ + make \ + curl \ + wget \ + git \ + g++ \ + gcc \ + libc6 \ + libc6-dev \ + binutils \ + file \ + openssl \ + libssl-dev \ + libudev-dev \ + pkg-config \ + dpkg-dev \ + libudev-dev &&\ +# install rustup + curl https://sh.rustup.rs -sSf | sh -s -- -y && \ +# rustup directory + PATH=/root/.cargo/bin:$PATH && \ +# show backtraces + RUST_BACKTRACE=1 && \ +# build parity +cd /build&&git clone https://github.com/slockit/parity -b in3 && \ + cd parity && \ + git pull&& \ + cargo build --verbose --release --features final && \ + #ls /build/parity/target/release/parity && \ + strip /build/parity/target/release/parity && \ + file /build/parity/target/release/parity&&mkdir -p /parity&& cp /build/parity/target/release/parity /parity&&\ +#cleanup Docker image + rm -rf /root/.cargo&&rm -rf /root/.multirust&&rm -rf /root/.rustup&&rm -rf /build&&\ + apt-get purge -y \ + # make + build-essential \ + # add-apt-repository + software-properties-common \ + make \ + curl \ + wget \ + git \ + g++ \ + gcc \ + binutils \ + file \ + pkg-config \ + dpkg-dev &&\ + rm -rf /var/lib/apt/lists/* +# setup ENTRYPOINT +EXPOSE 8080 8545 8180 +ENTRYPOINT ["/parity/parity"] From b55131d67ce3864cfa2ae293451ad2b0cb5d0198 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:43:10 +0200 Subject: [PATCH 23/98] fixed docker --- docker/slockit/Dockerfile | 65 --------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 docker/slockit/Dockerfile diff --git a/docker/slockit/Dockerfile b/docker/slockit/Dockerfile deleted file mode 100644 index b5f8178290a..00000000000 --- a/docker/slockit/Dockerfile +++ /dev/null @@ -1,65 +0,0 @@ -FROM ubuntu:14.04 -MAINTAINER Parity Technologies -WORKDIR /build -#ENV for build TAG -ARG BUILD_TAG -ENV BUILD_TAG ${BUILD_TAG:-master} -RUN echo "Build tag:" $BUILD_TAG -# install tools and dependencies -RUN apt-get update && \ - apt-get install -y --force-yes --no-install-recommends \ - # make - build-essential \ - # add-apt-repository - software-properties-common \ - make \ - curl \ - wget \ - git \ - g++ \ - gcc \ - libc6 \ - libc6-dev \ - binutils \ - file \ - openssl \ - libssl-dev \ - libudev-dev \ - pkg-config \ - dpkg-dev \ - libudev-dev &&\ -# install rustup - curl https://sh.rustup.rs -sSf | sh -s -- -y && \ -# rustup directory - PATH=/root/.cargo/bin:$PATH && \ -# show backtraces - RUST_BACKTRACE=1 && \ -# build parity -cd /build&&git clone https://github.com/slockit/parity -b in3 && \ - cd parity && \ - git pull&& \ - cargo build --verbose --release --features final && \ - #ls /build/parity/target/release/parity && \ - strip /build/parity/target/release/parity && \ - file /build/parity/target/release/parity&&mkdir -p /parity&& cp /build/parity/target/release/parity /parity&&\ -#cleanup Docker image - rm -rf /root/.cargo&&rm -rf /root/.multirust&&rm -rf /root/.rustup&&rm -rf /build&&\ - apt-get purge -y \ - # make - build-essential \ - # add-apt-repository - software-properties-common \ - make \ - curl \ - wget \ - git \ - g++ \ - gcc \ - binutils \ - file \ - pkg-config \ - dpkg-dev &&\ - rm -rf /var/lib/apt/lists/* -# setup ENTRYPOINT -EXPOSE 8080 8545 8180 -ENTRYPOINT ["/parity/parity"] From fc4da1cc4905791bf9d5132883dcb1b9715a598f Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:44:12 +0200 Subject: [PATCH 24/98] tabs --- docker/hub/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index 69cf8aac798..c3406a5bd3d 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -50,8 +50,8 @@ RUN apt-get update && \ # build parity cd /build&&git clone https://github.com/paritytech/parity && \ cd parity && \ - git pull&& \ - git checkout $BUILD_TAG && \ + git pull&& \ + git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From be62ef5b914df805c408b92c537dfa3739c29f2a Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 20 Sep 2018 16:47:36 +0200 Subject: [PATCH 25/98] fixed Compile-error --- rpc/src/v1/impls/eth.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 462abe90363..a4ffab0f60c 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -20,8 +20,8 @@ use std::thread; use std::time::{Instant, Duration, SystemTime, UNIX_EPOCH}; use std::sync::Arc; -use rlp::Rlp; -use ethereum_types::{U256, H256, Address}; +use rlp::{self, Rlp}; +use ethereum_types::{U256, H64, H256, H160, Address}; use parking_lot::Mutex; use ethash::{self, SeedHashCompute}; From b616a2039d11a40320584f39d4a8256f9a26852f Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 27 Mar 2018 18:35:39 +0200 Subject: [PATCH 26/98] added eth_getAccount --- ethcore/src/client/client.rs | 10 +++++++++- ethcore/src/client/test_client.rs | 21 +++++++++++++++----- ethcore/src/client/traits.rs | 9 ++++++++- ethcore/src/state/mod.rs | 33 ++++++++++++++++++++++++++----- 4 files changed, 61 insertions(+), 12 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 127f0f9eb5f..5f5f04be3b6 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -1324,7 +1324,15 @@ impl Balance for Client { } } -impl AccountData for Client {} +impl AccountData for Client { + fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { + match state { + StateOrBlock::State(s) => s.account(address).ok(), + StateOrBlock::Block(id) => self.state_at(id).and_then(|s| s.account(address).ok()), + } + } + +} impl ChainInfo for Client { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index c3d8c127b08..1f0ec876949 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -457,7 +457,16 @@ impl Balance for TestBlockChainClient { } } -impl AccountData for TestBlockChainClient {} +impl AccountData for TestBlockChainClient { + fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { + match state { + StateOrBlock::Block(BlockId::Latest) | StateOrBlock::State(_) => None, + _ => None, + } + } + + +} impl ChainInfo for TestBlockChainClient { fn chain_info(&self) -> BlockChainInfo { @@ -590,10 +599,12 @@ impl Call for TestBlockChainClient { } impl StateInfo for () { - fn nonce(&self, _address: &Address) -> ethtrie::Result { unimplemented!() } - fn balance(&self, _address: &Address) -> ethtrie::Result { unimplemented!() } - fn storage_at(&self, _address: &Address, _key: &H256) -> ethtrie::Result { unimplemented!() } - fn code(&self, _address: &Address) -> ethtrie::Result>> { unimplemented!() } + fn nonce(&self, _address: &Address) -> trie::Result { unimplemented!() } + fn balance(&self, _address: &Address) -> trie::Result { unimplemented!() } + fn storage_at(&self, _address: &Address, _key: &H256) -> trie::Result { unimplemented!() } + fn code(&self, _address: &Address) -> trie::Result>> { unimplemented!() } + fn account(&self, _address: &Address) -> trie::Result<(U256, U256, H256, H256)> { unimplemented!() } + } impl StateClient for TestBlockChainClient { diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index ebe70dcd82c..eb75f6eec51 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -110,7 +110,14 @@ pub trait Balance { } /// Provides methods to access account info -pub trait AccountData: Nonce + Balance {} +pub trait AccountData: Nonce + Balance { + /// Get address balance at the given block's state. + /// + /// May not return None if given BlockId::Latest. + /// Returns None if and only if the block's root hash has been pruned from the DB. + fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)>; + +} /// Provides `chain_info` method pub trait ChainInfo { diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index f34f1219daf..60da8f5c139 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -346,14 +346,20 @@ pub trait StateInfo { fn storage_at(&self, address: &Address, key: &H256) -> TrieResult; /// Get accounts' code. - fn code(&self, a: &Address) -> TrieResult>>; + fn code(&self, a: &Address) -> trie::Result>>; + + /// Get the account `a`. + fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)>; + + } impl StateInfo for State { - fn nonce(&self, a: &Address) -> TrieResult { State::nonce(self, a) } - fn balance(&self, a: &Address) -> TrieResult { State::balance(self, a) } - fn storage_at(&self, address: &Address, key: &H256) -> TrieResult { State::storage_at(self, address, key) } - fn code(&self, address: &Address) -> TrieResult>> { State::code(self, address) } + fn nonce(&self, a: &Address) -> trie::Result { State::nonce(self, a) } + fn balance(&self, a: &Address) -> trie::Result { State::balance(self, a) } + fn storage_at(&self, address: &Address, key: &H256) -> trie::Result { State::storage_at(self, address, key) } + fn code(&self, address: &Address) -> trie::Result>> { State::code(self, address) } + fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)> { State::account(self, a) } } const SEC_TRIE_DB_UNWRAP_STR: &'static str = "A state can only be created with valid root. Creating a SecTrieDB with a valid root will not fail. \ @@ -526,6 +532,23 @@ impl State { self.ensure_cached(a, RequireCache::CodeSize, false, |a| a.map_or(false, |a| a.code_hash() != KECCAK_EMPTY || *a.nonce() != self.account_start_nonce)) } + /// Get the balance of account `a`. + pub fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)> { + self.ensure_cached(a, RequireCache::None, true, |a| { + a.as_ref().map_or( + (U256::zero(), self.account_start_nonce, KECCAK_EMPTY, KECCAK_NULL_RLP), + |account| { + ( + *account.balance(), + *account.nonce(), + account.code_hash(), + *account.storage_root().unwrap_or(&H256::zero()), + ) + }, + ) + }) + } + /// Get the balance of account `a`. pub fn balance(&self, a: &Address) -> TrieResult { From e2cc24e8ff1120ad4334c6793f8576a39c189b56 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Mar 2018 09:06:37 +0200 Subject: [PATCH 27/98] changed to getProof --- ethcore/src/client/client.rs | 10 +--------- ethcore/src/client/test_client.rs | 13 +------------ ethcore/src/client/traits.rs | 9 +-------- ethcore/src/state/mod.rs | 23 ----------------------- rpc/src/v1/impls/eth.rs | 1 - 5 files changed, 3 insertions(+), 53 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 5f5f04be3b6..127f0f9eb5f 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -1324,15 +1324,7 @@ impl Balance for Client { } } -impl AccountData for Client { - fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { - match state { - StateOrBlock::State(s) => s.account(address).ok(), - StateOrBlock::Block(id) => self.state_at(id).and_then(|s| s.account(address).ok()), - } - } - -} +impl AccountData for Client {} impl ChainInfo for Client { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index 1f0ec876949..19df97c4882 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -457,16 +457,7 @@ impl Balance for TestBlockChainClient { } } -impl AccountData for TestBlockChainClient { - fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { - match state { - StateOrBlock::Block(BlockId::Latest) | StateOrBlock::State(_) => None, - _ => None, - } - } - - -} +impl AccountData for TestBlockChainClient {} impl ChainInfo for TestBlockChainClient { fn chain_info(&self) -> BlockChainInfo { @@ -603,8 +594,6 @@ impl StateInfo for () { fn balance(&self, _address: &Address) -> trie::Result { unimplemented!() } fn storage_at(&self, _address: &Address, _key: &H256) -> trie::Result { unimplemented!() } fn code(&self, _address: &Address) -> trie::Result>> { unimplemented!() } - fn account(&self, _address: &Address) -> trie::Result<(U256, U256, H256, H256)> { unimplemented!() } - } impl StateClient for TestBlockChainClient { diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index eb75f6eec51..ebe70dcd82c 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -110,14 +110,7 @@ pub trait Balance { } /// Provides methods to access account info -pub trait AccountData: Nonce + Balance { - /// Get address balance at the given block's state. - /// - /// May not return None if given BlockId::Latest. - /// Returns None if and only if the block's root hash has been pruned from the DB. - fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)>; - -} +pub trait AccountData: Nonce + Balance {} /// Provides `chain_info` method pub trait ChainInfo { diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index 60da8f5c139..df4ac87cbf3 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -347,11 +347,6 @@ pub trait StateInfo { /// Get accounts' code. fn code(&self, a: &Address) -> trie::Result>>; - - /// Get the account `a`. - fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)>; - - } impl StateInfo for State { @@ -359,7 +354,6 @@ impl StateInfo for State { fn balance(&self, a: &Address) -> trie::Result { State::balance(self, a) } fn storage_at(&self, address: &Address, key: &H256) -> trie::Result { State::storage_at(self, address, key) } fn code(&self, address: &Address) -> trie::Result>> { State::code(self, address) } - fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)> { State::account(self, a) } } const SEC_TRIE_DB_UNWRAP_STR: &'static str = "A state can only be created with valid root. Creating a SecTrieDB with a valid root will not fail. \ @@ -532,23 +526,6 @@ impl State { self.ensure_cached(a, RequireCache::CodeSize, false, |a| a.map_or(false, |a| a.code_hash() != KECCAK_EMPTY || *a.nonce() != self.account_start_nonce)) } - /// Get the balance of account `a`. - pub fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)> { - self.ensure_cached(a, RequireCache::None, true, |a| { - a.as_ref().map_or( - (U256::zero(), self.account_start_nonce, KECCAK_EMPTY, KECCAK_NULL_RLP), - |account| { - ( - *account.balance(), - *account.nonce(), - account.code_hash(), - *account.storage_root().unwrap_or(&H256::zero()), - ) - }, - ) - }) - } - /// Get the balance of account `a`. pub fn balance(&self, a: &Address) -> TrieResult { diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index a4ffab0f60c..ff7bd878e99 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -590,7 +590,6 @@ impl Eth for EthClient< }), None => Err(errors::state_pruned()), }; - Box::new(future::done(res)) } From 0b4ad4742ad268c035913c0b03728ac34d44e139 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Mar 2018 19:40:20 +0200 Subject: [PATCH 28/98] implemented storage_proof --- ethcore/src/state/account.rs | 2 +- rpc/src/v1/impls/eth.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ethcore/src/state/account.rs b/ethcore/src/state/account.rs index 160152fc70b..1a53d5e4cd6 100644 --- a/ethcore/src/state/account.rs +++ b/ethcore/src/state/account.rs @@ -581,7 +581,7 @@ impl Account { /// this will only work correctly under a secure trie. pub fn prove_storage(&self, db: &HashDB, storage_key: H256) -> TrieResult<(Vec, H256)> { let mut recorder = Recorder::new(); - + let trie = TrieDB::new(db, &self.storage_root)?; let item: U256 = { let panicky_decoder = |bytes:&[u8]| ::rlp::decode(bytes).expect("decoding db value failed"); diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index ff7bd878e99..a4ffab0f60c 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -590,6 +590,7 @@ impl Eth for EthClient< }), None => Err(errors::state_pruned()), }; + Box::new(future::done(res)) } From 345712bd767e6006558ca4c33cfea430bb376feb Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 19 Jun 2018 09:37:51 +0200 Subject: [PATCH 29/98] fixed docker --- docker/hub/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index c3406a5bd3d..1631b7441d3 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -51,7 +51,6 @@ RUN apt-get update && \ cd /build&&git clone https://github.com/paritytech/parity && \ cd parity && \ git pull&& \ - git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From 8c3adb405f5ec7f700e57367635e3624a5070344 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:27:07 +0200 Subject: [PATCH 30/98] removed slockit-changes --- docker/hub/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index 1631b7441d3..d1e06e4a242 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -50,7 +50,7 @@ RUN apt-get update && \ # build parity cd /build&&git clone https://github.com/paritytech/parity && \ cd parity && \ - git pull&& \ +git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From a3348c79a931a9ad4c5ce52e326d37b582ce5cb3 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:29:09 +0200 Subject: [PATCH 31/98] fixed Dockerfile --- docker/hub/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index d1e06e4a242..a8557e936d8 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -50,7 +50,8 @@ RUN apt-get update && \ # build parity cd /build&&git clone https://github.com/paritytech/parity && \ cd parity && \ -git checkout $BUILD_TAG && \ + git pull&& \ + git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From cbc8f647a9acd212191a281f65460aa19c0e7ae7 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:29:52 +0200 Subject: [PATCH 32/98] intend --- docker/hub/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index a8557e936d8..2bc26d5d953 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -50,8 +50,8 @@ RUN apt-get update && \ # build parity cd /build&&git clone https://github.com/paritytech/parity && \ cd parity && \ - git pull&& \ - git checkout $BUILD_TAG && \ + git pull&& \ + git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From 8f59da2da880185b17f8809412699ecffcdb49f6 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:30:31 +0200 Subject: [PATCH 33/98] spaces --- docker/hub/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index 2bc26d5d953..69cf8aac798 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -50,8 +50,8 @@ RUN apt-get update && \ # build parity cd /build&&git clone https://github.com/paritytech/parity && \ cd parity && \ - git pull&& \ - git checkout $BUILD_TAG && \ + git pull&& \ + git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From 785d35b619dab0a17ace8847c6b314047d4fc22b Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:31:42 +0200 Subject: [PATCH 34/98] removed spaces --- ethcore/src/state/account.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethcore/src/state/account.rs b/ethcore/src/state/account.rs index 1a53d5e4cd6..160152fc70b 100644 --- a/ethcore/src/state/account.rs +++ b/ethcore/src/state/account.rs @@ -581,7 +581,7 @@ impl Account { /// this will only work correctly under a secure trie. pub fn prove_storage(&self, db: &HashDB, storage_key: H256) -> TrieResult<(Vec, H256)> { let mut recorder = Recorder::new(); - + let trie = TrieDB::new(db, &self.storage_root)?; let item: U256 = { let panicky_decoder = |bytes:&[u8]| ::rlp::decode(bytes).expect("decoding db value failed"); From 0807ea37135c02aee8cf7cf7806b49bdb8f9a011 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:37:25 +0200 Subject: [PATCH 35/98] fixed whitespace --- docker/slockit/Dockerfile | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 docker/slockit/Dockerfile diff --git a/docker/slockit/Dockerfile b/docker/slockit/Dockerfile new file mode 100644 index 00000000000..b5f8178290a --- /dev/null +++ b/docker/slockit/Dockerfile @@ -0,0 +1,65 @@ +FROM ubuntu:14.04 +MAINTAINER Parity Technologies +WORKDIR /build +#ENV for build TAG +ARG BUILD_TAG +ENV BUILD_TAG ${BUILD_TAG:-master} +RUN echo "Build tag:" $BUILD_TAG +# install tools and dependencies +RUN apt-get update && \ + apt-get install -y --force-yes --no-install-recommends \ + # make + build-essential \ + # add-apt-repository + software-properties-common \ + make \ + curl \ + wget \ + git \ + g++ \ + gcc \ + libc6 \ + libc6-dev \ + binutils \ + file \ + openssl \ + libssl-dev \ + libudev-dev \ + pkg-config \ + dpkg-dev \ + libudev-dev &&\ +# install rustup + curl https://sh.rustup.rs -sSf | sh -s -- -y && \ +# rustup directory + PATH=/root/.cargo/bin:$PATH && \ +# show backtraces + RUST_BACKTRACE=1 && \ +# build parity +cd /build&&git clone https://github.com/slockit/parity -b in3 && \ + cd parity && \ + git pull&& \ + cargo build --verbose --release --features final && \ + #ls /build/parity/target/release/parity && \ + strip /build/parity/target/release/parity && \ + file /build/parity/target/release/parity&&mkdir -p /parity&& cp /build/parity/target/release/parity /parity&&\ +#cleanup Docker image + rm -rf /root/.cargo&&rm -rf /root/.multirust&&rm -rf /root/.rustup&&rm -rf /build&&\ + apt-get purge -y \ + # make + build-essential \ + # add-apt-repository + software-properties-common \ + make \ + curl \ + wget \ + git \ + g++ \ + gcc \ + binutils \ + file \ + pkg-config \ + dpkg-dev &&\ + rm -rf /var/lib/apt/lists/* +# setup ENTRYPOINT +EXPOSE 8080 8545 8180 +ENTRYPOINT ["/parity/parity"] From 2663199b3b9683666a2a2885a9b8bf66d8df2684 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:43:10 +0200 Subject: [PATCH 36/98] fixed docker --- docker/slockit/Dockerfile | 65 --------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 docker/slockit/Dockerfile diff --git a/docker/slockit/Dockerfile b/docker/slockit/Dockerfile deleted file mode 100644 index b5f8178290a..00000000000 --- a/docker/slockit/Dockerfile +++ /dev/null @@ -1,65 +0,0 @@ -FROM ubuntu:14.04 -MAINTAINER Parity Technologies -WORKDIR /build -#ENV for build TAG -ARG BUILD_TAG -ENV BUILD_TAG ${BUILD_TAG:-master} -RUN echo "Build tag:" $BUILD_TAG -# install tools and dependencies -RUN apt-get update && \ - apt-get install -y --force-yes --no-install-recommends \ - # make - build-essential \ - # add-apt-repository - software-properties-common \ - make \ - curl \ - wget \ - git \ - g++ \ - gcc \ - libc6 \ - libc6-dev \ - binutils \ - file \ - openssl \ - libssl-dev \ - libudev-dev \ - pkg-config \ - dpkg-dev \ - libudev-dev &&\ -# install rustup - curl https://sh.rustup.rs -sSf | sh -s -- -y && \ -# rustup directory - PATH=/root/.cargo/bin:$PATH && \ -# show backtraces - RUST_BACKTRACE=1 && \ -# build parity -cd /build&&git clone https://github.com/slockit/parity -b in3 && \ - cd parity && \ - git pull&& \ - cargo build --verbose --release --features final && \ - #ls /build/parity/target/release/parity && \ - strip /build/parity/target/release/parity && \ - file /build/parity/target/release/parity&&mkdir -p /parity&& cp /build/parity/target/release/parity /parity&&\ -#cleanup Docker image - rm -rf /root/.cargo&&rm -rf /root/.multirust&&rm -rf /root/.rustup&&rm -rf /build&&\ - apt-get purge -y \ - # make - build-essential \ - # add-apt-repository - software-properties-common \ - make \ - curl \ - wget \ - git \ - g++ \ - gcc \ - binutils \ - file \ - pkg-config \ - dpkg-dev &&\ - rm -rf /var/lib/apt/lists/* -# setup ENTRYPOINT -EXPOSE 8080 8545 8180 -ENTRYPOINT ["/parity/parity"] From 81286392aec348e40831cb1636db1ced7de44cba Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:44:12 +0200 Subject: [PATCH 37/98] tabs --- docker/hub/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index 69cf8aac798..c3406a5bd3d 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -50,8 +50,8 @@ RUN apt-get update && \ # build parity cd /build&&git clone https://github.com/paritytech/parity && \ cd parity && \ - git pull&& \ - git checkout $BUILD_TAG && \ + git pull&& \ + git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From aa194da6521e9d955207e63e1c4784e8fcb2fb08 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 18 Oct 2018 17:24:33 +0200 Subject: [PATCH 38/98] merged changes --- docker/hub/Dockerfile | 83 ------------------------------- ethcore/src/client/test_client.rs | 8 +-- ethcore/src/state/mod.rs | 10 ++-- rpc/src/v1/impls/eth.rs | 3 +- rpc/src/v1/impls/light/eth.rs | 2 +- rpc/src/v1/types/account_info.rs | 1 - 6 files changed, 12 insertions(+), 95 deletions(-) delete mode 100644 docker/hub/Dockerfile diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile deleted file mode 100644 index c3406a5bd3d..00000000000 --- a/docker/hub/Dockerfile +++ /dev/null @@ -1,83 +0,0 @@ -FROM ubuntu:14.04 -MAINTAINER Parity Technologies -WORKDIR /build -#ENV for build TAG -ARG BUILD_TAG -ENV BUILD_TAG ${BUILD_TAG:-master} -RUN echo "Build tag:" $BUILD_TAG -# install tools and dependencies -RUN apt-get update && \ - apt-get install -y --force-yes --no-install-recommends \ - # make - build-essential \ - # add-apt-repository - software-properties-common \ - make \ - curl \ - wget \ - git \ - g++ \ - gcc \ - libc6 \ - libc6-dev \ - binutils \ - file \ - openssl \ - libssl-dev \ - libudev-dev \ - pkg-config \ - dpkg-dev \ - # evmjit dependencies - zlib1g-dev \ - libedit-dev \ - libudev-dev &&\ -# cmake and llvm ppa's. then update ppa's - add-apt-repository -y "ppa:george-edison55/cmake-3.x" && \ - add-apt-repository "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.7 main" && \ - apt-get update && \ - apt-get install -y --force-yes cmake llvm-3.7-dev && \ -# install evmjit - git clone https://github.com/debris/evmjit && \ - cd evmjit && \ - mkdir build && cd build && \ - cmake .. && make && make install && cd && \ -# install rustup - curl https://sh.rustup.rs -sSf | sh -s -- -y && \ -# rustup directory - PATH=/root/.cargo/bin:$PATH && \ -# show backtraces - RUST_BACKTRACE=1 && \ -# build parity -cd /build&&git clone https://github.com/paritytech/parity && \ - cd parity && \ - git pull&& \ - git checkout $BUILD_TAG && \ - cargo build --verbose --release --features final && \ - #ls /build/parity/target/release/parity && \ - strip /build/parity/target/release/parity && \ - file /build/parity/target/release/parity&&mkdir -p /parity&& cp /build/parity/target/release/parity /parity&&\ -#cleanup Docker image - rm -rf /root/.cargo&&rm -rf /root/.multirust&&rm -rf /root/.rustup&&rm -rf /build&&\ - apt-get purge -y \ - # make - build-essential \ - # add-apt-repository - software-properties-common \ - make \ - curl \ - wget \ - git \ - g++ \ - gcc \ - binutils \ - file \ - pkg-config \ - dpkg-dev \ - # evmjit dependencies - zlib1g-dev \ - libedit-dev \ - cmake llvm-3.7-dev&&\ - rm -rf /var/lib/apt/lists/* -# setup ENTRYPOINT -EXPOSE 8080 8545 8180 -ENTRYPOINT ["/parity/parity"] diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index 19df97c4882..c3d8c127b08 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -590,10 +590,10 @@ impl Call for TestBlockChainClient { } impl StateInfo for () { - fn nonce(&self, _address: &Address) -> trie::Result { unimplemented!() } - fn balance(&self, _address: &Address) -> trie::Result { unimplemented!() } - fn storage_at(&self, _address: &Address, _key: &H256) -> trie::Result { unimplemented!() } - fn code(&self, _address: &Address) -> trie::Result>> { unimplemented!() } + fn nonce(&self, _address: &Address) -> ethtrie::Result { unimplemented!() } + fn balance(&self, _address: &Address) -> ethtrie::Result { unimplemented!() } + fn storage_at(&self, _address: &Address, _key: &H256) -> ethtrie::Result { unimplemented!() } + fn code(&self, _address: &Address) -> ethtrie::Result>> { unimplemented!() } } impl StateClient for TestBlockChainClient { diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index df4ac87cbf3..f34f1219daf 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -346,14 +346,14 @@ pub trait StateInfo { fn storage_at(&self, address: &Address, key: &H256) -> TrieResult; /// Get accounts' code. - fn code(&self, a: &Address) -> trie::Result>>; + fn code(&self, a: &Address) -> TrieResult>>; } impl StateInfo for State { - fn nonce(&self, a: &Address) -> trie::Result { State::nonce(self, a) } - fn balance(&self, a: &Address) -> trie::Result { State::balance(self, a) } - fn storage_at(&self, address: &Address, key: &H256) -> trie::Result { State::storage_at(self, address, key) } - fn code(&self, address: &Address) -> trie::Result>> { State::code(self, address) } + fn nonce(&self, a: &Address) -> TrieResult { State::nonce(self, a) } + fn balance(&self, a: &Address) -> TrieResult { State::balance(self, a) } + fn storage_at(&self, address: &Address, key: &H256) -> TrieResult { State::storage_at(self, address, key) } + fn code(&self, address: &Address) -> TrieResult>> { State::code(self, address) } } const SEC_TRIE_DB_UNWRAP_STR: &'static str = "A state can only be created with valid root. Creating a SecTrieDB with a valid root will not fail. \ diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index a4ffab0f60c..5c1246f38f8 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -20,7 +20,7 @@ use std::thread; use std::time::{Instant, Duration, SystemTime, UNIX_EPOCH}; use std::sync::Arc; -use rlp::{self, Rlp}; +use rlp::Rlp; use ethereum_types::{U256, H64, H256, H160, Address}; use parking_lot::Mutex; @@ -594,6 +594,7 @@ impl Eth for EthClient< Box::new(future::done(res)) } + fn storage_at(&self, address: RpcH160, pos: RpcU256, num: Trailing) -> BoxFuture { let address: Address = RpcH160::into(address); let position: U256 = RpcU256::into(pos); diff --git a/rpc/src/v1/impls/light/eth.rs b/rpc/src/v1/impls/light/eth.rs index a2633acfff6..38c70981688 100644 --- a/rpc/src/v1/impls/light/eth.rs +++ b/rpc/src/v1/impls/light/eth.rs @@ -46,7 +46,7 @@ use v1::helpers::{SyncPollFilter, PollManager}; use v1::helpers::light_fetch::{self, LightFetch}; use v1::traits::Eth; use v1::types::{ - RichBlock, Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, SyncInfo, + RichBlock, Block, BlockTransactions, BlockNumber, LightBlockNumber, Bytes, SyncStatus, SyncInfo, Transaction, CallRequest, Index, Filter, Log, Receipt, Work,EthAccount, H64 as RpcH64, H256 as RpcH256, H160 as RpcH160, U256 as RpcU256, }; diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index 8f455cdd46d..e5d90abd605 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -52,7 +52,6 @@ pub struct EthAccount{ } - /// Extended account information (used by `parity_allAccountInfo`). #[derive(Debug, Default, Clone, PartialEq, Serialize)] pub struct ExtAccountInfo { From e5b4e214c3114a744b211bf5cc79c2862dfa76a6 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 18 Oct 2018 17:37:37 +0200 Subject: [PATCH 39/98] fixed warnings --- rpc/src/v1/impls/eth.rs | 6 +++--- rpc/src/v1/impls/light/eth.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 5c1246f38f8..83ec8920f53 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -21,7 +21,7 @@ use std::time::{Instant, Duration, SystemTime, UNIX_EPOCH}; use std::sync::Arc; use rlp::Rlp; -use ethereum_types::{U256, H64, H256, H160, Address}; +use ethereum_types::{U256, H256, H160, Address}; use parking_lot::Mutex; use ethash::{self, SeedHashCompute}; @@ -571,8 +571,8 @@ impl Eth for EthClient< storage_hash : p.1.storage_root.into(), account_proof: Some(p.0.iter().map(|b| Bytes::new(b.clone())).collect::>()), storage_proof: Some( - values.iter().map(|storageIndex| { - let key2 : H256 = storageIndex.clone().into(); + values.iter().map(|storage_index| { + let key2 : H256 = storage_index.clone().into(); match self.client.prove_storage(key1, keccak(key2), id) { Some(sp) => StorageProof { key : key2.into(), diff --git a/rpc/src/v1/impls/light/eth.rs b/rpc/src/v1/impls/light/eth.rs index 38c70981688..942c2d455fb 100644 --- a/rpc/src/v1/impls/light/eth.rs +++ b/rpc/src/v1/impls/light/eth.rs @@ -471,7 +471,7 @@ impl Eth for EthClient { } - fn proof(&self, address: RpcH160, values:Vec, num: Trailing) -> BoxFuture { + fn proof(&self, _address: RpcH160, _values:Vec, _num: Trailing) -> BoxFuture { Box::new(future::err(errors::unimplemented(None))) } From eeceb4d3eb85f2f5d0ebbaa56c9969a852ad0b49 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 27 Mar 2018 18:35:39 +0200 Subject: [PATCH 40/98] added eth_getAccount --- ethcore/src/client/client.rs | 10 +++++++++- ethcore/src/client/test_client.rs | 11 ++++++++++- ethcore/src/client/traits.rs | 9 ++++++++- ethcore/src/state/mod.rs | 17 +++++++++++++++++ rpc/src/v1/types/account_info.rs | 16 ++++++++++++++++ 5 files changed, 60 insertions(+), 3 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 127f0f9eb5f..5f5f04be3b6 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -1324,7 +1324,15 @@ impl Balance for Client { } } -impl AccountData for Client {} +impl AccountData for Client { + fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { + match state { + StateOrBlock::State(s) => s.account(address).ok(), + StateOrBlock::Block(id) => self.state_at(id).and_then(|s| s.account(address).ok()), + } + } + +} impl ChainInfo for Client { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index c3d8c127b08..1df8307250c 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -457,7 +457,16 @@ impl Balance for TestBlockChainClient { } } -impl AccountData for TestBlockChainClient {} +impl AccountData for TestBlockChainClient { + fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { + match state { + StateOrBlock::Block(BlockId::Latest) | StateOrBlock::State(_) => None, + _ => None, + } + } + + +} impl ChainInfo for TestBlockChainClient { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index ebe70dcd82c..eb75f6eec51 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -110,7 +110,14 @@ pub trait Balance { } /// Provides methods to access account info -pub trait AccountData: Nonce + Balance {} +pub trait AccountData: Nonce + Balance { + /// Get address balance at the given block's state. + /// + /// May not return None if given BlockId::Latest. + /// Returns None if and only if the block's root hash has been pruned from the DB. + fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)>; + +} /// Provides `chain_info` method pub trait ChainInfo { diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index f34f1219daf..4a9169ff003 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -526,6 +526,23 @@ impl State { self.ensure_cached(a, RequireCache::CodeSize, false, |a| a.map_or(false, |a| a.code_hash() != KECCAK_EMPTY || *a.nonce() != self.account_start_nonce)) } + /// Get the balance of account `a`. + pub fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)> { + self.ensure_cached(a, RequireCache::None, true, |a| { + a.as_ref().map_or( + (U256::zero(), self.account_start_nonce, KECCAK_EMPTY, KECCAK_NULL_RLP), + |account| { + ( + *account.balance(), + *account.nonce(), + account.code_hash(), + *account.storage_root().unwrap_or(&H256::zero()), + ) + }, + ) + }) + } + /// Get the balance of account `a`. pub fn balance(&self, a: &Address) -> TrieResult { diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index e5d90abd605..f61106d0951 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -52,6 +52,22 @@ pub struct EthAccount{ } +/// Account information. +#[derive(Debug, Default, Clone, PartialEq, Serialize)] +pub struct EthAccount{ + #[serde(rename="address")] + pub address: H160, + #[serde(rename="balance")] + pub balance: U256, + #[serde(rename="nonce")] + pub nonce: U256, + #[serde(rename="codeHash")] + pub code_hash: H256, + #[serde(rename="storageHash")] + pub storage_hash: H256, + +} + /// Extended account information (used by `parity_allAccountInfo`). #[derive(Debug, Default, Clone, PartialEq, Serialize)] pub struct ExtAccountInfo { From 81fc2a2ff87e2b00927812b760687d0fbc875d5e Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Mar 2018 09:06:37 +0200 Subject: [PATCH 41/98] changed to getProof --- ethcore/src/client/client.rs | 10 +--------- ethcore/src/client/test_client.rs | 11 +---------- ethcore/src/client/traits.rs | 9 +-------- ethcore/src/state/mod.rs | 17 ----------------- rpc/src/v1/impls/eth.rs | 1 - rpc/src/v1/types/account_info.rs | 4 ++++ 6 files changed, 7 insertions(+), 45 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 5f5f04be3b6..127f0f9eb5f 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -1324,15 +1324,7 @@ impl Balance for Client { } } -impl AccountData for Client { - fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { - match state { - StateOrBlock::State(s) => s.account(address).ok(), - StateOrBlock::Block(id) => self.state_at(id).and_then(|s| s.account(address).ok()), - } - } - -} +impl AccountData for Client {} impl ChainInfo for Client { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index 1df8307250c..c3d8c127b08 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -457,16 +457,7 @@ impl Balance for TestBlockChainClient { } } -impl AccountData for TestBlockChainClient { - fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { - match state { - StateOrBlock::Block(BlockId::Latest) | StateOrBlock::State(_) => None, - _ => None, - } - } - - -} +impl AccountData for TestBlockChainClient {} impl ChainInfo for TestBlockChainClient { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index eb75f6eec51..ebe70dcd82c 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -110,14 +110,7 @@ pub trait Balance { } /// Provides methods to access account info -pub trait AccountData: Nonce + Balance { - /// Get address balance at the given block's state. - /// - /// May not return None if given BlockId::Latest. - /// Returns None if and only if the block's root hash has been pruned from the DB. - fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)>; - -} +pub trait AccountData: Nonce + Balance {} /// Provides `chain_info` method pub trait ChainInfo { diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index 4a9169ff003..f34f1219daf 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -526,23 +526,6 @@ impl State { self.ensure_cached(a, RequireCache::CodeSize, false, |a| a.map_or(false, |a| a.code_hash() != KECCAK_EMPTY || *a.nonce() != self.account_start_nonce)) } - /// Get the balance of account `a`. - pub fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)> { - self.ensure_cached(a, RequireCache::None, true, |a| { - a.as_ref().map_or( - (U256::zero(), self.account_start_nonce, KECCAK_EMPTY, KECCAK_NULL_RLP), - |account| { - ( - *account.balance(), - *account.nonce(), - account.code_hash(), - *account.storage_root().unwrap_or(&H256::zero()), - ) - }, - ) - }) - } - /// Get the balance of account `a`. pub fn balance(&self, a: &Address) -> TrieResult { diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 83ec8920f53..3b086b12f5f 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -590,7 +590,6 @@ impl Eth for EthClient< }), None => Err(errors::state_pruned()), }; - Box::new(future::done(res)) } diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index f61106d0951..88d6c0793bd 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -65,6 +65,10 @@ pub struct EthAccount{ pub code_hash: H256, #[serde(rename="storageHash")] pub storage_hash: H256, + #[serde(rename="accountProof")] + pub account_proof: Option>, + #[serde(rename="storageProof")] + pub storage_proof: Option)>>, } From 44327c64a9f7e048cc0d92c06294af0ed6fd7e7b Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Mar 2018 19:40:20 +0200 Subject: [PATCH 42/98] implemented storage_proof --- ethcore/src/state/account.rs | 2 +- rpc/src/v1/impls/eth.rs | 1 + rpc/src/v1/types/account_info.rs | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ethcore/src/state/account.rs b/ethcore/src/state/account.rs index 160152fc70b..1a53d5e4cd6 100644 --- a/ethcore/src/state/account.rs +++ b/ethcore/src/state/account.rs @@ -581,7 +581,7 @@ impl Account { /// this will only work correctly under a secure trie. pub fn prove_storage(&self, db: &HashDB, storage_key: H256) -> TrieResult<(Vec, H256)> { let mut recorder = Recorder::new(); - + let trie = TrieDB::new(db, &self.storage_root)?; let item: U256 = { let panicky_decoder = |bytes:&[u8]| ::rlp::decode(bytes).expect("decoding db value failed"); diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 3b086b12f5f..83ec8920f53 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -590,6 +590,7 @@ impl Eth for EthClient< }), None => Err(errors::state_pruned()), }; + Box::new(future::done(res)) } diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index 88d6c0793bd..081c3d60277 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -68,7 +68,7 @@ pub struct EthAccount{ #[serde(rename="accountProof")] pub account_proof: Option>, #[serde(rename="storageProof")] - pub storage_proof: Option)>>, + pub storage_proof: Option)>>, } From 90c24f5001e602ce72682c594a3256edd03fe537 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Mar 2018 20:00:37 +0200 Subject: [PATCH 43/98] better formatting of storage proof --- rpc/src/v1/types/account_info.rs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index 081c3d60277..8f455cdd46d 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -52,25 +52,6 @@ pub struct EthAccount{ } -/// Account information. -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct EthAccount{ - #[serde(rename="address")] - pub address: H160, - #[serde(rename="balance")] - pub balance: U256, - #[serde(rename="nonce")] - pub nonce: U256, - #[serde(rename="codeHash")] - pub code_hash: H256, - #[serde(rename="storageHash")] - pub storage_hash: H256, - #[serde(rename="accountProof")] - pub account_proof: Option>, - #[serde(rename="storageProof")] - pub storage_proof: Option)>>, - -} /// Extended account information (used by `parity_allAccountInfo`). #[derive(Debug, Default, Clone, PartialEq, Serialize)] From 1c2c603c866e2cdd007779a69405705e361cb284 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 15 May 2018 14:34:59 +0200 Subject: [PATCH 44/98] Update Dockerfile --- docker/hub/Dockerfile | 83 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 docker/hub/Dockerfile diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile new file mode 100644 index 00000000000..3ffdf290eb5 --- /dev/null +++ b/docker/hub/Dockerfile @@ -0,0 +1,83 @@ +FROM ubuntu:14.04 +MAINTAINER Parity Technologies +WORKDIR /build +#ENV for build TAG +ARG BUILD_TAG +ENV BUILD_TAG ${BUILD_TAG:-master} +RUN echo "Build tag:" $BUILD_TAG +# install tools and dependencies +RUN apt-get update && \ + apt-get install -y --force-yes --no-install-recommends \ + # make + build-essential \ + # add-apt-repository + software-properties-common \ + make \ + curl \ + wget \ + git \ + g++ \ + gcc \ + libc6 \ + libc6-dev \ + binutils \ + file \ + openssl \ + libssl-dev \ + libudev-dev \ + pkg-config \ + dpkg-dev \ + # evmjit dependencies + zlib1g-dev \ + libedit-dev \ + libudev-dev &&\ +# cmake and llvm ppa's. then update ppa's + add-apt-repository -y "ppa:george-edison55/cmake-3.x" && \ + add-apt-repository "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.7 main" && \ + apt-get update && \ + apt-get install -y --force-yes cmake llvm-3.7-dev && \ +# install evmjit + git clone https://github.com/debris/evmjit && \ + cd evmjit && \ + mkdir build && cd build && \ + cmake .. && make && make install && cd && \ +# install rustup + curl https://sh.rustup.rs -sSf | sh -s -- -y && \ +# rustup directory + PATH=/root/.cargo/bin:$PATH && \ +# show backtraces + RUST_BACKTRACE=1 && \ +# build parity +cd /build&&git clone https://github.com/slockit/parity && \ + cd parity && \ + git pull&& \ + git checkout $BUILD_TAG && \ + cargo build --verbose --release --features final && \ + #ls /build/parity/target/release/parity && \ + strip /build/parity/target/release/parity && \ + file /build/parity/target/release/parity&&mkdir -p /parity&& cp /build/parity/target/release/parity /parity&&\ +#cleanup Docker image + rm -rf /root/.cargo&&rm -rf /root/.multirust&&rm -rf /root/.rustup&&rm -rf /build&&\ + apt-get purge -y \ + # make + build-essential \ + # add-apt-repository + software-properties-common \ + make \ + curl \ + wget \ + git \ + g++ \ + gcc \ + binutils \ + file \ + pkg-config \ + dpkg-dev \ + # evmjit dependencies + zlib1g-dev \ + libedit-dev \ + cmake llvm-3.7-dev&&\ + rm -rf /var/lib/apt/lists/* +# setup ENTRYPOINT +EXPOSE 8080 8545 8180 +ENTRYPOINT ["/parity/parity"] From ce9d30d1167b1b279935a4183f7856e8a2a7aa87 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 19 Jun 2018 09:37:51 +0200 Subject: [PATCH 45/98] fixed docker --- docker/hub/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index 3ffdf290eb5..694783d10f3 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -51,7 +51,6 @@ RUN apt-get update && \ cd /build&&git clone https://github.com/slockit/parity && \ cd parity && \ git pull&& \ - git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From 8394d821526f6b4e7f605548a15243dc7e3acc67 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:27:07 +0200 Subject: [PATCH 46/98] removed slockit-changes --- docker/hub/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index 694783d10f3..08d0747ef27 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -50,7 +50,7 @@ RUN apt-get update && \ # build parity cd /build&&git clone https://github.com/slockit/parity && \ cd parity && \ - git pull&& \ +git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From ddbf8dbdea48dfb93d84d87642088c1ec9ac7f50 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:29:09 +0200 Subject: [PATCH 47/98] fixed Dockerfile --- docker/hub/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index 08d0747ef27..dd6c4934644 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -50,7 +50,8 @@ RUN apt-get update && \ # build parity cd /build&&git clone https://github.com/slockit/parity && \ cd parity && \ -git checkout $BUILD_TAG && \ + git pull&& \ + git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From 690d94c52dc8971f1badc721a6335aa0d5c27ad8 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:29:52 +0200 Subject: [PATCH 48/98] intend --- docker/hub/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index dd6c4934644..414ade56a04 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -50,8 +50,8 @@ RUN apt-get update && \ # build parity cd /build&&git clone https://github.com/slockit/parity && \ cd parity && \ - git pull&& \ - git checkout $BUILD_TAG && \ + git pull&& \ + git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From be46184ee6c7d7e90ca282ab2d37cd6a523601fc Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:30:31 +0200 Subject: [PATCH 49/98] spaces --- docker/hub/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index 414ade56a04..15391c36b2c 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -50,8 +50,8 @@ RUN apt-get update && \ # build parity cd /build&&git clone https://github.com/slockit/parity && \ cd parity && \ - git pull&& \ - git checkout $BUILD_TAG && \ + git pull&& \ + git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From 6f91025741df2adb84c328e6b3a1bde8834b4eee Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:31:42 +0200 Subject: [PATCH 50/98] removed spaces --- ethcore/src/state/account.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethcore/src/state/account.rs b/ethcore/src/state/account.rs index 1a53d5e4cd6..160152fc70b 100644 --- a/ethcore/src/state/account.rs +++ b/ethcore/src/state/account.rs @@ -581,7 +581,7 @@ impl Account { /// this will only work correctly under a secure trie. pub fn prove_storage(&self, db: &HashDB, storage_key: H256) -> TrieResult<(Vec, H256)> { let mut recorder = Recorder::new(); - + let trie = TrieDB::new(db, &self.storage_root)?; let item: U256 = { let panicky_decoder = |bytes:&[u8]| ::rlp::decode(bytes).expect("decoding db value failed"); From 39fd4912f5c303ab41fcb1aafacece659f078b5f Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:37:25 +0200 Subject: [PATCH 51/98] fixed whitespace --- docker/slockit/Dockerfile | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 docker/slockit/Dockerfile diff --git a/docker/slockit/Dockerfile b/docker/slockit/Dockerfile new file mode 100644 index 00000000000..b5f8178290a --- /dev/null +++ b/docker/slockit/Dockerfile @@ -0,0 +1,65 @@ +FROM ubuntu:14.04 +MAINTAINER Parity Technologies +WORKDIR /build +#ENV for build TAG +ARG BUILD_TAG +ENV BUILD_TAG ${BUILD_TAG:-master} +RUN echo "Build tag:" $BUILD_TAG +# install tools and dependencies +RUN apt-get update && \ + apt-get install -y --force-yes --no-install-recommends \ + # make + build-essential \ + # add-apt-repository + software-properties-common \ + make \ + curl \ + wget \ + git \ + g++ \ + gcc \ + libc6 \ + libc6-dev \ + binutils \ + file \ + openssl \ + libssl-dev \ + libudev-dev \ + pkg-config \ + dpkg-dev \ + libudev-dev &&\ +# install rustup + curl https://sh.rustup.rs -sSf | sh -s -- -y && \ +# rustup directory + PATH=/root/.cargo/bin:$PATH && \ +# show backtraces + RUST_BACKTRACE=1 && \ +# build parity +cd /build&&git clone https://github.com/slockit/parity -b in3 && \ + cd parity && \ + git pull&& \ + cargo build --verbose --release --features final && \ + #ls /build/parity/target/release/parity && \ + strip /build/parity/target/release/parity && \ + file /build/parity/target/release/parity&&mkdir -p /parity&& cp /build/parity/target/release/parity /parity&&\ +#cleanup Docker image + rm -rf /root/.cargo&&rm -rf /root/.multirust&&rm -rf /root/.rustup&&rm -rf /build&&\ + apt-get purge -y \ + # make + build-essential \ + # add-apt-repository + software-properties-common \ + make \ + curl \ + wget \ + git \ + g++ \ + gcc \ + binutils \ + file \ + pkg-config \ + dpkg-dev &&\ + rm -rf /var/lib/apt/lists/* +# setup ENTRYPOINT +EXPOSE 8080 8545 8180 +ENTRYPOINT ["/parity/parity"] From 1831b00e55d305abf88d32aec8fc3c73bc7a3804 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:43:10 +0200 Subject: [PATCH 52/98] fixed docker --- docker/slockit/Dockerfile | 65 --------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 docker/slockit/Dockerfile diff --git a/docker/slockit/Dockerfile b/docker/slockit/Dockerfile deleted file mode 100644 index b5f8178290a..00000000000 --- a/docker/slockit/Dockerfile +++ /dev/null @@ -1,65 +0,0 @@ -FROM ubuntu:14.04 -MAINTAINER Parity Technologies -WORKDIR /build -#ENV for build TAG -ARG BUILD_TAG -ENV BUILD_TAG ${BUILD_TAG:-master} -RUN echo "Build tag:" $BUILD_TAG -# install tools and dependencies -RUN apt-get update && \ - apt-get install -y --force-yes --no-install-recommends \ - # make - build-essential \ - # add-apt-repository - software-properties-common \ - make \ - curl \ - wget \ - git \ - g++ \ - gcc \ - libc6 \ - libc6-dev \ - binutils \ - file \ - openssl \ - libssl-dev \ - libudev-dev \ - pkg-config \ - dpkg-dev \ - libudev-dev &&\ -# install rustup - curl https://sh.rustup.rs -sSf | sh -s -- -y && \ -# rustup directory - PATH=/root/.cargo/bin:$PATH && \ -# show backtraces - RUST_BACKTRACE=1 && \ -# build parity -cd /build&&git clone https://github.com/slockit/parity -b in3 && \ - cd parity && \ - git pull&& \ - cargo build --verbose --release --features final && \ - #ls /build/parity/target/release/parity && \ - strip /build/parity/target/release/parity && \ - file /build/parity/target/release/parity&&mkdir -p /parity&& cp /build/parity/target/release/parity /parity&&\ -#cleanup Docker image - rm -rf /root/.cargo&&rm -rf /root/.multirust&&rm -rf /root/.rustup&&rm -rf /build&&\ - apt-get purge -y \ - # make - build-essential \ - # add-apt-repository - software-properties-common \ - make \ - curl \ - wget \ - git \ - g++ \ - gcc \ - binutils \ - file \ - pkg-config \ - dpkg-dev &&\ - rm -rf /var/lib/apt/lists/* -# setup ENTRYPOINT -EXPOSE 8080 8545 8180 -ENTRYPOINT ["/parity/parity"] From d09e66e8bda1a20da3792395afe4079f59ccdd28 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:44:12 +0200 Subject: [PATCH 53/98] tabs --- docker/hub/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index 15391c36b2c..3ffdf290eb5 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -50,8 +50,8 @@ RUN apt-get update && \ # build parity cd /build&&git clone https://github.com/slockit/parity && \ cd parity && \ - git pull&& \ - git checkout $BUILD_TAG && \ + git pull&& \ + git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From 9888eac2a3bd260359b4f435f0681dd5269ed908 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 27 Mar 2018 18:35:39 +0200 Subject: [PATCH 54/98] added eth_getAccount --- ethcore/src/client/client.rs | 10 +++++++++- ethcore/src/client/test_client.rs | 11 ++++++++++- ethcore/src/client/traits.rs | 9 ++++++++- ethcore/src/state/mod.rs | 17 +++++++++++++++++ 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 127f0f9eb5f..5f5f04be3b6 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -1324,7 +1324,15 @@ impl Balance for Client { } } -impl AccountData for Client {} +impl AccountData for Client { + fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { + match state { + StateOrBlock::State(s) => s.account(address).ok(), + StateOrBlock::Block(id) => self.state_at(id).and_then(|s| s.account(address).ok()), + } + } + +} impl ChainInfo for Client { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index c3d8c127b08..1df8307250c 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -457,7 +457,16 @@ impl Balance for TestBlockChainClient { } } -impl AccountData for TestBlockChainClient {} +impl AccountData for TestBlockChainClient { + fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { + match state { + StateOrBlock::Block(BlockId::Latest) | StateOrBlock::State(_) => None, + _ => None, + } + } + + +} impl ChainInfo for TestBlockChainClient { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index ebe70dcd82c..eb75f6eec51 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -110,7 +110,14 @@ pub trait Balance { } /// Provides methods to access account info -pub trait AccountData: Nonce + Balance {} +pub trait AccountData: Nonce + Balance { + /// Get address balance at the given block's state. + /// + /// May not return None if given BlockId::Latest. + /// Returns None if and only if the block's root hash has been pruned from the DB. + fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)>; + +} /// Provides `chain_info` method pub trait ChainInfo { diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index f34f1219daf..4a9169ff003 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -526,6 +526,23 @@ impl State { self.ensure_cached(a, RequireCache::CodeSize, false, |a| a.map_or(false, |a| a.code_hash() != KECCAK_EMPTY || *a.nonce() != self.account_start_nonce)) } + /// Get the balance of account `a`. + pub fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)> { + self.ensure_cached(a, RequireCache::None, true, |a| { + a.as_ref().map_or( + (U256::zero(), self.account_start_nonce, KECCAK_EMPTY, KECCAK_NULL_RLP), + |account| { + ( + *account.balance(), + *account.nonce(), + account.code_hash(), + *account.storage_root().unwrap_or(&H256::zero()), + ) + }, + ) + }) + } + /// Get the balance of account `a`. pub fn balance(&self, a: &Address) -> TrieResult { From 8beaa27e6f33d83cb6f8081c095ca72258300bd6 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Mar 2018 09:06:37 +0200 Subject: [PATCH 55/98] changed to getProof --- ethcore/src/client/client.rs | 10 +--------- ethcore/src/client/test_client.rs | 11 +---------- ethcore/src/client/traits.rs | 9 +-------- ethcore/src/state/mod.rs | 17 ----------------- rpc/src/v1/impls/eth.rs | 1 - 5 files changed, 3 insertions(+), 45 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 5f5f04be3b6..127f0f9eb5f 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -1324,15 +1324,7 @@ impl Balance for Client { } } -impl AccountData for Client { - fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { - match state { - StateOrBlock::State(s) => s.account(address).ok(), - StateOrBlock::Block(id) => self.state_at(id).and_then(|s| s.account(address).ok()), - } - } - -} +impl AccountData for Client {} impl ChainInfo for Client { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index 1df8307250c..c3d8c127b08 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -457,16 +457,7 @@ impl Balance for TestBlockChainClient { } } -impl AccountData for TestBlockChainClient { - fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { - match state { - StateOrBlock::Block(BlockId::Latest) | StateOrBlock::State(_) => None, - _ => None, - } - } - - -} +impl AccountData for TestBlockChainClient {} impl ChainInfo for TestBlockChainClient { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index eb75f6eec51..ebe70dcd82c 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -110,14 +110,7 @@ pub trait Balance { } /// Provides methods to access account info -pub trait AccountData: Nonce + Balance { - /// Get address balance at the given block's state. - /// - /// May not return None if given BlockId::Latest. - /// Returns None if and only if the block's root hash has been pruned from the DB. - fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)>; - -} +pub trait AccountData: Nonce + Balance {} /// Provides `chain_info` method pub trait ChainInfo { diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index 4a9169ff003..f34f1219daf 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -526,23 +526,6 @@ impl State { self.ensure_cached(a, RequireCache::CodeSize, false, |a| a.map_or(false, |a| a.code_hash() != KECCAK_EMPTY || *a.nonce() != self.account_start_nonce)) } - /// Get the balance of account `a`. - pub fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)> { - self.ensure_cached(a, RequireCache::None, true, |a| { - a.as_ref().map_or( - (U256::zero(), self.account_start_nonce, KECCAK_EMPTY, KECCAK_NULL_RLP), - |account| { - ( - *account.balance(), - *account.nonce(), - account.code_hash(), - *account.storage_root().unwrap_or(&H256::zero()), - ) - }, - ) - }) - } - /// Get the balance of account `a`. pub fn balance(&self, a: &Address) -> TrieResult { diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 83ec8920f53..3b086b12f5f 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -590,7 +590,6 @@ impl Eth for EthClient< }), None => Err(errors::state_pruned()), }; - Box::new(future::done(res)) } From f69855ca6308a1cceddade18d229199ca1c4817a Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Mar 2018 19:40:20 +0200 Subject: [PATCH 56/98] implemented storage_proof --- ethcore/src/state/account.rs | 2 +- rpc/src/v1/impls/eth.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ethcore/src/state/account.rs b/ethcore/src/state/account.rs index 160152fc70b..1a53d5e4cd6 100644 --- a/ethcore/src/state/account.rs +++ b/ethcore/src/state/account.rs @@ -581,7 +581,7 @@ impl Account { /// this will only work correctly under a secure trie. pub fn prove_storage(&self, db: &HashDB, storage_key: H256) -> TrieResult<(Vec, H256)> { let mut recorder = Recorder::new(); - + let trie = TrieDB::new(db, &self.storage_root)?; let item: U256 = { let panicky_decoder = |bytes:&[u8]| ::rlp::decode(bytes).expect("decoding db value failed"); diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 3b086b12f5f..83ec8920f53 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -590,6 +590,7 @@ impl Eth for EthClient< }), None => Err(errors::state_pruned()), }; + Box::new(future::done(res)) } From 3340d809f11401bad288dd551c203912178be699 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:31:42 +0200 Subject: [PATCH 57/98] removed spaces --- ethcore/src/state/account.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethcore/src/state/account.rs b/ethcore/src/state/account.rs index 1a53d5e4cd6..160152fc70b 100644 --- a/ethcore/src/state/account.rs +++ b/ethcore/src/state/account.rs @@ -581,7 +581,7 @@ impl Account { /// this will only work correctly under a secure trie. pub fn prove_storage(&self, db: &HashDB, storage_key: H256) -> TrieResult<(Vec, H256)> { let mut recorder = Recorder::new(); - + let trie = TrieDB::new(db, &self.storage_root)?; let item: U256 = { let panicky_decoder = |bytes:&[u8]| ::rlp::decode(bytes).expect("decoding db value failed"); From 2e4e809e5337ef4af35f9fb285cdd2ce93bdc25e Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:37:25 +0200 Subject: [PATCH 58/98] fixed whitespace --- docker/slockit/Dockerfile | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 docker/slockit/Dockerfile diff --git a/docker/slockit/Dockerfile b/docker/slockit/Dockerfile new file mode 100644 index 00000000000..b5f8178290a --- /dev/null +++ b/docker/slockit/Dockerfile @@ -0,0 +1,65 @@ +FROM ubuntu:14.04 +MAINTAINER Parity Technologies +WORKDIR /build +#ENV for build TAG +ARG BUILD_TAG +ENV BUILD_TAG ${BUILD_TAG:-master} +RUN echo "Build tag:" $BUILD_TAG +# install tools and dependencies +RUN apt-get update && \ + apt-get install -y --force-yes --no-install-recommends \ + # make + build-essential \ + # add-apt-repository + software-properties-common \ + make \ + curl \ + wget \ + git \ + g++ \ + gcc \ + libc6 \ + libc6-dev \ + binutils \ + file \ + openssl \ + libssl-dev \ + libudev-dev \ + pkg-config \ + dpkg-dev \ + libudev-dev &&\ +# install rustup + curl https://sh.rustup.rs -sSf | sh -s -- -y && \ +# rustup directory + PATH=/root/.cargo/bin:$PATH && \ +# show backtraces + RUST_BACKTRACE=1 && \ +# build parity +cd /build&&git clone https://github.com/slockit/parity -b in3 && \ + cd parity && \ + git pull&& \ + cargo build --verbose --release --features final && \ + #ls /build/parity/target/release/parity && \ + strip /build/parity/target/release/parity && \ + file /build/parity/target/release/parity&&mkdir -p /parity&& cp /build/parity/target/release/parity /parity&&\ +#cleanup Docker image + rm -rf /root/.cargo&&rm -rf /root/.multirust&&rm -rf /root/.rustup&&rm -rf /build&&\ + apt-get purge -y \ + # make + build-essential \ + # add-apt-repository + software-properties-common \ + make \ + curl \ + wget \ + git \ + g++ \ + gcc \ + binutils \ + file \ + pkg-config \ + dpkg-dev &&\ + rm -rf /var/lib/apt/lists/* +# setup ENTRYPOINT +EXPOSE 8080 8545 8180 +ENTRYPOINT ["/parity/parity"] From 501cd20133cb176d8a88ab7b66e7104347f62553 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:43:10 +0200 Subject: [PATCH 59/98] fixed docker --- docker/slockit/Dockerfile | 65 --------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 docker/slockit/Dockerfile diff --git a/docker/slockit/Dockerfile b/docker/slockit/Dockerfile deleted file mode 100644 index b5f8178290a..00000000000 --- a/docker/slockit/Dockerfile +++ /dev/null @@ -1,65 +0,0 @@ -FROM ubuntu:14.04 -MAINTAINER Parity Technologies -WORKDIR /build -#ENV for build TAG -ARG BUILD_TAG -ENV BUILD_TAG ${BUILD_TAG:-master} -RUN echo "Build tag:" $BUILD_TAG -# install tools and dependencies -RUN apt-get update && \ - apt-get install -y --force-yes --no-install-recommends \ - # make - build-essential \ - # add-apt-repository - software-properties-common \ - make \ - curl \ - wget \ - git \ - g++ \ - gcc \ - libc6 \ - libc6-dev \ - binutils \ - file \ - openssl \ - libssl-dev \ - libudev-dev \ - pkg-config \ - dpkg-dev \ - libudev-dev &&\ -# install rustup - curl https://sh.rustup.rs -sSf | sh -s -- -y && \ -# rustup directory - PATH=/root/.cargo/bin:$PATH && \ -# show backtraces - RUST_BACKTRACE=1 && \ -# build parity -cd /build&&git clone https://github.com/slockit/parity -b in3 && \ - cd parity && \ - git pull&& \ - cargo build --verbose --release --features final && \ - #ls /build/parity/target/release/parity && \ - strip /build/parity/target/release/parity && \ - file /build/parity/target/release/parity&&mkdir -p /parity&& cp /build/parity/target/release/parity /parity&&\ -#cleanup Docker image - rm -rf /root/.cargo&&rm -rf /root/.multirust&&rm -rf /root/.rustup&&rm -rf /build&&\ - apt-get purge -y \ - # make - build-essential \ - # add-apt-repository - software-properties-common \ - make \ - curl \ - wget \ - git \ - g++ \ - gcc \ - binutils \ - file \ - pkg-config \ - dpkg-dev &&\ - rm -rf /var/lib/apt/lists/* -# setup ENTRYPOINT -EXPOSE 8080 8545 8180 -ENTRYPOINT ["/parity/parity"] From 2ec8ecbb68211dce9976640b4a780aaa06d2e43f Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 27 Mar 2018 18:35:39 +0200 Subject: [PATCH 60/98] added eth_getAccount --- ethcore/src/client/client.rs | 10 +++++++++- ethcore/src/client/test_client.rs | 21 +++++++++++++++----- ethcore/src/client/traits.rs | 9 ++++++++- ethcore/src/state/mod.rs | 33 ++++++++++++++++++++++++++----- rpc/src/v1/types/account_info.rs | 16 +++++++++++++++ 5 files changed, 77 insertions(+), 12 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 127f0f9eb5f..5f5f04be3b6 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -1324,7 +1324,15 @@ impl Balance for Client { } } -impl AccountData for Client {} +impl AccountData for Client { + fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { + match state { + StateOrBlock::State(s) => s.account(address).ok(), + StateOrBlock::Block(id) => self.state_at(id).and_then(|s| s.account(address).ok()), + } + } + +} impl ChainInfo for Client { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index c3d8c127b08..1f0ec876949 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -457,7 +457,16 @@ impl Balance for TestBlockChainClient { } } -impl AccountData for TestBlockChainClient {} +impl AccountData for TestBlockChainClient { + fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { + match state { + StateOrBlock::Block(BlockId::Latest) | StateOrBlock::State(_) => None, + _ => None, + } + } + + +} impl ChainInfo for TestBlockChainClient { fn chain_info(&self) -> BlockChainInfo { @@ -590,10 +599,12 @@ impl Call for TestBlockChainClient { } impl StateInfo for () { - fn nonce(&self, _address: &Address) -> ethtrie::Result { unimplemented!() } - fn balance(&self, _address: &Address) -> ethtrie::Result { unimplemented!() } - fn storage_at(&self, _address: &Address, _key: &H256) -> ethtrie::Result { unimplemented!() } - fn code(&self, _address: &Address) -> ethtrie::Result>> { unimplemented!() } + fn nonce(&self, _address: &Address) -> trie::Result { unimplemented!() } + fn balance(&self, _address: &Address) -> trie::Result { unimplemented!() } + fn storage_at(&self, _address: &Address, _key: &H256) -> trie::Result { unimplemented!() } + fn code(&self, _address: &Address) -> trie::Result>> { unimplemented!() } + fn account(&self, _address: &Address) -> trie::Result<(U256, U256, H256, H256)> { unimplemented!() } + } impl StateClient for TestBlockChainClient { diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index ebe70dcd82c..eb75f6eec51 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -110,7 +110,14 @@ pub trait Balance { } /// Provides methods to access account info -pub trait AccountData: Nonce + Balance {} +pub trait AccountData: Nonce + Balance { + /// Get address balance at the given block's state. + /// + /// May not return None if given BlockId::Latest. + /// Returns None if and only if the block's root hash has been pruned from the DB. + fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)>; + +} /// Provides `chain_info` method pub trait ChainInfo { diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index f34f1219daf..60da8f5c139 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -346,14 +346,20 @@ pub trait StateInfo { fn storage_at(&self, address: &Address, key: &H256) -> TrieResult; /// Get accounts' code. - fn code(&self, a: &Address) -> TrieResult>>; + fn code(&self, a: &Address) -> trie::Result>>; + + /// Get the account `a`. + fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)>; + + } impl StateInfo for State { - fn nonce(&self, a: &Address) -> TrieResult { State::nonce(self, a) } - fn balance(&self, a: &Address) -> TrieResult { State::balance(self, a) } - fn storage_at(&self, address: &Address, key: &H256) -> TrieResult { State::storage_at(self, address, key) } - fn code(&self, address: &Address) -> TrieResult>> { State::code(self, address) } + fn nonce(&self, a: &Address) -> trie::Result { State::nonce(self, a) } + fn balance(&self, a: &Address) -> trie::Result { State::balance(self, a) } + fn storage_at(&self, address: &Address, key: &H256) -> trie::Result { State::storage_at(self, address, key) } + fn code(&self, address: &Address) -> trie::Result>> { State::code(self, address) } + fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)> { State::account(self, a) } } const SEC_TRIE_DB_UNWRAP_STR: &'static str = "A state can only be created with valid root. Creating a SecTrieDB with a valid root will not fail. \ @@ -526,6 +532,23 @@ impl State { self.ensure_cached(a, RequireCache::CodeSize, false, |a| a.map_or(false, |a| a.code_hash() != KECCAK_EMPTY || *a.nonce() != self.account_start_nonce)) } + /// Get the balance of account `a`. + pub fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)> { + self.ensure_cached(a, RequireCache::None, true, |a| { + a.as_ref().map_or( + (U256::zero(), self.account_start_nonce, KECCAK_EMPTY, KECCAK_NULL_RLP), + |account| { + ( + *account.balance(), + *account.nonce(), + account.code_hash(), + *account.storage_root().unwrap_or(&H256::zero()), + ) + }, + ) + }) + } + /// Get the balance of account `a`. pub fn balance(&self, a: &Address) -> TrieResult { diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index 8f455cdd46d..3cf262682f7 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -53,6 +53,22 @@ pub struct EthAccount{ } +/// Account information. +#[derive(Debug, Default, Clone, PartialEq, Serialize)] +pub struct EthAccount{ + #[serde(rename="address")] + pub address: H160, + #[serde(rename="balance")] + pub balance: U256, + #[serde(rename="nonce")] + pub nonce: U256, + #[serde(rename="codeHash")] + pub code_hash: H256, + #[serde(rename="storageHash")] + pub storage_hash: H256, + +} + /// Extended account information (used by `parity_allAccountInfo`). #[derive(Debug, Default, Clone, PartialEq, Serialize)] pub struct ExtAccountInfo { From 0297c277377dadd2f447bf725543a9a9d830bde4 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Mar 2018 09:06:37 +0200 Subject: [PATCH 61/98] changed to getProof --- ethcore/src/client/client.rs | 10 +--------- ethcore/src/client/test_client.rs | 13 +------------ ethcore/src/client/traits.rs | 9 +-------- ethcore/src/state/mod.rs | 23 ----------------------- rpc/src/v1/impls/eth.rs | 1 - rpc/src/v1/types/account_info.rs | 4 ++++ 6 files changed, 7 insertions(+), 53 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 5f5f04be3b6..127f0f9eb5f 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -1324,15 +1324,7 @@ impl Balance for Client { } } -impl AccountData for Client { - fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { - match state { - StateOrBlock::State(s) => s.account(address).ok(), - StateOrBlock::Block(id) => self.state_at(id).and_then(|s| s.account(address).ok()), - } - } - -} +impl AccountData for Client {} impl ChainInfo for Client { fn chain_info(&self) -> BlockChainInfo { diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index 1f0ec876949..19df97c4882 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -457,16 +457,7 @@ impl Balance for TestBlockChainClient { } } -impl AccountData for TestBlockChainClient { - fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)> { - match state { - StateOrBlock::Block(BlockId::Latest) | StateOrBlock::State(_) => None, - _ => None, - } - } - - -} +impl AccountData for TestBlockChainClient {} impl ChainInfo for TestBlockChainClient { fn chain_info(&self) -> BlockChainInfo { @@ -603,8 +594,6 @@ impl StateInfo for () { fn balance(&self, _address: &Address) -> trie::Result { unimplemented!() } fn storage_at(&self, _address: &Address, _key: &H256) -> trie::Result { unimplemented!() } fn code(&self, _address: &Address) -> trie::Result>> { unimplemented!() } - fn account(&self, _address: &Address) -> trie::Result<(U256, U256, H256, H256)> { unimplemented!() } - } impl StateClient for TestBlockChainClient { diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index eb75f6eec51..ebe70dcd82c 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -110,14 +110,7 @@ pub trait Balance { } /// Provides methods to access account info -pub trait AccountData: Nonce + Balance { - /// Get address balance at the given block's state. - /// - /// May not return None if given BlockId::Latest. - /// Returns None if and only if the block's root hash has been pruned from the DB. - fn account(&self, address: &Address, state: StateOrBlock) -> Option<(U256, U256, H256, H256)>; - -} +pub trait AccountData: Nonce + Balance {} /// Provides `chain_info` method pub trait ChainInfo { diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index 60da8f5c139..df4ac87cbf3 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -347,11 +347,6 @@ pub trait StateInfo { /// Get accounts' code. fn code(&self, a: &Address) -> trie::Result>>; - - /// Get the account `a`. - fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)>; - - } impl StateInfo for State { @@ -359,7 +354,6 @@ impl StateInfo for State { fn balance(&self, a: &Address) -> trie::Result { State::balance(self, a) } fn storage_at(&self, address: &Address, key: &H256) -> trie::Result { State::storage_at(self, address, key) } fn code(&self, address: &Address) -> trie::Result>> { State::code(self, address) } - fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)> { State::account(self, a) } } const SEC_TRIE_DB_UNWRAP_STR: &'static str = "A state can only be created with valid root. Creating a SecTrieDB with a valid root will not fail. \ @@ -532,23 +526,6 @@ impl State { self.ensure_cached(a, RequireCache::CodeSize, false, |a| a.map_or(false, |a| a.code_hash() != KECCAK_EMPTY || *a.nonce() != self.account_start_nonce)) } - /// Get the balance of account `a`. - pub fn account(&self, a: &Address) -> trie::Result<(U256, U256, H256, H256)> { - self.ensure_cached(a, RequireCache::None, true, |a| { - a.as_ref().map_or( - (U256::zero(), self.account_start_nonce, KECCAK_EMPTY, KECCAK_NULL_RLP), - |account| { - ( - *account.balance(), - *account.nonce(), - account.code_hash(), - *account.storage_root().unwrap_or(&H256::zero()), - ) - }, - ) - }) - } - /// Get the balance of account `a`. pub fn balance(&self, a: &Address) -> TrieResult { diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 83ec8920f53..3b086b12f5f 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -590,7 +590,6 @@ impl Eth for EthClient< }), None => Err(errors::state_pruned()), }; - Box::new(future::done(res)) } diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index 3cf262682f7..3e532e470be 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -66,6 +66,10 @@ pub struct EthAccount{ pub code_hash: H256, #[serde(rename="storageHash")] pub storage_hash: H256, + #[serde(rename="accountProof")] + pub account_proof: Option>, + #[serde(rename="storageProof")] + pub storage_proof: Option)>>, } From 61a27f3fa13a7938698573d8d2352c0568a7e7f3 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Mar 2018 19:40:20 +0200 Subject: [PATCH 62/98] implemented storage_proof --- ethcore/src/state/account.rs | 2 +- rpc/src/v1/impls/eth.rs | 1 + rpc/src/v1/types/account_info.rs | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ethcore/src/state/account.rs b/ethcore/src/state/account.rs index 160152fc70b..1a53d5e4cd6 100644 --- a/ethcore/src/state/account.rs +++ b/ethcore/src/state/account.rs @@ -581,7 +581,7 @@ impl Account { /// this will only work correctly under a secure trie. pub fn prove_storage(&self, db: &HashDB, storage_key: H256) -> TrieResult<(Vec, H256)> { let mut recorder = Recorder::new(); - + let trie = TrieDB::new(db, &self.storage_root)?; let item: U256 = { let panicky_decoder = |bytes:&[u8]| ::rlp::decode(bytes).expect("decoding db value failed"); diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 3b086b12f5f..83ec8920f53 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -590,6 +590,7 @@ impl Eth for EthClient< }), None => Err(errors::state_pruned()), }; + Box::new(future::done(res)) } diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index 3e532e470be..ad90ff717d0 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -69,7 +69,7 @@ pub struct EthAccount{ #[serde(rename="accountProof")] pub account_proof: Option>, #[serde(rename="storageProof")] - pub storage_proof: Option)>>, + pub storage_proof: Option)>>, } From 2ae1e3058a14cc07296d8f63b78c3f395b4bb762 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Mar 2018 20:00:37 +0200 Subject: [PATCH 63/98] better formatting of storage proof --- rpc/src/v1/types/account_info.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index ad90ff717d0..cdc2c82ae67 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -69,7 +69,7 @@ pub struct EthAccount{ #[serde(rename="accountProof")] pub account_proof: Option>, #[serde(rename="storageProof")] - pub storage_proof: Option)>>, + pub storage_proof: Option>, } From 232558ba7c25a110c6e5ff1384df5885cdebd679 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 19 Jun 2018 09:37:51 +0200 Subject: [PATCH 64/98] fixed docker --- docker/hub/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index 3ffdf290eb5..694783d10f3 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -51,7 +51,6 @@ RUN apt-get update && \ cd /build&&git clone https://github.com/slockit/parity && \ cd parity && \ git pull&& \ - git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From 76ecd30ad9fb4a2f77994e85ac725bc96935a046 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:27:07 +0200 Subject: [PATCH 65/98] removed slockit-changes --- docker/hub/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index 694783d10f3..08d0747ef27 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -50,7 +50,7 @@ RUN apt-get update && \ # build parity cd /build&&git clone https://github.com/slockit/parity && \ cd parity && \ - git pull&& \ +git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From 8101a00000d9a42fa5f016a421c9aea4db634588 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:29:09 +0200 Subject: [PATCH 66/98] fixed Dockerfile --- docker/hub/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index 08d0747ef27..dd6c4934644 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -50,7 +50,8 @@ RUN apt-get update && \ # build parity cd /build&&git clone https://github.com/slockit/parity && \ cd parity && \ -git checkout $BUILD_TAG && \ + git pull&& \ + git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From 529efe9b58b76532c9223966122d0701676875fd Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:29:52 +0200 Subject: [PATCH 67/98] intend --- docker/hub/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index dd6c4934644..414ade56a04 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -50,8 +50,8 @@ RUN apt-get update && \ # build parity cd /build&&git clone https://github.com/slockit/parity && \ cd parity && \ - git pull&& \ - git checkout $BUILD_TAG && \ + git pull&& \ + git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From 940690b2cbc8a26cb5609fe65e68fe52422d39d4 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:30:31 +0200 Subject: [PATCH 68/98] spaces --- docker/hub/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index 414ade56a04..15391c36b2c 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -50,8 +50,8 @@ RUN apt-get update && \ # build parity cd /build&&git clone https://github.com/slockit/parity && \ cd parity && \ - git pull&& \ - git checkout $BUILD_TAG && \ + git pull&& \ + git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From 6cc90849652226cfa8b611242c54e3e2ca7131ce Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:31:42 +0200 Subject: [PATCH 69/98] removed spaces --- ethcore/src/state/account.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethcore/src/state/account.rs b/ethcore/src/state/account.rs index 1a53d5e4cd6..160152fc70b 100644 --- a/ethcore/src/state/account.rs +++ b/ethcore/src/state/account.rs @@ -581,7 +581,7 @@ impl Account { /// this will only work correctly under a secure trie. pub fn prove_storage(&self, db: &HashDB, storage_key: H256) -> TrieResult<(Vec, H256)> { let mut recorder = Recorder::new(); - + let trie = TrieDB::new(db, &self.storage_root)?; let item: U256 = { let panicky_decoder = |bytes:&[u8]| ::rlp::decode(bytes).expect("decoding db value failed"); From e33d262492d5ca6acddc1c6aa83f25e04caa65bf Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:37:25 +0200 Subject: [PATCH 70/98] fixed whitespace --- docker/slockit/Dockerfile | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 docker/slockit/Dockerfile diff --git a/docker/slockit/Dockerfile b/docker/slockit/Dockerfile new file mode 100644 index 00000000000..b5f8178290a --- /dev/null +++ b/docker/slockit/Dockerfile @@ -0,0 +1,65 @@ +FROM ubuntu:14.04 +MAINTAINER Parity Technologies +WORKDIR /build +#ENV for build TAG +ARG BUILD_TAG +ENV BUILD_TAG ${BUILD_TAG:-master} +RUN echo "Build tag:" $BUILD_TAG +# install tools and dependencies +RUN apt-get update && \ + apt-get install -y --force-yes --no-install-recommends \ + # make + build-essential \ + # add-apt-repository + software-properties-common \ + make \ + curl \ + wget \ + git \ + g++ \ + gcc \ + libc6 \ + libc6-dev \ + binutils \ + file \ + openssl \ + libssl-dev \ + libudev-dev \ + pkg-config \ + dpkg-dev \ + libudev-dev &&\ +# install rustup + curl https://sh.rustup.rs -sSf | sh -s -- -y && \ +# rustup directory + PATH=/root/.cargo/bin:$PATH && \ +# show backtraces + RUST_BACKTRACE=1 && \ +# build parity +cd /build&&git clone https://github.com/slockit/parity -b in3 && \ + cd parity && \ + git pull&& \ + cargo build --verbose --release --features final && \ + #ls /build/parity/target/release/parity && \ + strip /build/parity/target/release/parity && \ + file /build/parity/target/release/parity&&mkdir -p /parity&& cp /build/parity/target/release/parity /parity&&\ +#cleanup Docker image + rm -rf /root/.cargo&&rm -rf /root/.multirust&&rm -rf /root/.rustup&&rm -rf /build&&\ + apt-get purge -y \ + # make + build-essential \ + # add-apt-repository + software-properties-common \ + make \ + curl \ + wget \ + git \ + g++ \ + gcc \ + binutils \ + file \ + pkg-config \ + dpkg-dev &&\ + rm -rf /var/lib/apt/lists/* +# setup ENTRYPOINT +EXPOSE 8080 8545 8180 +ENTRYPOINT ["/parity/parity"] From 96491901e88267a45425c3e6e2c9dd3ab7071e15 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:43:10 +0200 Subject: [PATCH 71/98] fixed docker --- docker/slockit/Dockerfile | 65 --------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 docker/slockit/Dockerfile diff --git a/docker/slockit/Dockerfile b/docker/slockit/Dockerfile deleted file mode 100644 index b5f8178290a..00000000000 --- a/docker/slockit/Dockerfile +++ /dev/null @@ -1,65 +0,0 @@ -FROM ubuntu:14.04 -MAINTAINER Parity Technologies -WORKDIR /build -#ENV for build TAG -ARG BUILD_TAG -ENV BUILD_TAG ${BUILD_TAG:-master} -RUN echo "Build tag:" $BUILD_TAG -# install tools and dependencies -RUN apt-get update && \ - apt-get install -y --force-yes --no-install-recommends \ - # make - build-essential \ - # add-apt-repository - software-properties-common \ - make \ - curl \ - wget \ - git \ - g++ \ - gcc \ - libc6 \ - libc6-dev \ - binutils \ - file \ - openssl \ - libssl-dev \ - libudev-dev \ - pkg-config \ - dpkg-dev \ - libudev-dev &&\ -# install rustup - curl https://sh.rustup.rs -sSf | sh -s -- -y && \ -# rustup directory - PATH=/root/.cargo/bin:$PATH && \ -# show backtraces - RUST_BACKTRACE=1 && \ -# build parity -cd /build&&git clone https://github.com/slockit/parity -b in3 && \ - cd parity && \ - git pull&& \ - cargo build --verbose --release --features final && \ - #ls /build/parity/target/release/parity && \ - strip /build/parity/target/release/parity && \ - file /build/parity/target/release/parity&&mkdir -p /parity&& cp /build/parity/target/release/parity /parity&&\ -#cleanup Docker image - rm -rf /root/.cargo&&rm -rf /root/.multirust&&rm -rf /root/.rustup&&rm -rf /build&&\ - apt-get purge -y \ - # make - build-essential \ - # add-apt-repository - software-properties-common \ - make \ - curl \ - wget \ - git \ - g++ \ - gcc \ - binutils \ - file \ - pkg-config \ - dpkg-dev &&\ - rm -rf /var/lib/apt/lists/* -# setup ENTRYPOINT -EXPOSE 8080 8545 8180 -ENTRYPOINT ["/parity/parity"] From 412ff56dbb2438ef0286fe104d0cd85d0c95653c Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 29 Jun 2018 11:44:12 +0200 Subject: [PATCH 72/98] tabs --- docker/hub/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile index 15391c36b2c..3ffdf290eb5 100644 --- a/docker/hub/Dockerfile +++ b/docker/hub/Dockerfile @@ -50,8 +50,8 @@ RUN apt-get update && \ # build parity cd /build&&git clone https://github.com/slockit/parity && \ cd parity && \ - git pull&& \ - git checkout $BUILD_TAG && \ + git pull&& \ + git checkout $BUILD_TAG && \ cargo build --verbose --release --features final && \ #ls /build/parity/target/release/parity && \ strip /build/parity/target/release/parity && \ From 76f5618fa1552a329246a45d5c14dd4a9354d792 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 18 Oct 2018 17:24:33 +0200 Subject: [PATCH 73/98] merged changes --- docker/hub/Dockerfile | 83 ------------------------------- ethcore/src/client/test_client.rs | 8 +-- ethcore/src/state/mod.rs | 10 ++-- 3 files changed, 9 insertions(+), 92 deletions(-) delete mode 100644 docker/hub/Dockerfile diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile deleted file mode 100644 index 3ffdf290eb5..00000000000 --- a/docker/hub/Dockerfile +++ /dev/null @@ -1,83 +0,0 @@ -FROM ubuntu:14.04 -MAINTAINER Parity Technologies -WORKDIR /build -#ENV for build TAG -ARG BUILD_TAG -ENV BUILD_TAG ${BUILD_TAG:-master} -RUN echo "Build tag:" $BUILD_TAG -# install tools and dependencies -RUN apt-get update && \ - apt-get install -y --force-yes --no-install-recommends \ - # make - build-essential \ - # add-apt-repository - software-properties-common \ - make \ - curl \ - wget \ - git \ - g++ \ - gcc \ - libc6 \ - libc6-dev \ - binutils \ - file \ - openssl \ - libssl-dev \ - libudev-dev \ - pkg-config \ - dpkg-dev \ - # evmjit dependencies - zlib1g-dev \ - libedit-dev \ - libudev-dev &&\ -# cmake and llvm ppa's. then update ppa's - add-apt-repository -y "ppa:george-edison55/cmake-3.x" && \ - add-apt-repository "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.7 main" && \ - apt-get update && \ - apt-get install -y --force-yes cmake llvm-3.7-dev && \ -# install evmjit - git clone https://github.com/debris/evmjit && \ - cd evmjit && \ - mkdir build && cd build && \ - cmake .. && make && make install && cd && \ -# install rustup - curl https://sh.rustup.rs -sSf | sh -s -- -y && \ -# rustup directory - PATH=/root/.cargo/bin:$PATH && \ -# show backtraces - RUST_BACKTRACE=1 && \ -# build parity -cd /build&&git clone https://github.com/slockit/parity && \ - cd parity && \ - git pull&& \ - git checkout $BUILD_TAG && \ - cargo build --verbose --release --features final && \ - #ls /build/parity/target/release/parity && \ - strip /build/parity/target/release/parity && \ - file /build/parity/target/release/parity&&mkdir -p /parity&& cp /build/parity/target/release/parity /parity&&\ -#cleanup Docker image - rm -rf /root/.cargo&&rm -rf /root/.multirust&&rm -rf /root/.rustup&&rm -rf /build&&\ - apt-get purge -y \ - # make - build-essential \ - # add-apt-repository - software-properties-common \ - make \ - curl \ - wget \ - git \ - g++ \ - gcc \ - binutils \ - file \ - pkg-config \ - dpkg-dev \ - # evmjit dependencies - zlib1g-dev \ - libedit-dev \ - cmake llvm-3.7-dev&&\ - rm -rf /var/lib/apt/lists/* -# setup ENTRYPOINT -EXPOSE 8080 8545 8180 -ENTRYPOINT ["/parity/parity"] diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index 19df97c4882..c3d8c127b08 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -590,10 +590,10 @@ impl Call for TestBlockChainClient { } impl StateInfo for () { - fn nonce(&self, _address: &Address) -> trie::Result { unimplemented!() } - fn balance(&self, _address: &Address) -> trie::Result { unimplemented!() } - fn storage_at(&self, _address: &Address, _key: &H256) -> trie::Result { unimplemented!() } - fn code(&self, _address: &Address) -> trie::Result>> { unimplemented!() } + fn nonce(&self, _address: &Address) -> ethtrie::Result { unimplemented!() } + fn balance(&self, _address: &Address) -> ethtrie::Result { unimplemented!() } + fn storage_at(&self, _address: &Address, _key: &H256) -> ethtrie::Result { unimplemented!() } + fn code(&self, _address: &Address) -> ethtrie::Result>> { unimplemented!() } } impl StateClient for TestBlockChainClient { diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index df4ac87cbf3..f34f1219daf 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -346,14 +346,14 @@ pub trait StateInfo { fn storage_at(&self, address: &Address, key: &H256) -> TrieResult; /// Get accounts' code. - fn code(&self, a: &Address) -> trie::Result>>; + fn code(&self, a: &Address) -> TrieResult>>; } impl StateInfo for State { - fn nonce(&self, a: &Address) -> trie::Result { State::nonce(self, a) } - fn balance(&self, a: &Address) -> trie::Result { State::balance(self, a) } - fn storage_at(&self, address: &Address, key: &H256) -> trie::Result { State::storage_at(self, address, key) } - fn code(&self, address: &Address) -> trie::Result>> { State::code(self, address) } + fn nonce(&self, a: &Address) -> TrieResult { State::nonce(self, a) } + fn balance(&self, a: &Address) -> TrieResult { State::balance(self, a) } + fn storage_at(&self, address: &Address, key: &H256) -> TrieResult { State::storage_at(self, address, key) } + fn code(&self, address: &Address) -> TrieResult>> { State::code(self, address) } } const SEC_TRIE_DB_UNWRAP_STR: &'static str = "A state can only be created with valid root. Creating a SecTrieDB with a valid root will not fail. \ From ddbc0cdd5a01a9da4842eb68982c308130409b8f Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 18 Oct 2018 20:27:45 +0200 Subject: [PATCH 74/98] fixed merge error --- rpc/src/v1/types/account_info.rs | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index cdc2c82ae67..e5d90abd605 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -32,27 +32,6 @@ pub struct StorageProof{ pub proof: Vec } -/// Account information. -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct EthAccount{ - #[serde(rename="address")] - pub address: H160, - #[serde(rename="balance")] - pub balance: U256, - #[serde(rename="nonce")] - pub nonce: U256, - #[serde(rename="codeHash")] - pub code_hash: H256, - #[serde(rename="storageHash")] - pub storage_hash: H256, - #[serde(rename="accountProof")] - pub account_proof: Option>, - #[serde(rename="storageProof")] - pub storage_proof: Option>, - -} - - /// Account information. #[derive(Debug, Default, Clone, PartialEq, Serialize)] pub struct EthAccount{ From 4c3d31809ba2c3dd1a97a920139c32f0d6a43720 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Sun, 28 Oct 2018 07:01:06 +0100 Subject: [PATCH 75/98] fixed formatting --- rpc/src/v1/impls/eth.rs | 14 +++++++------- rpc/src/v1/impls/light/eth.rs | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 83ec8920f53..1c797551dec 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -546,8 +546,8 @@ impl Eth for EthClient< Box::new(future::done(res)) } - fn proof(&self, _address: RpcH160, values:Vec, num: Trailing) -> BoxFuture { - let a : H160 = _address.clone().into(); + fn proof(&self, address: RpcH160, values: Vec, num: Trailing) -> BoxFuture { + let a: H160 = address.clone().into(); let key1 = keccak(a); let num = num.unwrap_or_default(); @@ -564,14 +564,13 @@ impl Eth for EthClient< try_bf!(check_known(&*self.client, num.clone())); let res = match self.client.prove_account(key1, id) { Some(p) => Ok(EthAccount { - address : _address.into(), + address : address.into(), balance : p.1.balance.into(), nonce : p.1.nonce.into(), code_hash : p.1.code_hash.into(), storage_hash : p.1.storage_root.into(), - account_proof: Some(p.0.iter().map(|b| Bytes::new(b.clone())).collect::>()), - storage_proof: Some( - values.iter().map(|storage_index| { + account_proof: Some( p.0.iter().map(|b| Bytes::new(b.clone())).collect::>()), + storage_proof: Some( values.iter().map(|storage_index| { let key2 : H256 = storage_index.clone().into(); match self.client.prove_storage(key1, keccak(key2), id) { Some(sp) => StorageProof { @@ -585,7 +584,8 @@ impl Eth for EthClient< proof : Vec::new() } } - }).collect::>() + }) + .collect::>() ) }), None => Err(errors::state_pruned()), diff --git a/rpc/src/v1/impls/light/eth.rs b/rpc/src/v1/impls/light/eth.rs index 942c2d455fb..0eaae344cbe 100644 --- a/rpc/src/v1/impls/light/eth.rs +++ b/rpc/src/v1/impls/light/eth.rs @@ -47,7 +47,7 @@ use v1::helpers::light_fetch::{self, LightFetch}; use v1::traits::Eth; use v1::types::{ RichBlock, Block, BlockTransactions, BlockNumber, LightBlockNumber, Bytes, SyncStatus, SyncInfo, - Transaction, CallRequest, Index, Filter, Log, Receipt, Work,EthAccount, + Transaction, CallRequest, Index, Filter, Log, Receipt, Work, EthAccount, H64 as RpcH64, H256 as RpcH256, H160 as RpcH160, U256 as RpcU256, }; use v1::metadata::Metadata; From 16abb5ecfcd72eaa5c3fe15e0197037f68f1e9b0 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 5 Nov 2018 16:55:06 +0100 Subject: [PATCH 76/98] fixed rename_all = "camelCase" --- rpc/src/v1/types/account_info.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index e5d90abd605..8cb975669f1 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -23,33 +23,24 @@ pub struct AccountInfo { } /// Datastructure with proof for one single storage-entry #[derive(Debug, Default, Clone, PartialEq, Serialize)] +#[serde(rename_all = "camelCase")] pub struct StorageProof{ - #[serde(rename="key")] pub key: U256, - #[serde(rename="value")] pub value: U256, - #[serde(rename="proof")] pub proof: Vec } /// Account information. #[derive(Debug, Default, Clone, PartialEq, Serialize)] +#[serde(rename_all = "camelCase")] pub struct EthAccount{ - #[serde(rename="address")] pub address: H160, - #[serde(rename="balance")] pub balance: U256, - #[serde(rename="nonce")] pub nonce: U256, - #[serde(rename="codeHash")] pub code_hash: H256, - #[serde(rename="storageHash")] pub storage_hash: H256, - #[serde(rename="accountProof")] pub account_proof: Option>, - #[serde(rename="storageProof")] pub storage_proof: Option>, - } /// Extended account information (used by `parity_allAccountInfo`). From 1e4216aad43d78049656a093d6d44f00979346e2 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 5 Nov 2018 16:59:38 +0100 Subject: [PATCH 77/98] fixed tabs --- rpc/src/v1/impls/eth.rs | 46 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 1c797551dec..adffbdb3fed 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -564,29 +564,29 @@ impl Eth for EthClient< try_bf!(check_known(&*self.client, num.clone())); let res = match self.client.prove_account(key1, id) { Some(p) => Ok(EthAccount { - address : address.into(), - balance : p.1.balance.into(), - nonce : p.1.nonce.into(), - code_hash : p.1.code_hash.into(), - storage_hash : p.1.storage_root.into(), - account_proof: Some( p.0.iter().map(|b| Bytes::new(b.clone())).collect::>()), - storage_proof: Some( values.iter().map(|storage_index| { - let key2 : H256 = storage_index.clone().into(); - match self.client.prove_storage(key1, keccak(key2), id) { - Some(sp) => StorageProof { - key : key2.into(), - value: sp.1.into(), - proof: sp.0.iter().map(|b| Bytes::new(b.clone())).collect::>() - }, - None => StorageProof { - key : key2.into(), - value : 0.into(), - proof : Vec::new() - } - } - }) - .collect::>() - ) + address : address.into(), + balance : p.1.balance.into(), + nonce : p.1.nonce.into(), + code_hash : p.1.code_hash.into(), + storage_hash : p.1.storage_root.into(), + account_proof: Some( p.0.iter().map(|b| Bytes::new(b.clone())).collect::>()), + storage_proof: Some( values.iter().map(|storage_index| { + let key2 : H256 = storage_index.clone().into(); + match self.client.prove_storage(key1, keccak(key2), id) { + Some(sp) => StorageProof { + key : key2.into(), + value: sp.1.into(), + proof: sp.0.iter().map(|b| Bytes::new(b.clone())).collect::>() + }, + None => StorageProof { + key : key2.into(), + value : 0.into(), + proof : Vec::new() + } + } + }) + .collect::>() + ) }), None => Err(errors::state_pruned()), }; From d3a2497c3e5d788fc508236cb3443dba56027136 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 5 Nov 2018 17:01:12 +0100 Subject: [PATCH 78/98] fixed spaces --- rpc/src/v1/types/account_info.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index 8cb975669f1..6875577e222 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -24,7 +24,7 @@ pub struct AccountInfo { /// Datastructure with proof for one single storage-entry #[derive(Debug, Default, Clone, PartialEq, Serialize)] #[serde(rename_all = "camelCase")] -pub struct StorageProof{ +pub struct StorageProof { pub key: U256, pub value: U256, pub proof: Vec @@ -33,7 +33,7 @@ pub struct StorageProof{ /// Account information. #[derive(Debug, Default, Clone, PartialEq, Serialize)] #[serde(rename_all = "camelCase")] -pub struct EthAccount{ +pub struct EthAccount { pub address: H160, pub balance: U256, pub nonce: U256, From df7a9ff510b75d06855da016cfd574f91805e0da Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 5 Nov 2018 17:57:07 +0100 Subject: [PATCH 79/98] removed port exposer --- scripts/docker/alpine/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/docker/alpine/Dockerfile b/scripts/docker/alpine/Dockerfile index 1af07ebdeaa..47b37372ebf 100644 --- a/scripts/docker/alpine/Dockerfile +++ b/scripts/docker/alpine/Dockerfile @@ -33,7 +33,7 @@ RUN addgroup -g 1000 parity \ USER parity -EXPOSE 5001 8080 8082 8083 8545 8546 8180 30303/tcp 30303/udp +EXPOSE 8080 8545 8180 WORKDIR /home/parity From 468f82f440dcd29cc3a08cbc5c88e66cad191631 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 5 Nov 2018 18:03:23 +0100 Subject: [PATCH 80/98] formatting --- rpc/src/v1/types/account_info.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index 6875577e222..d47d8288f17 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -21,6 +21,7 @@ pub struct AccountInfo { /// Account name pub name: String, } + /// Datastructure with proof for one single storage-entry #[derive(Debug, Default, Clone, PartialEq, Serialize)] #[serde(rename_all = "camelCase")] From 8edb13b535ea51121da6390a5dc2894f3339c02a Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 5 Nov 2018 18:05:09 +0100 Subject: [PATCH 81/98] fixed comment --- rpc/src/v1/traits/eth.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/src/v1/traits/eth.rs b/rpc/src/v1/traits/eth.rs index 2378d119990..fd73ddcbeed 100644 --- a/rpc/src/v1/traits/eth.rs +++ b/rpc/src/v1/traits/eth.rs @@ -63,7 +63,7 @@ build_rpc_trait! { #[rpc(name = "eth_getBalance")] fn balance(&self, H160, Trailing) -> BoxFuture; - /// Returns balance of the given account. + /// Returns the account- and storage-values of the specified account including the Merkle-proof #[rpc(name = "eth_getProof")] fn proof(&self, H160, Vec, Trailing) -> BoxFuture; From 85860f75be7039dd206b2d3628413cd8496d1aca Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 5 Nov 2018 19:10:35 +0100 Subject: [PATCH 82/98] use filter_map --- rpc/src/v1/impls/eth.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index adffbdb3fed..30fe892656f 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -570,19 +570,15 @@ impl Eth for EthClient< code_hash : p.1.code_hash.into(), storage_hash : p.1.storage_root.into(), account_proof: Some( p.0.iter().map(|b| Bytes::new(b.clone())).collect::>()), - storage_proof: Some( values.iter().map(|storage_index| { + storage_proof: Some( values.iter().filter_map(|storage_index| { let key2 : H256 = storage_index.clone().into(); match self.client.prove_storage(key1, keccak(key2), id) { - Some(sp) => StorageProof { + Some(sp) => Some(StorageProof { key : key2.into(), value: sp.1.into(), proof: sp.0.iter().map(|b| Bytes::new(b.clone())).collect::>() - }, - None => StorageProof { - key : key2.into(), - value : 0.into(), - proof : Vec::new() - } + }), + None => None } }) .collect::>() From b9885482ce86cbcbdb0a585cbc299269cab984e6 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 5 Nov 2018 19:12:08 +0100 Subject: [PATCH 83/98] formatting --- rpc/src/v1/types/account_info.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index d47d8288f17..6239d165f74 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -use v1::types::{ H160, H256, U256, Bytes}; +use v1::types::{H160, H256, U256, Bytes}; /// Account information. #[derive(Debug, Default, Clone, PartialEq, Serialize)] From 8662f39197c88a2328d710eb7ffdf2c955b33a8f Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 5 Nov 2018 19:22:46 +0100 Subject: [PATCH 84/98] use better variable names --- rpc/src/v1/impls/eth.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 30fe892656f..e718e247781 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -563,20 +563,20 @@ impl Eth for EthClient< try_bf!(check_known(&*self.client, num.clone())); let res = match self.client.prove_account(key1, id) { - Some(p) => Ok(EthAccount { + Some((proof,account)) => Ok(EthAccount { address : address.into(), - balance : p.1.balance.into(), - nonce : p.1.nonce.into(), - code_hash : p.1.code_hash.into(), - storage_hash : p.1.storage_root.into(), - account_proof: Some( p.0.iter().map(|b| Bytes::new(b.clone())).collect::>()), + balance : account.balance.into(), + nonce : account.nonce.into(), + code_hash : account.code_hash.into(), + storage_hash : account.storage_root.into(), + account_proof: Some( proof.iter().map(|b| Bytes::new(b.clone())).collect::>()), storage_proof: Some( values.iter().filter_map(|storage_index| { let key2 : H256 = storage_index.clone().into(); match self.client.prove_storage(key1, keccak(key2), id) { - Some(sp) => Some(StorageProof { + Some((storage_proof,storage_value)) => Some(StorageProof { key : key2.into(), - value: sp.1.into(), - proof: sp.0.iter().map(|b| Bytes::new(b.clone())).collect::>() + value: storage_value.into(), + proof: storage_proof.iter().map(|b| Bytes::new(b.clone())).collect::>() }), None => None } From c35cfbf8279a972c57853e042b239fdef6b871f4 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 6 Nov 2018 06:57:13 +0100 Subject: [PATCH 85/98] changed casting --- rpc/src/v1/impls/eth.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index e718e247781..169abccb5b0 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -569,14 +569,14 @@ impl Eth for EthClient< nonce : account.nonce.into(), code_hash : account.code_hash.into(), storage_hash : account.storage_root.into(), - account_proof: Some( proof.iter().map(|b| Bytes::new(b.clone())).collect::>()), - storage_proof: Some( values.iter().filter_map(|storage_index| { + account_proof: Some(proof.into_iter().map(Bytes::new).collect()), + storage_proof: Some(values.iter().filter_map(|storage_index| { let key2 : H256 = storage_index.clone().into(); match self.client.prove_storage(key1, keccak(key2), id) { Some((storage_proof,storage_value)) => Some(StorageProof { key : key2.into(), value: storage_value.into(), - proof: storage_proof.iter().map(|b| Bytes::new(b.clone())).collect::>() + proof: storage_proof.into_iter().map(Bytes::new).collect() }), None => None } From b3dd659a9381bda39f1de98b05a86daad2526238 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 6 Nov 2018 06:58:23 +0100 Subject: [PATCH 86/98] fixed tabs --- rpc/src/v1/impls/eth.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 169abccb5b0..71a2570b58f 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -453,7 +453,7 @@ fn check_known(client: &C, number: BlockNumber) -> Result<()> where C: BlockC const MAX_QUEUE_SIZE_TO_MINE_ON: usize = 4; // because uncles go back 6. impl Eth for EthClient where - C: miner::BlockChainClient + StateClient + ProvingBlockChainClient + Call + EngineInfo + 'static, + C: miner::BlockChainClient + StateClient + ProvingBlockChainClient + Call + EngineInfo + 'static, SN: SnapshotService + 'static, S: SyncProvider + 'static, M: MinerService + 'static, From e766cb1fe1483d5f1b98e971790992b6420bbe76 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 6 Nov 2018 07:01:12 +0100 Subject: [PATCH 87/98] remote into() from address --- rpc/src/v1/impls/eth.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 71a2570b58f..c0346351085 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -564,7 +564,7 @@ impl Eth for EthClient< try_bf!(check_known(&*self.client, num.clone())); let res = match self.client.prove_account(key1, id) { Some((proof,account)) => Ok(EthAccount { - address : address.into(), + address : address, balance : account.balance.into(), nonce : account.nonce.into(), code_hash : account.code_hash.into(), From 179bb7854d06ac92c3daabb91a91ca4553268dda Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Tue, 6 Nov 2018 07:01:25 +0100 Subject: [PATCH 88/98] remove space Co-Authored-By: simon-jentzsch --- rpc/src/v1/impls/eth.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index c0346351085..c82f730cab3 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -565,7 +565,7 @@ impl Eth for EthClient< let res = match self.client.prove_account(key1, id) { Some((proof,account)) => Ok(EthAccount { address : address, - balance : account.balance.into(), + balance: account.balance.into(), nonce : account.nonce.into(), code_hash : account.code_hash.into(), storage_hash : account.storage_root.into(), From 70c48a97e7e9e67874f8939141ebb492e9dfc825 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Tue, 6 Nov 2018 07:02:42 +0100 Subject: [PATCH 89/98] fixed storage_index Co-Authored-By: simon-jentzsch --- rpc/src/v1/impls/eth.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index c82f730cab3..31cc02a70b4 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -571,7 +571,7 @@ impl Eth for EthClient< storage_hash : account.storage_root.into(), account_proof: Some(proof.into_iter().map(Bytes::new).collect()), storage_proof: Some(values.iter().filter_map(|storage_index| { - let key2 : H256 = storage_index.clone().into(); + let key2: H256 = storage_index.into(); match self.client.prove_storage(key1, keccak(key2), id) { Some((storage_proof,storage_value)) => Some(StorageProof { key : key2.into(), From 3a9c3d88dcd1ef6d91eb8b840aee6de5e071e7c7 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 6 Nov 2018 07:05:03 +0100 Subject: [PATCH 90/98] fixed clone --- rpc/src/v1/impls/eth.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 31cc02a70b4..4f594329ad1 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -571,7 +571,7 @@ impl Eth for EthClient< storage_hash : account.storage_root.into(), account_proof: Some(proof.into_iter().map(Bytes::new).collect()), storage_proof: Some(values.iter().filter_map(|storage_index| { - let key2: H256 = storage_index.into(); + let key2: H256 = storage_index.clone().into(); match self.client.prove_storage(key1, keccak(key2), id) { Some((storage_proof,storage_value)) => Some(StorageProof { key : key2.into(), From 0c6c8a9333ba25f8c3535c129cf86ef351b18e21 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Tue, 6 Nov 2018 07:06:01 +0100 Subject: [PATCH 91/98] fixed format Co-Authored-By: simon-jentzsch --- rpc/src/v1/impls/eth.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 4f594329ad1..fc521fe07f6 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -573,7 +573,7 @@ impl Eth for EthClient< storage_proof: Some(values.iter().filter_map(|storage_index| { let key2: H256 = storage_index.clone().into(); match self.client.prove_storage(key1, keccak(key2), id) { - Some((storage_proof,storage_value)) => Some(StorageProof { + Some((storage_proof,storage_value)) => Some(StorageProof { key : key2.into(), value: storage_value.into(), proof: storage_proof.into_iter().map(Bytes::new).collect() From 972c4c2e11cc70de0d0a4b0b07d03ac05c148897 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 6 Nov 2018 07:34:15 +0100 Subject: [PATCH 92/98] fixed empty lines --- rpc/src/v1/impls/light/eth.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/rpc/src/v1/impls/light/eth.rs b/rpc/src/v1/impls/light/eth.rs index 0eaae344cbe..5d301fe00de 100644 --- a/rpc/src/v1/impls/light/eth.rs +++ b/rpc/src/v1/impls/light/eth.rs @@ -470,12 +470,10 @@ impl Eth for EthClient { })) } - fn proof(&self, _address: RpcH160, _values:Vec, _num: Trailing) -> BoxFuture { Box::new(future::err(errors::unimplemented(None))) } - fn compilers(&self) -> Result> { Err(errors::deprecated("Compilation functionality is deprecated.".to_string())) } From fa053571c91d3ae409371e91c962bb8f616db22e Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 6 Nov 2018 07:39:44 +0100 Subject: [PATCH 93/98] removed Option from EthAccount --- rpc/src/v1/impls/eth.rs | 5 ++--- rpc/src/v1/types/account_info.rs | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index fc521fe07f6..77ed83662c9 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -569,8 +569,8 @@ impl Eth for EthClient< nonce : account.nonce.into(), code_hash : account.code_hash.into(), storage_hash : account.storage_root.into(), - account_proof: Some(proof.into_iter().map(Bytes::new).collect()), - storage_proof: Some(values.iter().filter_map(|storage_index| { + account_proof: proof.into_iter().map(Bytes::new).collect(), + storage_proof: values.iter().filter_map(|storage_index| { let key2: H256 = storage_index.clone().into(); match self.client.prove_storage(key1, keccak(key2), id) { Some((storage_proof,storage_value)) => Some(StorageProof { @@ -582,7 +582,6 @@ impl Eth for EthClient< } }) .collect::>() - ) }), None => Err(errors::state_pruned()), }; diff --git a/rpc/src/v1/types/account_info.rs b/rpc/src/v1/types/account_info.rs index 6239d165f74..487507de902 100644 --- a/rpc/src/v1/types/account_info.rs +++ b/rpc/src/v1/types/account_info.rs @@ -40,8 +40,8 @@ pub struct EthAccount { pub nonce: U256, pub code_hash: H256, pub storage_hash: H256, - pub account_proof: Option>, - pub storage_proof: Option>, + pub account_proof: Vec, + pub storage_proof: Vec, } /// Extended account information (used by `parity_allAccountInfo`). From 4db8cecee03763d818b6584458b629780b0b96d5 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 6 Nov 2018 12:49:12 +0100 Subject: [PATCH 94/98] fixed storage_index --- rpc/src/v1/impls/eth.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 77ed83662c9..77cdb0b69e6 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -570,8 +570,8 @@ impl Eth for EthClient< code_hash : account.code_hash.into(), storage_hash : account.storage_root.into(), account_proof: proof.into_iter().map(Bytes::new).collect(), - storage_proof: values.iter().filter_map(|storage_index| { - let key2: H256 = storage_index.clone().into(); + storage_proof: values.into_iter().filter_map(|storage_index| { + let key2: H256 = storage_index.into(); match self.client.prove_storage(key1, keccak(key2), id) { Some((storage_proof,storage_value)) => Some(StorageProof { key : key2.into(), From 1d652dc3f9fe2885580a9990abd3de617a2c6b3b Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 8 Nov 2018 16:39:41 +0100 Subject: [PATCH 95/98] implemented test and fixed the struct-spaces --- rpc/src/v1/impls/eth.rs | 10 +++++----- rpc/src/v1/tests/eth.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 77cdb0b69e6..bc037bc291b 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -564,17 +564,17 @@ impl Eth for EthClient< try_bf!(check_known(&*self.client, num.clone())); let res = match self.client.prove_account(key1, id) { Some((proof,account)) => Ok(EthAccount { - address : address, + address: address, balance: account.balance.into(), - nonce : account.nonce.into(), - code_hash : account.code_hash.into(), - storage_hash : account.storage_root.into(), + nonce: account.nonce.into(), + code_hash: account.code_hash.into(), + storage_hash: account.storage_root.into(), account_proof: proof.into_iter().map(Bytes::new).collect(), storage_proof: values.into_iter().filter_map(|storage_index| { let key2: H256 = storage_index.into(); match self.client.prove_storage(key1, keccak(key2), id) { Some((storage_proof,storage_value)) => Some(StorageProof { - key : key2.into(), + key: key2.into(), value: storage_value.into(), proof: storage_proof.into_iter().map(Bytes::new).collect() }), diff --git a/rpc/src/v1/tests/eth.rs b/rpc/src/v1/tests/eth.rs index 231ee450eb4..61ed0275175 100644 --- a/rpc/src/v1/tests/eth.rs +++ b/rpc/src/v1/tests/eth.rs @@ -178,6 +178,32 @@ fn eth_get_balance() { assert_eq!(tester.handler.handle_request_sync(req_new_acc).unwrap(), res_new_acc); } +#[test] +fn eth_get_proof() { + let chain = extract_chain!("BlockchainTests/bcWalletTest/wallet2outOf3txs"); + let tester = EthTester::from_chain(&chain); + // final account state + let req_latest = r#"{ + "jsonrpc": "2.0", + "method": "eth_getProof", + "params": ["0xaaaf5374fce5edbc8e2a8697c15331677e6ebaaa", [], "latest"], + "id": 1 + }"#; + let res_latest = r#"{"jsonrpc":"2.0","result":{"accountProof":["0xf8b1a0c749a0d25542712916106fae8adc5a5d5566809f1cef58661ec9666ff4b37709808080808080a04878521819f07bcbb6bd79eaf87da6a6f0aff816087dfcea1c80c92bba370a698080a0f23515d10ef588628b535ccb8a8ff5f191cde270d83894ededf2b77f4d145c3980a06c1463aa46f1ad2f190dd191a91702e9defcb59dd1595078335968a5bbf722e580a0ba704acc8a6d64e75dba10184c6ba50db20221c4a4a37622ba6cba64f92309d28080","0xf869a037ca2b51f02389e1d8eef41a2a6980697a081e9e6514d041d753033f60b03bd3b846f8448009a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"],"address":"0xaaaf5374fce5edbc8e2a8697c15331677e6ebaaa","balance":"0x9","codeHash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","nonce":"0x0","storageHash":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","storageProof":[]},"id":1}"#.to_owned(); + assert_eq!(tester.handler.handle_request_sync(req_latest).unwrap(), res_latest); + + // non-existant account + let req_new_acc = r#"{ + "jsonrpc": "2.0", + "method": "eth_getProof", + "params": ["0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",[],"latest"], + "id": 3 + }"#; + + let res_new_acc = r#"{"jsonrpc":"2.0","result":{"accountProof":["0xf8b1a0c749a0d25542712916106fae8adc5a5d5566809f1cef58661ec9666ff4b37709808080808080a04878521819f07bcbb6bd79eaf87da6a6f0aff816087dfcea1c80c92bba370a698080a0f23515d10ef588628b535ccb8a8ff5f191cde270d83894ededf2b77f4d145c3980a06c1463aa46f1ad2f190dd191a91702e9defcb59dd1595078335968a5bbf722e580a0ba704acc8a6d64e75dba10184c6ba50db20221c4a4a37622ba6cba64f92309d28080"],"address":"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","balance":"0x0","codeHash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","nonce":"0x0","storageHash":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","storageProof":[]},"id":3}"#.to_owned(); + assert_eq!(tester.handler.handle_request_sync(req_new_acc).unwrap(), res_new_acc); +} + #[test] fn eth_block_number() { let chain = extract_chain!("BlockchainTests/bcGasPricerTest/RPC_API_Test"); From b27be88c2c7623b92e602d9f01bd51edd11b9140 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 19 Nov 2018 15:03:16 +0100 Subject: [PATCH 96/98] fixed tests --- rpc/src/v1/tests/eth.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rpc/src/v1/tests/eth.rs b/rpc/src/v1/tests/eth.rs index 6ed125294b7..b737852059f 100644 --- a/rpc/src/v1/tests/eth.rs +++ b/rpc/src/v1/tests/eth.rs @@ -209,8 +209,9 @@ fn eth_get_proof() { "params": ["0xaaaf5374fce5edbc8e2a8697c15331677e6ebaaa", [], "latest"], "id": 1 }"#; - let res_latest = r#"{"jsonrpc":"2.0","result":{"accountProof":["0xf8b1a0c749a0d25542712916106fae8adc5a5d5566809f1cef58661ec9666ff4b37709808080808080a04878521819f07bcbb6bd79eaf87da6a6f0aff816087dfcea1c80c92bba370a698080a0f23515d10ef588628b535ccb8a8ff5f191cde270d83894ededf2b77f4d145c3980a06c1463aa46f1ad2f190dd191a91702e9defcb59dd1595078335968a5bbf722e580a0ba704acc8a6d64e75dba10184c6ba50db20221c4a4a37622ba6cba64f92309d28080","0xf869a037ca2b51f02389e1d8eef41a2a6980697a081e9e6514d041d753033f60b03bd3b846f8448009a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"],"address":"0xaaaf5374fce5edbc8e2a8697c15331677e6ebaaa","balance":"0x9","codeHash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","nonce":"0x0","storageHash":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","storageProof":[]},"id":1}"#.to_owned(); - assert_eq!(tester.handler.handle_request_sync(req_latest).unwrap(), res_latest); + + let res_latest = r#","address":"0xaaaf5374fce5edbc8e2a8697c15331677e6ebaaa","balance":"0x9","codeHash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","nonce":"0x0","storageHash":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","storageProof":[]},"id":1}"#.to_owned(); + assert!(tester.handler.handle_request_sync(req_latest).unwrap().to_string().ends_with(res_latest.as_str())); // non-existant account let req_new_acc = r#"{ @@ -220,8 +221,8 @@ fn eth_get_proof() { "id": 3 }"#; - let res_new_acc = r#"{"jsonrpc":"2.0","result":{"accountProof":["0xf8b1a0c749a0d25542712916106fae8adc5a5d5566809f1cef58661ec9666ff4b37709808080808080a04878521819f07bcbb6bd79eaf87da6a6f0aff816087dfcea1c80c92bba370a698080a0f23515d10ef588628b535ccb8a8ff5f191cde270d83894ededf2b77f4d145c3980a06c1463aa46f1ad2f190dd191a91702e9defcb59dd1595078335968a5bbf722e580a0ba704acc8a6d64e75dba10184c6ba50db20221c4a4a37622ba6cba64f92309d28080"],"address":"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","balance":"0x0","codeHash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","nonce":"0x0","storageHash":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","storageProof":[]},"id":3}"#.to_owned(); - assert_eq!(tester.handler.handle_request_sync(req_new_acc).unwrap(), res_new_acc); + let res_new_acc = r#","address":"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","balance":"0x0","codeHash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","nonce":"0x0","storageHash":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","storageProof":[]},"id":3}"#.to_owned(); + assert!(tester.handler.handle_request_sync(req_new_acc).unwrap().to_string().ends_with(res_new_acc.as_str())); } #[test] From 151ff0905857605ce1089484a602316c5016a99a Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 19 Nov 2018 15:35:20 +0100 Subject: [PATCH 97/98] added experimental RPCs flag for getProof --- parity/rpc_apis.rs | 1 + rpc/src/v1/impls/eth.rs | 5 +++++ rpc/src/v1/tests/eth.rs | 10 ++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/parity/rpc_apis.rs b/parity/rpc_apis.rs index 6e922147bec..8acbae7c33f 100644 --- a/parity/rpc_apis.rs +++ b/parity/rpc_apis.rs @@ -291,6 +291,7 @@ impl FullDependencies { allow_pending_receipt_query: !self.geth_compatibility, send_block_number_in_get_work: !self.geth_compatibility, gas_price_percentile: self.gas_price_percentile, + allow_experimental_rpcs: self.experimental_rpcs, } ); handler.extend_with(client.to_delegate()); diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 6917197e134..b3ef5a21ee7 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -65,6 +65,8 @@ pub struct EthClientOptions { pub send_block_number_in_get_work: bool, /// Gas Price Percentile used as default gas price. pub gas_price_percentile: usize, + /// Enable Experimental RPC-Calls + pub allow_experimental_rpcs: bool, } impl EthClientOptions { @@ -84,6 +86,7 @@ impl Default for EthClientOptions { allow_pending_receipt_query: true, send_block_number_in_get_work: true, gas_price_percentile: 50, + allow_experimental_rpcs: false, } } } @@ -549,6 +552,8 @@ impl Eth for EthClient< } fn proof(&self, address: RpcH160, values: Vec, num: Trailing) -> BoxFuture { + try_bf!(errors::require_experimental(self.options.allow_experimental_rpcs, "1186")); + let a: H160 = address.clone().into(); let key1 = keccak(a); diff --git a/rpc/src/v1/tests/eth.rs b/rpc/src/v1/tests/eth.rs index b737852059f..b0c599aa892 100644 --- a/rpc/src/v1/tests/eth.rs +++ b/rpc/src/v1/tests/eth.rs @@ -38,7 +38,7 @@ use parity_runtime::Runtime; use jsonrpc_core::IoHandler; use v1::helpers::dispatch::FullDispatcher; use v1::helpers::nonce; -use v1::impls::{EthClient, SigningUnsafeClient}; +use v1::impls::{EthClient, EthClientOptions, SigningUnsafeClient}; use v1::metadata::Metadata; use v1::tests::helpers::{TestSnapshotService, TestSyncProvider, Config}; use v1::traits::eth::Eth; @@ -140,7 +140,13 @@ impl EthTester { &opt_account_provider, &miner_service, &external_miner, - Default::default(), + EthClientOptions { + pending_nonce_from_queue: false, + allow_pending_receipt_query: true, + send_block_number_in_get_work: true, + gas_price_percentile: 50, + allow_experimental_rpcs: true, + }, ); let reservations = Arc::new(Mutex::new(nonce::Reservations::new(runtime.executor()))); From ad9c2418eab217278516dcf974d20b4a4a73f163 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 19 Nov 2018 18:49:20 +0100 Subject: [PATCH 98/98] optmized code --- rpc/src/v1/impls/eth.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index b3ef5a21ee7..82174560029 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -577,16 +577,14 @@ impl Eth for EthClient< code_hash: account.code_hash.into(), storage_hash: account.storage_root.into(), account_proof: proof.into_iter().map(Bytes::new).collect(), - storage_proof: values.into_iter().filter_map(|storage_index| { + storage_proof: values.into_iter().filter_map(|storage_index| { let key2: H256 = storage_index.into(); - match self.client.prove_storage(key1, keccak(key2), id) { - Some((storage_proof,storage_value)) => Some(StorageProof { - key: key2.into(), - value: storage_value.into(), - proof: storage_proof.into_iter().map(Bytes::new).collect() - }), - None => None - } + self.client.prove_storage(key1, keccak(key2), id) + .map(|(storage_proof,storage_value)| StorageProof { + key: key2.into(), + value: storage_value.into(), + proof: storage_proof.into_iter().map(Bytes::new).collect() + }) }) .collect::>() }),