fixes EIP1559 tx gasCost validation

pre EIP1559 max(gasCost) is tx.gasLimit * tx.gasPrice
the new EIP1559 max(gasCost) before the transaction can be executed is
tx.gasLimit * tx.maxFeePerGas
This commit is contained in:
jangko 2021-09-28 22:16:15 +07:00
parent d8dedb0469
commit 460432f154
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
1 changed files with 7 additions and 2 deletions

View File

@ -304,7 +304,12 @@ proc validateTransaction*(vmState: BaseVMState, tx: Transaction,
maxPriorityFee=tx.maxPriorityFee maxPriorityFee=tx.maxPriorityFee
return return
let gasCost = tx.gasLimit.u256 * tx.gasPrice.u256 # the signer must be able to afford the transaction
let gasCost = if tx.txType >= TxEip1559:
tx.gasLimit.u256 * tx.maxFee.u256
else:
tx.gasLimit.u256 * tx.gasPrice.u256
if gasCost > balance: if gasCost > balance:
debug "invalid tx: not enough cash for gas", debug "invalid tx: not enough cash for gas",
available=balance, available=balance,