Skip to content

Commit

Permalink
Add missing download image step and remove unused lcli dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmygchen committed May 31, 2024
1 parent be80833 commit 41a3ee3
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 22 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/local-testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: jpribyl/action-docker-layer-caching@v0.1.1
# Ignore the failure of a step and avoid terminating the job.
continue-on-error: true

- name: Build Docker image
run: |
docker build --build-arg FEATURES=portable -t lighthouse:local .
Expand Down Expand Up @@ -45,6 +49,15 @@ jobs:
sudo apt install -y kurtosis-cli yq
kurtosis analytics disable
- name: Download Docker image artifact
uses: actions/download-artifact@v4
with:
name: lighthouse-docker
path: .

- name: Load Docker image
run: docker load -i lighthouse-docker.tar

- name: Start local testnet
run: ./start_local_testnet.sh -e local -c -b false && sleep 60
working-directory: scripts/local_testnet
Expand Down Expand Up @@ -84,6 +97,15 @@ jobs:
sudo apt install -y kurtosis-cli yq
kurtosis analytics disable
- name: Download Docker image artifact
uses: actions/download-artifact@v4
with:
name: lighthouse-docker
path: .

- name: Load Docker image
run: docker load -i lighthouse-docker.tar

- name: Run the doppelganger protection failure test script
run: |
./doppelganger_protection.sh failure
Expand Down
3 changes: 0 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions lcli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@ ethereum_hashing = { workspace = true }
ethereum_ssz = { workspace = true }
environment = { workspace = true }
eth2_network_config = { workspace = true }
genesis = { workspace = true }
deposit_contract = { workspace = true }
tree_hash = { workspace = true }
clap_utils = { workspace = true }
lighthouse_network = { workspace = true }
validator_dir = { workspace = true, features = ["insecure_keys"] }
validator_dir = { workspace = true }
lighthouse_version = { workspace = true }
account_utils = { workspace = true }
eth2_wallet = { workspace = true }
eth1_test_rig = { workspace = true }
sensitive_url = { workspace = true }
eth2 = { workspace = true }
snap = { workspace = true }
beacon_chain = { workspace = true }
Expand Down
9 changes: 5 additions & 4 deletions scripts/local_testnet/stop_local_testnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ set -Eeuo pipefail

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
ENCLAVE_NAME=${1:-local-testnet}
LOGS_PATH=$SCRIPT_DIR/logs/$ENCLAVE_NAME
LOGS_PATH=$SCRIPT_DIR/logs
LOGS_SUBDIR=$LOGS_PATH/$ENCLAVE_NAME

rm -rf $LOGS_PATH
# Make sure parent directory exists.
mkdir -p $LOGS_PATH
kurtosis enclave dump $ENCLAVE_NAME $LOGS_PATH
echo "Local testnet logs stored to $LOGS_PATH."
kurtosis enclave dump $ENCLAVE_NAME $LOGS_SUBDIR
echo "Local testnet logs stored to $LOGS_SUBDIR."

kurtosis enclave rm -f $ENCLAVE_NAME
echo "Local testnet stopped."
28 changes: 17 additions & 11 deletions scripts/tests/doppelganger_protection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Requires `docker`, `kurtosis`, `yq`, `curl`, `jq`

set -Eeuo pipefail
set -u

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
NETWORK_PARAMS_FILE=$SCRIPT_DIR/network_params.yaml
Expand Down Expand Up @@ -35,15 +35,15 @@ function check_service_exit_with_timeout() {
function exit_and_dump_logs() {
local exit_code=$1
echo "Shutting down"
$SCRIPT_DIR/../local_testnet/stop_local_testnet.sh
$SCRIPT_DIR/../local_testnet/stop_local_testnet.sh $ENCLAVE_NAME
echo "Done"
exit $exit_code
}

# Start local testnet
$SCRIPT_DIR/../local_testnet/start_local_testnet.sh -e $ENCLAVE_NAME -b false -c -n $NETWORK_PARAMS_FILE

# Immediately stop node 4
# Immediately stop node 4 (as we only need the node 4 validator keys generated for later use)
kurtosis service stop $ENCLAVE_NAME cl-4-lighthouse-geth el-4-geth-lighthouse vc-4-geth-lighthouse

echo "Waiting an epoch before starting the next validator client"
Expand Down Expand Up @@ -97,10 +97,12 @@ if [[ "$BEHAVIOR" == "success" ]]; then
vc_4_range_start=$(($KEYS_PER_NODE * 3))
vc_4_range_end=$(($KEYS_PER_NODE * 4 - 1))
vc_4_keys_artifact_id="4-lighthouse-geth-$vc_4_range_start-$vc_4_range_end-0"
vc_port=5062
service_name=vc-4

kurtosis service add \
--files /validator_keys:$vc_4_keys_artifact_id,/testnet:el_cl_genesis_data \
--ports http=:$vc_port/tcp \
$ENCLAVE_NAME $service_name $LH_IMAGE_NAME -- lighthouse \
vc \
--debug-level debug \
Expand All @@ -110,7 +112,9 @@ if [[ "$BEHAVIOR" == "success" ]]; then
--init-slashing-protection \
--beacon-nodes=http://$bn_2_url:$bn_2_port \
--enable-doppelganger-protection \
--suggested-fee-recipient 0x690B9A9E9aa1C9dB991C7721a92d351Db4FaC990
--suggested-fee-recipient 0x690B9A9E9aa1C9dB991C7721a92d351Db4FaC990 \
--http \
--http-port $vc_port

doppelganger_failure=0

Expand All @@ -123,7 +127,7 @@ if [[ "$BEHAVIOR" == "success" ]]; then

# Get BN2 localhost URL
bn2_2_local_url=$(kurtosis enclave inspect $ENCLAVE_NAME | grep 'cl-2-lighthouse-geth' | grep -oP 'http://[^ ]+')
echo "Performing checks using BN: $bn2_2_local_url"
echo "Performing checks using beacon node 2: $bn2_2_local_url"

# Get VC4 validator keys
keys_path=$SCRIPT_DIR/$ENCLAVE_NAME/node_4/validators
Expand All @@ -133,9 +137,8 @@ if [[ "$BEHAVIOR" == "success" ]]; then

for val in 0x*; do
[[ -e $val ]] || continue
resp=$(curl -s $bn2_2_local_url/lighthouse/validator_inclusion/3/$val)
# TODO: error handling
is_attester=$(echo $resp | jq | grep -q '"is_previous_epoch_target_attester": false')
curl -s $bn2_2_local_url/lighthouse/validator_inclusion/3/$val | jq | grep -q '"is_previous_epoch_target_attester": false'
is_attester=$?
if [[ $is_attester -eq 0 ]]; then
echo "$val did not attest in epoch 2."
else
Expand All @@ -144,6 +147,10 @@ if [[ "$BEHAVIOR" == "success" ]]; then
fi
done

if [[ $doppelganger_failure -eq 1 ]]; then
exit_and_dump_logs 1
fi

# Sleep two epochs, then make sure all validators were active in epoch 4. Use
# `is_previous_epoch_target_attester` from epoch 5 for a complete view of epoch 4 inclusion.
#
Expand All @@ -152,9 +159,8 @@ if [[ "$BEHAVIOR" == "success" ]]; then
sleep $(( $SECONDS_PER_SLOT * 32 * 2 ))
for val in 0x*; do
[[ -e $val ]] || continue
resp=$(curl -s $bn2_2_host_url/lighthouse/validator_inclusion/5/$val)
# TODO: error handling
is_attester=$(echo $resp | jq | grep -q '"is_previous_epoch_target_attester": true')
curl -s $bn2_2_host_url/lighthouse/validator_inclusion/5/$val | jq | grep -q '"is_previous_epoch_target_attester": true'
is_attester=$?
if [[ $is_attester -eq 0 ]]; then
echo "$val attested in epoch 4."
else
Expand Down

0 comments on commit 41a3ee3

Please sign in to comment.