Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post-merge test vectors from Nethermind to Reth #8

Merged
merged 9 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/post-merge-run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Test

on:
pull_request:
push:
branches:
- master

env:
REQWEST_TEST_BODY_FULL: 1
RUST_BACKTRACE: 1

jobs:
post-merge-run:
name: Test post merge run
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust || 'stable' }}
targets: ${{ matrix.target }}
- name: Setup docker (missing on MacOS)
if: runner.os == 'macos'
run: |
brew install docker
brew install docker-buildx
- name: Test jq is installed
run: jq --help
# Vectors are already generated, but this serves as a test
- name: Generate vectors
run: ./generate_test_vectors.sh
# Test vectors against nethermind
- name: Apply vectors to Nethermind
run: ./apply_test_vectors_nethermind.sh
# Test vectors against Reth
- name: Apply vectors to Reth
run: ./apply_test_vectors_reth.sh


1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ alloy-sol-types = "0.7.6"
revm = "11.0.0"
revm-primitives = "6.0.0"
serde_json = "1.0.117"
hex = "0.4.3"

[target.'cfg(unix)'.dependencies]
tikv-jemallocator = { version = "0.5.0", optional = true }
Expand Down
73 changes: 73 additions & 0 deletions apply_test_vectors.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash
set -e

# Expects reth to be running on the background

OUT_DIR=./blocks

N=5

# Retry the curl command until it succeeds
until curl -X POST -H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x0", false],"id":1}' \
http://localhost:8545; do
echo "Retrying..."
sleep 2
done


function apply_block_file() {
BLOCK_FILEPATH=$1
BLOCK=$(<$BLOCK_FILEPATH)
echo Applying $BLOCK

# The ASCII representation of `2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a`
JWT_SECRET="********************************"
# Generate a JWT token using the secret key
# jwt is this CLI tool https://github.com/mike-engel/jwt-cli/tree/main
# iat is appended automatically
JWT_TOKEN=$(jwt encode --alg HS256 --secret "$JWT_SECRET")
echo JWT_TOKEN: $JWT_TOKEN

RESPONSE=$(curl -X POST -H "Content-Type: application/json" \
-H "Authorization: Bearer $JWT_TOKEN" \
--data "{
\"jsonrpc\":\"2.0\",
\"method\":\"engine_newPayloadV1\",
\"params\":[
$BLOCK
],
\"id\":1
}" \
http://localhost:8546 \
)
echo engine_newPayloadV1 with new block RESPONSE $RESPONSE

BLOCK_HASH=$(echo $BLOCK | jq --raw-output '.blockHash')

RESPONSE=$(curl -X POST -H "Content-Type: application/json" \
-H "Authorization: Bearer $JWT_TOKEN" \
--data "{
\"jsonrpc\":\"2.0\",
\"method\":\"engine_forkchoiceUpdatedV1\",
\"params\":[
{
\"headBlockHash\": \"$BLOCK_HASH\",
\"safeBlockHash\": \"0x0000000000000000000000000000000000000000000000000000000000000000\",
\"finalizedBlockHash\": \"0x0000000000000000000000000000000000000000000000000000000000000000\"
},
null
],
\"id\":1
}" \
http://localhost:8546 \
)
echo engine_forkchoiceUpdatedV1 set new block as head RESPONSE $RESPONSE
}


for ((i = 1; i <= N; i++)); do
BLOCK_FILEPATH=$OUT_DIR/block_$i.json
apply_block_file $BLOCK_FILEPATH
done

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

./run_nethermind.sh &
./apply_test_vectors.sh
# TODO more resilient shutdown
docker rm -f neth-vec-gen 2>/dev/null

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

./run_reth.sh &
./apply_test_vectors.sh


16 changes: 16 additions & 0 deletions blocks/block_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"baseFeePerGas": "0x342770c0",
"blockHash": "0xc0f683b61355455d49af3dbb11fe1f65e9ae8670890d6fb1aadcbf5f8acc960b",
"blockNumber": "0x1",
"extraData": "0x4e65746865726d696e64",
"feeRecipient": "0x0000000000000000000000000000000000000000",
"gasLimit": "0x989680",
"gasUsed": "0x0",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"parentHash": "0xa7931c99fd2b7b5e323a2fda8a2dd607cea04f03835c3f29bfe7c057c8b5672e",
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot": "0xa59f6ea19d9ee6d7e79bcb286e6d8838b47b48351b37960e24c0a72d41fa1629",
"timestamp": "0x6553f101",
"transactions": []
}
16 changes: 16 additions & 0 deletions blocks/block_2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"baseFeePerGas": "0x2da282a8",
"blockHash": "0xc314b27368528ec560d035ef9f5dc46e2aea6d21b618eeb37e91723fefdfb2d9",
"blockNumber": "0x2",
"extraData": "0x4e65746865726d696e64",
"feeRecipient": "0x0000000000000000000000000000000000000000",
"gasLimit": "0x989680",
"gasUsed": "0x0",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"parentHash": "0xc0f683b61355455d49af3dbb11fe1f65e9ae8670890d6fb1aadcbf5f8acc960b",
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot": "0xa59f6ea19d9ee6d7e79bcb286e6d8838b47b48351b37960e24c0a72d41fa1629",
"timestamp": "0x6553f102",
"transactions": []
}
16 changes: 16 additions & 0 deletions blocks/block_3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"baseFeePerGas": "0x27ee3253",
"blockHash": "0xd51a4d79676ddad8e938c38ec1344a77feefa369475acb358563f37a74a4d9d6",
"blockNumber": "0x3",
"extraData": "0x4e65746865726d696e64",
"feeRecipient": "0x0000000000000000000000000000000000000000",
"gasLimit": "0x989680",
"gasUsed": "0x0",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"parentHash": "0xc314b27368528ec560d035ef9f5dc46e2aea6d21b618eeb37e91723fefdfb2d9",
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot": "0xa59f6ea19d9ee6d7e79bcb286e6d8838b47b48351b37960e24c0a72d41fa1629",
"timestamp": "0x6553f103",
"transactions": []
}
16 changes: 16 additions & 0 deletions blocks/block_4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"baseFeePerGas": "0x22f06c09",
"blockHash": "0x011405450b1431877c952c73d0ea0c964c67d006b3134aea5be7a59823e40e39",
"blockNumber": "0x4",
"extraData": "0x4e65746865726d696e64",
"feeRecipient": "0x0000000000000000000000000000000000000000",
"gasLimit": "0x989680",
"gasUsed": "0x0",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"parentHash": "0xd51a4d79676ddad8e938c38ec1344a77feefa369475acb358563f37a74a4d9d6",
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot": "0xa59f6ea19d9ee6d7e79bcb286e6d8838b47b48351b37960e24c0a72d41fa1629",
"timestamp": "0x6553f104",
"transactions": []
}
16 changes: 16 additions & 0 deletions blocks/block_5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"baseFeePerGas": "0x1e925e88",
"blockHash": "0x9a86f6d4d524388c300b8a09a145d0406fcf13d343ef8574c46fc0ffad9a45a0",
"blockNumber": "0x5",
"extraData": "0x4e65746865726d696e64",
"feeRecipient": "0x0000000000000000000000000000000000000000",
"gasLimit": "0x989680",
"gasUsed": "0x0",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"parentHash": "0x011405450b1431877c952c73d0ea0c964c67d006b3134aea5be7a59823e40e39",
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot": "0xa59f6ea19d9ee6d7e79bcb286e6d8838b47b48351b37960e24c0a72d41fa1629",
"timestamp": "0x6553f105",
"transactions": []
}
7 changes: 4 additions & 3 deletions chiado_genesis_alloc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
},
"terminalTotalDifficulty": 0,
"terminalTotalDifficultyPassed": true,
"shanghaiTime": 1704401480,
"cancunTime": 1704403000,
"shanghaiTime": 9999999999,
"cancunTime": 9999999999,
"minBlobGasPrice": 1000000000,
"maxBlobGasPerBlock": 262144,
"targetBlobGasPerBlock": 131072,
"blobGasPriceUpdateFraction": 1112826,
"blockRewardsContract": "0x2000000000000000000000000000000000000001",
"aura": {
"stepDuration": 5,
"blockReward": 0,
Expand Down Expand Up @@ -416,4 +417,4 @@
"code": ""
}
}
}
}
Loading
Loading