@@ -5,40 +5,51 @@ import * as td from 'testdouble'
5
5
import { assert , describe , it } from 'vitest'
6
6
7
7
import blocks from '../../testdata/blocks/kaustinen4.json'
8
- import genesisJSON from '../../testdata/geth-genesis/kaustinen5 .json'
8
+ import genesisJSON from '../../testdata/geth-genesis/kaustinen6 .json'
9
9
import { getRpcClient , setupChain } from '../helpers.js'
10
10
11
11
import type { Chain } from '../../../src/blockchain'
12
12
import type { BeaconPayloadJson } from '@ethereumjs/block'
13
13
import type { Common } from '@ethereumjs/common'
14
14
import type { HttpClient } from 'jayson/promise'
15
- const genesisVerkleStateRoot = '0x382960711d9ccf58b9db20122e2253eb9bfa99d513f8c9d4e85b55971721f4de '
16
- const genesisVerkleBlockHash = '0x086326f2922364dba375e7c9bed375d622845615c0974ffd1d3be0e34edbfbc3 '
15
+ const genesisVerkleStateRoot = '0x1fbf85345a3cbba9a6d44f991b721e55620a22397c2a93ee8d5011136ac300ee '
16
+ const genesisVerkleBlockHash = '0x3fe165c03e7a77d1e3759362ebeeb16fd964cb411ce11fbe35c7032fab5b9a8a '
17
17
18
18
/**
19
- * One can run this test in two formats:
20
- * 1. On the saved blocks, comma separated which are limited (353,368,374,467)
19
+ * One can run this test in this format:
20
+ * 1. Directly pull slots from a kaustinen beacon url
21
+ * `TEST_ONLINE_SLOTS=15 PEER_BEACON_URL=https://beacon.verkle-gen-devnet-6.ethpandaops.io DEBUG=ethjs,vm:*,evm:*,statemanager:verkle* npx vitest run test/rpc/engine/kaustinen6.spec.ts`
22
+ *
23
+ * However there are other ways to run the test with save data and testvectors but they are from old versions but
24
+ * can be updated to make it work
25
+ *
26
+ * a. On the saved blocks, comma separated (were produced for kaustinen4 )
21
27
* `TEST_SAVED_NUMBERS=353,368,374,467 npx vitest run test/rpc/engine/kaustinen5.spec.ts`
22
- * 2. Directly pull slots from a kaustinen beacon url
23
- * `TEST_ONLINE_SLOTS=15 PEER_BEACON_URL=https://beacon.verkle-gen-devnet-5.ethpandaops.io DEBUG=ethjs,vm:*,evm:*,statemanager:verkle* npx vitest run test/rpc/engine/kaustinen5.spec.ts`
24
- * 3. Geth produced testvectors
25
- * `TEST_GETH_VEC_DIR=test/testdata/gethk5vecs DEBUG=ethjs,vm:*,evm:*,statemanager:verkle* npx vitest run test/rpc/engine/kaustinen5.spec.ts`
28
+ * b. Geth produced testvectors (were produced for kaustinen5)
29
+ * `TEST_GETH_VEC_DIR=test/testdata/gethk5vecs DEBUG=ethjs,vm:*,evm:*,statemanager:verkle* npx vitest run test/rpc/engine/kaustinen6.spec.ts`
26
30
*/
27
31
28
32
const originalValidate = ( BlockHeader as any ) . prototype . _consensusFormatValidation
29
33
30
34
async function fetchExecutionPayload (
31
35
peerBeaconUrl : string ,
32
36
slot : number | string
33
- ) : Promise < BeaconPayloadJson > {
34
- const beaconBlock = await ( await fetch ( `${ peerBeaconUrl } /eth/v2/beacon/blocks/${ slot } ` ) ) . json ( )
35
- return beaconBlock . data . message . body . execution_payload
37
+ ) : Promise < BeaconPayloadJson | undefined > {
38
+ let beaconPayload : BeaconPayloadJson | undefined = undefined
39
+ try {
40
+ const beaconBlock = await ( await fetch ( `${ peerBeaconUrl } /eth/v2/beacon/blocks/${ slot } ` ) ) . json ( )
41
+ beaconPayload = beaconBlock . data . message . body . execution_payload
42
+ // eslint-disable-next-line no-empty
43
+ } catch ( _e ) { }
44
+
45
+ return beaconPayload
36
46
}
37
47
38
48
async function runBlock (
39
49
{ chain, rpc, common } : { chain : Chain ; rpc : HttpClient ; common : Common } ,
40
50
{ execute, parent } : { execute : any ; parent : any } ,
41
- isBeaconData : boolean
51
+ isBeaconData : boolean ,
52
+ context : any
42
53
) {
43
54
const blockCache = chain . blockCache
44
55
@@ -51,6 +62,11 @@ async function runBlock(
51
62
const executePayload =
52
63
isBeaconData === true ? executionPayloadFromBeaconPayload ( execute as any ) : execute
53
64
const res = await rpc . request ( 'engine_newPayloadV2' , [ executePayload ] )
65
+
66
+ // if the block was not executed mark as skip so it shows in test
67
+ if ( res . result . status === 'ACCEPTED' ) {
68
+ context . skip ( )
69
+ }
54
70
assert . equal ( res . result . status , 'VALID' , 'valid status should be received' )
55
71
}
56
72
@@ -75,21 +91,22 @@ describe(`valid verkle network setup`, async () => {
75
91
const savedTestCases = process . env . TEST_SAVED_NUMBERS ?. split ( ',' ) ?? [ ]
76
92
77
93
for ( const testCase of savedTestCases ) {
78
- it ( `run saved block ${ testCase } ` , async ( ) => {
94
+ it ( `run saved block ${ testCase } ` , async ( context ) => {
79
95
let testData
80
96
let isBeaconData
81
97
if ( process . env . SAVED_DATA_DIR !== undefined ) {
82
98
const fileName = `${ process . env . SAVED_DATA_DIR } /${ testCase } .json`
83
- testData = JSON . parse ( readFileSync ( fileName ) ) [ testCase ]
99
+ testData = JSON . parse ( readFileSync ( fileName , 'utf8' ) ) [ testCase ]
84
100
isBeaconData = false
85
101
} else {
102
+ // @ts -expect-error -- Typescript complains that `testCase` can't index the `blocks` object
86
103
testData = blocks [ testCase ]
87
104
isBeaconData = true
88
105
}
89
106
if ( testData === undefined ) {
90
107
throw Error ( 'unavailable data' )
91
108
}
92
- await runBlock ( { common, chain, rpc } , testData , isBeaconData )
109
+ await runBlock ( { common, chain, rpc } , testData , isBeaconData , context )
93
110
} )
94
111
}
95
112
@@ -107,9 +124,14 @@ describe(`valid verkle network setup`, async () => {
107
124
let parent = await fetchExecutionPayload ( process . env . PEER_BEACON_URL , startSlot - 1 )
108
125
for ( let i = startSlot ; i <= endSlot ; i ++ ) {
109
126
const execute = await fetchExecutionPayload ( process . env . PEER_BEACON_URL , i )
110
- it ( `run fetched block slot: ${ i } number: ${ execute . block_number } ` , async ( ) => {
127
+ if ( execute === undefined ) {
128
+ // may be there was no block on this slot
129
+ continue
130
+ }
131
+
132
+ it ( `run fetched block slot: ${ i } number: ${ execute . block_number } ` , async ( context ) => {
111
133
try {
112
- await runBlock ( { common, chain, rpc } , { parent, execute } , true )
134
+ await runBlock ( { common, chain, rpc } , { parent, execute } , true , context )
113
135
} finally {
114
136
parent = execute
115
137
}
@@ -123,8 +145,8 @@ describe(`valid verkle network setup`, async () => {
123
145
let parent = gethVecs [ 0 ]
124
146
for ( let i = 1 ; i < gethVecs . length ; i ++ ) {
125
147
const execute = gethVecs [ i ]
126
- it ( `run geth vector: ${ execute . blockNumber } ` , async ( ) => {
127
- await runBlock ( { common, chain, rpc } , { parent, execute } , false )
148
+ it ( `run geth vector: ${ execute . blockNumber } ` , async ( context ) => {
149
+ await runBlock ( { common, chain, rpc } , { parent, execute } , false , context )
128
150
parent = execute
129
151
} )
130
152
}
@@ -139,8 +161,8 @@ describe(`valid verkle network setup`, async () => {
139
161
140
162
async function loadGethVectors ( vectorsDirPath : string , opts : { common : Common } ) {
141
163
// set chain id to 1 for geth vectors
142
- opts . common . _chainParams . chainId = BigInt ( 1 )
143
- const stateDiffVec = JSON . parse ( readFileSync ( `${ vectorsDirPath } /statediffs.json` ) )
164
+ opts . common [ ' _chainParams' ] . chainId = BigInt ( 1 )
165
+ const stateDiffVec = JSON . parse ( readFileSync ( `${ vectorsDirPath } /statediffs.json` , 'utf8' ) )
144
166
const executionWitness0 = {
145
167
stateDiff : [ ] ,
146
168
verkleProof : {
0 commit comments