@@ -189,7 +189,11 @@ def get_last_256_block_hashes(chain: BlockChain) -> List[Hash32]:
189
189
return recent_block_hashes
190
190
191
191
192
- def state_transition (chain : BlockChain , block : Block ) -> None :
192
+ def state_transition (
193
+ chain : BlockChain ,
194
+ block : Block ,
195
+ inclusion_list_transactions : Tuple [LegacyTransaction | Bytes , ...] = (),
196
+ ) -> None :
193
197
"""
194
198
Attempts to apply a block to an existing block chain.
195
199
@@ -210,6 +214,8 @@ def state_transition(chain: BlockChain, block: Block) -> None:
210
214
History and current state.
211
215
block :
212
216
Block to apply to `chain`.
217
+ inclusion_list_transactions :
218
+ Inclusion list transactions against which the block will be validated.
213
219
"""
214
220
if len (rlp .encode (block )) > MAX_RLP_BLOCK_SIZE :
215
221
raise InvalidBlock ("Block rlp size exceeds MAX_RLP_BLOCK_SIZE" )
@@ -236,6 +242,7 @@ def state_transition(chain: BlockChain, block: Block) -> None:
236
242
block_env = block_env ,
237
243
transactions = block .transactions ,
238
244
withdrawals = block .withdrawals ,
245
+ inclusion_list_transactions = inclusion_list_transactions ,
239
246
)
240
247
block_state_root = state_root (block_env .state )
241
248
transactions_root = root (block_output .transactions_trie )
@@ -727,6 +734,7 @@ def apply_body(
727
734
block_env : vm .BlockEnvironment ,
728
735
transactions : Tuple [LegacyTransaction | Bytes , ...],
729
736
withdrawals : Tuple [Withdrawal , ...],
737
+ inclusion_list_transactions : Tuple [LegacyTransaction | Bytes , ...],
730
738
) -> vm .BlockOutput :
731
739
"""
732
740
Executes a block.
@@ -746,6 +754,8 @@ def apply_body(
746
754
Transactions included in the block.
747
755
withdrawals :
748
756
Withdrawals to be processed in the current block.
757
+ inclusion_list_transactions :
758
+ Inclusion list transactions against which the block will be validated.
749
759
750
760
Returns
751
761
-------
@@ -769,6 +779,13 @@ def apply_body(
769
779
for i , tx in enumerate (map (decode_transaction , transactions )):
770
780
process_transaction (block_env , block_output , tx , Uint (i ))
771
781
782
+ validate_inclusion_list_transactions (
783
+ block_env = block_env ,
784
+ block_output = block_output ,
785
+ transactions = transactions ,
786
+ inclusion_list_transactions = inclusion_list_transactions ,
787
+ )
788
+
772
789
process_withdrawals (block_env , block_output , withdrawals )
773
790
774
791
process_general_purpose_requests (
@@ -1053,3 +1070,61 @@ def check_gas_limit(gas_limit: Uint, parent_gas_limit: Uint) -> bool:
1053
1070
return False
1054
1071
1055
1072
return True
1073
+
1074
+
1075
+ def validate_inclusion_list_transactions (
1076
+ block_env : vm .BlockEnvironment ,
1077
+ block_output : vm .BlockOutput ,
1078
+ transactions : Tuple [LegacyTransaction | Bytes , ...],
1079
+ inclusion_list_transactions : Tuple [LegacyTransaction | Bytes , ...],
1080
+ ) -> None :
1081
+ """
1082
+ Validate whether the block satisfies inclusion list constraints.
1083
+
1084
+ It checks if each inclusion list transaction is present in the block.
1085
+ For those not included, it checks if there was sufficient gas remaining
1086
+ to include the transaction and whether the transaction is valid against
1087
+ the nonce and balance of the sender. If any inclusion list transaction
1088
+ could have been included but was not, the block is marked as not
1089
+ satisfying inclusion list constraints. Any inclusion list transaction
1090
+ that is a blob transaction is ignored.
1091
+
1092
+ Compliance with inclusion list constraints does not affect any other
1093
+ block outputs.
1094
+
1095
+ [EIP-7805]: https://eips.ethereum.org/EIPS/eip-7805
1096
+
1097
+ Parameters
1098
+ ----------
1099
+ block_env :
1100
+ Environment for the Ethereum Virtual Machine.
1101
+ block_output :
1102
+ The block output for the current block.
1103
+ transactions :
1104
+ Transactions included in the block.
1105
+ inclusion_list_transactions :
1106
+ Inclusion list transactions against which the block will be validated.
1107
+ """
1108
+ for inclusion_list_transaction in inclusion_list_transactions :
1109
+ # Skip if an inclusion list transaction is present in the block.
1110
+ if inclusion_list_transaction in transactions :
1111
+ continue
1112
+
1113
+ tx = decode_transaction (inclusion_list_transaction )
1114
+
1115
+ # Ignore blob transactions.
1116
+ if isinstance (tx , BlobTransaction ):
1117
+ continue
1118
+
1119
+ try :
1120
+ # Run the tests of intrinsic validity.
1121
+ validate_transaction (tx )
1122
+ check_transaction (block_env , block_output , tx )
1123
+ except EthereumException :
1124
+ # This inclusion list transaction could not be included.
1125
+ continue
1126
+ else :
1127
+ # This inclusion list transaction could have been included.
1128
+ # Mark the block as not satisfying inclusion list constraints.
1129
+ block_output .is_inclusion_list_satisfied = False
1130
+ break
0 commit comments