nimbus-eth2/docs/mev_mergemock_test.md

67 lines
14 KiB
Markdown

# How to run and clone Merge Mock
- Clone and run Merge Mock using https://github.com/protolambda/mergemock#quick-start
```
$ git clone https://github.com/protolambda/mergemock # tested with commit 114c25ad2f07c9bc6c16d2223d3e84c3c512dc9e from 2022-05-25
$ cd mergemock
$ wget https://gist.githubusercontent.com/lightclient/799c727e826483a2804fc5013d0d3e3d/raw/2e8824fa8d9d9b040f351b86b75c66868fb9b115/genesis.json
$ openssl rand -hex 32 | tr -d "\n" > jwt.hex
$ go run . relay
INFO [2022-06-03T08:12:50Z] Loaded JWT secret val="5b63d4c3c389d43809553a3747bce72b13711db8f3501d3e4d6f18a312064eb0"
INFO [2022-06-03T08:12:50Z] Persisted trie from memory database fields.time="5.478µs" gcnodes="0" gcsize="0.00 B" gctime="0s" livenodes="1" livesize="0.00 B" nodes="1" size="151.00 B"
INFO [2022-06-03T08:12:50Z] Loaded most recent local header age="53y2mo6d" hash="0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131" number="0" td="17179869184"
INFO [2022-06-03T08:12:50Z] Loaded most recent local full block age="53y2mo6d" hash="0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131" number="0" td="17179869184"
INFO [2022-06-03T08:12:50Z] Loaded most recent local fast block age="53y2mo6d" hash="0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131" number="0" td="17179869184"
WARNING[2022-06-03T08:12:50Z] Failed to load snapshot, regenerating err="missing or corrupted snapshot"
INFO [2022-06-03T08:12:50Z] Rebuilding state snapshot
INFO [2022-06-03T08:12:50Z] Resuming state snapshot generation accounts="0" elapsed="245.706µs" root="0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45" slots="0" storage="0.00 B"
INFO [2022-06-03T08:12:50Z] Generated state snapshot accounts="1" elapsed="400.253µs" slots="0" storage="50.00 B"
INFO [2022-06-03T08:12:50Z] Engine started listenAddr="127.0.0.1:8551"
INFO [2022-06-03T08:12:50Z] Relay started listenAddr="127.0.0.1:28545"
```
# Run Nimbus's MEV/Merge Mock test script
```
$ ./env nim c -r scripts/test_mev_vector
NOT 2022-06-03 08:15:06.648+00:00 New database from snapshot tid=1389294 file=blockchain_dag.nim:1800 genesisBlockRoot=9058609e genesisStateRoot=0fef5721 tailBlockRoot=9058609e tailStateRoot=0fef5721 fork="(previous_version: 00000000, current_version: 00000000, epoch: 0)" validators=64 tailStateSlot=0 genesisStateSlot=0
DBG 2022-06-03 08:15:06.649+00:00 Message sent to RPC server topics="JSONRPC-HTTP-CLIENT" tid=1389294 file=httpclient.nim:104 address="ok((id: \"127.0.0.1:8551\", scheme: NonSecure, hostname: \"127.0.0.1\", port: 8551, path: \"\", query: \"\", anchor: \"\", username: \"\", password: \"\", addresses: @[127.0.0.1:8551]))" msg_len=79
DBG 2022-06-03 08:15:06.650+00:00 Message sent to RPC server topics="JSONRPC-HTTP-CLIENT" tid=1389294 file=httpclient.nim:104 address="ok((id: \"127.0.0.1:8551\", scheme: NonSecure, hostname: \"127.0.0.1\", port: 8551, path: \"\", query: \"\", anchor: \"\", username: \"\", password: \"\", addresses: @[127.0.0.1:8551]))" msg_len=506
DBG 2022-06-03 08:15:06.650+00:00 Sending REST request to remote server tid=1389294 file=client.nim:418 remote=127.0.0.1:28545 request=/eth/v1/builder/header/1/0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131/0xa6d310dbbfab9a22450f59993f87a4ce5db6223f3b5f1f30d2c4ec718922d400e0b3c7741de8e59960f72411a0ee10a7 http_method=GET
DBG 2022-06-03 08:15:06.651+00:00 Got REST response headers from remote server tid=1389294 file=client.nim:421 status=200 http_method=GET remote=127.0.0.1:28545 request=/eth/v1/builder/header/1/0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131/0xa6d310dbbfab9a22450f59993f87a4ce5db6223f3b5f1f30d2c4ec718922d400e0b3c7741de8e59960f72411a0ee10a7 connection=1
DBG 2022-06-03 08:15:06.652+00:00 Received REST response body from remote server tid=1389294 file=client.nim:462 status=200 http_method=GET remote=127.0.0.1:28545 request=/eth/v1/builder/header/1/0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131/0xa6d310dbbfab9a22450f59993f87a4ce5db6223f3b5f1f30d2c4ec718922d400e0b3c7741de8e59960f72411a0ee10a7 connection=1 contentType=application/json size=1672
DBG 2022-06-03 08:15:06.652+00:00 Sending REST request to remote server tid=1389294 file=client.nim:508 remote=127.0.0.1:28545 request=/eth/v1/builder/blinded_blocks http_method=POST
DBG 2022-06-03 08:15:06.653+00:00 Opened connection to remote server tid=1389294 file=client.nim:512 remote=127.0.0.1:28545 request=/eth/v1/builder/blinded_blocks http_method=POST connection=2
DBG 2022-06-03 08:15:06.653+00:00 REST request body has been sent tid=1389294 file=client.nim:521 remote=127.0.0.1:28545 request=/eth/v1/builder/blinded_blocks size=2734 http_method=POST connection=2
DBG 2022-06-03 08:15:06.655+00:00 Got REST response headers from remote server tid=1389294 file=client.nim:528 status=200 http_method=POST remote=127.0.0.1:28545 request=/eth/v1/builder/blinded_blocks connection=2
DBG 2022-06-03 08:15:06.655+00:00 Received REST response body from remote server tid=1389294 file=client.nim:567 contentType=application/json size=1247 remote=127.0.0.1:28545 request=/eth/v1/builder/blinded_blocks connection=2
[OK] forkchoiceUpdated, getHeader, and submitBlindedBlock
```
While on the Merge Mock side:
```
INFO [2022-06-03T08:14:57Z] Forkchoice updated attributes="&{12 0x0000000000000000000000000000000000000000000000000000000000000000 0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B}" finalized="0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131" head="0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131" safe="0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131"
INFO [2022-06-03T08:14:57Z] Preparing new payload payload_id="0x0000000000000001" prev_randao="0x0000000000000000000000000000000000000000000000000000000000000000" suggested_fee_recipient="0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B" timestamp="12"
INFO [2022-06-03T08:14:57Z] getHeader parentHash="0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131" pubkey="0xa6d310dbbfab9a22450f59993f87a4ce5db6223f3b5f1f30d2c4ec718922d400e0b3c7741de8e59960f72411a0ee10a7" slot="1"
INFO [2022-06-03T08:14:57Z] Consensus client retrieved prepared payload header parentHash="0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131" pubkey="0xa6d310dbbfab9a22450f59993f87a4ce5db6223f3b5f1f30d2c4ec718922d400e0b3c7741de8e59960f72411a0ee10a7" slot="1"
2022/06/03 08:14:57 http: superfluous response.WriteHeader call from main.(*responseWriter).WriteHeader (utils.go:34)
INFO [2022-06-03T08:14:57Z] http: GET /eth/v1/builder/header/1/0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131/0xa6d310dbbfab9a22450f59993f87a4ce5db6223f3b5f1f30d2c4ec718922d400e0b3c7741de8e59960f72411a0ee10a7 200 durationMs="0" method="GET" path="/eth/v1/builder/header/1/0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131/0xa6d310dbbfab9a22450f59993f87a4ce5db6223f3b5f1f30d2c4ec718922d400e0b3c7741de8e59960f72411a0ee10a7" status="200"
INFO [2022-06-03T08:14:57Z] &{0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131 0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B 0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] 0x0000000000000000000000000000000000000000000000000000000000000000 1 10000000 0 12 [] 7 0x6bc31fed8860b9b4b907cc994f16ffa32f9b08d229cb1767f0d50c299eb137e2 []} method="getPayload"
INFO [2022-06-03T08:14:57Z] http: POST /eth/v1/builder/blinded_blocks 0 durationMs="1" method="POST" path="/eth/v1/builder/blinded_blocks" status="0"
INFO [2022-06-03T08:15:04Z] Forkchoice updated attributes="&{12 0x0000000000000000000000000000000000000000000000000000000000000000 0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B}" finalized="0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131" head="0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131" safe="0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131"
INFO [2022-06-03T08:15:04Z] Preparing new payload payload_id="0x0000000000000002" prev_randao="0x0000000000000000000000000000000000000000000000000000000000000000" suggested_fee_recipient="0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B" timestamp="12"
INFO [2022-06-03T08:15:04Z] getHeader parentHash="0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131" pubkey="0xa6d310dbbfab9a22450f59993f87a4ce5db6223f3b5f1f30d2c4ec718922d400e0b3c7741de8e59960f72411a0ee10a7" slot="1"
INFO [2022-06-03T08:15:04Z] Consensus client retrieved prepared payload header parentHash="0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131" pubkey="0xa6d310dbbfab9a22450f59993f87a4ce5db6223f3b5f1f30d2c4ec718922d400e0b3c7741de8e59960f72411a0ee10a7" slot="1"
2022/06/03 08:15:04 http: superfluous response.WriteHeader call from main.(*responseWriter).WriteHeader (utils.go:34)
INFO [2022-06-03T08:15:04Z] http: GET /eth/v1/builder/header/1/0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131/0xa6d310dbbfab9a22450f59993f87a4ce5db6223f3b5f1f30d2c4ec718922d400e0b3c7741de8e59960f72411a0ee10a7 200 durationMs="0" method="GET" path="/eth/v1/builder/header/1/0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131/0xa6d310dbbfab9a22450f59993f87a4ce5db6223f3b5f1f30d2c4ec718922d400e0b3c7741de8e59960f72411a0ee10a7" status="200"
INFO [2022-06-03T08:15:04Z] &{0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131 0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B 0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] 0x0000000000000000000000000000000000000000000000000000000000000000 1 10000000 0 12 [] 7 0x6bc31fed8860b9b4b907cc994f16ffa32f9b08d229cb1767f0d50c299eb137e2 []} method="getPayload"
INFO [2022-06-03T08:15:04Z] http: POST /eth/v1/builder/blinded_blocks 0 durationMs="1" method="POST" path="/eth/v1/builder/blinded_blocks" status="0"
INFO [2022-06-03T08:15:06Z] Forkchoice updated attributes="&{12 0x0000000000000000000000000000000000000000000000000000000000000000 0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B}" finalized="0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131" head="0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131" safe="0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131"
INFO [2022-06-03T08:15:06Z] Preparing new payload payload_id="0x0000000000000003" prev_randao="0x0000000000000000000000000000000000000000000000000000000000000000" suggested_fee_recipient="0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B" timestamp="12"
INFO [2022-06-03T08:15:06Z] getHeader parentHash="0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131" pubkey="0xa6d310dbbfab9a22450f59993f87a4ce5db6223f3b5f1f30d2c4ec718922d400e0b3c7741de8e59960f72411a0ee10a7" slot="1"
INFO [2022-06-03T08:15:06Z] Consensus client retrieved prepared payload header parentHash="0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131" pubkey="0xa6d310dbbfab9a22450f59993f87a4ce5db6223f3b5f1f30d2c4ec718922d400e0b3c7741de8e59960f72411a0ee10a7" slot="1"
2022/06/03 08:15:06 http: superfluous response.WriteHeader call from main.(*responseWriter).WriteHeader (utils.go:34)
INFO [2022-06-03T08:15:06Z] http: GET /eth/v1/builder/header/1/0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131/0xa6d310dbbfab9a22450f59993f87a4ce5db6223f3b5f1f30d2c4ec718922d400e0b3c7741de8e59960f72411a0ee10a7 200 durationMs="0" method="GET" path="/eth/v1/builder/header/1/0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131/0xa6d310dbbfab9a22450f59993f87a4ce5db6223f3b5f1f30d2c4ec718922d400e0b3c7741de8e59960f72411a0ee10a7" status="200"
INFO [2022-06-03T08:15:06Z] &{0xa0513a503d5bd6e89a144c3268e5b7e9da9dbf63df125a360e3950a7d0d67131 0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B 0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] 0x0000000000000000000000000000000000000000000000000000000000000000 1 10000000 0 12 [] 7 0x6bc31fed8860b9b4b907cc994f16ffa32f9b08d229cb1767f0d50c299eb137e2 []} method="getPayload"
INFO [2022-06-03T08:15:06Z] http: POST /eth/v1/builder/blinded_blocks 0 durationMs="1" method="POST" path="/eth/v1/builder/blinded_blocks" status="0"
```