Replace ganache-cli with anvil (#3555)

## Issue Addressed

N/A

## Proposed Changes

Replace ganache-cli with anvil https://github.com/foundry-rs/foundry/blob/master/anvil/README.md
We can lose all js dependencies in CI as a consequence.

## Additional info
Also changes the ethers-rs version used in the execution layer (for the transaction reconstruction) to a newer one. This was necessary to get use the ethers utils for anvil. The fixed execution engine integration tests should catch any potential issues with the payload reconstruction after #3592 


Co-authored-by: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
Pawan Dhananjay
2023-05-15 07:22:02 +00:00
parent 3c029d48bf
commit 8a3eb4df9c
24 changed files with 465 additions and 506 deletions

View File

@@ -1,11 +1,11 @@
//! NOTE: These tests will not pass unless ganache is running on `ENDPOINT` (see below).
//! NOTE: These tests will not pass unless an anvil is running on `ENDPOINT` (see below).
//!
//! You can start a suitable instance using the `ganache_test_node.sh` script in the `scripts`
//! You can start a suitable instance using the `anvil_test_node.sh` script in the `scripts`
//! dir in the root of the `lighthouse` repo.
#![cfg(test)]
use environment::{Environment, EnvironmentBuilder};
use eth1::{Eth1Endpoint, DEFAULT_CHAIN_ID};
use eth1_test_rig::{DelayThenDeposit, GanacheEth1Instance};
use eth1_test_rig::{AnvilEth1Instance, DelayThenDeposit, Middleware};
use genesis::{Eth1Config, Eth1GenesisService};
use sensitive_url::SensitiveUrl;
use state_processing::is_valid_genesis_state;
@@ -29,15 +29,14 @@ fn basic() {
let mut spec = env.eth2_config().spec.clone();
env.runtime().block_on(async {
let eth1 = GanacheEth1Instance::new(DEFAULT_CHAIN_ID.into())
let eth1 = AnvilEth1Instance::new(DEFAULT_CHAIN_ID.into())
.await
.expect("should start eth1 environment");
let deposit_contract = &eth1.deposit_contract;
let web3 = eth1.web3();
let client = eth1.json_rpc_client();
let now = web3
.eth()
.block_number()
let now = client
.get_block_number()
.await
.map(|v| v.as_u64())
.expect("should get block number");
@@ -89,7 +88,7 @@ fn basic() {
.map(|(_, state)| state)
.expect("should finish waiting for genesis");
// Note: using ganache these deposits are 1-per-block, therefore we know there should only be
// Note: using anvil these deposits are 1-per-block, therefore we know there should only be
// the minimum number of validators.
assert_eq!(
state.validators().len(),