@@ -106,11 +106,7 @@ def count_blobs(txs: List[Transaction]) -> int:
106106 Returns the number of blobs in a list of transactions.
107107 """
108108 return sum (
109- [
110- len (tx .blob_versioned_hashes )
111- for tx in txs
112- if tx .blob_versioned_hashes is not None
113- ]
109+ [len (tx .blob_versioned_hashes ) for tx in txs if tx .blob_versioned_hashes is not None ]
114110 )
115111
116112
@@ -247,10 +243,7 @@ class Block(Header):
247243 returned by the `evm_transition_tool`.
248244 """
249245 exception : (
250- List [TransactionException | BlockException ]
251- | TransactionException
252- | BlockException
253- | None
246+ List [TransactionException | BlockException ] | TransactionException | BlockException | None
254247 ) = None
255248 """
256249 If set, the block is expected to be rejected by the client.
@@ -271,9 +264,7 @@ class Block(Header):
271264 """
272265 List of withdrawals to perform for this block.
273266 """
274- requests : List [DepositRequest | WithdrawalRequest | ConsolidationRequest ] | None = (
275- None
276- )
267+ requests : List [DepositRequest | WithdrawalRequest | ConsolidationRequest ] | None = None
277268 """
278269 Custom list of requests to embed in this block.
279270 """
@@ -295,9 +286,7 @@ def set_environment(self, env: Environment) -> Environment:
295286 """
296287 new_env_values ["difficulty" ] = self .difficulty
297288 new_env_values ["fee_recipient" ] = (
298- self .fee_recipient
299- if self .fee_recipient is not None
300- else Environment ().fee_recipient
289+ self .fee_recipient if self .fee_recipient is not None else Environment ().fee_recipient
301290 )
302291 new_env_values ["gas_limit" ] = (
303292 self .gas_limit or env .parent_gas_limit or Environment ().gas_limit
@@ -322,9 +311,7 @@ def set_environment(self, env: Environment) -> Environment:
322311 if len (env .block_hashes ) == 0 :
323312 new_env_values ["number" ] = 0
324313 else :
325- new_env_values ["number" ] = (
326- max ([Number (n ) for n in env .block_hashes .keys ()]) + 1
327- )
314+ new_env_values ["number" ] = max ([Number (n ) for n in env .block_hashes .keys ()]) + 1
328315
329316 if self .timestamp is not None :
330317 new_env_values ["timestamp" ] = self .timestamp
@@ -364,9 +351,8 @@ def make_genesis(
364351 assert (
365352 env .withdrawals is None or len (env .withdrawals ) == 0
366353 ), "withdrawals must be empty at genesis"
367- assert (
368- env .parent_beacon_block_root is None
369- or env .parent_beacon_block_root == Hash (0 )
354+ assert env .parent_beacon_block_root is None or env .parent_beacon_block_root == Hash (
355+ 0
370356 ), "parent_beacon_block_root must be empty at genesis"
371357
372358 pre_alloc = Alloc .merge (
@@ -403,15 +389,11 @@ def make_genesis(
403389 blob_gas_used = env .blob_gas_used ,
404390 excess_blob_gas = env .excess_blob_gas ,
405391 withdrawals_root = (
406- Withdrawal .list_root (env .withdrawals )
407- if env .withdrawals is not None
408- else None
392+ Withdrawal .list_root (env .withdrawals ) if env .withdrawals is not None else None
409393 ),
410394 parent_beacon_block_root = env .parent_beacon_block_root ,
411395 requests_root = (
412- Requests (root = []).trie_root
413- if fork .header_requests_required (0 , 0 )
414- else None
396+ Requests (root = []).trie_root if fork .header_requests_required (0 , 0 ) else None
415397 ),
416398 )
417399
@@ -422,9 +404,7 @@ def make_genesis(
422404 withdrawals = None if env .withdrawals is None else [],
423405 deposit_requests = [] if fork .header_requests_required (0 , 0 ) else None ,
424406 withdrawal_requests = [] if fork .header_requests_required (0 , 0 ) else None ,
425- consolidation_requests = []
426- if fork .header_requests_required (0 , 0 )
427- else None ,
407+ consolidation_requests = [] if fork .header_requests_required (0 , 0 ) else None ,
428408 ).with_rlp (
429409 txs = [],
430410 requests = Requests () if fork .header_requests_required (0 , 0 ) else None ,
@@ -577,9 +557,7 @@ def generate_block_data(
577557
578558 requests = None
579559 if fork .header_requests_required (header .number , header .timestamp ):
580- requests_list : List [
581- DepositRequest | WithdrawalRequest | ConsolidationRequest
582- ] = []
560+ requests_list : List [DepositRequest | WithdrawalRequest | ConsolidationRequest ] = []
583561 if transition_tool_output .result .deposit_requests is not None :
584562 requests_list += transition_tool_output .result .deposit_requests
585563 if transition_tool_output .result .withdrawal_requests is not None :
@@ -610,7 +588,6 @@ def generate_block_data(
610588 # TODO: hack for now, replace with actual witness output once available from t8n
611589 if transition_tool_output .result .verkle_conversion_ended :
612590 witness_parent_root = transition_tool_output .result .parent_root
613- assert witness_parent_root == header .parent_hash
614591 transition_tool_output .witness = Witness (
615592 verkle_proof = transition_tool_output .result .verkle_proof ,
616593 state_diff = transition_tool_output .result .state_diff ,
@@ -672,8 +649,8 @@ def verify_witness(
672649 Compares the expected witness check allocation account against the values updated
673650 in the block execution witness state diff.
674651 """
675- witness_check_state_diff , witness_check_address_mapping = (
676- t8n . get_witness_check_mapping ( witness_check )
652+ witness_check_state_diff , witness_check_address_mapping = t8n . get_witness_check_mapping (
653+ witness_check
677654 )
678655 actual_stem_dict = {sd .stem : sd for sd in state_diff .root }
679656 expected_stem_dict = {sd .stem : sd for sd in witness_check_state_diff .root }
@@ -697,9 +674,7 @@ def verify_witness(
697674 )
698675
699676 actual_suffix_dict = {sd .suffix : sd for sd in stem_state_diff .suffix_diffs }
700- expected_suffix_dict = {
701- sd .suffix : sd for sd in expected_stem_state_diff .suffix_diffs
702- }
677+ expected_suffix_dict = {sd .suffix : sd for sd in expected_stem_state_diff .suffix_diffs }
703678 # Check that all actual suffixes are in expected suffixes
704679 for actual_suffix , suffix_diff in actual_suffix_dict .items ():
705680 actual_current_value = suffix_diff .current_value
@@ -718,9 +693,7 @@ def verify_witness(
718693 indent = 4 ,
719694 )
720695 )
721- if str (actual_current_value ) != str (
722- expected_suffix_state_diff .current_value
723- ):
696+ if str (actual_current_value ) != str (expected_suffix_state_diff .current_value ):
724697 raise ValueError (
725698 "Witness check failed - current value mismatch.\n \n "
726699 + pformat (
@@ -729,9 +702,7 @@ def verify_witness(
729702 "stem" : str (actual_stem ),
730703 "suffix" : actual_suffix ,
731704 "value_actual" : str (actual_current_value ),
732- "value_expected" : str (
733- expected_suffix_state_diff .current_value
734- ),
705+ "value_expected" : str (expected_suffix_state_diff .current_value ),
735706 },
736707 indent = 4 ,
737708 )
@@ -755,12 +726,8 @@ def verify_witness(
755726 )
756727 )
757728
758- actual_suffix_dict = {
759- sd .suffix : sd for sd in actual_stem_state_diff .suffix_diffs
760- }
761- expected_suffix_dict = {
762- sd .suffix : sd for sd in expected_stem_state_diff .suffix_diffs
763- }
729+ actual_suffix_dict = {sd .suffix : sd for sd in actual_stem_state_diff .suffix_diffs }
730+ expected_suffix_dict = {sd .suffix : sd for sd in expected_stem_state_diff .suffix_diffs }
764731
765732 # Check that all expected suffixes are in actual suffixes
766733 for (
@@ -775,9 +742,7 @@ def verify_witness(
775742 "test_account_address" : str (address ),
776743 "stem" : str (expected_stem ),
777744 "suffix" : expected_suffix ,
778- "value_expected" : str (
779- expected_suffix_state_diff .current_value
780- ),
745+ "value_expected" : str (expected_suffix_state_diff .current_value ),
781746 "value_actual" : "value not found" ,
782747 },
783748 indent = 4 ,
@@ -794,12 +759,8 @@ def verify_witness(
794759 "test_account_address" : str (address ),
795760 "stem" : str (expected_stem ),
796761 "suffix" : expected_suffix ,
797- "value_actual" : str (
798- actual_suffix_state_diff .current_value
799- ),
800- "value_expected" : str (
801- expected_suffix_state_diff .current_value
802- ),
762+ "value_actual" : str (actual_suffix_state_diff .current_value ),
763+ "value_expected" : str (expected_suffix_state_diff .current_value ),
803764 },
804765 indent = 4 ,
805766 )
@@ -862,10 +823,7 @@ def make_fixture(
862823 txs = [FixtureTransaction .from_transaction (tx ) for tx in txs ],
863824 ommers = [],
864825 withdrawals = (
865- [
866- FixtureWithdrawal .from_withdrawal (w )
867- for w in new_env .withdrawals
868- ]
826+ [FixtureWithdrawal .from_withdrawal (w ) for w in new_env .withdrawals ]
869827 if new_env .withdrawals is not None
870828 else None
871829 ),
@@ -893,9 +851,7 @@ def make_fixture(
893851 if requests is not None
894852 else None
895853 ),
896- witness = FixtureWitness .from_witness (witness )
897- if witness is not None
898- else None ,
854+ witness = FixtureWitness .from_witness (witness ) if witness is not None else None ,
899855 ).with_rlp (txs = txs , requests = requests )
900856 if block .exception is None :
901857 fixture_blocks .append (fixture_block )
@@ -911,8 +867,7 @@ def make_fixture(
911867 expect_exception = block .exception ,
912868 rlp_decoded = (
913869 None
914- if BlockException .RLP_STRUCTURES_ENCODING
915- in block .exception
870+ if BlockException .RLP_STRUCTURES_ENCODING in block .exception
916871 else fixture_block .without_rlp ()
917872 ),
918873 ),
@@ -971,16 +926,14 @@ def make_hive_fixture(
971926
972927 for block in self .blocks :
973928 # TODO: fix witness for hive fixture? Do we need it?
974- new_env , header , txs , new_alloc , requests , new_vkt , _ = (
975- self .generate_block_data (
976- t8n = t8n ,
977- fork = fork ,
978- block = block ,
979- previous_env = env ,
980- previous_alloc = alloc ,
981- previous_vkt = vkt ,
982- eips = eips ,
983- )
929+ new_env , header , txs , new_alloc , requests , new_vkt , _ = self .generate_block_data (
930+ t8n = t8n ,
931+ fork = fork ,
932+ block = block ,
933+ previous_env = env ,
934+ previous_alloc = alloc ,
935+ previous_vkt = vkt ,
936+ eips = eips ,
984937 )
985938 if block .rlp is None :
986939 fixture_payloads .append (
@@ -999,9 +952,7 @@ def make_hive_fixture(
999952 env = apply_new_parent (new_env , header )
1000953 head_hash = header .block_hash
1001954 vkt = new_vkt
1002- fcu_version = fork .engine_forkchoice_updated_version (
1003- header .number , header .timestamp
1004- )
955+ fcu_version = fork .engine_forkchoice_updated_version (header .number , header .timestamp )
1005956 assert (
1006957 fcu_version is not None
1007958 ), "A hive fixture was requested but no forkchoice update is defined. The framework should"
0 commit comments