Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/Nethermind/Nethermind.Evm.Test/Eip7918Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,25 @@ private static IEnumerable<TestCaseData> 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));
}
}
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down