2021-10-13 14:08:50 +00:00
|
|
|
{.used.}
|
|
|
|
|
|
|
|
# https://notes.ethereum.org/@9AeMAlpyQYaAAyuj47BzRw/rkwW3ceVY
|
2021-11-17 19:45:39 +00:00
|
|
|
# Monitor traffic: socat -v TCP-LISTEN:9550,fork TCP-CONNECT:127.0.0.1:8550
|
2021-10-13 14:08:50 +00:00
|
|
|
|
|
|
|
import
|
|
|
|
unittest2,
|
|
|
|
chronos, web3/[engine_api_types, ethtypes],
|
|
|
|
../beacon_chain/eth1/eth1_monitor,
|
|
|
|
../beacon_chain/spec/[digest, presets],
|
|
|
|
./testutil
|
|
|
|
|
|
|
|
suite "Merge test vectors":
|
|
|
|
let web3Provider = (waitFor Web3DataProvider.new(
|
2021-11-17 19:45:39 +00:00
|
|
|
default(Eth1Address), "http://127.0.0.1:8550")).get
|
2021-10-13 14:08:50 +00:00
|
|
|
|
2021-11-10 11:41:02 +00:00
|
|
|
test "getPayload, executePayload, and forkchoiceUpdated":
|
|
|
|
const feeRecipient =
|
|
|
|
Eth1Address.fromHex("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b")
|
2021-10-13 14:08:50 +00:00
|
|
|
let
|
2021-11-17 19:45:39 +00:00
|
|
|
existingBlock = waitFor web3Provider.getBlockByNumber(0)
|
2021-11-10 11:41:02 +00:00
|
|
|
payloadId = waitFor web3Provider.forkchoiceUpdated(
|
|
|
|
existingBlock.hash.asEth2Digest,
|
2021-10-13 14:08:50 +00:00
|
|
|
existingBlock.hash.asEth2Digest,
|
|
|
|
existingBlock.timestamp.uint64 + 12,
|
|
|
|
default(Eth2Digest).data, # Random
|
2021-11-10 11:41:02 +00:00
|
|
|
feeRecipient)
|
2021-10-13 14:08:50 +00:00
|
|
|
payload = waitFor web3Provider.getPayload(
|
2021-11-15 14:55:03 +00:00
|
|
|
array[8, byte] (payloadId.payloadId.get))
|
2021-10-13 14:08:50 +00:00
|
|
|
payloadStatus = waitFor web3Provider.executePayload(payload)
|
|
|
|
fcupdatedStatus = waitFor web3Provider.forkchoiceUpdated(
|
2021-11-10 11:41:02 +00:00
|
|
|
payload.blockHash.asEth2Digest,
|
2021-10-13 14:08:50 +00:00
|
|
|
payload.blockHash.asEth2Digest,
|
|
|
|
existingBlock.timestamp.uint64 + 24,
|
|
|
|
default(Eth2Digest).data, # Random
|
2021-11-10 11:41:02 +00:00
|
|
|
feeRecipient)
|
|
|
|
|
2021-10-13 14:08:50 +00:00
|
|
|
payload2 = waitFor web3Provider.getPayload(
|
2021-11-15 14:55:03 +00:00
|
|
|
array[8, byte] (fcupdatedStatus.payloadId.get))
|
2021-10-13 14:08:50 +00:00
|
|
|
payloadStatus2 = waitFor web3Provider.executePayload(payload2)
|
|
|
|
fcupdatedStatus2 = waitFor web3Provider.forkchoiceUpdated(
|
2021-11-10 11:41:02 +00:00
|
|
|
payload2.blockHash.asEth2Digest,
|
|
|
|
payload2.blockHash.asEth2Digest,
|
|
|
|
existingBlock.timestamp.uint64 + 36,
|
|
|
|
default(Eth2Digest).data, # Random
|
|
|
|
feeRecipient)
|
2021-10-13 14:08:50 +00:00
|
|
|
|
2021-11-10 11:41:02 +00:00
|
|
|
check:
|
|
|
|
payloadStatus.status == "VALID"
|
|
|
|
fcupdatedStatus.status == "SUCCESS"
|
|
|
|
payloadStatus2.status == "VALID"
|
|
|
|
fcupdatedStatus2.status == "SUCCESS"
|