mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-19 12:56:12 +00:00
Improve compile time (#1989)
## Issue Addressed Closes #1264 ## Proposed Changes * Milagro BLS: tweak the feature flags so that Milagro doesn't get compiled if we're using BLST. Profiling showed that it was consuming about 1 minute of CPU time out of 60 minutes of CPU time (real time ~15 mins). A 1.6% saving. * Reduce monomorphization: compiling for 3 different `EthSpec` types causes a heck of a lot of generic functions to be instantiated (monomorphized). Removing 2 of 3 cuts the LLVM+linking step from around 250 seconds to 180 seconds, a saving of 70 seconds (real time!). This applies only to `make` and not the CI build, because we test with the minimal spec on CI. * Update `web3` crate to v0.13. This is perhaps the most controversial change, because it requires axing some deposit contract tools from `lcli`. I suspect these tools weren't used much anyway, and could be maintained separately, but I'm also happy to revert this change. However, it does save us a lot of compile time. With #1839, we now have 3 versions of Tokio (and all of Tokio's deps). This change brings us down to 2 versions, but 1 should be achievable once web3 (and reqwest) move to Tokio 0.3. * Remove `lcli` from the Docker image. It's a dev tool and can be built from the repo if required.
This commit is contained in:
@@ -1,71 +0,0 @@
|
||||
use clap::ArgMatches;
|
||||
use deposit_contract::{
|
||||
testnet::{ABI, BYTECODE},
|
||||
CONTRACT_DEPLOY_GAS,
|
||||
};
|
||||
use environment::Environment;
|
||||
use futures::compat::Future01CompatExt;
|
||||
use std::path::PathBuf;
|
||||
use tokio_compat_02::FutureExt;
|
||||
use types::EthSpec;
|
||||
use web3::{
|
||||
contract::{Contract, Options},
|
||||
transports::Ipc,
|
||||
types::{Address, U256},
|
||||
Web3,
|
||||
};
|
||||
|
||||
pub 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")?;
|
||||
|
||||
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);
|
||||
|
||||
let bytecode = String::from_utf8(BYTECODE.to_vec()).map_err(|e| {
|
||||
format!(
|
||||
"Unable to parse deposit contract bytecode as utf-8: {:?}",
|
||||
e
|
||||
)
|
||||
})?;
|
||||
|
||||
env.runtime().block_on(
|
||||
async {
|
||||
// It's unlikely that this will be the _actual_ deployment block, however it'll be close
|
||||
// enough to serve our purposes.
|
||||
//
|
||||
// We only need the deposit block to put a lower bound on the block number we need to search
|
||||
// for deposit logs.
|
||||
let deploy_block = web3
|
||||
.eth()
|
||||
.block_number()
|
||||
.compat()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to get block number: {}", 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);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
.compat(),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user