This repository was archived by the owner on Sep 8, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +25
-12
lines changed
Expand file tree Collapse file tree 3 files changed +25
-12
lines changed Original file line number Diff line number Diff line change @@ -50,8 +50,13 @@ def validate_transaction(self, transaction: SignedTransactionAPI) -> None:
5050 self .vm_state .validate_transaction (transaction )
5151
5252 def build_evm_message (self , transaction : SignedTransactionAPI ) -> MessageAPI :
53-
54- gas_fee = transaction .gas * transaction .gas_price
53+ # Use vm_state.get_gas_price instead of transaction_context.gas_price so
54+ # that we can run get_transaction_result (aka~ eth_call) and estimate_gas.
55+ # Both work better if the GASPRICE opcode returns the original real price,
56+ # but the sender's balance doesn't actually deduct the gas. This get_gas_price()
57+ # will return 0 for eth_call, but transaction_context.gas_price will return
58+ # the same value as the GASPRICE opcode.
59+ gas_fee = transaction .gas * self .vm_state .get_gas_price (transaction )
5560
5661 # Buy Gas
5762 self .vm_state .delta_balance (transaction .sender , - 1 * gas_fee )
Original file line number Diff line number Diff line change 3939
4040
4141class LondonTransactionExecutor (BerlinTransactionExecutor ):
42- def build_evm_message (
43- self ,
44- transaction : SignedTransactionAPI ,
45- ) -> MessageAPI :
42+ def build_evm_message (self , transaction : SignedTransactionAPI ) -> MessageAPI :
43+ # Use vm_state.get_gas_price instead of transaction_context.gas_price so
44+ # that we can run get_transaction_result (aka~ eth_call) and estimate_gas.
45+ # Both work better if the GASPRICE opcode returns the original real price,
46+ # but the sender's balance doesn't actually deduct the gas. This get_gas_price()
47+ # will return 0 for eth_call, but transaction_context.gas_price will return
48+ # the same value as the GASPRICE opcode.
4649 gas_fee = transaction .gas * self .vm_state .get_gas_price (transaction )
4750
4851 # Buy Gas
Original file line number Diff line number Diff line change @@ -89,12 +89,17 @@ def gas_limit(self) -> int:
8989 return self .execution_context .gas_limit
9090
9191 def get_gas_price (self , transaction : SignedTransactionAPI ) -> int :
92- base_gas_price = self .execution_context .base_fee_per_gas
93- priority_fee_per_gas = min (
94- transaction .max_priority_fee_per_gas ,
95- transaction .max_fee_per_gas - base_gas_price ,
96- )
97- return priority_fee_per_gas + base_gas_price
92+ execution_context = self .execution_context
93+ try :
94+ base_gas_price = execution_context .base_fee_per_gas
95+ except AttributeError :
96+ return transaction .gas_price
97+ else :
98+ effective_price = min (
99+ transaction .max_fee_per_gas ,
100+ transaction .max_priority_fee_per_gas + base_gas_price ,
101+ )
102+ return effective_price
98103
99104 #
100105 # Access to account db
You can’t perform that action at this time.
0 commit comments