Skip to content
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

verkle: verkle genesis test-vectors #659

Merged
merged 102 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
962cefe
osaka folder
jsign Jul 31, 2024
cae733f
osaka/verkle: init
jsign May 9, 2024
b35b08f
osaka/verkle: add 6800 transfer test
jsign May 9, 2024
a09b579
whitelist: add verkle related keywords
jsign May 9, 2024
2fc7397
osaka: add verkle helpers
jsign May 9, 2024
e7da063
osaka/verkle: fix tests
jsign May 9, 2024
89aae0d
whitelist: add more keywords
jsign May 9, 2024
d65a6ba
osaka/vkt: add contract creation test and more vkt_* helpers
jsign May 9, 2024
0851e2f
osaka/verkle: EIP-4762 init
jsign May 9, 2024
35b8220
osaka/verkle: eip4762 transfer witness checks
jsign May 9, 2024
12c8561
osaka/verkle: EIP-4762 add simpel contract exec witness test
jsign May 9, 2024
b9fd4f6
osaka/verkle: fix comments
jsign May 9, 2024
63be88e
osaka/verkle: set that conversion ended
jsign May 13, 2024
9f6679f
osaka/verkle: t8n limitations adjustements
jsign May 21, 2024
2c90a9f
osaka/verkle: more adjustements
jsign May 21, 2024
1c88d72
osaka/verkle: EIP-6800 storage slot writes
jsign May 21, 2024
a18f7c2
osaka/verkle: EIP-6800 code chunking tests
jsign May 22, 2024
905f08f
osaka/verkle: EIP-4762 generalize eth transfer test and include tx fa…
jsign May 22, 2024
9e64ca7
osaka/verkle: rely on fork to configure verkle genesis tests
jsign May 22, 2024
fba4478
osaka/verkle: EIP-4762 add *CALL tests
jsign May 24, 2024
5770f20
osaka/verkle: EIP-4762 add *CALL insufficient gas for dynamic cost tests
jsign May 24, 2024
685fa4a
osaka/verkle: EIP-4762 add *CALL revert tests
jsign May 24, 2024
77d42c0
osaka/verkle: EIP-4762 add *CALL warm cost tests
jsign May 24, 2024
0dbdbd1
osaka/verkle: EIP-4762 add EXTCODESIZE normal test
jsign May 24, 2024
e8e62bf
osaka/verkle: EIP-4762 add EXTCODESIZE warm test
jsign May 24, 2024
992ecdd
osaka/verkle: EIP-4762 add CODECOPY basic test
jsign May 27, 2024
8563119
osaka/verkle: EIP-4762 add CODECOPY in initcode test
jsign May 27, 2024
335c969
osaka/verkle: EIP-4762 add CODECOPY with insufficient gas test
jsign May 27, 2024
129160f
osaka/verkle: EIP-4762 support EXTCODECOPY in existing CODECOPY test
jsign May 27, 2024
28b74da
osaka/verkle: EIP-4762 support EXTCODECOPY in existing CODECOPY initc…
jsign May 27, 2024
a24417f
osaka/verkle: EIP-4762 file renamings
jsign May 27, 2024
84f5da5
osaka/verkle: EIP-4762 support EXTCODECOPY in existing CODECOPY insuf…
jsign May 27, 2024
6704362
osaka/verkle: EIP-4762 support CODECOPY & EXTCODECOPY WARM test
jsign May 27, 2024
c45682b
osaka/verkle: EIP-4762 support EXTCODECOPY precompile test
jsign May 27, 2024
aef9585
osaka/verkle: EIP-4762 fix Initcode missing .bytecode
jsign May 27, 2024
3bb6a38
osaka/verkle: EIP-4762 support *CREATE witness test
jsign May 27, 2024
babc7bb
osaka/verkle: EIP-4762 support *CREATE with insufficient dynamig gas …
jsign May 28, 2024
03e507f
osaka/verkle: EIP-4762 support *CREATE with address collision test
jsign May 28, 2024
0f63316
osaka/verkle: EIP-4762 support BALANCE witness test
jsign May 28, 2024
0345c90
osaka/verkle: EIP-4762 support BALANCE insufficient dynamig gas test
jsign May 28, 2024
9cb260c
osaka/verkle: EIP-4762 support BALANCE warm test
jsign May 28, 2024
597a1f7
osaka/verkle: EIP-4762 support SELFDESTRUCT test
jsign May 28, 2024
7f7e1e9
osaka/verkle: EIP-4762 support SELFDESTRUCT insufficient gas test
jsign May 28, 2024
6b07973
osaka/verkle: EIP-4762 support EXTCODEHASH test
jsign May 29, 2024
05f58ea
osaka/verkle: EIP-4762 support SLOAD test
jsign May 29, 2024
1ef2d15
osaka/verkle: EIP-4762 support SLOAD with insufficient gas test
jsign May 29, 2024
18f029e
osaka/verkle: EIP-4762 support SSTORE test
jsign May 29, 2024
5365511
osaka/verkle: EIP-4762 support SSTORE with insufficient gas test
jsign May 29, 2024
3b5c943
osaka/verkle: EIP-4762 support withdrawals test
jsign May 29, 2024
23d9220
osaka/verkle: EIP-4762 support coinbase test
jsign May 29, 2024
565de80
osaka/verkle: EIP-4762 more code execution tests
jsign May 29, 2024
6f8c541
osaka/verkle: EIP-4762 more code execution tests
jsign May 30, 2024
3045113
osaka/verkle: EIP-4762 *CALL insufficient gas for 63/64 tests
jsign May 30, 2024
099ebfc
osaka/verkle: EIP-4762 CREATE* insufficient gas for 63/64 tests
jsign May 30, 2024
8dbf5a2
osaka/verkle: EIP-4762 CREATE* calldata bigger than returned code test
jsign Jun 3, 2024
6f82be4
osaka/verkle: redesign witness helpers
jsign Jun 4, 2024
7324baa
osaka/verkle: EIP-4762 contract execution with new witness helpers
jsign Jun 4, 2024
b176139
osaka/verkle: EIP-4762 BALANCE improvements
jsign Jun 4, 2024
d46251f
osaka/verkle: witness helper support None witness values
jsign Jun 4, 2024
b599169
osaka/verkle: EIP-4762 *CALL improvements
jsign Jun 4, 2024
ffe5003
osaka/verkle: EIP-4762 coinbase rewards improvements
jsign Jun 5, 2024
488420b
osaka/verkle: EIP-4762 code execution improvements
jsign Jun 5, 2024
4475ee6
osaka/verkle: EIP-4762 tx creation and *CREATE improvements
jsign Jun 5, 2024
142da63
osaka/verkle: EIP-4762 EXTCODEHASH improvements
jsign Jun 6, 2024
189353d
osaka/verkle: EIP-4762 EXTCODESIZE improvements
jsign Jun 6, 2024
2552eaa
osaka/verkle: EIP-4762 *CODECOPY improvements
jsign Jun 6, 2024
6458a9c
osaka/verkle: EIP-4762 SELFDESTRUCT improvements
jsign Jun 6, 2024
0d31c68
osaka/verkle: EIP-4762 SLOAD improvements
jsign Jun 7, 2024
7e6b2a6
osaka/verkle: EIP-4762 SSTORE improvements
jsign Jun 7, 2024
014e491
osaka/verkle: EIP-4762 tx events improvements
jsign Jun 7, 2024
705e55c
osaka/verkle: EIP-4762 withdrawals improvements
jsign Jun 10, 2024
8b57d52
osaka/verkle: EIP-7709 init
jsign Jun 10, 2024
b006f2b
osaka/verkle: EIP-7709 BLOCKHASH tests
jsign Jun 10, 2024
e74f13b
osaka/verkle: EIP-7709 filling file
jsign Jun 10, 2024
fac8413
osaka: fixes
jsign Jul 1, 2024
a4ed401
osaka/verkle: fix balance value
jsign Jul 30, 2024
56f1633
rebase
jsign Jul 31, 2024
e2db680
verkle: comment test with failing compilation
jsign Jul 31, 2024
adc9c20
verkle: fix fork naming
jsign Jul 31, 2024
9fddb92
fix(fw): fill verkle genesis with input vkt & env conv ended.
spencer-tb Aug 1, 2024
95915c8
verkle/6800: fix test
jsign Aug 1, 2024
2f00c44
verkle/6800: fix test
jsign Aug 1, 2024
0775828
feat(fw): add verkle state root geth t8n sub-command.
spencer-tb Aug 2, 2024
34ace2c
feat(fw): add verkle state root sub-command.
spencer-tb Aug 2, 2024
dda885c
feat(fw): fix genesis state root for conversion tests.
spencer-tb Aug 2, 2024
970caa6
verkle: fix precompile address to avoid requiring valid calldata
jsign Aug 5, 2024
de813b1
verkle: initcode fixes
jsign Aug 5, 2024
237b9a7
verkle: fix tests naming
jsign Aug 5, 2024
1d6c3fb
feat(fw): add pre alloc to t8n input alongside vkt.
spencer-tb Aug 6, 2024
a4f6dc9
verkle: fix balance tests
jsign Aug 6, 2024
2e0b3b0
verkle: fixes
jsign Aug 6, 2024
1ea0372
feat(fw): create verkle types.
spencer-tb Aug 1, 2024
ea76635
chore: typo.
spencer-tb Aug 1, 2024
af96fb7
wip(fw): add the witness to fixture from t8n output result.
spencer-tb Aug 6, 2024
a94000f
fix(fw): witness in fixtures from t8n output result.
spencer-tb Aug 6, 2024
ed32c9e
fix(fw): add basic test for witness model.
spencer-tb Aug 6, 2024
4645bd7
fix(fw): fix tests for witness model.
spencer-tb Aug 6, 2024
be06ec7
adjustement for filling
jsign Aug 6, 2024
53fa104
verkle: fix sstore test
jsign Aug 7, 2024
81fa30f
verkle: fixes
jsign Aug 7, 2024
95c1aa0
feat: add release configs for genesis & conv tests.
spencer-tb Aug 8, 2024
fba0400
Merge pull request #6 from spencer-tb/verkle-release-conf
jsign Aug 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion configs/evm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ eip7692:
impl: evmone
repo: ethereum/evmone
ref: master
evm-bin: evmone-t8n
evm-bin: evmone-t8n
verkle:
impl: geth
repo: gballet/go-ethereum
ref: jsign-t8n-verkle-genesis-rebased
evm-bin: evm
10 changes: 9 additions & 1 deletion configs/feature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@ develop:
eip7692:
evm-type: eip7692
fill-params: --fork=CancunEIP7692 ./tests/prague
solc: 0.8.21
solc: 0.8.21
verkle-genesis:
evm-type: verkle
fill-params: --fork=Verkle -m blockchain_test
solc: 0.8.24
verkle-conversion-stride-0:
evm-type: verkle
fill-params: --fork=EIP6800Transition -m blockchain_test
solc: 0.8.24
2 changes: 2 additions & 0 deletions src/ethereum_test_base_types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
HexNumber,
Number,
NumberBoundTypeVar,
PaddedFixedSizeBytes,
ZeroPaddedHexNumber,
)
from .composite_types import Account, Alloc, Storage, StorageRootType
Expand Down Expand Up @@ -53,6 +54,7 @@
"HexNumber",
"Number",
"NumberBoundTypeVar",
"PaddedFixedSizeBytes",
"ReferenceSpec",
"Storage",
"StorageRootType",
Expand Down
15 changes: 15 additions & 0 deletions src/ethereum_test_base_types/base_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,21 @@ def __ne__(self, other: object) -> bool:
return not self.__eq__(other)


class PaddedFixedSizeBytes(FixedSizeBytes):
"""
Class that represents fixed-size bytes with padded hex output.
"""

def hex(self, *args, **kwargs) -> str:
"""
Returns the hexadecimal representation of the bytes with padding.
"""
hex_str = super().hex(*args, **kwargs)[2:]
if len(hex_str) % 2 != 0:
hex_str = "0" + hex_str
return "0x" + hex_str.zfill(self.byte_length * 2)


class Address(FixedSizeBytes[20]): # type: ignore
"""
Class that helps represent Ethereum addresses in tests.
Expand Down
1 change: 1 addition & 0 deletions src/ethereum_test_base_types/pydantic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Base pydantic classes used to define the models for Ethereum tests.
"""

from typing import TypeVar

from pydantic import BaseModel, ConfigDict
Expand Down
16 changes: 16 additions & 0 deletions src/ethereum_test_fixtures/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
WithdrawalRequest,
WithdrawalRequestGeneric,
)
from ethereum_test_types.verkle import Witness

from .base import BaseFixture
from .formats import FixtureFormats
Expand Down Expand Up @@ -412,6 +413,19 @@ def from_consolidation_request(
return cls(**d.model_dump())


class FixtureWitness(Witness):
"""
Structure to represent a single verkle block witness.
"""

@classmethod
def from_witness(cls, w: Witness) -> "FixtureWitness":
"""
Returns a FixtureWitness from a Witness.
"""
return cls(**w.model_dump())


class FixtureBlockBase(CamelModel):
"""Representation of an Ethereum block within a test Fixture without RLP bytes."""

Expand All @@ -423,6 +437,8 @@ class FixtureBlockBase(CamelModel):
withdrawal_requests: List[FixtureWithdrawalRequest] | None = None
consolidation_requests: List[FixtureConsolidationRequest] | None = None

witness: FixtureWitness | None = None

@computed_field(alias="blocknumber") # type: ignore[misc]
@cached_property
def block_number(self) -> Number:
Expand Down
3 changes: 2 additions & 1 deletion src/ethereum_test_specs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
from ethereum_test_base_types import to_hex
from ethereum_test_fixtures import BaseFixture, FixtureFormats
from ethereum_test_forks import Fork
from ethereum_test_types import Alloc, Environment, Transaction, VerkleTree, Withdrawal
from ethereum_test_types import Alloc, Environment, Transaction, Withdrawal
from ethereum_test_types.verkle import VerkleTree
from evm_transition_tool import Result, TransitionTool


Expand Down
63 changes: 46 additions & 17 deletions src/ethereum_test_specs/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
HeaderNonce,
HexNumber,
Number,
to_json,
)
from ethereum_test_exceptions import BlockException, EngineAPIError, TransactionException
from ethereum_test_fixtures import BaseFixture, FixtureFormats
Expand All @@ -34,6 +33,7 @@
FixtureTransaction,
FixtureWithdrawal,
FixtureWithdrawalRequest,
FixtureWitness,
InvalidFixtureBlock,
)
from ethereum_test_forks import EIP6800Transition, Fork, Verkle
Expand All @@ -45,10 +45,10 @@
Removable,
Requests,
Transaction,
VerkleTree,
Withdrawal,
WithdrawalRequest,
)
from ethereum_test_types.verkle import VerkleTree, Witness
from evm_transition_tool import TransitionTool

from .base import BaseTest, verify_result, verify_transactions
Expand Down Expand Up @@ -328,6 +328,7 @@ class BlockchainTest(BaseTest):
def make_genesis(
self,
fork: Fork,
t8n: TransitionTool,
) -> Tuple[Alloc, FixtureBlock]:
"""
Create a genesis block from the blockchain test definition.
Expand All @@ -346,7 +347,14 @@ def make_genesis(
)
if empty_accounts := pre_alloc.empty_accounts():
raise Exception(f"Empty accounts in pre state: {empty_accounts}")
state_root = pre_alloc.state_root()

state_root: bytes
# TODO: refine, currently uses `evm verkle state-root` to get this.
if fork < Verkle or fork is EIP6800Transition:
state_root = pre_alloc.state_root()
else:
state_root = t8n.get_verkle_state_root(mpt_alloc=pre_alloc)

genesis = FixtureHeader(
parent_hash=0,
ommers_hash=EmptyOmmersRoot,
Expand Down Expand Up @@ -404,6 +412,7 @@ def generate_block_data(
Alloc,
Optional[Requests],
Optional[VerkleTree],
Optional[Witness],
]:
"""
Generate common block data for both make_fixture and make_hive_fixture.
Expand Down Expand Up @@ -436,7 +445,7 @@ def generate_block_data(
txs=txs,
env=env,
fork=fork,
vkt=to_json(previous_vkt) if previous_vkt is not None else None,
vkt=previous_vkt,
chain_id=self.chain_id,
reward=fork.get_reward(env.number, env.timestamp),
eips=eips,
Expand All @@ -446,13 +455,17 @@ def generate_block_data(
try:
rejected_txs = verify_transactions(txs, transition_tool_output.result)
verify_result(transition_tool_output.result, env)
# TODO: add verify witness (against vkt)
# verify_witness(transition_tool_output.witness, transition_tool_output.vkt)
except Exception as e:
print_traces(t8n.get_traces())
pprint(transition_tool_output.result)
pprint(previous_alloc)
pprint(transition_tool_output.alloc)
if transition_tool_output.vkt is not None:
pprint(transition_tool_output.vkt)
if transition_tool_output.witness is not None:
pprint(transition_tool_output.witness)
raise e

if len(rejected_txs) > 0 and block.exception is None:
Expand Down Expand Up @@ -525,6 +538,11 @@ def generate_block_data(
)
)
transition_tool_output.alloc = previous_alloc
# TODO: hack for now
transition_tool_output.witness = Witness(
verkle_proof=transition_tool_output.result.verkle_proof,
state_diff=transition_tool_output.result.state_diff,
)

return (
env,
Expand All @@ -533,6 +551,7 @@ def generate_block_data(
transition_tool_output.alloc,
requests,
transition_tool_output.vkt,
transition_tool_output.witness,
)

def network_info(self, fork: Fork, eips: Optional[List[int]] = None):
Expand All @@ -556,7 +575,7 @@ def verify_post_state(
Verifies the post state after all block/s or payload/s are generated.
"""
try:
if env.verkle_conversion_started:
if env.verkle_conversion_started or env.verkle_conversion_ended:
if vkt is not None:
pass # TODO: skip exact account verify checks
# verify_post_vkt(t8n=t8n, expected_post=self.post, got_vkt=vkt)
Expand All @@ -579,13 +598,19 @@ def make_fixture(
"""
fixture_blocks: List[FixtureBlock | InvalidFixtureBlock] = []

pre, genesis = self.make_genesis(fork)
pre, genesis = self.make_genesis(fork, t8n)

alloc = pre
env = environment_from_parent_header(genesis.header)
head = genesis.header.block_hash
vkt: Optional[VerkleTree] = None

# Filling for verkle genesis tests
if fork is Verkle:
env.verkle_conversion_ended = True
# convert alloc to vkt
vkt = t8n.from_mpt_to_vkt(alloc)

# Hack for filling naive verkle transition tests
if fork is EIP6800Transition:
# Add a dummy block before the fork transition
Expand All @@ -603,14 +628,16 @@ def make_fixture(
# This is the most common case, the RLP needs to be constructed
# based on the transactions to be included in the block.
# Set the environment according to the block to execute.
new_env, header, txs, new_alloc, requests, new_vkt = self.generate_block_data(
t8n=t8n,
fork=fork,
block=block,
previous_env=env,
previous_alloc=alloc,
previous_vkt=vkt,
eips=eips,
new_env, header, txs, new_alloc, requests, new_vkt, witness = (
self.generate_block_data(
t8n=t8n,
fork=fork,
block=block,
previous_env=env,
previous_alloc=alloc,
previous_vkt=vkt,
eips=eips,
)
)
fixture_block = FixtureBlockBase(
header=header,
Expand Down Expand Up @@ -645,6 +672,7 @@ def make_fixture(
if requests is not None
else None
),
witness=FixtureWitness.from_witness(witness) if witness is not None else None,
).with_rlp(txs=txs, requests=requests)
if block.exception is None:
fixture_blocks.append(fixture_block)
Expand Down Expand Up @@ -699,7 +727,7 @@ def make_hive_fixture(
"""
fixture_payloads: List[FixtureEngineNewPayload] = []

pre, genesis = self.make_genesis(fork)
pre, genesis = self.make_genesis(fork, t8n)
alloc = pre
env = environment_from_parent_header(genesis.header)
head_hash = genesis.header.block_hash
Expand All @@ -718,7 +746,8 @@ def make_hive_fixture(
self.blocks.append(Block())

for block in self.blocks:
new_env, header, txs, new_alloc, requests, new_vkt = self.generate_block_data(
# TODO: fix witness for hive fixture? Do we need it?
new_env, header, txs, new_alloc, requests, new_vkt, _ = self.generate_block_data(
t8n=t8n,
fork=fork,
block=block,
Expand Down Expand Up @@ -762,7 +791,7 @@ def make_hive_fixture(
# Most clients require the header to start the sync process, so we create an empty
# block on top of the last block of the test to send it as new payload and trigger the
# sync process.
_, sync_header, _, _, requests, _ = self.generate_block_data(
_, sync_header, _, _, requests, _, _ = self.generate_block_data(
t8n=t8n,
fork=fork,
block=Block(),
Expand Down
2 changes: 0 additions & 2 deletions src/ethereum_test_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
Storage,
TestParameterGroup,
Transaction,
VerkleTree,
Withdrawal,
WithdrawalRequest,
add_kzg_version,
Expand Down Expand Up @@ -133,7 +132,6 @@
"TransactionException",
"Withdrawal",
"WithdrawalRequest",
"VerkleTree",
"Yul",
"YulCompiler",
"add_kzg_version",
Expand Down
2 changes: 0 additions & 2 deletions src/ethereum_test_types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
Requests,
Storage,
Transaction,
VerkleTree,
Withdrawal,
WithdrawalRequest,
)
Expand All @@ -54,7 +53,6 @@
"TestPrivateKey",
"TestPrivateKey2",
"Transaction",
"VerkleTree",
"Withdrawal",
"WithdrawalRequest",
"ZeroPaddedHexNumber",
Expand Down
9 changes: 0 additions & 9 deletions src/ethereum_test_types/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1250,12 +1250,3 @@ def consolidation_requests(self) -> List[ConsolidationRequest]:
Returns the list of consolidation requests.
"""
return [c for c in self.root if isinstance(c, ConsolidationRequest)]


# TODO: use a type like HashInt but that doesn't pad zero. DO NOT PAD THE ZEROS. KEEP ALL ZEROS.
class VerkleTree(RootModel[Dict[str, str]]):
"""
Definition of a verkle tree return from the geth t8n.
"""

root: Dict[str, str] = Field(default_factory=dict)
14 changes: 14 additions & 0 deletions src/ethereum_test_types/verkle/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
Ethereum Verkle Test Types.
"""

from .types import IpaProof, StateDiff, SuffixStateDiff, VerkleProof, VerkleTree, Witness

__all__ = (
"IpaProof",
"StateDiff",
"SuffixStateDiff",
"VerkleProof",
"VerkleTree",
"Witness",
)
Loading
Loading