Skip to content

Commit

Permalink
verkle: initcode fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Ignacio Hagopian <[email protected]>
  • Loading branch information
jsign committed Aug 5, 2024
1 parent a28e7c5 commit 861ad2a
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_extcodecopy_precompile(blockchain_test: BlockchainTestFiller, fork: str
to=None,
gas_limit=1_000_000,
gas_price=10,
data=Initcode(deploy_code=Op.EXTCODECOPY(target, 0, 0, 100)).bytecode,
data=Initcode(deploy_code=Op.EXTCODECOPY(target, 0, 0, 100)),
)
blocks = [Block(txs=[tx])]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def _generic_codecopy(
if instr == Op.EXTCODECOPY:
to = None
extcodecopy_code = Op.EXTCODECOPY(TestAddress2, 0, offset, size) * repeat
data = Initcode(deploy_code=extcodecopy_code).bytecode
data = Initcode(deploy_code=extcodecopy_code)

tx = Transaction(
ty=0x0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def test_generic_codecopy_initcode(blockchain_test: BlockchainTestFiller, fork:
contract_address = compute_create_address(TestAddress, 0)
if instruction == Op.EXTCODECOPY:
deploy_code = Op.EXTCODECOPY(contract_address, 0, 0, 100) + Op.ORIGIN * 100
data = Initcode(deploy_code=deploy_code).bytecode
data = Initcode(deploy_code=deploy_code)
else:
data = Initcode(deploy_code=Op.CODECOPY(0, 0, 100) + Op.ORIGIN * 100).bytecode
data = Initcode(deploy_code=Op.CODECOPY(0, 0, 100) + Op.ORIGIN * 100)

tx = Transaction(
ty=0x0,
Expand Down
9 changes: 5 additions & 4 deletions tests/verkle/eip4762_verkle_gas_witness/test_creates.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Block,
BlockchainTestFiller,
Environment,
Bytecode,
Initcode,
TestAddress,
TestAddress2,
Expand Down Expand Up @@ -277,15 +278,15 @@ def _create(
}

deploy_code = Initcode(
initcode_prefix=Op.STOP if initcode_stop_prefix else "", deploy_code=contract_code
initcode_prefix=Op.STOP if initcode_stop_prefix else Bytecode(), deploy_code=contract_code
)
if create_instruction == Op.CREATE:
pre[TestAddress2] = Account(
code=Op.CALLDATACOPY(0, 0, len(deploy_code)) + Op.CREATE(value, 0, len(deploy_code))
)
tx_target = TestAddress2
tx_value = 0
tx_data = deploy_code.bytecode
tx_data = deploy_code
if generate_collision:
contract_address = compute_create_address(TestAddress, 0)
pre[contract_address] = Account(nonce=1)
Expand All @@ -296,14 +297,14 @@ def _create(
)
tx_target = TestAddress2
tx_value = 0
tx_data = deploy_code.bytecode
tx_data = deploy_code
if generate_collision:
contract_address = compute_create2_address(TestAddress, 0xDEADBEEF, deploy_code)
pre[contract_address] = Account(nonce=1)
else:
tx_target = None
tx_value = value
tx_data = deploy_code.bytecode
tx_data = deploy_code
if generate_collision:
contract_address = compute_create_address(TestAddress, 0)
pre[contract_address] = Account(nonce=1)
Expand Down
5 changes: 3 additions & 2 deletions tests/verkle/eip4762_verkle_gas_witness/test_extcodesize.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Block,
BlockchainTestFiller,
Environment,
Bytecode,
Initcode,
TestAddress,
TestAddress2,
Expand Down Expand Up @@ -95,7 +96,7 @@ def _extcodesize(
blockchain_test: BlockchainTestFiller,
fork: str,
target: Address,
bytecode: bytes,
bytecode: Bytecode,
extra_witness: Witness,
gas_limit=1_000_000,
warm=False,
Expand Down Expand Up @@ -124,7 +125,7 @@ def _extcodesize(
gas_price=10,
data=Initcode(
deploy_code=Op.EXTCODESIZE(target) * (2 if warm else 1) + Op.PUSH0 + Op.SSTORE
).bytecode,
),
)
blocks = [Block(txs=[tx])]

Expand Down
3 changes: 2 additions & 1 deletion tests/verkle/eip4762_verkle_gas_witness/test_sload.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from ethereum_test_tools import (
Account,
Block,
Bytecode,
BlockchainTestFiller,
Environment,
TestAddress,
Expand Down Expand Up @@ -86,7 +87,7 @@ def _sload(
number=1,
timestamp=1000,
)
code = bytes()
code = Bytecode()
for slot in storage_slot_accesses:
code += Op.SLOAD(slot)

Expand Down
3 changes: 2 additions & 1 deletion tests/verkle/eip4762_verkle_gas_witness/test_sstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Account,
Block,
BlockchainTestFiller,
Bytecode,
Environment,
TestAddress,
TestAddress2,
Expand Down Expand Up @@ -111,7 +112,7 @@ def _sstore(
number=1,
timestamp=1000,
)
code = bytes()
code = Bytecode()
for slot_write in storage_slot_writes:
code += Op.SSTORE(slot_write[0], slot_write[1])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_code_chunking(blockchain_test: BlockchainTestFiller, fork: str, bytecod
to=None,
gas_limit=100000000,
gas_price=10,
data=Initcode(deploy_code=bytecode).deploy_code,
data=Initcode(deploy_code=bytecode),
)
blocks = [Block(txs=[tx])]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_contract_creation(
gas_limit=100000000,
gas_price=10,
value=value,
data=Initcode(deploy_code=bytecode).deploy_code,
data=Initcode(deploy_code=bytecode),
)
blocks = [Block(txs=[tx])]

Expand Down
22 changes: 11 additions & 11 deletions tests/verkle/eip7709_blockhash_witness/test_filling.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
(https://eips.ethereum.org/EIPS/eip-7709).
"""

import pytest
# import pytest

from ethereum_test_tools import (
Account,
Address,
Block,
BlockchainTestFiller,
Environment,
TestAddress,
TestAddress2,
Transaction,
)
# from ethereum_test_tools import (
# Account,
# Address,
# Block,
# BlockchainTestFiller,
# Environment,
# TestAddress,
# TestAddress2,
# Transaction,
# )

# TODO(verkle): add test for per-block filling of blockhash history in state and witness.

0 comments on commit 861ad2a

Please sign in to comment.