add initial merge test vector scripts

This commit is contained in:
Dustin Brody 2021-09-30 03:00:25 +00:00
parent 6b3bf7eb7b
commit 4a26e48226
No known key found for this signature in database
GPG Key ID: 3D7A11A0156519DC
2 changed files with 86 additions and 28 deletions

View File

@ -0,0 +1,42 @@
#!/usr/bin/env bash
set -Eeuo pipefail
# https://notes.ethereum.org/@9AeMAlpyQYaAAyuj47BzRw/rkwW3ceVY
#
# git clone --branch merge-interop-spec https://github.com/MariusVanDerWijden/go-ethereum.git
#
# Last checked against geth as of
# commit d6b04900423634d27be1178edf46622394085bb9 (HEAD -> merge-interop-spec, origin/merge-interop-spec)
# Author: Marius van der Wijden <m.vanderwijden@live.de>
# Date: Wed Sep 29 19:24:56 2021 +0200
#
# eth/catalyst: fix random in payload, payloadid as hexutil
# Prepare a payload
resp_prepare_payload=$(curl -sX POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"engine_preparePayload","params":[{"parentHash":"0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131", "timestamp":"0x5", "random":"0x0000000000000000000000000000000000000000000000000000000000000000", "feeRecipient":"0x0000000000000000000000000000000000000000"}],"id":67}' http://localhost:8545)
echo "engine_preparePayload response: ${resp_prepare_payload}"
# Interop version of response, not current main version of response
[[ ${resp_prepare_payload} == '{"jsonrpc":"2.0","id":67,"result":"0x0"}' ]] || (echo "Unexpected response to engine_preparePayload"; false)
# Get the payload
resp_get_payload=$(curl -sX POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"engine_getPayload","params":["0x0"],"id":67}' http://localhost:8545)
echo "engine_getPayload response: ${resp_get_payload}"
expected_resp_get_payload='{"jsonrpc":"2.0","id":67,"result":{"blockHash":"0xb084c10440f05f5a23a55d1d7ebcb1b3892935fb56f23cdc9a7f42c348eed174","parentHash":"0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131","coinbase":"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b","stateRoot":"0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45","receiptRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","random":"0x0000000000000000000000000000000000000000000000000000000000000000","blockNumber":"0x1","gasLimit":"0x989680","gasUsed":"0x0","timestamp":"0x5","extraData":"0x","baseFeePerGas":"0x0","transactions":[]}}'
empirical_resp_get_payload='{"jsonrpc":"2.0","id":67,"result":{"blockHash":"0x7a694c5e6e372e6f865b073c101c2fba01f899f16480eb13f7e333a3b7e015bc","parentHash":"0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131","coinbase":"0x0000000000000000000000000000000000000000","stateRoot":"0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45","receiptRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","random":"0x0000000000000000000000000000000000000000000000000000000000000000","blockNumber":"0x1","gasLimit":"0x989680","gasUsed":"0x0","timestamp":"0x5","extraData":"0x","baseFeePerGas":"0x0","transactions":[]}}'
[[ ${resp_get_payload} == ${expected_resp_get_payload} ]] || [[ ${resp_get_payload} == ${empirical_resp_get_payload} ]] || (echo "Unexpected response to engine_getPayload"; false)
# Execute the payload
# Needed two tweaks vs upstream note: (a) add blockNumber field and (b) switch receiptRoots to receiptRoot
resp_execute_payload=$(curl -sX POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"engine_executePayload","params":[{"blockHash":"0xb084c10440f05f5a23a55d1d7ebcb1b3892935fb56f23cdc9a7f42c348eed174","parentHash":"0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131","coinbase":"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b","stateRoot":"0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45","receiptRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","random":"0x0000000000000000000000000000000000000000000000000000000000000000","number":"0x1","gasLimit":"0x989680","gasUsed":"0x0","blockNumber":"0x1","timestamp":"0x5","extraData":"0x","baseFeePerGas":"0x0","transactions":[]}],"id":67}' http://localhost:8545)
[[ ${resp_execute_payload} == '{"jsonrpc":"2.0","id":67,"result":{"status":"VALID"}}' ]] || (echo "Unexpected response to engine_executePayload"; false)
# Mark the payload as valid
resp_consensus_validated=$(curl -sX POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"engine_consensusValidated","params":[{"blockHash":"0xb084c10440f05f5a23a55d1d7ebcb1b3892935fb56f23cdc9a7f42c348eed174", "status":"VALID"}],"id":67}' http://localhost:8545)
[[ ${resp_consensus_validated} == '{"jsonrpc":"2.0","id":67,"result":null}' ]] || (echo "Unexpected response to engine_consensusValidated"; false)
# Update the fork choice
resp_fork_choice_updated=$(curl -sX POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"engine_forkChoiceUpdated","params":[{"headBlockHash":"0xb084c10440f05f5a23a55d1d7ebcb1b3892935fb56f23cdc9a7f42c348eed174", "finalizedBlockHash":"0xb084c10440f05f5a23a55d1d7ebcb1b3892935fb56f23cdc9a7f42c348eed174"}],"id":67}' http://localhost:8545)
[[ ${resp_consensus_validated} == '{"jsonrpc":"2.0","id":67,"result":null}' ]] || (echo "Unexpected response to engine_forkChoiceUpdated"; false)
echo "Execution test vectors for Merge passed"

View File

@ -1,36 +1,52 @@
#!/usr/bin/env bash
# set -Eeuo pipefail
# https://github.com/prysmaticlabs/bazel-go-ethereum/blob/catalyst/run-catalyst.sh
# https://notes.ethereum.org/@9AeMAlpyQYaAAyuj47BzRw/rkwW3ceVY
# To increase verbosity: debug.verbosity(4)
# MetaMask seed phrase for address with balance is:
# lecture manual soon title cloth uncle gesture cereal common fruit tooth crater
echo \{ \
\"config\": \{ \
\"chainId\": 220720, \
\"homesteadBlock\": 0, \
\"eip150Block\": 0, \
\"eip155Block\": 0, \
\"eip158Block\": 0, \
\"byzantiumBlock\": 0, \
\"constantinopleBlock\": 0, \
\"petersburgBlock\": 0, \
\"istanbulBlock\": 0, \
\"catalystBlock\": 0 \
\}, \
\"alloc\": \{\"0x4A55eF8869af149aea4E07874cd8598044Eea2cb\": \{\"balance\": \"1000000000000000000\"\}\}, \
\"coinbase\": \"0x0000000000000000000000000000000000000000\", \
\"difficulty\": \"0x20000\", \
\"extraData\": \"\", \
\"gasLimit\": \"0x2fefd8\", \
\"nonce\": \"0x0000000000220720\", \
\"mixhash\": \"0x0000000000000000000000000000000000000000000000000000000000000000\", \
\"parentHash\": \"0x0000000000000000000000000000000000000000000000000000000000000000\", \
\"timestamp\": \"0x00\" \
\} > /tmp/catalystgenesis.json
GENESISJSON=$(mktemp)
GETHDATADIR=$(mktemp -d)
# TODO these paths need to be generalized
rm /tmp/catalystchaindata -rvf
~/clients/catalyst/build/bin/catalyst --catalyst --datadir /tmp/catalystchaindata init /tmp/catalystgenesis.json
~/clients/catalyst/build/bin/catalyst --catalyst --rpc --rpcapi net,eth,eth2,consensus,catalyst --nodiscover --miner.etherbase 0x1000000000000000000000000000000000000000 --datadir /tmp/catalystchaindata console
echo \{\
\"config\": \{\
\"chainId\":1,\
\"homesteadBlock\":0,\
\"daoForkBlock\":0,\
\"daoForkSupport\":true,\
\"eip150Block\":0,\
\"eip155Block\":0,\
\"eip158Block\":0,\
\"byzantiumBlock\":0,\
\"constantinopleBlock\":0,\
\"petersburgBlock\":0,\
\"istanbulBlock\":0,\
\"muirGlacierBlock\":0,\
\"berlinBlock\":0,\
\"londonBlock\":0,\
\"clique\": \{\
\"period\": 5,\
\"epoch\": 30000\
\},\
\"terminalTotalDifficulty\":0\
\},\
\"nonce\":\"0x42\",\
\"timestamp\":\"0x0\",\
\"extraData\":\"0x0000000000000000000000000000000000000000000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\
\"gasLimit\":\"0x989680\",\
\"difficulty\":\"0x400000000\",\
\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\
\"coinbase\":\"0x0000000000000000000000000000000000000000\",\
\"alloc\":\{\
\"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\":\{\"balance\":\"0x6d6172697573766477000000\"\} \
\},\
\"number\":\"0x0\",\
\"gasUsed\":\"0x0\",\
\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\
\"baseFeePerGas\":\"0x7\"\
\} > ${GENESISJSON}
~/execution_clients/go-ethereum/build/bin/geth --catalyst --http --ws -http.api "engine" --datadir ${GETHDATADIR} init ${GENESISJSON}
~/execution_clients/go-ethereum/build/bin/geth --catalyst --http --ws -http.api "engine" --nodiscover --miner.etherbase 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b --datadir ${GETHDATADIR} console