2022-04-11 10:00:39 +00:00
|
|
|
import
|
2023-08-21 02:08:54 +00:00
|
|
|
./engine/engine_spec,
|
|
|
|
./types,
|
|
|
|
./test_env
|
2022-04-11 10:00:39 +00:00
|
|
|
|
2023-08-21 02:08:54 +00:00
|
|
|
proc specExecute(ws: BaseSpec): bool =
|
|
|
|
var
|
|
|
|
ws = EngineSpec(ws)
|
2023-09-06 09:18:26 +00:00
|
|
|
env = TestEnv.new(ws.chainFile, false)
|
2023-03-09 23:40:55 +00:00
|
|
|
|
2023-09-06 09:18:26 +00:00
|
|
|
env.engine.setRealTTD(ws.ttd)
|
|
|
|
env.setupCLMock()
|
|
|
|
|
2023-08-21 02:08:54 +00:00
|
|
|
if ws.slotsToFinalized != 0:
|
|
|
|
env.slotsToFinalized(ws.slotsToFinalized)
|
|
|
|
if ws.slotsToSafe != 0:
|
|
|
|
env.slotsToSafe(ws.slotsToSafe)
|
2022-04-11 10:00:39 +00:00
|
|
|
|
2023-08-21 02:08:54 +00:00
|
|
|
result = ws.exec(env)
|
2023-09-06 09:18:26 +00:00
|
|
|
env.close()
|
2022-06-17 00:53:33 +00:00
|
|
|
|
2023-08-21 02:08:54 +00:00
|
|
|
let engineTestList* = [
|
2022-06-01 13:32:07 +00:00
|
|
|
# Engine API Negative Test Cases
|
2023-08-21 02:08:54 +00:00
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Invalid Terminal Block in ForkchoiceUpdated",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidTerminalBlockForkchoiceUpdated,
|
|
|
|
ttd: 1000000
|
|
|
|
))#[,
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Invalid GetPayload Under PoW",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidGetPayloadUnderPoW,
|
|
|
|
ttd: 1000000
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Invalid Terminal Block in NewPayload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidTerminalBlockNewPayload,
|
|
|
|
ttd: 1000000,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-06-01 13:32:07 +00:00
|
|
|
name: "Inconsistent Head in ForkchoiceState",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: inconsistentForkchoiceState1,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-06-01 13:32:07 +00:00
|
|
|
name: "Inconsistent Safe in ForkchoiceState",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: inconsistentForkchoiceState2,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-06-01 13:32:07 +00:00
|
|
|
name: "Inconsistent Finalized in ForkchoiceState",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: inconsistentForkchoiceState3,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Unknown HeadBlockHash",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: unknownHeadBlockHash,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Unknown SafeBlockHash",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: unknownSafeBlockHash,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Unknown FinalizedBlockHash",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: unknownFinalizedBlockHash,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-06-01 13:32:07 +00:00
|
|
|
name: "ForkchoiceUpdated Invalid Payload Attributes",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidPayloadAttributes1,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-06-01 13:32:07 +00:00
|
|
|
name: "ForkchoiceUpdated Invalid Payload Attributes (Syncing)",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidPayloadAttributes2,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Pre-TTD ForkchoiceUpdated After PoS Switch",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: preTTDFinalizedBlockHash,
|
|
|
|
ttd: 2,
|
|
|
|
)),
|
2022-06-01 13:32:07 +00:00
|
|
|
# Invalid Payload Tests
|
2023-08-21 02:08:54 +00:00
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Bad Hash on NewPayload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: badHashOnNewPayload1,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-06-01 13:32:07 +00:00
|
|
|
name: "Bad Hash on NewPayload Syncing",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: badHashOnNewPayload2,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-06-01 13:32:07 +00:00
|
|
|
name: "Bad Hash on NewPayload Side Chain",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: badHashOnNewPayload3,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-06-01 13:32:07 +00:00
|
|
|
name: "Bad Hash on NewPayload Side Chain Syncing",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: badHashOnNewPayload4,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "ParentHash==BlockHash on NewPayload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: parentHashOnExecPayload,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-06-17 00:53:33 +00:00
|
|
|
name: "Invalid Transition Payload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidTransitionPayload,
|
|
|
|
ttd: 393504,
|
|
|
|
chainFile: "blocks_2_td_393504.rlp",
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Invalid ParentHash NewPayload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidPayload1,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Invalid StateRoot NewPayload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidPayload2,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-06-13 09:42:01 +00:00
|
|
|
name: "Invalid StateRoot NewPayload, Empty Transactions",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidPayload3,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Invalid ReceiptsRoot NewPayload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidPayload4,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Invalid Number NewPayload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidPayload5,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Invalid GasLimit NewPayload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidPayload6,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Invalid GasUsed NewPayload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidPayload7,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Invalid Timestamp NewPayload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidPayload8,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Invalid PrevRandao NewPayload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidPayload9,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Invalid Incomplete Transactions NewPayload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidPayload10,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Invalid Transaction Signature NewPayload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidPayload11,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Invalid Transaction Nonce NewPayload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidPayload12,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Invalid Transaction GasPrice NewPayload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidPayload13,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Invalid Transaction Gas NewPayload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidPayload14,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Invalid Transaction Value NewPayload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidPayload15,
|
|
|
|
)),
|
2022-04-11 10:00:39 +00:00
|
|
|
|
2022-06-27 13:18:54 +00:00
|
|
|
# Invalid Ancestor Re-Org Tests (Reveal via newPayload)
|
2023-08-21 02:08:54 +00:00
|
|
|
TestDesc(
|
2022-06-27 13:18:54 +00:00
|
|
|
name: "Invalid Ancestor Chain Re-Org, Invalid StateRoot, Invalid P1', Reveal using newPayload",
|
|
|
|
slotsToFinalized: 20,
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidMissingAncestor1,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-06-27 13:18:54 +00:00
|
|
|
name: "Invalid Ancestor Chain Re-Org, Invalid StateRoot, Invalid P9', Reveal using newPayload",
|
|
|
|
slotsToFinalized: 20,
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidMissingAncestor2,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-06-27 13:18:54 +00:00
|
|
|
name: "Invalid Ancestor Chain Re-Org, Invalid StateRoot, Invalid P10', Reveal using newPayload",
|
|
|
|
slotsToFinalized: 20,
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: invalidMissingAncestor3,
|
|
|
|
)),
|
2022-06-27 13:18:54 +00:00
|
|
|
|
2022-04-11 10:00:39 +00:00
|
|
|
# Eth RPC Status on ForkchoiceUpdated Events
|
2023-08-21 02:08:54 +00:00
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Latest Block after NewPayload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: blockStatusExecPayload1,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-06-01 13:32:07 +00:00
|
|
|
name: "Latest Block after NewPayload (Transition Block)",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: blockStatusExecPayload2,
|
|
|
|
ttd: 5,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Latest Block after New HeadBlock",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: blockStatusHeadBlock1,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-06-01 13:32:07 +00:00
|
|
|
name: "Latest Block after New HeadBlock (Transition Block)",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: blockStatusHeadBlock2,
|
|
|
|
ttd: 5,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-06-27 04:15:23 +00:00
|
|
|
name: "safe Block after New SafeBlockHash",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: blockStatusSafeBlock,
|
|
|
|
ttd: 5,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-06-27 04:15:23 +00:00
|
|
|
name: "finalized Block after New FinalizedBlockHash",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: blockStatusFinalizedBlock,
|
|
|
|
ttd: 5,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Latest Block after Reorg",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: blockStatusReorg,
|
|
|
|
)),
|
2022-04-11 10:00:39 +00:00
|
|
|
|
|
|
|
# Payload Tests
|
2023-08-21 02:08:54 +00:00
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Re-Execute Payload",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: reExecPayloads,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Multiple New Payloads Extending Canonical Chain",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: multipleNewCanonicalPayloads,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Out of Order Payload Execution",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: outOfOrderPayloads,
|
|
|
|
)),
|
2022-04-11 10:00:39 +00:00
|
|
|
|
|
|
|
# Transaction Reorg using Engine API
|
2023-08-21 02:08:54 +00:00
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Transaction Reorg",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: transactionReorg,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Sidechain Reorg",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: sidechainReorg,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-06-01 13:32:07 +00:00
|
|
|
name: "Re-Org Back into Canonical Chain",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: reorgBack,
|
|
|
|
)),
|
|
|
|
TestDesc(
|
2022-06-01 13:32:07 +00:00
|
|
|
name: "Re-Org Back to Canonical Chain From Syncing Chain",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: reorgBackFromSyncing,
|
|
|
|
)),
|
2022-04-11 10:00:39 +00:00
|
|
|
|
|
|
|
# Suggested Fee Recipient in Payload creation
|
2023-08-21 02:08:54 +00:00
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Suggested Fee Recipient Test",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: suggestedFeeRecipient,
|
|
|
|
)),
|
2022-04-11 10:00:39 +00:00
|
|
|
|
|
|
|
# PrevRandao opcode tests
|
2023-08-21 02:08:54 +00:00
|
|
|
TestDesc(
|
2022-04-20 07:57:50 +00:00
|
|
|
name: "PrevRandao Opcode Transactions",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: prevRandaoOpcodeTx,
|
|
|
|
ttd: 10,
|
|
|
|
)),
|
2022-04-11 10:00:39 +00:00
|
|
|
|
|
|
|
# Multi-Client Sync tests
|
2023-08-21 02:08:54 +00:00
|
|
|
TestDesc(
|
2022-04-11 10:00:39 +00:00
|
|
|
name: "Sync Client Post Merge",
|
2023-08-21 02:08:54 +00:00
|
|
|
run: specExecute,
|
|
|
|
spec: EngineSpec(
|
|
|
|
exec: postMergeSync,
|
|
|
|
ttd: 10,
|
|
|
|
)),]#
|
2023-03-09 23:40:55 +00:00
|
|
|
]
|