2017-01-25 18:51:41 +01:00
|
|
|
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
|
2016-07-19 09:21:41 +02:00
|
|
|
// This file is part of Parity.
|
|
|
|
|
|
|
|
// Parity is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// Parity is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2016-08-18 15:01:24 +02:00
|
|
|
use std::collections::BTreeMap;
|
2016-08-03 18:05:17 +02:00
|
|
|
use util::{U256, Address, H256, H2048, Bytes, Itertools};
|
2016-10-31 12:57:48 +01:00
|
|
|
use util::stats::Histogram;
|
2016-07-19 09:21:41 +02:00
|
|
|
use blockchain::TreeRoute;
|
2016-09-27 16:50:24 +02:00
|
|
|
use verification::queue::QueueInfo as BlockQueueInfo;
|
2016-07-19 09:21:41 +02:00
|
|
|
use block::{OpenBlock, SealedBlock};
|
|
|
|
use header::{BlockNumber};
|
2017-01-13 09:51:36 +01:00
|
|
|
use transaction::{LocalizedTransaction, PendingTransaction, SignedTransaction};
|
2017-01-24 10:03:58 +01:00
|
|
|
use transaction_import::TransactionImportResult;
|
2016-07-19 09:21:41 +02:00
|
|
|
use log_entry::LocalizedLogEntry;
|
|
|
|
use filter::Filter;
|
2017-01-24 10:03:58 +01:00
|
|
|
use error::{ImportResult, CallError, Error as EthcoreError};
|
2016-07-19 09:21:41 +02:00
|
|
|
use receipt::LocalizedReceipt;
|
|
|
|
use trace::LocalizedTrace;
|
2016-10-28 16:42:24 +02:00
|
|
|
use evm::{Factory as EvmFactory, Schedule};
|
2016-07-19 09:21:41 +02:00
|
|
|
use executive::Executed;
|
|
|
|
use env_info::LastHashes;
|
|
|
|
use block_import_error::BlockImportError;
|
2016-08-17 15:54:24 +02:00
|
|
|
use ipc::IpcConfig;
|
2016-11-04 17:35:02 +01:00
|
|
|
use types::ids::*;
|
|
|
|
use types::trace_filter::Filter as TraceFilter;
|
|
|
|
use types::call_analytics::CallAnalytics;
|
2016-07-19 09:21:41 +02:00
|
|
|
use types::blockchain_info::BlockChainInfo;
|
|
|
|
use types::block_status::BlockStatus;
|
2016-10-31 16:58:35 +01:00
|
|
|
use types::mode::Mode;
|
2016-11-09 23:25:54 +01:00
|
|
|
use types::pruning_info::PruningInfo;
|
2016-12-28 13:44:51 +01:00
|
|
|
use encoded;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
|
|
|
#[ipc(client_ident="RemoteClient")]
|
|
|
|
/// Blockchain database client. Owns and manages a blockchain and a block queue.
|
|
|
|
pub trait BlockChainClient : Sync + Send {
|
|
|
|
|
|
|
|
/// Get raw block header data by block id.
|
2016-12-28 13:44:51 +01:00
|
|
|
fn block_header(&self, id: BlockId) -> Option<encoded::Header>;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
2016-12-11 02:02:40 +01:00
|
|
|
/// Look up the block number for the given block ID.
|
|
|
|
fn block_number(&self, id: BlockId) -> Option<BlockNumber>;
|
2016-12-11 16:52:41 +01:00
|
|
|
|
2016-07-19 09:21:41 +02:00
|
|
|
/// Get raw block body data by block id.
|
|
|
|
/// Block body is an RLP list of two items: uncles and transactions.
|
2016-12-28 13:44:51 +01:00
|
|
|
fn block_body(&self, id: BlockId) -> Option<encoded::Body>;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
|
|
|
/// Get raw block data by block header hash.
|
2016-12-28 13:44:51 +01:00
|
|
|
fn block(&self, id: BlockId) -> Option<encoded::Block>;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
|
|
|
/// Get block status by block header hash.
|
2016-12-09 23:01:43 +01:00
|
|
|
fn block_status(&self, id: BlockId) -> BlockStatus;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
|
|
|
/// Get block total difficulty.
|
2016-12-09 23:01:43 +01:00
|
|
|
fn block_total_difficulty(&self, id: BlockId) -> Option<U256>;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
|
|
|
/// Attempt to get address nonce at given block.
|
2016-12-09 23:01:43 +01:00
|
|
|
/// May not fail on BlockId::Latest.
|
|
|
|
fn nonce(&self, address: &Address, id: BlockId) -> Option<U256>;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
2016-11-27 11:11:56 +01:00
|
|
|
/// Attempt to get address storage root at given block.
|
2016-12-09 23:01:43 +01:00
|
|
|
/// May not fail on BlockId::Latest.
|
|
|
|
fn storage_root(&self, address: &Address, id: BlockId) -> Option<H256>;
|
2016-11-27 11:11:56 +01:00
|
|
|
|
2016-07-19 09:21:41 +02:00
|
|
|
/// Get address nonce at the latest block's state.
|
|
|
|
fn latest_nonce(&self, address: &Address) -> U256 {
|
2016-12-09 23:01:43 +01:00
|
|
|
self.nonce(address, BlockId::Latest)
|
|
|
|
.expect("nonce will return Some when given BlockId::Latest. nonce was given BlockId::Latest. \
|
2016-07-19 09:21:41 +02:00
|
|
|
Therefore nonce has returned Some; qed")
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Get block hash.
|
2016-12-09 23:01:43 +01:00
|
|
|
fn block_hash(&self, id: BlockId) -> Option<H256>;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
2016-08-08 17:25:15 +02:00
|
|
|
/// Get address code at given block's state.
|
2016-12-09 23:01:43 +01:00
|
|
|
fn code(&self, address: &Address, id: BlockId) -> Option<Option<Bytes>>;
|
2016-08-08 17:25:15 +02:00
|
|
|
|
|
|
|
/// Get address code at the latest block's state.
|
|
|
|
fn latest_code(&self, address: &Address) -> Option<Bytes> {
|
2016-12-09 23:01:43 +01:00
|
|
|
self.code(address, BlockId::Latest)
|
|
|
|
.expect("code will return Some if given BlockId::Latest; qed")
|
2016-08-08 17:25:15 +02:00
|
|
|
}
|
2016-07-19 09:21:41 +02:00
|
|
|
|
|
|
|
/// Get address balance at the given block's state.
|
|
|
|
///
|
2016-12-09 23:01:43 +01:00
|
|
|
/// May not return None if given BlockId::Latest.
|
2016-07-19 09:21:41 +02:00
|
|
|
/// Returns None if and only if the block's root hash has been pruned from the DB.
|
2016-12-09 23:01:43 +01:00
|
|
|
fn balance(&self, address: &Address, id: BlockId) -> Option<U256>;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
|
|
|
/// Get address balance at the latest block's state.
|
|
|
|
fn latest_balance(&self, address: &Address) -> U256 {
|
2016-12-09 23:01:43 +01:00
|
|
|
self.balance(address, BlockId::Latest)
|
|
|
|
.expect("balance will return Some if given BlockId::Latest. balance was given BlockId::Latest \
|
2016-07-19 09:21:41 +02:00
|
|
|
Therefore balance has returned Some; qed")
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Get value of the storage at given position at the given block's state.
|
|
|
|
///
|
2016-12-09 23:01:43 +01:00
|
|
|
/// May not return None if given BlockId::Latest.
|
2016-07-19 09:21:41 +02:00
|
|
|
/// Returns None if and only if the block's root hash has been pruned from the DB.
|
2016-12-09 23:01:43 +01:00
|
|
|
fn storage_at(&self, address: &Address, position: &H256, id: BlockId) -> Option<H256>;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
|
|
|
/// Get value of the storage at given position at the latest block's state.
|
|
|
|
fn latest_storage_at(&self, address: &Address, position: &H256) -> H256 {
|
2016-12-09 23:01:43 +01:00
|
|
|
self.storage_at(address, position, BlockId::Latest)
|
|
|
|
.expect("storage_at will return Some if given BlockId::Latest. storage_at was given BlockId::Latest. \
|
2016-07-19 09:21:41 +02:00
|
|
|
Therefore storage_at has returned Some; qed")
|
|
|
|
}
|
|
|
|
|
2016-10-03 11:13:10 +02:00
|
|
|
/// Get a list of all accounts in the block `id`, if fat DB is in operation, otherwise `None`.
|
2016-11-27 11:11:56 +01:00
|
|
|
/// If `after` is set the list starts with the following item.
|
2016-12-09 23:01:43 +01:00
|
|
|
fn list_accounts(&self, id: BlockId, after: Option<&Address>, count: u64) -> Option<Vec<Address>>;
|
2016-11-27 11:11:56 +01:00
|
|
|
|
|
|
|
/// Get a list of all storage keys in the block `id`, if fat DB is in operation, otherwise `None`.
|
|
|
|
/// If `after` is set the list starts with the following item.
|
2016-12-09 23:01:43 +01:00
|
|
|
fn list_storage(&self, id: BlockId, account: &Address, after: Option<&H256>, count: u64) -> Option<Vec<H256>>;
|
2016-10-03 11:13:10 +02:00
|
|
|
|
2016-07-19 09:21:41 +02:00
|
|
|
/// Get transaction with given hash.
|
2016-12-09 23:01:43 +01:00
|
|
|
fn transaction(&self, id: TransactionId) -> Option<LocalizedTransaction>;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
2016-12-07 23:13:53 +01:00
|
|
|
/// Get the hash of block that contains the transaction, if any.
|
2016-12-09 23:01:43 +01:00
|
|
|
fn transaction_block(&self, id: TransactionId) -> Option<H256>;
|
2016-12-07 23:13:53 +01:00
|
|
|
|
2016-07-19 09:21:41 +02:00
|
|
|
/// Get uncle with given id.
|
2016-12-28 13:44:51 +01:00
|
|
|
fn uncle(&self, id: UncleId) -> Option<encoded::Header>;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
|
|
|
/// Get transaction receipt with given hash.
|
2016-12-09 23:01:43 +01:00
|
|
|
fn transaction_receipt(&self, id: TransactionId) -> Option<LocalizedReceipt>;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
|
|
|
/// Get a tree route between `from` and `to`.
|
|
|
|
/// See `BlockChain::tree_route`.
|
|
|
|
fn tree_route(&self, from: &H256, to: &H256) -> Option<TreeRoute>;
|
|
|
|
|
|
|
|
/// Get all possible uncle hashes for a block.
|
|
|
|
fn find_uncles(&self, hash: &H256) -> Option<Vec<H256>>;
|
|
|
|
|
|
|
|
/// Get latest state node
|
|
|
|
fn state_data(&self, hash: &H256) -> Option<Bytes>;
|
|
|
|
|
|
|
|
/// Get raw block receipts data by block header hash.
|
|
|
|
fn block_receipts(&self, hash: &H256) -> Option<Bytes>;
|
|
|
|
|
|
|
|
/// Import a block into the blockchain.
|
|
|
|
fn import_block(&self, bytes: Bytes) -> Result<H256, BlockImportError>;
|
2016-10-18 18:16:00 +02:00
|
|
|
|
|
|
|
/// Import a block with transaction receipts. Does no sealing and transaction validation.
|
|
|
|
fn import_block_with_receipts(&self, block_bytes: Bytes, receipts_bytes: Bytes) -> Result<H256, BlockImportError>;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
|
|
|
/// Get block queue information.
|
|
|
|
fn queue_info(&self) -> BlockQueueInfo;
|
|
|
|
|
|
|
|
/// Clear block queue and abort all import activity.
|
|
|
|
fn clear_queue(&self);
|
|
|
|
|
|
|
|
/// Get blockchain information.
|
|
|
|
fn chain_info(&self) -> BlockChainInfo;
|
|
|
|
|
2016-08-17 19:25:02 +02:00
|
|
|
/// Get the registrar address, if it exists.
|
|
|
|
fn additional_params(&self) -> BTreeMap<String, String>;
|
|
|
|
|
2016-07-19 09:21:41 +02:00
|
|
|
/// Get the best block header.
|
2016-12-28 13:44:51 +01:00
|
|
|
fn best_block_header(&self) -> encoded::Header;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
|
|
|
/// Returns numbers of blocks containing given bloom.
|
2016-12-09 23:01:43 +01:00
|
|
|
fn blocks_with_bloom(&self, bloom: &H2048, from_block: BlockId, to_block: BlockId) -> Option<Vec<BlockNumber>>;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
|
|
|
/// Returns logs matching given filter.
|
2016-09-21 12:51:10 +02:00
|
|
|
fn logs(&self, filter: Filter) -> Vec<LocalizedLogEntry>;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
|
|
|
/// Makes a non-persistent transaction call.
|
2016-12-09 23:01:43 +01:00
|
|
|
fn call(&self, t: &SignedTransaction, block: BlockId, analytics: CallAnalytics) -> Result<Executed, CallError>;
|
2016-07-27 21:34:32 +02:00
|
|
|
|
2017-01-10 18:56:41 +01:00
|
|
|
/// Estimates how much gas will be necessary for a call.
|
|
|
|
fn estimate_gas(&self, t: &SignedTransaction, block: BlockId) -> Result<U256, CallError>;
|
|
|
|
|
2016-07-27 21:34:32 +02:00
|
|
|
/// Replays a given transaction for inspection.
|
2016-12-09 23:01:43 +01:00
|
|
|
fn replay(&self, t: TransactionId, analytics: CallAnalytics) -> Result<Executed, CallError>;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
|
|
|
/// Returns traces matching given filter.
|
|
|
|
fn filter_traces(&self, filter: TraceFilter) -> Option<Vec<LocalizedTrace>>;
|
|
|
|
|
|
|
|
/// Returns trace with given id.
|
|
|
|
fn trace(&self, trace: TraceId) -> Option<LocalizedTrace>;
|
|
|
|
|
|
|
|
/// Returns traces created by transaction.
|
2016-12-09 23:01:43 +01:00
|
|
|
fn transaction_traces(&self, trace: TransactionId) -> Option<Vec<LocalizedTrace>>;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
|
|
|
/// Returns traces created by transaction from block.
|
2016-12-09 23:01:43 +01:00
|
|
|
fn block_traces(&self, trace: BlockId) -> Option<Vec<LocalizedTrace>>;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
|
|
|
/// Get last hashes starting from best block.
|
|
|
|
fn last_hashes(&self) -> LastHashes;
|
|
|
|
|
|
|
|
/// Queue transactions for importing.
|
2016-12-10 21:22:19 +01:00
|
|
|
fn queue_transactions(&self, transactions: Vec<Bytes>, peer_id: usize);
|
2016-07-19 09:21:41 +02:00
|
|
|
|
2016-11-29 16:54:30 +01:00
|
|
|
/// Queue conensus engine message.
|
|
|
|
fn queue_consensus_message(&self, message: Bytes);
|
2016-08-15 14:25:57 +02:00
|
|
|
|
2016-12-16 14:54:26 +01:00
|
|
|
/// List all transactions that are allowed into the next block.
|
|
|
|
fn ready_transactions(&self) -> Vec<PendingTransaction>;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
2016-10-31 12:57:48 +01:00
|
|
|
/// Sorted list of transaction gas prices from at least last sample_size blocks.
|
|
|
|
fn gas_price_corpus(&self, sample_size: usize) -> Vec<U256> {
|
2016-07-19 09:21:41 +02:00
|
|
|
let mut h = self.chain_info().best_block_hash;
|
|
|
|
let mut corpus = Vec::new();
|
2016-10-25 12:21:21 +02:00
|
|
|
while corpus.is_empty() {
|
|
|
|
for _ in 0..sample_size {
|
2016-12-28 13:44:51 +01:00
|
|
|
let block = self.block(BlockId::Hash(h)).expect("h is either the best_block_hash or an ancestor; qed");
|
2016-10-25 12:21:21 +02:00
|
|
|
let header = block.header_view();
|
|
|
|
if header.number() == 0 {
|
2016-10-31 12:57:48 +01:00
|
|
|
return corpus;
|
2016-10-25 12:21:21 +02:00
|
|
|
}
|
|
|
|
block.transaction_views().iter().foreach(|t| corpus.push(t.gas_price()));
|
|
|
|
h = header.parent_hash().clone();
|
2016-07-19 09:21:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
corpus.sort();
|
2016-10-31 12:57:48 +01:00
|
|
|
corpus
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Calculate median gas price from recent blocks if they have any transactions.
|
|
|
|
fn gas_price_median(&self, sample_size: usize) -> Option<U256> {
|
|
|
|
let corpus = self.gas_price_corpus(sample_size);
|
2016-11-03 22:22:25 +01:00
|
|
|
corpus.get(corpus.len() / 2).cloned()
|
2016-10-31 12:57:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Get the gas price distribution based on recent blocks if they have any transactions.
|
|
|
|
fn gas_price_histogram(&self, sample_size: usize, bucket_number: usize) -> Option<Histogram> {
|
|
|
|
let raw_corpus = self.gas_price_corpus(sample_size);
|
|
|
|
let raw_len = raw_corpus.len();
|
|
|
|
// Throw out outliers.
|
2016-11-03 22:22:25 +01:00
|
|
|
let (corpus, _) = raw_corpus.split_at(raw_len - raw_len / 40);
|
2016-10-31 12:57:48 +01:00
|
|
|
Histogram::new(corpus, bucket_number)
|
2016-07-19 09:21:41 +02:00
|
|
|
}
|
2016-10-31 16:58:35 +01:00
|
|
|
|
2016-11-03 22:22:25 +01:00
|
|
|
/// Get the preferred network ID to sign on
|
2016-12-04 19:48:26 +01:00
|
|
|
fn signing_network_id(&self) -> Option<u64>;
|
2016-11-03 22:22:25 +01:00
|
|
|
|
|
|
|
/// Get the mode.
|
2016-10-31 16:58:35 +01:00
|
|
|
fn mode(&self) -> Mode;
|
|
|
|
|
2016-11-03 22:22:25 +01:00
|
|
|
/// Set the mode.
|
2016-10-31 16:58:35 +01:00
|
|
|
fn set_mode(&self, mode: Mode);
|
2016-11-04 17:35:02 +01:00
|
|
|
|
2016-12-11 16:52:41 +01:00
|
|
|
/// Disable the client from importing blocks. This cannot be undone in this session and indicates
|
|
|
|
/// that a subsystem has reason to believe this executable incapable of syncing the chain.
|
|
|
|
fn disable(&self);
|
|
|
|
|
2016-12-09 23:01:43 +01:00
|
|
|
/// Returns engine-related extra info for `BlockId`.
|
|
|
|
fn block_extra_info(&self, id: BlockId) -> Option<BTreeMap<String, String>>;
|
2016-11-04 17:35:02 +01:00
|
|
|
|
2016-12-09 23:01:43 +01:00
|
|
|
/// Returns engine-related extra info for `UncleId`.
|
|
|
|
fn uncle_extra_info(&self, id: UncleId) -> Option<BTreeMap<String, String>>;
|
2016-11-09 23:25:54 +01:00
|
|
|
|
|
|
|
/// Returns information about pruning/data availability.
|
|
|
|
fn pruning_info(&self) -> PruningInfo;
|
2016-12-10 23:58:39 +01:00
|
|
|
|
|
|
|
/// Like `call`, but with various defaults. Designed to be used for calling contracts.
|
|
|
|
fn call_contract(&self, address: Address, data: Bytes) -> Result<Bytes, String>;
|
|
|
|
|
2017-01-24 10:03:58 +01:00
|
|
|
/// Import a transaction: used for misbehaviour reporting.
|
|
|
|
fn transact_contract(&self, address: Address, data: Bytes) -> Result<TransactionImportResult, EthcoreError>;
|
|
|
|
|
2016-12-10 23:58:39 +01:00
|
|
|
/// Get the address of the registry itself.
|
|
|
|
fn registrar_address(&self) -> Option<Address>;
|
|
|
|
|
2016-12-23 18:46:17 +01:00
|
|
|
/// Get the address of a particular blockchain service, if available.
|
2016-12-10 23:58:39 +01:00
|
|
|
fn registry_address(&self, name: String) -> Option<Address>;
|
2016-07-19 09:21:41 +02:00
|
|
|
}
|
|
|
|
|
2016-12-05 16:55:33 +01:00
|
|
|
impl IpcConfig for BlockChainClient { }
|
|
|
|
|
2016-07-19 09:21:41 +02:00
|
|
|
/// Extended client interface used for mining
|
2016-12-05 16:55:33 +01:00
|
|
|
pub trait MiningBlockChainClient: BlockChainClient {
|
2016-07-19 09:21:41 +02:00
|
|
|
/// Returns OpenBlock prepared for closing.
|
2016-09-22 14:48:22 +02:00
|
|
|
fn prepare_open_block(&self,
|
|
|
|
author: Address,
|
|
|
|
gas_range_target: (U256, U256),
|
|
|
|
extra_data: Bytes
|
|
|
|
) -> OpenBlock;
|
2016-07-19 09:21:41 +02:00
|
|
|
|
|
|
|
/// Returns EvmFactory.
|
|
|
|
fn vm_factory(&self) -> &EvmFactory;
|
|
|
|
|
2016-12-08 12:03:34 +01:00
|
|
|
/// Broadcast a block proposal.
|
|
|
|
fn broadcast_proposal_block(&self, block: SealedBlock);
|
|
|
|
|
2016-07-19 09:21:41 +02:00
|
|
|
/// Import sealed block. Skips all verifications.
|
|
|
|
fn import_sealed_block(&self, block: SealedBlock) -> ImportResult;
|
2016-10-28 16:42:24 +02:00
|
|
|
|
|
|
|
/// Returns latest schedule.
|
|
|
|
fn latest_schedule(&self) -> Schedule;
|
2016-07-19 09:21:41 +02:00
|
|
|
}
|
|
|
|
|
2017-01-10 12:23:59 +01:00
|
|
|
/// Client facilities used by internally sealing Engines.
|
|
|
|
pub trait EngineClient: MiningBlockChainClient {
|
|
|
|
/// Make a new block and seal it.
|
|
|
|
fn update_sealing(&self);
|
|
|
|
|
|
|
|
/// Submit a seal for a block in the mining queue.
|
|
|
|
fn submit_seal(&self, block_hash: H256, seal: Vec<Bytes>);
|
|
|
|
|
|
|
|
/// Broadcast a consensus message to the network.
|
|
|
|
fn broadcast_consensus_message(&self, message: Bytes);
|
|
|
|
}
|
|
|
|
|
2016-12-05 16:55:33 +01:00
|
|
|
/// Extended client interface for providing proofs of the state.
|
|
|
|
pub trait ProvingBlockChainClient: BlockChainClient {
|
|
|
|
/// Prove account storage at a specific block id.
|
|
|
|
///
|
|
|
|
/// Both provided keys assume a secure trie.
|
|
|
|
/// Returns a vector of raw trie nodes (in order from the root) proving the storage query.
|
|
|
|
/// Nodes after `from_level` may be omitted.
|
|
|
|
/// An empty vector indicates unservable query.
|
2016-12-09 23:01:43 +01:00
|
|
|
fn prove_storage(&self, key1: H256, key2: H256, from_level: u32, id: BlockId) -> Vec<Bytes>;
|
2016-12-05 16:55:33 +01:00
|
|
|
|
|
|
|
/// Prove account existence at a specific block id.
|
|
|
|
/// The key is the keccak hash of the account's address.
|
|
|
|
/// Returns a vector of raw trie nodes (in order from the root) proving the query.
|
|
|
|
/// Nodes after `from_level` may be omitted.
|
2016-12-10 14:56:41 +01:00
|
|
|
/// An empty vector indicates unservable query.
|
2016-12-09 23:01:43 +01:00
|
|
|
fn prove_account(&self, key1: H256, from_level: u32, id: BlockId) -> Vec<Bytes>;
|
2016-12-05 16:55:33 +01:00
|
|
|
|
|
|
|
/// Get code by address hash.
|
2016-12-09 23:01:43 +01:00
|
|
|
fn code_by_hash(&self, account_key: H256, id: BlockId) -> Bytes;
|
2016-12-10 14:56:41 +01:00
|
|
|
}
|