-
Notifications
You must be signed in to change notification settings - Fork 781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
common: configure and fix kaustinen4 verkle testnet sync #3269
Merged
Merged
Changes from 21 commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
1befc1c
common: configure syncing kaustinen3 verkle testnet
g11tech 594f94c
fix the vmexecution for verkle stateless init
g11tech e81515f
track and ignore the BLOCKHASH witness to avoid k3 blockhash issues
g11tech b890167
remove the tx to/from access fees
g11tech 251f388
setup kaunstinen3 block15 stateless test execution for debugging
g11tech a9e5dc8
fix charging and waiving of tx origin/dest access fees
g11tech 1c5f0b0
configure to run kaustinen4
g11tech dc1306f
setup to test the failing block 368
g11tech 1c34416
debug and fix the code chunking boundary conditions
g11tech 2cfa736
skip missing chunk lookup on the invalid opcode if code not loaded fr…
g11tech b17a392
setup to debug the failing block374 in spec
g11tech d8ffbb2
fix genesis spec
g11tech 7523f65
add block353 to the test spec and help debug nethermind/besu for acce…
g11tech d55385f
add partial account functionality and set stateless verkle manager to…
g11tech 7222037
load all partial basic data in account and use the same in the get co…
g11tech d859671
debug and fix block372 working including stem hack for k4
g11tech 5726e1f
sync further and now setup failing block 479 for debugging
g11tech 5b5eaef
change stem formation for addresses less than 20 bytes to match kaust…
g11tech d5705df
update test to test more than one block
g11tech d8df57e
add capability to test spec run blocks off beacon url
g11tech eab6a46
debug and handle if CL returns payload with snake case witness
g11tech 4c0e4ab
fix the comment
g11tech d2142a9
vm: clear verkle cache in runBlock if opt is true
gabrocheleau 547e092
add functionality to start stateless execution from any block in chain
g11tech ee9800a
chore: merge with master
gabrocheleau 1385262
configure client to decouple execution and keep syncing despite chain…
g11tech a9bc254
modify the client to continue syncing ignoring block failures
g11tech ed1f1bd
save failing blocks if indicated by the flag
g11tech 7e7bf2a
update test to pick generated testcases from dir
g11tech f8a1db6
debug and add missing data in toexecutionwitness
g11tech aec1f6f
fix the test spec for various scenarios
g11tech 8067869
add witness errors to the debug log
g11tech 8adb7a9
debug and fix the issue for slot mismatch of a valid block - 521
g11tech d06b42c
add hack to get over the stem matching issue of kaustinen4 by brutefo…
g11tech 3244d86
allow one to provide witnesses to a rlped block via opts
g11tech 4e27c76
restore stem calc to correct one
g11tech 7ed686c
apply fix for codechunk comparision and better post state mismatches …
g11tech aaa5839
setup the kaustinen4 spec test to use geth test vectors
g11tech 92e0dc1
remove the code creation cost and fix the code creation write cost an…
g11tech 8c3d7c1
fix charging code read acceses for codecopy if from calldata and remo…
g11tech a3ca621
debug and match the create opcode gas consumptions
g11tech bd20bb9
commit new vestors and a fix for the contract create costs to not cha…
g11tech 2e1b158
add blockhash set/get accesses and remove ignoring them from post sta…
g11tech e9973ef
remove cold cost for sload and sstore
g11tech b392741
Merge remote-tracking branch 'origin/master' into kaustinen3
g11tech d5f8a96
debug and fix 3 testcases in verkle stateless manager spec
g11tech 3487ed7
fix rest of spec
g11tech e6b3f7d
make the get contract size optional in interface
g11tech 326eff0
fix lint
g11tech 357496d
fix vm api test
g11tech 44f06c1
restore kaustinen2 genesis for preimages spec
g11tech 0395441
Merge remote-tracking branch 'origin/master' into kaustinen3
g11tech d7e2635
client spec and lint fixes
g11tech File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { Block, BlockHeader, executionPayloadFromBeaconPayload } from '@ethereumjs/block' | ||
import * as td from 'testdouble' | ||
import { assert, describe, it } from 'vitest' | ||
|
||
import blocks from '../../testdata/blocks/kaustinen4.json' | ||
import genesisJSON from '../../testdata/geth-genesis/kaustinen4.json' | ||
import { getRpcClient, setupChain } from '../helpers.js' | ||
|
||
import type { Chain } from '../../../src/blockchain' | ||
import type { BeaconPayloadJson } from '@ethereumjs/block' | ||
import type { Common } from '@ethereumjs/common' | ||
import type { HttpClient } from 'jayson/promise' | ||
const genesisVerkleStateRoot = '0x382960711d9ccf58b9db20122e2253eb9bfa99d513f8c9d4e85b55971721f4de' | ||
const genesisVerkleBlockHash = '0x8493ed97fd4314acb6ed519867b086dc698e25df37ebe8f2bc77313537710744' | ||
|
||
/** | ||
* One can run this test in two formats: | ||
* 1. On the saved blocks, comma separated which are limited (345,375,368,467) | ||
* `TEST_SAVED_NUMBERS=345,375,368,467 npx vitest run test/rpc/engine/kaustinen4.spec.ts` | ||
* 2. Directly pull slots from a kaustinen beacon url | ||
* `TEST_ONLINE_SLOTS=345,353..360 PEER_BEACON_URL=https://beacon.verkle-gen-devnet-4.ethpandaops.io npx vitest run test/rpc/engine/kaustinen4.spec.ts` | ||
*/ | ||
|
||
const originalValidate = (BlockHeader as any).prototype._consensusFormatValidation | ||
|
||
async function fetchExecutionPayload( | ||
peerBeaconUrl: string, | ||
slot: number | string | ||
): Promise<BeaconPayloadJson> { | ||
const beaconBlock = await (await fetch(`${peerBeaconUrl}/eth/v2/beacon/blocks/${slot}`)).json() | ||
return beaconBlock.data.message.body.execution_payload | ||
} | ||
|
||
async function runBlock( | ||
{ chain, rpc, common }: { chain: Chain; rpc: HttpClient; common: Common }, | ||
{ execute, parent }: { execute: any; parent: any } | ||
) { | ||
const blockCache = chain.blockCache | ||
|
||
const parentPayload = executionPayloadFromBeaconPayload(parent as any) | ||
const parentBlock = await Block.fromExecutionPayload(parentPayload, { common }) | ||
blockCache.remoteBlocks.set(parentPayload.blockHash.slice(2), parentBlock) | ||
blockCache.executedBlocks.set(parentPayload.blockHash.slice(2), parentBlock) | ||
|
||
const executePayload = executionPayloadFromBeaconPayload(execute as any) | ||
const res = await rpc.request('engine_newPayloadV2', [executePayload]) | ||
assert.equal(res.result.status, 'VALID', 'valid status should be received') | ||
} | ||
|
||
describe(`valid verkle network setup`, async () => { | ||
const { server, chain, common } = await setupChain(genesisJSON, 'post-merge', { | ||
engine: true, | ||
genesisStateRoot: genesisVerkleStateRoot, | ||
}) | ||
const rpc = getRpcClient(server) | ||
it('genesis should be correctly setup', async () => { | ||
const res = await rpc.request('eth_getBlockByNumber', ['0x0', false]) | ||
|
||
const block0 = res.result | ||
assert.equal(block0.hash, genesisVerkleBlockHash) | ||
assert.equal(block0.stateRoot, genesisVerkleStateRoot) | ||
}) | ||
|
||
// currently it seems the the blocks can't be played one after another as it seems | ||
// to not do clean init of the statemanager. this isn't a problem in sequential | ||
// execution, but need to be fixed up in the stateless random execution | ||
// TEST_SAVED_NUMBERS=353,368,374,479 | ||
const savedTestCases = process.env.TEST_SAVED_NUMBERS?.split(',') ?? [] | ||
|
||
for (const testCase of savedTestCases) { | ||
it(`run saved block ${testCase}`, async () => { | ||
const testData = blocks[testCase] | ||
if (testData === undefined) { | ||
throw Error('unavailable data') | ||
} | ||
await runBlock({ common, chain, rpc }, blocks[testCase]) | ||
}) | ||
} | ||
|
||
// we can also test online slots (not numbers because ELs don't provide witnesses | ||
// directly, so we need to pull payload from beacon) | ||
// TEST_ONLINE_SLOTS=345,375,368..467, | ||
for (const numberOrRange of process.env.TEST_ONLINE_SLOTS?.split(',') ?? []) { | ||
if (process.env.PEER_BEACON_URL === undefined) { | ||
throw Error(`PEER_BEACON_URL env is not defined`) | ||
} | ||
|
||
const rangeSplit = numberOrRange.split('..') | ||
const startSlot = parseInt(rangeSplit[0]) | ||
const endSlot = parseInt(rangeSplit[1] ?? rangeSplit[0]) | ||
let parent = await fetchExecutionPayload(process.env.PEER_BEACON_URL, startSlot - 1) | ||
for (let i = startSlot; i <= endSlot; i++) { | ||
const execute = await fetchExecutionPayload(process.env.PEER_BEACON_URL, startSlot) | ||
console.log(execute.execution_witness) | ||
it(`run fetched block slot: ${i} number: ${execute.block_number}`, async () => { | ||
await runBlock({ common, chain, rpc }, { parent, execute }) | ||
parent = execute | ||
}) | ||
} | ||
} | ||
|
||
it(`reset TD`, () => { | ||
server.close() | ||
BlockHeader.prototype['_consensusFormatValidation'] = originalValidate | ||
td.reset() | ||
}) | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so cool, just tested this, works like a charm!!! 🔥 👍 🙂