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:
50
50
self .vm_state .validate_transaction (transaction )
51
51
52
52
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 )
55
60
56
61
# Buy Gas
57
62
self .vm_state .delta_balance (transaction .sender , - 1 * gas_fee )
Original file line number Diff line number Diff line change 39
39
40
40
41
41
class 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.
46
49
gas_fee = transaction .gas * self .vm_state .get_gas_price (transaction )
47
50
48
51
# Buy Gas
Original file line number Diff line number Diff line change @@ -89,12 +89,17 @@ def gas_limit(self) -> int:
89
89
return self .execution_context .gas_limit
90
90
91
91
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
98
103
99
104
#
100
105
# Access to account db
You can’t perform that action at this time.
0 commit comments