Skip to content

Commit

Permalink
Error early if apply test vectors returns INVALID payload (#20)
Browse files Browse the repository at this point in the history
* ci fixes

* resolving comments
  • Loading branch information
debjit-bw authored Oct 16, 2024
1 parent ec71c67 commit dbea759
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/post-merge-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
brew install docker-buildx
- name: Test jq is installed
run: jq --help
- name: Install jwt and add to path
run: cargo install jwt-cli && export PATH=$HOME/.cargo/bin:$PATH
# Vectors are already generated, but this serves as a test
- name: Generate vectors
run: bash ./scripts/generate_test_vectors_nethermind.sh
Expand Down
9 changes: 9 additions & 0 deletions scripts/apply_test_vectors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ function apply_block_file() {
http://localhost:8546 \
)
echo engine_forkchoiceUpdatedV1 set new block as head RESPONSE $RESPONSE


PAYLOAD_STATUS=$(echo $RESPONSE | jq --raw-output '.result.payloadStatus.status')
echo PAYLOAD_STATUS: $PAYLOAD_STATUS
# If the status is not "VALID", exit the script with a non-zero code to make CI fail
if [ "$PAYLOAD_STATUS" != "VALID" ]; then
echo "Error: Payload status is $PAYLOAD_STATUS, failing CI."
exit 1
fi
}


Expand Down
22 changes: 18 additions & 4 deletions scripts/generate_test_vectors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,28 @@ until curl -X POST -H "Content-Type: application/json" \
sleep 2
done

BLOCK_COUNTER=0
echo "EL is available"

declare -i BLOCK_COUNTER=0

function make_block() {
((BLOCK_COUNTER++))
# increment block counter
BLOCK_COUNTER=$((BLOCK_COUNTER + 1))

echo "Making block $BLOCK_COUNTER"

HEAD_BLOCK=$(curl -X POST -H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", false],"id":1}' \
http://localhost:8545)
--data "{
\"jsonrpc\":\"2.0\",
\"method\":\"eth_getBlockByNumber\",
\"params\":[
\"latest\",
false
],
\"id\":1
}" \
http://localhost:8545 \
)

# --raw-output remove the double quotes
HEAD_BLOCK_HASH=$(echo $HEAD_BLOCK | jq --raw-output '.result.hash')
Expand Down
3 changes: 3 additions & 0 deletions scripts/run_reth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#
# reth genesis from https://github.com/ethpandaops/ethereum-genesis-generator/blob/a4b6733ea9d47b2b2ec497f5212f0265b83fb601/apps/el-gen/genesis_geth.py#L34

# if TMPDIR is empty, use /tmp
TMPDIR=${TMPDIR:-/tmp}

DATA_DIR=$TMPDIR/reth_test
# Ensure no data from previous tests
rm -rf $DATA_DIR
Expand Down

0 comments on commit dbea759

Please sign in to comment.