Updates to tests and local testnet for Ganache 7 (#3056)
## Issue Addressed #2961 ## Proposed Changes -- update `--chainId` -> `--chain.chainId` -- remove `--keepAliveTimeout` -- fix log to listen for -- rename `ganache-cli` to `ganache` everywhere Co-authored-by: realbigsean <sean@sigmaprime.io>
This commit is contained in:
parent
9bc9527998
commit
ae5b141dc4
2
.github/workflows/local-testnet.yml
vendored
2
.github/workflows/local-testnet.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
|
|
||||||
- name: Install ganache
|
- name: Install ganache
|
||||||
run: npm install ganache-cli@latest --global
|
run: npm install ganache@latest --global
|
||||||
|
|
||||||
# https://github.com/actions/cache/blob/main/examples.md#rust---cargo
|
# https://github.com/actions/cache/blob/main/examples.md#rust---cargo
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v2
|
||||||
|
38
.github/workflows/test-suite.yml
vendored
38
.github/workflows/test-suite.yml
vendored
@ -50,8 +50,8 @@ jobs:
|
|||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: Get latest version of stable Rust
|
- name: Get latest version of stable Rust
|
||||||
run: rustup update stable
|
run: rustup update stable
|
||||||
- name: Install ganache-cli
|
- name: Install ganache
|
||||||
run: sudo npm install -g ganache-cli
|
run: sudo npm install -g ganache
|
||||||
- name: Run tests in release
|
- name: Run tests in release
|
||||||
run: make test-release
|
run: make test-release
|
||||||
release-tests-windows:
|
release-tests-windows:
|
||||||
@ -62,8 +62,18 @@ jobs:
|
|||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: Get latest version of stable Rust
|
- name: Get latest version of stable Rust
|
||||||
run: rustup update stable
|
run: rustup update stable
|
||||||
- name: Install ganache-cli
|
- name: Add msbuild to PATH
|
||||||
run: npm install -g ganache-cli
|
uses: microsoft/setup-msbuild@v1.0.2
|
||||||
|
- name: Use Python 2.7
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: "2.7"
|
||||||
|
- name: Set node config to use python2.7
|
||||||
|
run: npm config set python %pythonLocation%
|
||||||
|
- name: Set msvs_version to 2019
|
||||||
|
run: npm config set msvs_version 2019 --global
|
||||||
|
- name: Install ganache
|
||||||
|
run: npm install -g ganache
|
||||||
- name: Install make
|
- name: Install make
|
||||||
run: choco install -y make
|
run: choco install -y make
|
||||||
- uses: KyleMayes/install-llvm-action@v1
|
- uses: KyleMayes/install-llvm-action@v1
|
||||||
@ -102,8 +112,8 @@ jobs:
|
|||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: Get latest version of stable Rust
|
- name: Get latest version of stable Rust
|
||||||
run: rustup update stable
|
run: rustup update stable
|
||||||
- name: Install ganache-cli
|
- name: Install ganache
|
||||||
run: sudo npm install -g ganache-cli
|
run: sudo npm install -g ganache
|
||||||
- name: Run tests in debug
|
- name: Run tests in debug
|
||||||
run: make test-debug
|
run: make test-debug
|
||||||
state-transition-vectors-ubuntu:
|
state-transition-vectors-ubuntu:
|
||||||
@ -146,8 +156,8 @@ jobs:
|
|||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: Get latest version of stable Rust
|
- name: Get latest version of stable Rust
|
||||||
run: rustup update stable
|
run: rustup update stable
|
||||||
- name: Install ganache-cli
|
- name: Install ganache
|
||||||
run: sudo npm install -g ganache-cli
|
run: sudo npm install -g ganache
|
||||||
- name: Run the beacon chain sim that starts from an eth1 contract
|
- name: Run the beacon chain sim that starts from an eth1 contract
|
||||||
run: cargo run --release --bin simulator eth1-sim
|
run: cargo run --release --bin simulator eth1-sim
|
||||||
no-eth1-simulator-ubuntu:
|
no-eth1-simulator-ubuntu:
|
||||||
@ -158,8 +168,8 @@ jobs:
|
|||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: Get latest version of stable Rust
|
- name: Get latest version of stable Rust
|
||||||
run: rustup update stable
|
run: rustup update stable
|
||||||
- name: Install ganache-cli
|
- name: Install ganache
|
||||||
run: sudo npm install -g ganache-cli
|
run: sudo npm install -g ganache
|
||||||
- name: Run the beacon chain sim without an eth1 connection
|
- name: Run the beacon chain sim without an eth1 connection
|
||||||
run: cargo run --release --bin simulator no-eth1-sim
|
run: cargo run --release --bin simulator no-eth1-sim
|
||||||
syncing-simulator-ubuntu:
|
syncing-simulator-ubuntu:
|
||||||
@ -170,8 +180,8 @@ jobs:
|
|||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: Get latest version of stable Rust
|
- name: Get latest version of stable Rust
|
||||||
run: rustup update stable
|
run: rustup update stable
|
||||||
- name: Install ganache-cli
|
- name: Install ganache
|
||||||
run: sudo npm install -g ganache-cli
|
run: sudo npm install -g ganache
|
||||||
- name: Run the syncing simulator
|
- name: Run the syncing simulator
|
||||||
run: cargo run --release --bin simulator syncing-sim
|
run: cargo run --release --bin simulator syncing-sim
|
||||||
doppelganger-protection-test:
|
doppelganger-protection-test:
|
||||||
@ -182,8 +192,8 @@ jobs:
|
|||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: Get latest version of stable Rust
|
- name: Get latest version of stable Rust
|
||||||
run: rustup update stable
|
run: rustup update stable
|
||||||
- name: Install ganache-cli
|
- name: Install ganache
|
||||||
run: sudo npm install -g ganache-cli
|
run: sudo npm install -g ganache
|
||||||
- name: Install lighthouse and lcli
|
- name: Install lighthouse and lcli
|
||||||
run: |
|
run: |
|
||||||
make
|
make
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//! NOTE: These tests will not pass unless ganache-cli is running on `ENDPOINT` (see below).
|
//! NOTE: These tests will not pass unless ganache 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 `ganache_test_node.sh` script in the `scripts`
|
||||||
//! dir in the root of the `lighthouse` repo.
|
//! dir in the root of the `lighthouse` repo.
|
||||||
|
@ -9,9 +9,9 @@ particularly useful for development but still a good way to ensure you have the
|
|||||||
base dependencies.
|
base dependencies.
|
||||||
|
|
||||||
The additional requirements for developers are:
|
The additional requirements for developers are:
|
||||||
- [`ganache-cli`](https://github.com/trufflesuite/ganache-cli). This is used to
|
- [`ganache v7`](https://github.com/trufflesuite/ganache). This is used to
|
||||||
simulate the execution chain during tests. You'll get failures during tests if you
|
simulate the execution chain during tests. You'll get failures during tests if you
|
||||||
don't have `ganache-cli` available on your `PATH`.
|
don't have `ganache` available on your `PATH` or if ganache is older than v7.
|
||||||
- [`cmake`](https://cmake.org/cmake/help/latest/command/install.html). Used by
|
- [`cmake`](https://cmake.org/cmake/help/latest/command/install.html). Used by
|
||||||
some dependencies. See [`Installation Guide`](./installation.md) for more info.
|
some dependencies. See [`Installation Guide`](./installation.md) for more info.
|
||||||
- [`java 11 runtime`](https://openjdk.java.net/projects/jdk/). 11 is the minimum,
|
- [`java 11 runtime`](https://openjdk.java.net/projects/jdk/). 11 is the minimum,
|
||||||
|
@ -30,7 +30,7 @@ use validator_dir::ValidatorDir;
|
|||||||
|
|
||||||
// TODO: create tests for the `lighthouse account validator deposit` command. This involves getting
|
// TODO: create tests for the `lighthouse account validator deposit` command. This involves getting
|
||||||
// access to an IPC endpoint during testing or adding support for deposit submission via HTTP and
|
// access to an IPC endpoint during testing or adding support for deposit submission via HTTP and
|
||||||
// using ganache-cli.
|
// using ganache.
|
||||||
|
|
||||||
/// Returns the `lighthouse account` command.
|
/// Returns the `lighthouse account` command.
|
||||||
fn account_cmd() -> Command {
|
fn account_cmd() -> Command {
|
||||||
|
@ -4,7 +4,7 @@ set -Eeuo pipefail
|
|||||||
|
|
||||||
source ./vars.env
|
source ./vars.env
|
||||||
|
|
||||||
exec ganache-cli \
|
exec ganache \
|
||||||
--defaultBalanceEther 1000000000 \
|
--defaultBalanceEther 1000000000 \
|
||||||
--gasLimit 1000000000 \
|
--gasLimit 1000000000 \
|
||||||
--accounts 10 \
|
--accounts 10 \
|
||||||
@ -12,4 +12,4 @@ exec ganache-cli \
|
|||||||
--port 8545 \
|
--port 8545 \
|
||||||
--blockTime $SECONDS_PER_ETH1_BLOCK \
|
--blockTime $SECONDS_PER_ETH1_BLOCK \
|
||||||
--networkId "$NETWORK_ID" \
|
--networkId "$NETWORK_ID" \
|
||||||
--chainId "$NETWORK_ID"
|
--chain.chainId "$NETWORK_ID"
|
||||||
|
@ -86,10 +86,10 @@ execute_command_add_PID() {
|
|||||||
echo "$!" >> $PID_FILE
|
echo "$!" >> $PID_FILE
|
||||||
}
|
}
|
||||||
|
|
||||||
# Start ganache-cli, setup things up and start the bootnode.
|
# Start ganache, setup things up and start the bootnode.
|
||||||
# The delays are necessary, hopefully there is a better way :(
|
# The delays are necessary, hopefully there is a better way :(
|
||||||
|
|
||||||
# Delay to let ganache-cli to get started
|
# Delay to let ganache to get started
|
||||||
execute_command_add_PID ganache_test_node.log ./ganache_test_node.sh
|
execute_command_add_PID ganache_test_node.log ./ganache_test_node.sh
|
||||||
sleeping 10
|
sleeping 10
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Requires `lighthouse`, ``lcli`, `ganache-cli`, `curl`, `jq`
|
# Requires `lighthouse`, ``lcli`, `ganache`, `curl`, `jq`
|
||||||
|
|
||||||
BEHAVIOR=$1
|
BEHAVIOR=$1
|
||||||
|
|
||||||
|
@ -36,14 +36,14 @@ impl GanacheInstance {
|
|||||||
loop {
|
loop {
|
||||||
if start + Duration::from_millis(GANACHE_STARTUP_TIMEOUT_MILLIS) <= Instant::now() {
|
if start + Duration::from_millis(GANACHE_STARTUP_TIMEOUT_MILLIS) <= Instant::now() {
|
||||||
break Err(
|
break Err(
|
||||||
"Timed out waiting for ganache to start. Is ganache-cli installed?".to_string(),
|
"Timed out waiting for ganache to start. Is ganache installed?".to_string(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut line = String::new();
|
let mut line = String::new();
|
||||||
if let Err(e) = reader.read_line(&mut line) {
|
if let Err(e) = reader.read_line(&mut line) {
|
||||||
break Err(format!("Failed to read line from ganache process: {:?}", e));
|
break Err(format!("Failed to read line from ganache process: {:?}", e));
|
||||||
} else if line.starts_with("Listening on") {
|
} else if line.starts_with("RPC Listening on") {
|
||||||
break Ok(());
|
break Ok(());
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
@ -69,13 +69,13 @@ impl GanacheInstance {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Start a new `ganache-cli` process, waiting until it indicates that it is ready to accept
|
/// Start a new `ganache` process, waiting until it indicates that it is ready to accept
|
||||||
/// RPC connections.
|
/// RPC connections.
|
||||||
pub fn new(network_id: u64, chain_id: u64) -> Result<Self, String> {
|
pub fn new(network_id: u64, chain_id: u64) -> Result<Self, String> {
|
||||||
let port = unused_tcp_port()?;
|
let port = unused_tcp_port()?;
|
||||||
let binary = match cfg!(windows) {
|
let binary = match cfg!(windows) {
|
||||||
true => "ganache-cli.cmd",
|
true => "ganache.cmd",
|
||||||
false => "ganache-cli",
|
false => "ganache",
|
||||||
};
|
};
|
||||||
let child = Command::new(binary)
|
let child = Command::new(binary)
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
@ -85,15 +85,13 @@ impl GanacheInstance {
|
|||||||
.arg("1000000000")
|
.arg("1000000000")
|
||||||
.arg("--accounts")
|
.arg("--accounts")
|
||||||
.arg("10")
|
.arg("10")
|
||||||
.arg("--keepAliveTimeout")
|
|
||||||
.arg("0")
|
|
||||||
.arg("--port")
|
.arg("--port")
|
||||||
.arg(format!("{}", port))
|
.arg(format!("{}", port))
|
||||||
.arg("--mnemonic")
|
.arg("--mnemonic")
|
||||||
.arg("\"vast thought differ pull jewel broom cook wrist tribe word before omit\"")
|
.arg("\"vast thought differ pull jewel broom cook wrist tribe word before omit\"")
|
||||||
.arg("--networkId")
|
.arg("--networkId")
|
||||||
.arg(format!("{}", network_id))
|
.arg(format!("{}", network_id))
|
||||||
.arg("--chainId")
|
.arg("--chain.chainId")
|
||||||
.arg(format!("{}", chain_id))
|
.arg(format!("{}", chain_id))
|
||||||
.spawn()
|
.spawn()
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
@ -110,8 +108,8 @@ impl GanacheInstance {
|
|||||||
pub fn fork(&self) -> Result<Self, String> {
|
pub fn fork(&self) -> Result<Self, String> {
|
||||||
let port = unused_tcp_port()?;
|
let port = unused_tcp_port()?;
|
||||||
let binary = match cfg!(windows) {
|
let binary = match cfg!(windows) {
|
||||||
true => "ganache-cli.cmd",
|
true => "ganache.cmd",
|
||||||
false => "ganache-cli",
|
false => "ganache",
|
||||||
};
|
};
|
||||||
let child = Command::new(binary)
|
let child = Command::new(binary)
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
@ -119,9 +117,7 @@ impl GanacheInstance {
|
|||||||
.arg(self.endpoint())
|
.arg(self.endpoint())
|
||||||
.arg("--port")
|
.arg("--port")
|
||||||
.arg(format!("{}", port))
|
.arg(format!("{}", port))
|
||||||
.arg("--keepAliveTimeout")
|
.arg("--chain.chainId")
|
||||||
.arg("0")
|
|
||||||
.arg("--chainId")
|
|
||||||
.arg(format!("{}", self.chain_id))
|
.arg(format!("{}", self.chain_id))
|
||||||
.spawn()
|
.spawn()
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
@ -178,8 +174,7 @@ impl GanacheInstance {
|
|||||||
.await
|
.await
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
.map_err(|_| {
|
.map_err(|_| {
|
||||||
"utils should mine new block with evm_mine (only works with ganache-cli!)"
|
"utils should mine new block with evm_mine (only works with ganache!)".to_string()
|
||||||
.to_string()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! Provides utilities for deploying and manipulating the eth2 deposit contract on the eth1 chain.
|
//! Provides utilities for deploying and manipulating the eth2 deposit contract on the eth1 chain.
|
||||||
//!
|
//!
|
||||||
//! Presently used with [`ganache-cli`](https://github.com/trufflesuite/ganache-cli) to simulate
|
//! Presently used with [`ganache`](https://github.com/trufflesuite/ganache) to simulate
|
||||||
//! the deposit contract for testing beacon node eth1 integration.
|
//! the deposit contract for testing beacon node eth1 integration.
|
||||||
//!
|
//!
|
||||||
//! Not tested to work with actual clients (e.g., geth). It should work fine, however there may be
|
//! Not tested to work with actual clients (e.g., geth). It should work fine, however there may be
|
||||||
@ -23,7 +23,7 @@ use web3::Web3;
|
|||||||
pub const DEPLOYER_ACCOUNTS_INDEX: usize = 0;
|
pub const DEPLOYER_ACCOUNTS_INDEX: usize = 0;
|
||||||
pub const DEPOSIT_ACCOUNTS_INDEX: usize = 0;
|
pub const DEPOSIT_ACCOUNTS_INDEX: usize = 0;
|
||||||
|
|
||||||
/// Provides a dedicated ganache-cli instance with the deposit contract already deployed.
|
/// Provides a dedicated ganache instance with the deposit contract already deployed.
|
||||||
pub struct GanacheEth1Instance {
|
pub struct GanacheEth1Instance {
|
||||||
pub ganache: GanacheInstance,
|
pub ganache: GanacheInstance,
|
||||||
pub deposit_contract: DepositContract,
|
pub deposit_contract: DepositContract,
|
||||||
|
@ -10,7 +10,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
|||||||
.about(
|
.about(
|
||||||
"Lighthouse Beacon Chain Simulator creates `n` beacon node and validator clients, \
|
"Lighthouse Beacon Chain Simulator creates `n` beacon node and validator clients, \
|
||||||
each with `v` validators. A deposit contract is deployed at the start of the \
|
each with `v` validators. A deposit contract is deployed at the start of the \
|
||||||
simulation using a local `ganache-cli` instance (you must have `ganache-cli` \
|
simulation using a local `ganache` instance (you must have `ganache` \
|
||||||
installed and avaliable on your path). All beacon nodes independently listen \
|
installed and avaliable on your path). All beacon nodes independently listen \
|
||||||
for genesis from the deposit contract, then start operating. \
|
for genesis from the deposit contract, then start operating. \
|
||||||
\
|
\
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
//! This crate provides a simluation that creates `n` beacon node and validator clients, each with
|
//! This crate provides a simluation that creates `n` beacon node and validator clients, each with
|
||||||
//! `v` validators. A deposit contract is deployed at the start of the simulation using a local
|
//! `v` validators. A deposit contract is deployed at the start of the simulation using a local
|
||||||
//! `ganache-cli` instance (you must have `ganache-cli` installed and avaliable on your path). All
|
//! `ganache` instance (you must have `ganache` installed and avaliable on your path). All
|
||||||
//! beacon nodes independently listen for genesis from the deposit contract, then start operating.
|
//! beacon nodes independently listen for genesis from the deposit contract, then start operating.
|
||||||
//!
|
//!
|
||||||
//! As the simulation runs, there are checks made to ensure that all components are running
|
//! As the simulation runs, there are checks made to ensure that all components are running
|
||||||
|
Loading…
Reference in New Issue
Block a user