ethabi version 5 (#7723)
* Refactor updater to use ethabi-derive * Grumble: do_call type alias * Empty commit to trigger test re-run * migration to ethabi-5.0 * migration to ethabi-5.0 in progress * use ethabi_deriven to generate TransactAcl contract * use ethabi_deriven to generate Registry contract * hash-fetch uses ethabi_derive, removed retain cycle from updater, fixed #7720 * node-filter crate uses ethabi_derive to generate peer_set contract interface * use LruCache in node-filter instead of HashMap * validator_set engine uses ethabi_derive * ethcore does not depend on native_contracts * miner does no depend on native_contracts * secret_store does not use native_contracts (in progress) * removed native-contracts * ethcore and updater does not depend on futures * updated ethereum-types * fixed all warnings caused by using new version of ethereum-types * updated ethabi_derive && ethabi_contract to get rid of warnings * removed another retain cycle in updater, fixed following minor version on update * moved contracts out of native_contracts res * updated ethabi_contract * fixed failing test * fixed failing test * there is no need to create two contracts of the same kind any more * simplify updater::ReleaseTrack conversion into u8 and add several tests for it * applied review suggestions * applied review suggestions
This commit is contained in:
@@ -645,17 +645,17 @@ fn execute_export_state(cmd: ExportState) -> Result<(), String> {
|
||||
if i != 0 {
|
||||
out.write(b",").expect("Write error");
|
||||
}
|
||||
out.write_fmt(format_args!("\n\"0x{}\": {{\"balance\": \"{:x}\", \"nonce\": \"{:x}\"", account.hex(), balance, client.nonce(&account, at).unwrap_or_else(U256::zero))).expect("Write error");
|
||||
out.write_fmt(format_args!("\n\"0x{:x}\": {{\"balance\": \"{:x}\", \"nonce\": \"{:x}\"", account, balance, client.nonce(&account, at).unwrap_or_else(U256::zero))).expect("Write error");
|
||||
let code = client.code(&account, at).unwrap_or(None).unwrap_or_else(Vec::new);
|
||||
if !code.is_empty() {
|
||||
out.write_fmt(format_args!(", \"code_hash\": \"0x{}\"", keccak(&code).hex())).expect("Write error");
|
||||
out.write_fmt(format_args!(", \"code_hash\": \"0x{:x}\"", keccak(&code))).expect("Write error");
|
||||
if cmd.code {
|
||||
out.write_fmt(format_args!(", \"code\": \"{}\"", code.to_hex())).expect("Write error");
|
||||
}
|
||||
}
|
||||
let storage_root = client.storage_root(&account, at).unwrap_or(KECCAK_NULL_RLP);
|
||||
if storage_root != KECCAK_NULL_RLP {
|
||||
out.write_fmt(format_args!(", \"storage_root\": \"0x{}\"", storage_root.hex())).expect("Write error");
|
||||
out.write_fmt(format_args!(", \"storage_root\": \"0x{:x}\"", storage_root)).expect("Write error");
|
||||
if cmd.storage {
|
||||
out.write_fmt(format_args!(", \"storage\": {{")).expect("Write error");
|
||||
let mut last_storage: Option<H256> = None;
|
||||
@@ -669,7 +669,7 @@ fn execute_export_state(cmd: ExportState) -> Result<(), String> {
|
||||
if last_storage.is_some() {
|
||||
out.write(b",").expect("Write error");
|
||||
}
|
||||
out.write_fmt(format_args!("\n\t\"0x{}\": \"0x{}\"", key.hex(), client.storage_at(&account, &key, at).unwrap_or_else(Default::default).hex())).expect("Write error");
|
||||
out.write_fmt(format_args!("\n\t\"0x{:x}\": \"0x{:x}\"", key, client.storage_at(&account, &key, at).unwrap_or_else(Default::default))).expect("Write error");
|
||||
last_storage = Some(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1384,7 +1384,13 @@ mod tests {
|
||||
acc_conf: Default::default(),
|
||||
gas_pricer_conf: Default::default(),
|
||||
miner_extras: Default::default(),
|
||||
update_policy: UpdatePolicy { enable_downloading: true, require_consensus: true, filter: UpdateFilter::Critical, track: ReleaseTrack::Unknown, path: default_hypervisor_path() },
|
||||
update_policy: UpdatePolicy {
|
||||
enable_downloading: true,
|
||||
require_consensus: true,
|
||||
filter: UpdateFilter::Critical,
|
||||
track: ReleaseTrack::Unknown,
|
||||
path: default_hypervisor_path()
|
||||
},
|
||||
mode: Default::default(),
|
||||
tracing: Default::default(),
|
||||
compaction: Default::default(),
|
||||
|
||||
@@ -22,7 +22,7 @@ use dir::default_data_path;
|
||||
use dir::helpers::replace_home;
|
||||
use ethcore::client::{Client, BlockChainClient, BlockId};
|
||||
use ethsync::LightSync;
|
||||
use futures::{future, IntoFuture, Future};
|
||||
use futures::{Future, future, IntoFuture};
|
||||
use hash_fetch::fetch::Client as FetchClient;
|
||||
use hash_fetch::urlhint::ContractClient;
|
||||
use light::client::LightChainClient;
|
||||
@@ -70,18 +70,22 @@ pub struct FullRegistrar {
|
||||
pub client: Arc<Client>,
|
||||
}
|
||||
|
||||
impl FullRegistrar {
|
||||
pub fn new(client: Arc<Client>) -> Self {
|
||||
FullRegistrar {
|
||||
client,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ContractClient for FullRegistrar {
|
||||
fn registrar(&self) -> Result<Address, String> {
|
||||
self.client.additional_params().get("registrar")
|
||||
self.client.registrar_address()
|
||||
.ok_or_else(|| "Registrar not defined.".into())
|
||||
.and_then(|registrar| {
|
||||
registrar.parse().map_err(|e| format!("Invalid registrar address: {:?}", e))
|
||||
})
|
||||
}
|
||||
|
||||
fn call(&self, address: Address, data: Bytes) -> Box<Future<Item=Bytes, Error=String> + Send> {
|
||||
Box::new(self.client.call_contract(BlockId::Latest, address, data)
|
||||
.into_future())
|
||||
fn call(&self, address: Address, data: Bytes) -> Box<Future<Item = Bytes, Error = String> + Send> {
|
||||
Box::new(self.client.call_contract(BlockId::Latest, address, data).into_future())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,13 +108,13 @@ impl<T: LightChainClient + 'static> ContractClient for LightRegistrar<T> {
|
||||
})
|
||||
}
|
||||
|
||||
fn call(&self, address: Address, data: Bytes) -> Box<Future<Item=Bytes, Error=String> + Send> {
|
||||
fn call(&self, address: Address, data: Bytes) -> Box<Future<Item = Bytes, Error = String> + Send> {
|
||||
let header = self.client.best_block_header();
|
||||
let env_info = self.client.env_info(BlockId::Hash(header.hash()))
|
||||
.ok_or_else(|| format!("Cannot fetch env info for header {}", header.hash()));
|
||||
|
||||
let env_info = match env_info {
|
||||
Ok(x) => x,
|
||||
Ok(e) => e,
|
||||
Err(e) => return Box::new(future::err(e)),
|
||||
};
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ fn print_hash_of(maybe_file: Option<String>) -> Result<String, String> {
|
||||
if let Some(file) = maybe_file {
|
||||
let mut f = BufReader::new(File::open(&file).map_err(|_| "Unable to open file".to_owned())?);
|
||||
let hash = keccak_buffer(&mut f).map_err(|_| "Unable to read from file".to_owned())?;
|
||||
Ok(hash.hex())
|
||||
Ok(format!("{:x}", hash))
|
||||
} else {
|
||||
Err("Streaming from standard input not yet supported. Specify a file.".to_owned())
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ use ethcore_logger::{Config as LogConfig, RotatingLogger};
|
||||
use ethsync::{self, SyncConfig};
|
||||
use fdlimit::raise_fd_limit;
|
||||
use hash_fetch::fetch::{Fetch, Client as FetchClient};
|
||||
use hash_fetch;
|
||||
use informant::{Informant, LightNodeInformantData, FullNodeInformantData};
|
||||
use journaldb::Algorithm;
|
||||
use light::Cache as LightDataCache;
|
||||
@@ -304,11 +305,11 @@ fn execute_light_impl(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger
|
||||
// the dapps server
|
||||
let signer_service = Arc::new(signer::new_service(&cmd.ws_conf, &cmd.ui_conf, &cmd.logger_config));
|
||||
let (node_health, dapps_deps) = {
|
||||
let contract_client = Arc::new(::dapps::LightRegistrar {
|
||||
let contract_client = ::dapps::LightRegistrar {
|
||||
client: client.clone(),
|
||||
sync: light_sync.clone(),
|
||||
on_demand: on_demand.clone(),
|
||||
});
|
||||
};
|
||||
|
||||
struct LightSyncStatus(Arc<LightSync>);
|
||||
impl fmt::Debug for LightSyncStatus {
|
||||
@@ -334,7 +335,7 @@ fn execute_light_impl(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger
|
||||
(node_health.clone(), dapps::Dependencies {
|
||||
sync_status,
|
||||
node_health,
|
||||
contract_client: contract_client,
|
||||
contract_client: Arc::new(contract_client),
|
||||
fetch: fetch.clone(),
|
||||
signer: signer_service.clone(),
|
||||
ui_address: cmd.ui_conf.redirection_address(),
|
||||
@@ -676,13 +677,14 @@ pub fn execute_impl(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>)
|
||||
// spin up event loop
|
||||
let event_loop = EventLoop::spawn();
|
||||
|
||||
let contract_client = Arc::new(::dapps::FullRegistrar::new(client.clone()));
|
||||
|
||||
// the updater service
|
||||
let updater = Updater::new(
|
||||
Arc::downgrade(&(service.client() as Arc<BlockChainClient>)),
|
||||
Arc::downgrade(&sync_provider),
|
||||
update_policy,
|
||||
fetch.clone(),
|
||||
event_loop.remote(),
|
||||
hash_fetch::Client::with_fetch(contract_client.clone(), fetch.clone(), event_loop.remote())
|
||||
);
|
||||
service.add_notify(updater.clone());
|
||||
|
||||
@@ -698,7 +700,6 @@ pub fn execute_impl(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>)
|
||||
// the dapps server
|
||||
let (node_health, dapps_deps) = {
|
||||
let (sync, client) = (sync_provider.clone(), client.clone());
|
||||
let contract_client = Arc::new(::dapps::FullRegistrar { client: client.clone() });
|
||||
|
||||
struct SyncStatus(Arc<ethsync::SyncProvider>, Arc<Client>, ethsync::NetworkConfiguration);
|
||||
impl fmt::Debug for SyncStatus {
|
||||
@@ -725,7 +726,7 @@ pub fn execute_impl(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>)
|
||||
(node_health.clone(), dapps::Dependencies {
|
||||
sync_status,
|
||||
node_health,
|
||||
contract_client: contract_client,
|
||||
contract_client,
|
||||
fetch: fetch.clone(),
|
||||
signer: signer_service.clone(),
|
||||
ui_address: cmd.ui_conf.redirection_address(),
|
||||
|
||||
Reference in New Issue
Block a user