3333 FixtureTransaction ,
3434 FixtureWithdrawal ,
3535 FixtureWithdrawalRequest ,
36+ FixtureWitness ,
3637 InvalidFixtureBlock ,
3738)
3839from ethereum_test_forks import EIP6800Transition , Fork , Verkle
4748 Withdrawal ,
4849 WithdrawalRequest ,
4950)
50- from ethereum_test_types .verkle import VerkleTree
51+ from ethereum_test_types .verkle import VerkleTree , Witness
5152from evm_transition_tool import TransitionTool
5253
5354from .base import BaseTest , verify_result , verify_transactions
@@ -411,6 +412,7 @@ def generate_block_data(
411412 Alloc ,
412413 Optional [Requests ],
413414 Optional [VerkleTree ],
415+ Optional [Witness ],
414416 ]:
415417 """
416418 Generate common block data for both make_fixture and make_hive_fixture.
@@ -453,13 +455,17 @@ def generate_block_data(
453455 try :
454456 rejected_txs = verify_transactions (txs , transition_tool_output .result )
455457 verify_result (transition_tool_output .result , env )
458+ # TODO: add verify witness (against vkt)
459+ # verify_witness(transition_tool_output.witness, transition_tool_output.vkt)
456460 except Exception as e :
457461 print_traces (t8n .get_traces ())
458462 pprint (transition_tool_output .result )
459463 pprint (previous_alloc )
460464 pprint (transition_tool_output .alloc )
461465 if transition_tool_output .vkt is not None :
462466 pprint (transition_tool_output .vkt )
467+ if transition_tool_output .witness is not None :
468+ pprint (transition_tool_output .witness )
463469 raise e
464470
465471 if len (rejected_txs ) > 0 and block .exception is None :
@@ -532,6 +538,11 @@ def generate_block_data(
532538 )
533539 )
534540 transition_tool_output .alloc = previous_alloc
541+ # TODO: hack for now
542+ transition_tool_output .witness = Witness (
543+ verkle_proof = transition_tool_output .result .verkle_proof ,
544+ state_diff = transition_tool_output .result .state_diff ,
545+ )
535546
536547 return (
537548 env ,
@@ -540,6 +551,7 @@ def generate_block_data(
540551 transition_tool_output .alloc ,
541552 requests ,
542553 transition_tool_output .vkt ,
554+ transition_tool_output .witness ,
543555 )
544556
545557 def network_info (self , fork : Fork , eips : Optional [List [int ]] = None ):
@@ -616,14 +628,16 @@ def make_fixture(
616628 # This is the most common case, the RLP needs to be constructed
617629 # based on the transactions to be included in the block.
618630 # Set the environment according to the block to execute.
619- new_env , header , txs , new_alloc , requests , new_vkt = self .generate_block_data (
620- t8n = t8n ,
621- fork = fork ,
622- block = block ,
623- previous_env = env ,
624- previous_alloc = alloc ,
625- previous_vkt = vkt ,
626- eips = eips ,
631+ new_env , header , txs , new_alloc , requests , new_vkt , witness = (
632+ self .generate_block_data (
633+ t8n = t8n ,
634+ fork = fork ,
635+ block = block ,
636+ previous_env = env ,
637+ previous_alloc = alloc ,
638+ previous_vkt = vkt ,
639+ eips = eips ,
640+ )
627641 )
628642 fixture_block = FixtureBlockBase (
629643 header = header ,
@@ -658,6 +672,7 @@ def make_fixture(
658672 if requests is not None
659673 else None
660674 ),
675+ witness = FixtureWitness .from_witness (witness ) if witness is not None else None ,
661676 ).with_rlp (txs = txs , requests = requests )
662677 if block .exception is None :
663678 fixture_blocks .append (fixture_block )
@@ -731,7 +746,8 @@ def make_hive_fixture(
731746 self .blocks .append (Block ())
732747
733748 for block in self .blocks :
734- new_env , header , txs , new_alloc , requests , new_vkt = self .generate_block_data (
749+ # TODO: fix witness for hive fixture? Do we need it?
750+ new_env , header , txs , new_alloc , requests , new_vkt , _ = self .generate_block_data (
735751 t8n = t8n ,
736752 fork = fork ,
737753 block = block ,
@@ -775,7 +791,7 @@ def make_hive_fixture(
775791 # Most clients require the header to start the sync process, so we create an empty
776792 # block on top of the last block of the test to send it as new payload and trigger the
777793 # sync process.
778- _ , sync_header , _ , _ , requests , _ = self .generate_block_data (
794+ _ , sync_header , _ , _ , requests , _ , _ = self .generate_block_data (
779795 t8n = t8n ,
780796 fork = fork ,
781797 block = Block (),
0 commit comments