From 47124ca40456a8ee5f1a9371c14be34f498f2dc7 Mon Sep 17 00:00:00 2001 From: pawanjay176 Date: Tue, 28 Apr 2020 18:21:52 +0530 Subject: [PATCH] Fix lcli merge conflicts --- Cargo.lock | 64 +++++++++++++++++++++++++++-- beacon_node/eth1/Cargo.toml | 2 +- lcli/Cargo.toml | 2 +- lcli/src/deploy_deposit_contract.rs | 39 +++++++++--------- lcli/src/main.rs | 18 ++++---- lcli/src/refund_deposit_contract.rs | 33 +++++++-------- tests/eth1_test_rig/Cargo.toml | 2 +- 7 files changed, 111 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2bc14dfad0..eda0a53dd2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -917,7 +917,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1110,7 +1110,7 @@ dependencies = [ "toml 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "tree_hash 0.1.1", "types 0.2.0", - "web3 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "web3 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1122,7 +1122,7 @@ dependencies = [ "serde_json 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "types 0.2.0", - "web3 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "web3 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1491,6 +1491,61 @@ dependencies = [ "num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "futures-executor" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-io" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro-hack 0.5.15 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-sink" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-task" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-util" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-channel 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-macro 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.15 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-nested 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "gcc" version = "0.3.55" @@ -5721,6 +5776,7 @@ dependencies = [ "checksum mio-named-pipes 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f5e374eff525ce1c5b7687c4cef63943e7686524a387933ad27ca7ec43779cb3" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +"checksum miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "396aa0f2003d7df8395cb93e09871561ccc3e785f0acb369170e8cc74ddf9226" "checksum multistream-select 0.6.1 (git+https://github.com/SigP/rust-libp2p?rev=71cf486b4d992862f5a05f9f4ef5e5c1631f4add)" = "" "checksum native-tls 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2b0d88c06fe90d5ee94048ba40409ef1d9315d86f6f38c2efdaad4fb50c58b2d" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" @@ -5812,7 +5868,7 @@ dependencies = [ "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum rustls 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b25a18b1bf7387f0145e7f8324e700805aade3842dd3db2e74e4cdeb4677c09e" "checksum rw-stream-sink 0.1.2 (git+https://github.com/SigP/rust-libp2p?rev=71cf486b4d992862f5a05f9f4ef5e5c1631f4add)" = "" -"checksum ryu 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535622e6be132bccd223f4bb2b8ac8d53cda3c7a6394944d3b2b33fb974f9d76" +"checksum ryu 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ed3d612bc64430efeb3f7ee6ef26d590dce0c43249217bddc62112540c7941e1" "checksum safemem 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" "checksum same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" "checksum schannel 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "039c25b130bd8c1321ee2d7de7fde2659fa9c2744e4bb29711cfc852ea53cd19" diff --git a/beacon_node/eth1/Cargo.toml b/beacon_node/eth1/Cargo.toml index 7400f604f1..4e95602aba 100644 --- a/beacon_node/eth1/Cargo.toml +++ b/beacon_node/eth1/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" eth1_test_rig = { path = "../../tests/eth1_test_rig" } environment = { path = "../../lighthouse/environment" } toml = "^0.5" -web3 = "0.8.0" +web3 = "0.10.0" sloggers = "0.3.4" [dependencies] diff --git a/lcli/Cargo.toml b/lcli/Cargo.toml index e63b20c376..7a423d8caa 100644 --- a/lcli/Cargo.toml +++ b/lcli/Cargo.toml @@ -21,7 +21,7 @@ regex = "1.3.1" eth1_test_rig = { path = "../tests/eth1_test_rig" } futures = {version = "0.3", features = ["compat"]} environment = { path = "../lighthouse/environment" } -web3 = "0.8.0" +web3 = "0.10.0" eth2_testnet_config = { path = "../eth2/utils/eth2_testnet_config" } dirs = "2.0" genesis = { path = "../beacon_node/genesis" } diff --git a/lcli/src/deploy_deposit_contract.rs b/lcli/src/deploy_deposit_contract.rs index 39339c54b8..c99e3fe234 100644 --- a/lcli/src/deploy_deposit_contract.rs +++ b/lcli/src/deploy_deposit_contract.rs @@ -5,7 +5,7 @@ use deposit_contract::{ CONTRACT_DEPLOY_GAS, }; use environment::Environment; -use futures::{Future, IntoFuture}; +use futures::compat::Future01CompatExt; use std::path::PathBuf; use types::EthSpec; use web3::{ @@ -15,7 +15,10 @@ use web3::{ Web3, }; -pub fn run(mut env: Environment, matches: &ArgMatches) -> Result<(), String> { +pub async fn run( + _env: Environment, + matches: &ArgMatches<'_>, +) -> Result<(), String> { let eth1_ipc_path: PathBuf = clap_utils::parse_required(matches, "eth1-ipc")?; let from_address: Address = clap_utils::parse_required(matches, "from-address")?; let confirmations: usize = clap_utils::parse_required(matches, "confirmations")?; @@ -43,23 +46,21 @@ pub fn run(mut env: Environment, matches: &ArgMatches) -> Result< .await .map_err(|e| format!("Failed to get block number: {}", e))?; - let address = env.runtime().block_on( - Contract::deploy(web3.eth(), &ABI) - .map_err(|e| format!("Unable to build contract deployer: {:?}", e))? - .confirmations(confirmations) - .options(Options { - gas: Some(U256::from(CONTRACT_DEPLOY_GAS)), - ..Options::default() - }) - .execute(bytecode, (), from_address) - .into_future() - .map_err(|e| format!("Unable to execute deployment: {:?}", e)) - .and_then(|pending| { - pending.map_err(|e| format!("Unable to await pending contract: {:?}", e)) - }) - .map(|tx_receipt| tx_receipt.address()) - .map_err(|e| format!("Failed to execute deployment: {:?}", e)), - )?; + let pending_contract = Contract::deploy(web3.eth(), &ABI) + .map_err(|e| format!("Unable to build contract deployer: {:?}", e))? + .confirmations(confirmations) + .options(Options { + gas: Some(U256::from(CONTRACT_DEPLOY_GAS)), + ..Options::default() + }) + .execute(bytecode, (), from_address) + .map_err(|e| format!("Unable to execute deployment: {:?}", e))?; + + let address = pending_contract + .compat() + .await + .map_err(|e| format!("Unable to await pending contract: {:?}", e))? + .address(); println!("deposit_contract_address: {:?}", address); println!("deposit_contract_deploy_block: {}", deploy_block); diff --git a/lcli/src/main.rs b/lcli/src/main.rs index ebda88f93e..0f51f6abbf 100644 --- a/lcli/src/main.rs +++ b/lcli/src/main.rs @@ -410,7 +410,7 @@ async fn main() { macro_rules! run_with_spec { ($env_builder: expr) => { - match run($env_builder, &matches) { + match run($env_builder, &matches).await { Ok(()) => process::exit(0), Err(e) => { println!("Failed to run lcli: {}", e); @@ -421,9 +421,9 @@ async fn main() { } match matches.value_of("spec") { - Some("minimal") => run_with_spec!(EnvironmentBuilder::minimal()).await, - Some("mainnet") => run_with_spec!(EnvironmentBuilder::mainnet()).await, - Some("interop") => run_with_spec!(EnvironmentBuilder::interop()).await, + Some("minimal") => run_with_spec!(EnvironmentBuilder::minimal()), + Some("mainnet") => run_with_spec!(EnvironmentBuilder::mainnet()), + Some("interop") => run_with_spec!(EnvironmentBuilder::interop()), spec => { // This path should be unreachable due to slog having a `default_value` unreachable!("Unknown spec configuration: {:?}", spec); @@ -431,7 +431,10 @@ async fn main() { } } -fn run(env_builder: EnvironmentBuilder, matches: &ArgMatches) -> Result<(), String> { +async fn run( + env_builder: EnvironmentBuilder, + matches: &ArgMatches<'_>, +) -> Result<(), String> { let env = env_builder .multi_threaded_tokio_runtime() .map_err(|e| format!("should start tokio runtime: {:?}", e))? @@ -485,14 +488,15 @@ fn run(env_builder: EnvironmentBuilder, matches: &ArgMatches) -> run_parse_hex::(matches).map_err(|e| format!("Failed to pretty print hex: {}", e)) } ("deploy-deposit-contract", Some(matches)) => { - deploy_deposit_contract::run::(env, matches) + deploy_deposit_contract::run::(env, matches).await .map_err(|e| format!("Failed to run deploy-deposit-contract command: {}", e)) } ("refund-deposit-contract", Some(matches)) => { - refund_deposit_contract::run::(env, matches) + refund_deposit_contract::run::(env, matches).await .map_err(|e| format!("Failed to run refund-deposit-contract command: {}", e)) } ("eth1-genesis", Some(matches)) => eth1_genesis::run::(env, matches) + .await .map_err(|e| format!("Failed to run eth1-genesis command: {}", e)), ("interop-genesis", Some(matches)) => interop_genesis::run::(env, matches) .map_err(|e| format!("Failed to run interop-genesis command: {}", e)), diff --git a/lcli/src/refund_deposit_contract.rs b/lcli/src/refund_deposit_contract.rs index 719a8ef1b0..dd39d0dbdf 100644 --- a/lcli/src/refund_deposit_contract.rs +++ b/lcli/src/refund_deposit_contract.rs @@ -1,6 +1,6 @@ use clap::ArgMatches; use environment::Environment; -use futures::Future; +use futures::compat::Future01CompatExt; use std::path::PathBuf; use types::EthSpec; use web3::{ @@ -12,7 +12,7 @@ use web3::{ /// `keccak("steal()")[0..4]` pub const STEAL_FN_SIGNATURE: &[u8] = &[0xcf, 0x7a, 0x89, 0x65]; -pub fn run(mut env: Environment, matches: &ArgMatches) -> Result<(), String> { +pub async fn run(_env: Environment, matches: &ArgMatches<'_>) -> Result<(), String> { let eth1_ipc_path: PathBuf = clap_utils::parse_required(matches, "eth1-ipc")?; let from: Address = clap_utils::parse_required(matches, "from-address")?; let contract_address: Address = clap_utils::parse_required(matches, "contract-address")?; @@ -21,20 +21,21 @@ pub fn run(mut env: Environment, matches: &ArgMatches) -> Result< Ipc::new(eth1_ipc_path).map_err(|e| format!("Unable to connect to eth1 IPC: {:?}", e))?; let web3 = Web3::new(transport); - env.runtime().block_on( - web3.eth() - .send_transaction(TransactionRequest { - from, - to: Some(contract_address), - gas: Some(U256::from(400_000)), - gas_price: None, - value: Some(U256::zero()), - data: Some(STEAL_FN_SIGNATURE.into()), - nonce: None, - condition: None, - }) - .map_err(|e| format!("Failed to call deposit fn: {:?}", e)), - )?; + let _ = web3 + .eth() + .send_transaction(TransactionRequest { + from, + to: Some(contract_address), + gas: Some(U256::from(400_000)), + gas_price: None, + value: Some(U256::zero()), + data: Some(STEAL_FN_SIGNATURE.into()), + nonce: None, + condition: None, + }) + .compat() + .await + .map_err(|e| format!("Failed to call deposit fn: {:?}", e))?; Ok(()) } diff --git a/tests/eth1_test_rig/Cargo.toml b/tests/eth1_test_rig/Cargo.toml index 23f2a9e05a..90dc58436f 100644 --- a/tests/eth1_test_rig/Cargo.toml +++ b/tests/eth1_test_rig/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Paul Hauner "] edition = "2018" [dependencies] -web3 = "0.8.0" +web3 = "0.10.0" tokio = { version = "0.2", features = ["time"] } futures = { version = "0.3", features = ["compat"] } types = { path = "../../eth2/types"}