Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,48 @@ def test_invalid_then_valid_siblings(blockchain_test, pre) -> None:
"""
)

REDELIVERY_MODULE = textwrap.dedent(
"""\
import pytest

from execution_testing import (
Block,
BlockAccessListExpectation,
BlockException,
Bytes,
Transaction,
)


@pytest.mark.valid_from("Amsterdam")
@pytest.mark.blockchain_test_engine_only
@pytest.mark.exception_test
def test_redelivered_then_extended(blockchain_test, pre) -> None:
# The first copy carries the wrong list under the canonical
# header, so both copies are one block.
tx =Transaction(to=0, value=1, sender=pre.fund_eoa())
wrong_list = BlockAccessListExpectation().modify_rlp(
lambda _: Bytes(b"\\xc0")
)
blockchain_test(
pre=pre,
post={},
blocks=[
Block(
txs=[tx],
expected_block_access_list=wrong_list,
exception=[
BlockException.INVALID_BLOCK_ACCESS_LIST,
BlockException.INVALID_BLOCK_HASH,
],
),
Block(txs=[tx]),
Block(),
],
)
"""
)

ERROR_CODE_MODULE = textwrap.dedent(
"""\
import pytest
Expand Down Expand Up @@ -611,6 +653,29 @@ def test_invalid_chains_carry_the_appended_block(
)


def test_redelivered_block_below_a_later_leaf_has_no_target(
pytester: pytest.Pytester,
) -> None:
"""
A block first rejected for its delivered list, then accepted below a
later leaf, keeps no target: the rejected copy's would build on the
block's parent state, and the later leaf's target carries the block.
"""
test_module = make_test_module(
pytester, REDELIVERY_MODULE, "test_redelivery.py"
)
output = fill(pytester, test_module, "--fork", "Amsterdam")

engine_x = fixtures_of_format(output, "blockchain_tests_engine_x")
(fixture,) = engine_x.values()
rejected, accepted, _ = fixture["engineNewPayloads"]
assert (
rejected["params"][0]["blockHash"]
== accepted["params"][0]["blockHash"]
), "both copies are one block"
assert_sync_payloads_above(fixture, blocks=3, leaf_indices=[2])


def test_error_code_chain_keeps_its_announcement(
pytester: pytest.Pytester,
) -> None:
Expand Down
31 changes: 15 additions & 16 deletions tests/london/eip1559_fee_market_change/test_fee_cap_width.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,38 +151,37 @@ def test_fee_cap_at_balance_limit(
gas_limit=GAS_LIMIT,
max_priority_fee_per_gas=max_priority_fee_per_gas,
)
# The value and any blob fee, which the fee cap does not scale.
other_costs = tx.copy(max_fee_per_gas=0).signer_minimum_balance(fork=fork)
largest_fee_cap = (MAX_BALANCE - other_costs) // tx.gas_limit
# What the sender owes at a zero fee cap: the value and any blob fee.
fixed_costs = tx.copy(max_fee_per_gas=0).signer_minimum_balance(fork=fork)
largest_fee_cap = (MAX_BALANCE - fixed_costs) // GAS_LIMIT

if above_largest:
fee_cap = largest_fee_cap + 1
# No balance covers this cost, so a client may reject it as an
# overflow before it reads the balance.
tx = tx.copy(
max_fee_per_gas=largest_fee_cap + 1,
error=[
TransactionException.INSUFFICIENT_ACCOUNT_FUNDS,
TransactionException.GASLIMIT_PRICE_PRODUCT_OVERFLOW,
],
)
assert tx.signer_minimum_balance(fork=fork) > MAX_BALANCE
pre.fund_address(sender, MAX_BALANCE)
error = [
TransactionException.INSUFFICIENT_ACCOUNT_FUNDS,
TransactionException.GASLIMIT_PRICE_PRODUCT_OVERFLOW,
]
post = {
witness: Account(storage={}),
sender: Account(nonce=tx.nonce),
}
else:
tx = tx.copy(max_fee_per_gas=largest_fee_cap)
upfront_cost = tx.signer_minimum_balance(fork=fork)
assert upfront_cost <= MAX_BALANCE
pre.fund_address(sender, upfront_cost)
fee_cap = largest_fee_cap
error = None
post = {
witness: Account(
storage={0: BASE_FEE_PER_GAS + max_priority_fee_per_gas}
),
sender: Account(nonce=tx.nonce + 1),
}

tx = tx.copy(max_fee_per_gas=fee_cap, error=error)
upfront_cost = tx.signer_minimum_balance(fork=fork)
assert (upfront_cost > MAX_BALANCE) == above_largest
pre.fund_address(sender, min(upfront_cost, MAX_BALANCE))

state_test(
env=Environment(base_fee_per_gas=BASE_FEE_PER_GAS),
pre=pre,
Expand Down