Skip to content

Commit

Permalink
Clean up scripts (#12)
Browse files Browse the repository at this point in the history
* Clean up scripts

* Update workflow paths

* Run with bash:
  • Loading branch information
dapplion authored Sep 28, 2024
1 parent 7e83d93 commit cab0a46
Show file tree
Hide file tree
Showing 25 changed files with 115 additions and 51 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/post-merge-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ jobs:
run: jq --help
# Vectors are already generated, but this serves as a test
- name: Generate vectors
run: ./generate_test_vectors.sh
run: bash ./scripts/generate_test_vectors_nethermind.sh
# Test vectors against nethermind
- name: Apply vectors to Nethermind
run: ./apply_test_vectors_nethermind.sh
run: bash ./scripts/apply_test_vectors_nethermind.sh
# Test vectors against Reth
- name: Apply vectors to Reth
run: ./apply_test_vectors_reth.sh
run: bash ./scripts/apply_test_vectors_reth.sh


8 changes: 0 additions & 8 deletions apply_test_vectors_nethermind.sh

This file was deleted.

7 changes: 0 additions & 7 deletions apply_test_vectors_reth.sh

This file was deleted.

5 changes: 4 additions & 1 deletion apply_test_vectors.sh → scripts/apply_test_vectors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ set -e

# Expects reth to be running on the background

OUT_DIR=./blocks
# Script's directory
DIR="$(dirname "$0")"

OUT_DIR=$DIR/blocks

N=5

Expand Down
20 changes: 20 additions & 0 deletions scripts/apply_test_vectors_nethermind.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -e

# Script's directory
DIR="$(dirname "$0")"

$DIR/run_nethermind.sh &
BG_PID=$!

# Set the trap to call cleanup
cleanup() {
echo "Stopping node process (PID: $BG_PID)..."
kill $BG_PID 2>/dev/null || true
# Also force clean the docker container, killing the attached process is not enough
docker rm -f neth-vec-gen 2>/dev/null || true
}
trap cleanup EXIT

$DIR/apply_test_vectors.sh

19 changes: 19 additions & 0 deletions scripts/apply_test_vectors_reth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -e

# Script's directory
DIR="$(dirname "$0")"

$DIR/run_reth.sh &
BG_PID=$!

# Set the trap to call cleanup if an error occurs
cleanup() {
echo "Stopping node process (PID: $BG_PID)..."
kill $BG_PID 2>/dev/null || true
}
trap cleanup EXIT

$DIR/apply_test_vectors.sh


File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
33 changes: 5 additions & 28 deletions generate_test_vectors.sh → scripts/generate_test_vectors.sh
Original file line number Diff line number Diff line change
@@ -1,40 +1,20 @@
#!/bin/bash
set -e

# Script to generate test vectors from Nethermind. It connects to the engine API of Nethermid to produce
# Script to generate test vectors for a running client. It connects to the engine API at :8546 to produce
# blocks on the genesis block and stores them in $OUT_DIR. The jwtsecret is hardcoded, do not modify it.
# To run just do:
#
# ```
# ./generate_test_vectors.sh
# ```

OUT_DIR=./blocks
# Script's directory
DIR="$(dirname "$0")"

OUT_DIR=$DIR/blocks
mkdir -p $OUT_DIR

# Clean up existing container if it exists
docker rm -f neth-vec-gen 2>/dev/null

# Start the container in the background
docker run --name neth-vec-gen --rm -d \
-v $PWD/networkdata:/networkdata \
-p 8545:8545 \
-p 8546:8546 \
nethermind/nethermind \
--config=none \
--Init.ChainSpecPath=/networkdata/chainspec.json \
--Init.DiscoveryEnabled=false \
--JsonRpc.Enabled=true \
--JsonRpc.Host=0.0.0.0 \
--JsonRpc.Port=8545 \
--JsonRpc.EngineHost=0.0.0.0 \
--JsonRpc.EnginePort=8546 \
--JsonRpc.JwtSecretFile=/networkdata/jwtsecret \
--TraceStore.Enabled=true
# --Init.ExitOnBlockNumber=4 \

# Capture the logs in the background
docker logs -f neth-vec-gen &

# Retry the curl command until it succeeds
until curl -X POST -H "Content-Type: application/json" \
Expand Down Expand Up @@ -169,6 +149,3 @@ for ((i = 1; i <= N; i++)); do
make_block
done

# Clean up container
docker rm -f neth-vec-gen 2>/dev/null

28 changes: 28 additions & 0 deletions scripts/generate_test_vectors_nethermind.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
set -e

# Script to generate test vectors from Nethermind. It connects to the engine API of Nethermid to produce
# blocks on the genesis block and stores them in $OUT_DIR. The jwtsecret is hardcoded, do not modify it.
# To run just do:
#
# ```
# ./generate_test_vectors_nethermind.sh
# ```

# Script's directory
DIR="$(dirname "$0")"

$DIR/run_nethermind.sh &
BG_PID=$!

# Set the trap to call cleanup
cleanup() {
echo "Stopping node process (PID: $BG_PID)..."
kill $BG_PID 2>/dev/null || true
# Also force clean the docker container, killing the attached process is not enough
docker rm -f neth-vec-gen 2>/dev/null || true
}
trap cleanup EXIT

$DIR/generate_test_vectors.sh

26 changes: 26 additions & 0 deletions scripts/generate_test_vectors_reth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -e

# Script to generate test vectors from Reth. It connects to the engine API of Reth to produce
# blocks on the genesis block and stores them in $OUT_DIR. The jwtsecret is hardcoded, do not modify it.
# To run just do:
#
# ```
# ./generate_test_vectors_reth.sh
# ```

# Script's directory
DIR="$(dirname "$0")"

$DIR/run_reth.sh &
BG_PID=$!

# Set the trap to call cleanup if an error occurs
cleanup() {
echo "Stopping node process (PID: $BG_PID)..."
kill $BG_PID 2>/dev/null || true
}
trap cleanup EXIT

$DIR/generate_test_vectors.sh

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 5 additions & 2 deletions run_nethermind.sh → scripts/run_nethermind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ set -e
# Script to run Nethermind dockerized and attach to it.
# The jwtsecret is hardcoded, do not modify it.

# Script's directory
DIR="$(dirname "$0")"

# Clean up existing container if it exists
docker rm -f neth-vec-gen 2>/dev/null

# Start the container in the background
# Start the container
docker run --name neth-vec-gen --rm \
-v $PWD/networkdata:/networkdata \
-v $DIR/networkdata:/networkdata \
-p 8545:8545 \
-p 8546:8546 \
nethermind/nethermind \
Expand Down
7 changes: 5 additions & 2 deletions run_reth.sh → scripts/run_reth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@ DATA_DIR=$TMPDIR/reth_test
# Ensure no data from previous tests
rm -rf $DATA_DIR

# Script's directory
DIR="$(dirname "$0")"

# $PWD/target/release/reth \
cargo run -- \
node \
-vvvv \
--chain=$PWD/chiado_genesis_alloc.json \
--chain=$DIR/chiado_genesis_alloc.json \
--datadir=$DATA_DIR \
--http \
--http.port=8545 \
--http.addr=0.0.0.0 \
--http.corsdomain='*' \
--http.api=admin,net,eth,web3,debug,trace \
--authrpc.port=8546 \
--authrpc.jwtsecret=$PWD/networkdata/jwtsecret \
--authrpc.jwtsecret=$DIR/networkdata/jwtsecret \
--authrpc.addr=0.0.0.0 \
--port=0 \
--disable-discovery
Expand Down

0 comments on commit cab0a46

Please sign in to comment.