Skip to content

Commit 6017d7d

Browse files
committed
Validate London txn gas costs, plus tests
1 parent b7daeac commit 6017d7d

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

eth/tools/factories/transaction.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,42 @@ def new_access_list_transaction(
7777
)
7878

7979
return tx.as_signed_transaction(private_key)
80+
81+
82+
@curry
83+
def new_fee_burn_transaction(
84+
vm,
85+
from_,
86+
to,
87+
private_key,
88+
amount=0,
89+
max_priority_fee_per_gas=1,
90+
max_fee_per_gas=10**10,
91+
gas=100000,
92+
data=b'',
93+
nonce=None,
94+
chain_id=1,
95+
access_list=None):
96+
"""
97+
Create and return a transaction sending amount from <from_> to <to>.
98+
99+
The transaction will be signed with the given private key.
100+
"""
101+
if nonce is None:
102+
nonce = vm.state.get_nonce(from_)
103+
if access_list is None:
104+
access_list = []
105+
106+
tx = vm.get_transaction_builder().new_unsigned_fee_burn_transaction(
107+
chain_id=chain_id,
108+
nonce=nonce,
109+
max_priority_fee_per_gas=max_priority_fee_per_gas,
110+
max_fee_per_gas=max_fee_per_gas,
111+
gas=gas,
112+
to=to,
113+
value=amount,
114+
data=data,
115+
access_list=access_list,
116+
)
117+
118+
return tx.as_signed_transaction(private_key)

eth/vm/forks/london/transactions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class LondonTransactionBuilder(BerlinTransactionBuilder):
224224
legacy_unsigned = LondonUnsignedLegacyTransaction
225225

226226
@classmethod
227-
def new_unsigned_base_gas_price_transaction(
227+
def new_unsigned_fee_burn_transaction(
228228
cls,
229229
chain_id: int,
230230
nonce: int,
@@ -249,7 +249,7 @@ def new_unsigned_base_gas_price_transaction(
249249
return transaction
250250

251251
@classmethod
252-
def new_base_gas_price_transaction(
252+
def new_fee_burn_transaction(
253253
cls,
254254
chain_id: int,
255255
nonce: int,

eth/vm/forks/london/validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def validate_london_normalized_transaction(
3838
)
3939

4040
effective_gas_price = priority_fee_per_gas + base_fee_per_gas
41-
total_transaction_cost = transaction.value + effective_gas_price
41+
total_transaction_cost = transaction.value + effective_gas_price * transaction.gas
4242

4343
if sender_balance < total_transaction_cost:
4444
raise ValidationError(

0 commit comments

Comments
 (0)