From 66c66e92605137c89a51f6add135ad2b8cbc55ac Mon Sep 17 00:00:00 2001 From: Alexey Osipov Date: Thu, 26 Jan 2023 03:49:00 +0300 Subject: [PATCH] Temporary fix gas rules, probably not necessary --- .../TransactionProcessor.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs b/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs index 81117ae2244..238b664d6af 100644 --- a/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs +++ b/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs @@ -141,6 +141,11 @@ private void Execute(Transaction transaction, BlockHeader block, ITxTracer txTra bool notSystemTransaction = !transaction.IsSystem(); bool deleteCallerAccount = false; + if (UInt256.MaxValue == block.ParentExcessDataGas && spec.IsEip4844Enabled) + { + throw new InvalidOperationException(); + } + if (!notSystemTransaction) { spec = new SystemTransactionReleaseSpec(spec); @@ -178,10 +183,6 @@ private void Execute(Transaction transaction, BlockHeader block, ITxTracer txTra QuickFail(transaction, block, txTracer, eip658NotEnabled, "sender has deployed code"); return; } - if (UInt256.MaxValue == block.ParentExcessDataGas && spec.IsEip4844Enabled) - { - throw new InvalidOperationException(); - } if (!noValidation && transaction.Nonce >= ulong.MaxValue - 1) { @@ -256,13 +257,13 @@ private void Execute(Transaction transaction, BlockHeader block, ITxTracer txTra } UInt256 blobsGasCost = IntrinsicGasCalculator.CalculateBlobsGasCost(transaction, block.ParentExcessDataGas, spec); - UInt256 senderReservedGasPayment = noValidation ? UInt256.Zero : ((ulong)gasLimit * effectiveGasPrice + blobsGasCost); + UInt256 senderReservedGasPayment = noValidation ? UInt256.Zero : ((ulong)gasLimit * effectiveGasPrice); if (notSystemTransaction) { UInt256 senderBalance = _stateProvider.GetBalance(caller); if (!noValidation && ((ulong)intrinsicGas * effectiveGasPrice + value + blobsGasCost > senderBalance || - senderReservedGasPayment + value > senderBalance)) + senderReservedGasPayment + value + blobsGasCost > senderBalance)) { TraceLogInvalidTx(transaction, $"INSUFFICIENT_SENDER_BALANCE: ({caller})_BALANCE = {senderBalance}"); @@ -271,7 +272,7 @@ private void Execute(Transaction transaction, BlockHeader block, ITxTracer txTra } if (!noValidation && spec.IsEip1559Enabled && !transaction.IsFree() && - senderBalance < (UInt256)transaction.GasLimit * transaction.MaxFeePerGas + value) + senderBalance < (UInt256)transaction.GasLimit * transaction.MaxFeePerGas + value + blobsGasCost) { TraceLogInvalidTx(transaction, $"INSUFFICIENT_MAX_FEE_PER_GAS_FOR_SENDER_BALANCE: ({caller})_BALANCE = {senderBalance}, MAX_FEE_PER_GAS: {transaction.MaxFeePerGas}"); @@ -511,6 +512,7 @@ private void Execute(Transaction transaction, BlockHeader block, ITxTracer txTra substate.Logs.Any() ? substate.Logs.ToArray() : Array.Empty(), stateRoot); } } + _stateProvider.SubtractFromBalance(caller, blobsGasCost, spec); } private void PrepareAccountForContractDeployment(Address contractAddress, IReleaseSpec spec)