diff --git a/src/Nethermind/Nethermind.Evm.Test/Eip7918Tests.cs b/src/Nethermind/Nethermind.Evm.Test/Eip7918Tests.cs index aa8ee81eeef..960badcf5fe 100644 --- a/src/Nethermind/Nethermind.Evm.Test/Eip7918Tests.cs +++ b/src/Nethermind/Nethermind.Evm.Test/Eip7918Tests.cs @@ -91,4 +91,25 @@ private static IEnumerable GenerateTestCases() (ulong)baseFeePerGas + 100, expectedExcessBlobGas); } + + [Test] + public void Excess_blob_gas_with_null_ExcessBlobGas_applies_floor_correctly() + { + IReleaseSpec spec = Osaka.Instance; + int blobsUsed = (int)spec.TargetBlobCount + 1; + + // null ExcessBlobGas treated as 0, floor applies + BlockHeader parentHeader = Build.A.BlockHeader + .WithBlobGasUsed(BlobGasCalculator.CalculateBlobGas(blobsUsed)) + .WithExcessBlobGas(null) + .WithBaseFee(1_000_000_000) + .TestObject; + + ulong? result = BlobGasCalculator.CalculateExcessBlobGas(parentHeader, spec); + + ulong blobGasUsed = BlobGasCalculator.CalculateBlobGas(blobsUsed); + ulong expected = blobGasUsed * (spec.MaxBlobCount - spec.TargetBlobCount) / spec.MaxBlobCount; + + Assert.That(result, Is.EqualTo(expected)); + } } diff --git a/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs b/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs index 7dbe87e1de8..cce5cfa7ee5 100644 --- a/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs +++ b/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs @@ -117,7 +117,7 @@ static bool FakeExponentialOverflow(UInt256 factor, UInt256 num, UInt256 denomin if (releaseSpec.IsEip7918Enabled) { - TryCalculateFeePerBlobGas(parentBlockHeader, releaseSpec.BlobBaseFeeUpdateFraction, out UInt256 feePerBlobGas); + TryCalculateFeePerBlobGas(excessBlobGas, releaseSpec.BlobBaseFeeUpdateFraction, out UInt256 feePerBlobGas); UInt256 floorCost = Eip7918Constants.BlobBaseCost * parentBlockHeader.BaseFeePerGas; UInt256 targetCost = Eip4844Constants.GasPerBlob * feePerBlobGas;