mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-18 12:22:51 +00:00
* Add progress on new deposits * Add deposited command to account manager * Remove old lcli::helpers mod * Clean clap_utils * Refactor lcli deposit contract commands to use IPC * Make testnet optional for environment * Use dbg formatting for deploy address * Add command to generate bootnode enr * Ensure lcli returns with 1 on error * Ensure account manager returns 1 on error * Disallow deposits to the zero address * Update web3 in eth1 crate * Ensure correct lighthouse dir is created * Reduce deposit gas requirement * Update cargo.lock * Add progress on new deposits * Add deposited command to account manager * Remove old lcli::helpers mod * Clean clap_utils * Refactor lcli deposit contract commands to use IPC * Add command to generate bootnode enr * Ensure lcli returns with 1 on error * Ensure account manager returns 1 on error * Update web3 in eth1 crate * Update Cargo.lock * Move lcli out of main install script * Change --limit to --at-least * Change --datadir to --validator-dir * Remove duplication in docs
41 lines
1.3 KiB
Rust
41 lines
1.3 KiB
Rust
use clap::ArgMatches;
|
|
use environment::Environment;
|
|
use futures::Future;
|
|
use std::path::PathBuf;
|
|
use types::EthSpec;
|
|
use web3::{
|
|
transports::Ipc,
|
|
types::{Address, TransactionRequest, U256},
|
|
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> {
|
|
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")?;
|
|
|
|
let (_event_loop_handle, transport) =
|
|
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)),
|
|
)?;
|
|
|
|
Ok(())
|
|
}
|