Skip to content

Commit

Permalink
do not export rlp_decoded if there is BlockException.RLP_STRUCTURES_E…
Browse files Browse the repository at this point in the history
…NCODING (#427)
  • Loading branch information
winsvega authored Feb 9, 2024
1 parent 7c03cb5 commit 3376669
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/ethereum_test_tools/exceptions/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class ExceptionBase(Enum):
Base class for exceptions.
"""

def __contains__(self, exception) -> bool:
"""
Checks if provided exception is equal to this
"""
return self == exception

def __or__(
self,
other: Union["TransactionException", "BlockException", ExceptionList],
Expand Down Expand Up @@ -147,6 +153,10 @@ class BlockException(ExceptionBase):
"""
Block's excess blob gas in header is incorrect.
"""
RLP_STRUCTURES_ENCODING = auto()
"""
Block's rlp encoding is valid but ethereum structures in it are invalid
"""


ExceptionType = Union[TransactionException, BlockException, ExceptionList]
7 changes: 6 additions & 1 deletion src/ethereum_test_tools/spec/blockchain/blockchain_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from ..debugging import print_traces
from .types import (
Block,
BlockException,
Fixture,
FixtureBlock,
FixtureEngineNewPayload,
Expand Down Expand Up @@ -353,7 +354,11 @@ def make_fixture(
InvalidFixtureBlock(
rlp=rlp,
expected_exception=block.exception,
rlp_decoded=replace(fixture_block, rlp=None),
rlp_decoded=(
None
if BlockException.RLP_STRUCTURES_ENCODING in block.exception
else replace(fixture_block, rlp=None)
),
),
)
else:
Expand Down
3 changes: 2 additions & 1 deletion tests/cancun/eip4844_blobs/test_blob_txs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,8 @@ def test_invalid_blob_tx_contract_creation(
blocks=[
Block(
txs=txs,
exception=TransactionException.TYPE_3_TX_CONTRACT_CREATION,
exception=TransactionException.TYPE_3_TX_CONTRACT_CREATION
| BlockException.RLP_STRUCTURES_ENCODING,
header_verify=header_verify,
)
],
Expand Down
5 changes: 4 additions & 1 deletion tests/cancun/eip4844_blobs/test_blob_txs_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Address,
Block,
BlockchainTestFiller,
BlockException,
Environment,
Header,
TestAddress,
Expand Down Expand Up @@ -256,7 +257,9 @@ def blocks(
if any(txs_wrapped_blobs):
# This is a block exception because the invalid block is only created in the RLP version,
# not in the transition tool.
block_error = TransactionException.TYPE_3_TX_WITH_FULL_BLOBS
block_error = (
TransactionException.TYPE_3_TX_WITH_FULL_BLOBS | BlockException.RLP_STRUCTURES_ENCODING
)
if len(txs) > 0:
header_blob_gas_used = (
sum(
Expand Down

0 comments on commit 3376669

Please sign in to comment.