Skip to content

Commit

Permalink
verkle: fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Ignacio Hagopian <[email protected]>
  • Loading branch information
jsign committed Sep 11, 2024
1 parent 9c56c4a commit fd637be
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
5 changes: 1 addition & 4 deletions tests/verkle/eip4762_verkle_gas_witness/test_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,7 @@ def _generic_call(

witness_check = WitnessCheck(fork=Verkle)
for address in [TestAddress, caller_address, env.fee_recipient]:
witness_check.add_account_full(
address=address,
account=(None if address == env.fee_recipient else pre[address]),
)
witness_check.add_account_full(address=address, account=pre.get(address))
if enough_gas_read_witness:
if value > 0 or (target != precompile_address and target != precompile_address):
witness_check.add_account_basic_data(address=target, account=pre[target])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,34 @@
Block,
BlockchainTestFiller,
Environment,
Initcode,
TestAddress,
TestAddress2,
Transaction,
WitnessCheck,
)
from ethereum_test_tools.vm.opcode import Opcodes as Op
from ethereum_test_types.verkle.helpers import chunkify_code
from ethereum_test_forks import Fork


# TODO(verkle): Update reference spec version
REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md"
REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0"

precompile_address = Address("0x04")
system_contract_address = Address("0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02")
system_contract_address = Address("0xfffffffffffffffffffffffffffffffffffffffe")


# TODO(verkle): update to Osaka when t8n supports the fork.
@pytest.mark.valid_from("Verkle")
@pytest.mark.parametrize(
"target",
[
precompile_address,
# precompile_address,
system_contract_address,
],
)
def test_extcodecopy_precompile(blockchain_test: BlockchainTestFiller, fork: str, target):
def test_extcodecopy_precompile(blockchain_test: BlockchainTestFiller, fork: Fork, target):
"""
Test EXTCODECOPY targeting a precompile or system contract.
"""
Expand All @@ -51,24 +54,34 @@ def test_extcodecopy_precompile(blockchain_test: BlockchainTestFiller, fork: str
)
pre = {
TestAddress: Account(balance=1000000000000000000000),
TestAddress2: Account(
balance=1000000000000000000000, code=Op.EXTCODECOPY(target, 0, 0, 100)
),
}

tx = Transaction(
ty=0x0,
chain_id=0x01,
nonce=0,
to=None,
to=TestAddress2,
gas_limit=1_000_000,
gas_price=10,
data=Initcode(deploy_code=Op.EXTCODECOPY(target, 0, 0, 100)),
)

witness_check = WitnessCheck(fork=Verkle)
for address in [env.fee_recipient, TestAddress]:
witness_check.add_account_full(
address=address,
account=(None if address == env.fee_recipient else pre[address]),
)
for address in [env.fee_recipient, TestAddress, TestAddress2]:
witness_check.add_account_full(address=address, account=pre.get(address))
code_chunks = chunkify_code(pre[TestAddress2].code)
for i, chunk in enumerate(code_chunks, start=0):
witness_check.add_code_chunk(address=TestAddress2, chunk_number=i, value=chunk)

if target == system_contract_address:
code = Account(**fork.pre_allocation_blockchain()[system_contract_address]).code
code_chunks = chunkify_code(code)
for i in range(5):
witness_check.add_code_chunk(
address=TestAddress2, chunk_number=i, value=code_chunks[i]
)

blocks = [
Block(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"instruction",
[
Op.CODECOPY,
Op.EXTCODECOPY,
# Op.EXTCODECOPY,
],
)
def test_generic_codecopy_initcode(blockchain_test: BlockchainTestFiller, fork: str, instruction):
Expand Down

0 comments on commit fd637be

Please sign in to comment.