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":
|
Backfill support for ChainDAG (#3171)
In the ChainDAG, 3 block pointers are kept: genesis, tail and head. This
PR adds one more block pointer: the backfill block which represents the
block that has been backfilled so far.
When doing a checkpoint sync, a random block is given as starting point
- this is the tail block, and we require that the tail block has a
corresponding state.
When backfilling, we end up with blocks without corresponding states,
hence we cannot use `tail` as a backfill pointer - there is no state.
Nonetheless, we need to keep track of where we are in the backfill
process between restarts, such that we can answer GetBeaconBlocksByRange
requests.
This PR adds the basic support for backfill handling - it needs to be
integrated with backfill sync, and the REST API needs to be adjusted to
take advantage of the new backfilled blocks when responding to certain
requests.
Future work will also enable moving the tail in either direction:
* pruning means moving the tail forward in time and removing states
* backwards means recreating past states from genesis, such that
intermediate states are recreated step by step all the way to the tail -
at that point, tail, genesis and backfill will match up.
* backfilling is done when backfill != genesis - later, this will be the
WSS checkpoint instead
2021-12-13 13:36:06 +00:00
|
|
|
setup:
|
|
|
|
let web3Provider = (waitFor Web3DataProvider.new(
|
2022-02-11 18:38:44 +00:00
|
|
|
default(Eth1Address), "ws://127.0.0.1:8551")).get
|
2021-10-13 14:08:50 +00:00
|
|
|
|
2022-02-04 12:12:19 +00:00
|
|
|
test "getPayload, newPayload, and forkchoiceUpdated":
|
2021-11-10 11:41:02 +00:00
|
|
|
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))
|
2022-02-04 12:12:19 +00:00
|
|
|
payloadStatus = waitFor web3Provider.newPayload(payload)
|
2021-10-13 14:08:50 +00:00
|
|
|
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))
|
2022-02-04 12:12:19 +00:00
|
|
|
payloadStatus2 = waitFor web3Provider.newPayload(payload2)
|
2021-10-13 14:08:50 +00:00
|
|
|
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:
|
2022-02-04 12:12:19 +00:00
|
|
|
payloadStatus.status == PayloadExecutionStatus.valid
|
2022-02-11 18:38:44 +00:00
|
|
|
fcupdatedStatus.payloadStatus.status == PayloadExecutionStatus.valid
|
2022-02-04 12:12:19 +00:00
|
|
|
payloadStatus2.status == PayloadExecutionStatus.valid
|
2022-02-11 18:38:44 +00:00
|
|
|
fcupdatedStatus2.payloadStatus.status == PayloadExecutionStatus.valid
|