Skip to content

Commit

Permalink
use frozenset instead of list
Browse files Browse the repository at this point in the history
  • Loading branch information
anvacaru committed Jan 14, 2025
1 parent 3cd7248 commit fa9b275
Showing 1 changed file with 50 additions and 27 deletions.
77 changes: 50 additions & 27 deletions kevm-pyk/src/kevm_pyk/gst_to_kore.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,64 @@
SORT_MODE: Final = SortApp('SortMode')
SORT_ETHEREUM_SIMULATION: Final = SortApp('SortEthereumSimulation')

GST_DISCARD_KEYS: Final = [
'//',
'_info',
'callcreates',
'sealEngine',
'transactionSequence',
'chainname',
'expectException',
'lastblockhash',
]
GST_LOAD_KEYS: Final = ['env', 'pre', 'rlp', 'network', 'genesisRLP']
GST_EXEC_KEYS: Final = ['exec', 'blocks']
GST_POST_KEYS: Final = ['post', 'postState', 'postStateHash']
GST_ALL_POST_KEYS: Final = GST_POST_KEYS + ['expect', 'export']
GST_CHECK_KEYS: Final = GST_ALL_POST_KEYS + [
'logs',
'out',
'gas',
'blockHeader',
'transactions',
'uncleHeaders',
'genesisBlockHeader',
'withdrawals',
'blocknumber',
]
_GST_DISCARD_KEYS: Final = frozenset(
[
'//',
'_info',
'callcreates',
'sealEngine',
'transactionSequence',
'chainname',
'expectException',
'lastblockhash',
]
)
_GST_LOAD_KEYS: Final = frozenset(
[
'env',
'pre',
'rlp',
'network',
'genesisRLP',
]
)
_GST_EXEC_KEYS: Final = frozenset(
[
'exec',
'blocks',
]
)
_GST_POST_KEYS: Final = frozenset(
[
'post',
'postState',
'postStateHash',
]
)
_GST_ALL_POST_KEYS: Final = _GST_POST_KEYS.union(['expect', 'export'])
_GST_CHECK_KEYS: Final = _GST_ALL_POST_KEYS.union(
[
'logs',
'out',
'gas',
'blockHeader',
'transactions',
'uncleHeaders',
'genesisBlockHeader',
'withdrawals',
'blocknumber',
]
)


def filter_gst_keys(gst_data: dict) -> dict:
"""Filters the discarded keys out of a single GeneralStateTest.
:param gst_data: A single test from a GST file structured as {"test_name": {test_fields}, ... }.
:returns: The gst_data object after filtering out GST_DISCARD_KEYS.
:returns: The gst_data object after filtering out _GST_DISCARD_KEYS.
"""
return {
test_name: {k: v for k, v in test_data.items() if k not in GST_DISCARD_KEYS}
test_name: {k: v for k, v in test_data.items() if k not in _GST_DISCARD_KEYS}
for test_name, test_data in gst_data.items()
}

Expand Down

0 comments on commit fa9b275

Please sign in to comment.