mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 18:32:42 +00:00
Fix lcli merge conflicts
This commit is contained in:
@@ -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<T: EthSpec>(mut env: Environment<T>, matches: &ArgMatches) -> Result<(), String> {
|
||||
pub async fn run<T: EthSpec>(
|
||||
_env: Environment<T>,
|
||||
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<T: EthSpec>(mut env: Environment<T>, 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);
|
||||
|
||||
@@ -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<T: EthSpec>(env_builder: EnvironmentBuilder<T>, matches: &ArgMatches) -> Result<(), String> {
|
||||
async fn run<T: EthSpec>(
|
||||
env_builder: EnvironmentBuilder<T>,
|
||||
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<T: EthSpec>(env_builder: EnvironmentBuilder<T>, matches: &ArgMatches) ->
|
||||
run_parse_hex::<T>(matches).map_err(|e| format!("Failed to pretty print hex: {}", e))
|
||||
}
|
||||
("deploy-deposit-contract", Some(matches)) => {
|
||||
deploy_deposit_contract::run::<T>(env, matches)
|
||||
deploy_deposit_contract::run::<T>(env, matches).await
|
||||
.map_err(|e| format!("Failed to run deploy-deposit-contract command: {}", e))
|
||||
}
|
||||
("refund-deposit-contract", Some(matches)) => {
|
||||
refund_deposit_contract::run::<T>(env, matches)
|
||||
refund_deposit_contract::run::<T>(env, matches).await
|
||||
.map_err(|e| format!("Failed to run refund-deposit-contract command: {}", e))
|
||||
}
|
||||
("eth1-genesis", Some(matches)) => eth1_genesis::run::<T>(env, matches)
|
||||
.await
|
||||
.map_err(|e| format!("Failed to run eth1-genesis command: {}", e)),
|
||||
("interop-genesis", Some(matches)) => interop_genesis::run::<T>(env, matches)
|
||||
.map_err(|e| format!("Failed to run interop-genesis command: {}", e)),
|
||||
|
||||
@@ -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<T: EthSpec>(mut env: Environment<T>, matches: &ArgMatches) -> Result<(), String> {
|
||||
pub async fn run<T: EthSpec>(_env: Environment<T>, 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<T: EthSpec>(mut env: Environment<T>, 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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user