Skip to content

Commit b87c710

Browse files
authored
simulators/ethereum/engine: re-org to chain with missing/invalid payload (#526)
1 parent ee8d448 commit b87c710

File tree

4 files changed

+586
-193
lines changed

4 files changed

+586
-193
lines changed

simulators/ethereum/engine/README.md

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,38 @@ Expected outcome is that the forkchoiceUpdate proceeds, but the call returns an
7171
- Pre-TTD Block Hash:
7272
Perform a forkchoiceUpdated call using a block hash part of the canonical chain that precedes the block where the TTD occurred. (Behavior is undefined for this edge case and not verified, but should not produce unrecoverable error)
7373

74+
### Eth RPC Status on ForkchoiceUpdated Events:
75+
- Latest Block after NewPayload:
76+
Verify the Block returned by the Eth RPC after a new payload is executed. Eth RPC should still return previous block.
77+
78+
- Latest Block after New HeadBlock:
79+
Verify the Block returned by the Eth RPC after a new HeadBlockHash is set using forkchoiceUpdated. Eth RPC should return new block.
80+
81+
- Latest Block after New SafeBlock:
82+
Verify the Block returned by the Eth RPC after a new SafeBlockHash is set using forkchoiceUpdated. Eth RPC should return new block.
83+
84+
- Latest Block after New FinalizedBlock:
85+
Verify the Block returned by the Eth RPC after a new FinalizedBlockHash is set using forkchoiceUpdated. Eth RPC should return new block.
86+
87+
- Latest Block after Reorg:
88+
Verify the Block returned by the Eth RPC after a forkchoiceUpdated reorgs HeadBlockHash/SafeBlockHash to a sidechain and back. Eth RPC should return the appropriate block everytime.
89+
90+
### Payload Execution
91+
- Re-Execute Payload:
92+
Re-execute already executed payloads (10) and verify that no errors occur.
93+
94+
- Multiple New Payloads Extending Canonical Chain:
95+
Send 80 valid NewPayload directives extending the canonical chain. Only one of the payloads is selected using ForkchoiceUpdated directive.
96+
97+
- Out of Order Payload Execution:
98+
Launch a first client and produce N payloads.
99+
Launch a second client and send payloads (NewPayload) in reverse order (N, N - 1, ..., 1).
100+
The payloads should be ACCEPTED/SYNCING, and the last payload should be VALID (since payload 1 successfully links the chain with the Genesis).
101+
102+
- Valid NewPayload->ForkchoiceUpdated on Syncing Client:
103+
Skip sending NewPayload to the client, but send the ForkchoiceUpdated to this missing payload, which will send the client to Syncing, then send the valid payload. Response should be either `ACCEPTED` or `SYNCING`.
104+
105+
### Invalid Payload Tests
74106
- Bad blockhash on NewPayload:
75107
Send a NewPayload directive to the client including an incorrect BlockHash, should result in an error in all the following cases:
76108
- NewPayload while not syncing, on canonical chain
@@ -103,36 +135,20 @@ Modify fields including:
103135
- Gas
104136
- Value
105137

106-
### Eth RPC Status on ForkchoiceUpdated Events:
107-
- Latest Block after NewPayload:
108-
Verify the Block returned by the Eth RPC after a new payload is executed. Eth RPC should still return previous block.
109-
110-
- Latest Block after New HeadBlock:
111-
Verify the Block returned by the Eth RPC after a new HeadBlockHash is set using forkchoiceUpdated. Eth RPC should return new block.
112-
113-
- Latest Block after New SafeBlock:
114-
Verify the Block returned by the Eth RPC after a new SafeBlockHash is set using forkchoiceUpdated. Eth RPC should return new block.
115-
116-
- Latest Block after New FinalizedBlock:
117-
Verify the Block returned by the Eth RPC after a new FinalizedBlockHash is set using forkchoiceUpdated. Eth RPC should return new block.
118-
119-
- Latest Block after Reorg:
120-
Verify the Block returned by the Eth RPC after a forkchoiceUpdated reorgs HeadBlockHash/SafeBlockHash to a sidechain and back. Eth RPC should return the appropriate block everytime.
121-
122-
### Payload Execution
123-
- Re-Execute Payload:
124-
Re-execute already executed payloads (10) and verify that no errors occur.
125-
126-
- Multiple New Payloads Extending Canonical Chain:
127-
Send 80 valid NewPayload directives extending the canonical chain. Only one of the payloads is selected using ForkchoiceUpdated directive.
138+
- Invalid Ancestor Re-Org Tests
139+
Attempt to re-org to an unknown side chain which at some point contains an invalid payload.
140+
The side chain is constructed in parallel while the CL Mock builds the canonical chain, but changing the extraData to simply produce a different hash.
141+
At a given point, the side chain invalidates one of the payloads by modifying one of the payload fields.
142+
Once the side chain reaches a certain deviation height (N) from the commonAncestor, the CL switches to it by either of the following methods:
143+
a) `newPayload` each of the payloads in the side chain, and the invalid payload shall return `INVALID`
144+
b) Force the main client to partially sync the side chain by sending the initial slice of the chain (before the invalid payload) to another client, and the rest to the primary client.
145+
Method (b) results in the client returning `ACCEPTED` or `SYNCING` on the `newPayload(INV_P)`, but eventually the client must return `INVALID` to the head of the side chain because it was built on top of an invalid payload.
146+
```
147+
commonAncestor◄─▲── P1 ◄─ P2 ◄─ P3 ◄─ ... ◄─ Pn
148+
149+
└── P1' ◄─ P2' ◄─ ... ◄─ INV_P ◄─ ... ◄─ Pn'
150+
```
128151

129-
- Out of Order Payload Execution:
130-
Launch a first client and produce N payloads.
131-
Launch a second client and send payloads (NewPayload) in reverse order (N, N - 1, ..., 1).
132-
The payloads should be ACCEPTED/SYNCING, and the last payload should be VALID (since payload 1 successfully links the chain with the Genesis).
133-
134-
- Valid NewPayload->ForkchoiceUpdated on Syncing Client:
135-
Skip sending NewPayload to the client, but send the ForkchoiceUpdated to this missing payload, which will send the client to Syncing, then send the valid payload. Response should be either `ACCEPTED` or `SYNCING`.
136152

137153
### Re-org using Engine API
138154
- Transaction Reorg using ForkchoiceUpdated:

0 commit comments

Comments
 (0)