Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EIP 7742 implementation #7518

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
de19765
Get target_blob_count, max_blob_count from Engine Api
yerke26 Sep 30, 2024
eca6690
fix HeaderDecoder, restore Eip4844 changes, Add Eip7742
yerke26 Oct 1, 2024
7ac90df
Merge branch 'master' into feature/eip-7742
yerke26 Oct 1, 2024
9be8a53
fix HeaderDecoder
yerke26 Oct 1, 2024
c592412
move new params from ExecutionPayload to ExecutionPayloadV4
yerke26 Oct 1, 2024
f6ae01c
revert minor changes
yerke26 Oct 1, 2024
f803097
added new params to PayloadAttributes
yerke26 Oct 1, 2024
7043124
fix tests
yerke26 Oct 1, 2024
fef9cb2
fix whitespaces
yerke26 Oct 1, 2024
cc02ce5
add tests
yerke26 Oct 2, 2024
206d514
Merge branch 'master' into feature/eip-7742
yerke26 Oct 2, 2024
9fbb9c1
add missing fields
yerke26 Oct 4, 2024
8ada4e2
fix PayloadAttributes
yerke26 Oct 7, 2024
3ae0fed
add engine_forkchoiceUpdatedV4 to EngineRpcModule.Prague
yerke26 Oct 7, 2024
372868a
change to engine_forkchoiceUpdatedV4
yerke26 Oct 7, 2024
0bd75c6
Merge branch 'master' into feature/eip-7742
yerke26 Oct 7, 2024
4b5fbfc
add new fields to EngineModuleTests.V4
yerke26 Oct 7, 2024
5078b76
added new engine_forkchoiceUpdatedV4 to EngineRpcCapabilitiesProvider
yerke26 Oct 7, 2024
a92cdde
fix test cases
yerke26 Oct 8, 2024
c032480
Merge branch 'master' into feature/eip-7742
yerke26 Oct 8, 2024
4ab5fda
fix whitespace
yerke26 Oct 8, 2024
0ba2006
fix EngineRpcCapabilitiesProvider, revert ChainSpecBasedSpecProviderT…
yerke26 Oct 8, 2024
911d232
remove unnecessary comment
yerke26 Oct 8, 2024
f806f22
remove comments
yerke26 Oct 8, 2024
8dc3d6a
Merge branch 'master' into feature/eip-7742
yerke26 Oct 15, 2024
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
2 changes: 1 addition & 1 deletion src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected EthereumTestResult RunTest(GeneralStateTest test, ITxTracer txTracer)
BlobGasUsed = (ulong)test.ParentBlobGasUsed,
ExcessBlobGas = (ulong)test.ParentExcessBlobGas,
};
header.ExcessBlobGas = BlobGasCalculator.CalculateExcessBlobGas(parent, spec);
header.ExcessBlobGas = BlobGasCalculator.CalculateExcessBlobGas(parent, spec, header);
}

Block block = Build.A.Block.WithTransactions(test.Transaction).WithHeader(header).TestObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ public TestEip4844Config(ulong? maxBlobGasPerBlock = null)

public ulong GasPerBlob => Eip4844Constants.GasPerBlob;

public int GetMaxBlobsPerBlock() => (int)(MaxBlobGasPerBlock / GasPerBlob);
public ulong GetMaxBlobsPerBlock() => MaxBlobGasPerBlock / GasPerBlob;
}
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ protected virtual BlockHeader PrepareBlockHeader(BlockHeader parent,
{
Author = blockAuthor,
MixHash = payloadAttributes?.PrevRandao,
ParentBeaconBlockRoot = payloadAttributes?.ParentBeaconBlockRoot
ParentBeaconBlockRoot = payloadAttributes?.ParentBeaconBlockRoot,
TargetBlobCount = payloadAttributes?.TargetBlobCount,
MaxBlobCount = payloadAttributes?.MaxBlobCount,
};

UInt256 difficulty = _difficultyCalculator.Calculate(header, parent);
Expand Down
28 changes: 28 additions & 0 deletions src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public class PayloadAttributes

public Hash256? ParentBeaconBlockRoot { get; set; }

public ulong? TargetBlobCount { get; set; }

public ulong? MaxBlobCount { get; set; }

public virtual long? GetGasLimit() => null;

public override string ToString() => ToString(string.Empty);
Expand All @@ -48,6 +52,16 @@ public string ToString(string indentation)
sb.Append($", {nameof(ParentBeaconBlockRoot)} : {ParentBeaconBlockRoot}");
}

if (TargetBlobCount is not null)
{
sb.Append($", {nameof(TargetBlobCount)} : {TargetBlobCount}");
}

if (MaxBlobCount is not null)
{
sb.Append($", {nameof(MaxBlobCount)} : {MaxBlobCount}");
}

sb.Append('}');

return sb.ToString();
Expand Down Expand Up @@ -111,6 +125,18 @@ protected virtual int WritePayloadIdMembers(BlockHeader parentHeader, Span<byte>
position += Keccak.Size;
}

if (TargetBlobCount.HasValue)
{
BinaryPrimitives.WriteUInt64BigEndian(inputSpan.Slice(position, sizeof(ulong)), TargetBlobCount.Value);
position += sizeof(ulong);
}

if (MaxBlobCount.HasValue)
{
BinaryPrimitives.WriteUInt64BigEndian(inputSpan.Slice(position, sizeof(ulong)), MaxBlobCount.Value);
position += sizeof(ulong);
}

return position;
}

Expand Down Expand Up @@ -167,6 +193,7 @@ public static class PayloadAttributesExtensions
public static int GetVersion(this PayloadAttributes executionPayload) =>
executionPayload switch
{
{ MaxBlobCount: not null, TargetBlobCount: not null } => EngineApiVersions.Prague,
{ ParentBeaconBlockRoot: not null, Withdrawals: not null } => EngineApiVersions.Cancun,
{ Withdrawals: not null } => EngineApiVersions.Shanghai,
_ => EngineApiVersions.Paris
Expand All @@ -175,6 +202,7 @@ public static int GetVersion(this PayloadAttributes executionPayload) =>
public static int ExpectedPayloadAttributesVersion(this IReleaseSpec spec) =>
spec switch
{
{ IsEip7742Enabled: true } => EngineApiVersions.Prague,
{ IsEip4844Enabled: true } => EngineApiVersions.Cancun,
{ WithdrawalsEnabled: true } => EngineApiVersions.Shanghai,
_ => EngineApiVersions.Paris
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public IEnumerable<Transaction> GetTransactions(BlockHeader parent, long gasLimi

int checkedTransactions = 0;
int selectedTransactions = 0;
using ArrayPoolList<Transaction> selectedBlobTxs = new(_eip4844Config.GetMaxBlobsPerBlock());
using ArrayPoolList<Transaction> selectedBlobTxs = new((int)(parent.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock()));

SelectBlobTransactions(blobTransactions, parent, spec, selectedBlobTxs);

Expand Down Expand Up @@ -128,7 +128,7 @@ private void SelectBlobTransactions(IEnumerable<Transaction> blobTransactions, B

foreach (Transaction blobTx in blobTransactions)
{
if (blobGasCounter >= _eip4844Config.MaxBlobGasPerBlock)
if (!spec.IsEip7742Enabled && blobGasCounter >= _eip4844Config.MaxBlobGasPerBlock)
{
if (_logger.IsTrace) _logger.Trace($"Declining {blobTx.ToShortString()}, no more blob space. Block already have {blobGasCounter} blob gas which is max value allowed.");
break;
Expand All @@ -137,7 +137,7 @@ private void SelectBlobTransactions(IEnumerable<Transaction> blobTransactions, B
checkedBlobTransactions++;

ulong txBlobGas = (ulong)(blobTx.BlobVersionedHashes?.Length ?? 0) * _eip4844Config.GasPerBlob;
if (txBlobGas > _eip4844Config.MaxBlobGasPerBlock - blobGasCounter)
if (!spec.IsEip7742Enabled && txBlobGas > _eip4844Config.MaxBlobGasPerBlock - blobGasCounter)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm is this handled correcty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing here, need to skip the logic related to MaxBlobGasPerBlock

{
if (_logger.IsTrace) _logger.Trace($"Declining {blobTx.ToShortString()}, not enough blob space.");
continue;
Expand Down Expand Up @@ -188,7 +188,7 @@ private bool TryGetFullBlobTx(Transaction blobTx, [NotNullWhen(true)] out Transa

private bool TryUpdateFeePerBlobGas(Transaction lightBlobTx, BlockHeader parent, IReleaseSpec spec, out UInt256 feePerBlobGas)
{
ulong? excessDataGas = BlobGasCalculator.CalculateExcessBlobGas(parent, spec);
ulong? excessDataGas = BlobGasCalculator.CalculateExcessBlobGas(parent, spec, parent);
if (excessDataGas is null)
{
if (_logger.IsTrace) _logger.Trace($"Declining {lightBlobTx.ToShortString()}, the specification is not configured to handle shard blob transactions.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ private bool ValidateEip4844Fields(Block block, IReleaseSpec spec, out string? e

ulong blobGasUsed = BlobGasCalculator.CalculateBlobGas(blobsInBlock);

if (blobGasUsed > Eip4844Constants.MaxBlobGasPerBlock)
if (!spec.IsEip7742Enabled && blobGasUsed > Eip4844Constants.MaxBlobGasPerBlock)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but if EIP enabled than we do what? I think it is not handled correctly

Copy link
Contributor Author

@yerke26 yerke26 Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon activating this EIP (i.e. before processing any transactions), the verification of the blob maximum as given in EIP-4844 can be skipped. Concretely, this means any logic relating to MAX_BLOB_GAS_PER_BLOCK as given in EIP-4844 can be deprecated

This is written in EIP specification, I think if IsEip7742Enabled = true we need to skip this logic

{
error = BlockErrorMessages.BlobGasUsedAboveBlockLimit;
if (_logger.IsDebug) _logger.Debug($"{Invalid(block)} {error}.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ private bool ValidateBlobGasFields(BlockHeader header, BlockHeader parentHeader,
return false;
}

ulong? expectedExcessBlobGas = BlobGasCalculator.CalculateExcessBlobGas(parentHeader, spec);
ulong? expectedExcessBlobGas = BlobGasCalculator.CalculateExcessBlobGas(parentHeader, spec, header);
if (header.ExcessBlobGas != expectedExcessBlobGas)
{
if (_logger.IsWarn) _logger.Warn($"ExcessBlobGas field is incorrect: {header.ExcessBlobGas}, should be {expectedExcessBlobGas}.");
Expand Down
14 changes: 9 additions & 5 deletions src/Nethermind/Nethermind.Consensus/Validators/TxValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,19 @@ public ValidationResult IsWellFormed(Transaction transaction, IReleaseSpec relea
{ To: null } => TxErrorMessages.TxMissingTo,
{ MaxFeePerBlobGas: null } => TxErrorMessages.BlobTxMissingMaxFeePerBlobGas,
{ BlobVersionedHashes: null } => TxErrorMessages.BlobTxMissingBlobVersionedHashes,
_ => ValidateBlobFields(transaction)
_ => ValidateBlobFields(transaction, releaseSpec)
};

private ValidationResult ValidateBlobFields(Transaction transaction)
private ValidationResult ValidateBlobFields(Transaction transaction, IReleaseSpec releaseSpec)
{
int blobCount = transaction.BlobVersionedHashes!.Length;
ulong totalDataGas = BlobGasCalculator.CalculateBlobGas(blobCount);
return totalDataGas > Eip4844Constants.MaxBlobGasPerTransaction ? TxErrorMessages.BlobTxGasLimitExceeded
: blobCount < Eip4844Constants.MinBlobsPerTransaction ? TxErrorMessages.BlobTxMissingBlobs
if (!releaseSpec.IsEip7742Enabled
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing here, need to skip the logic related to MaxBlobGasPerBlock which is equal to MaxBlobGasPerTransaction

&& BlobGasCalculator.CalculateBlobGas(blobCount) > Eip4844Constants.MaxBlobGasPerTransaction)
{
return TxErrorMessages.BlobTxGasLimitExceeded;
}

return blobCount < Eip4844Constants.MinBlobsPerTransaction ? TxErrorMessages.BlobTxMissingBlobs
: ValidateBlobVersionedHashes();

ValidationResult ValidateBlobVersionedHashes()
Expand Down
12 changes: 12 additions & 0 deletions src/Nethermind/Nethermind.Core.Test/Builders/BlockHeaderBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,16 @@ public BlockHeaderBuilder WithRequestsRoot(Hash256? requestsRoot)
TestObjectInternal.RequestsRoot = requestsRoot;
return this;
}

public BlockHeaderBuilder WithTargetBlobCount(ulong? targetBlobCount)
{
TestObjectInternal.TargetBlobCount = targetBlobCount;
return this;
}

public BlockHeaderBuilder WithMaxBlobCount(ulong? maxBlobCount)
{
TestObjectInternal.MaxBlobCount = maxBlobCount;
return this;
}
}
3 changes: 3 additions & 0 deletions src/Nethermind/Nethermind.Core/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ public Transaction[] Transactions

public Hash256? RequestsRoot => Header.RequestsRoot; // do not add setter here

public ulong? TargetBlobCount => Header.TargetBlobCount; // do not add setter here

public ulong? MaxBlobCount => Header.MaxBlobCount; // do not add setter here
[JsonIgnore]
public ArrayPoolList<AddressAsKey>? AccountChanges { get; set; }
[JsonIgnore]
Expand Down
2 changes: 2 additions & 0 deletions src/Nethermind/Nethermind.Core/BlockHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public BlockHeader(

public string SealEngineType { get; set; } = Core.SealEngineType.Ethash;
public bool IsPostMerge { get; set; }
public ulong? TargetBlobCount { get; set; }
public ulong? MaxBlobCount { get; set; }

public string ToString(string indent)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Core/Eip4844Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ public static void OverrideIfAny(
TargetBlobGasPerBlock = targetBlobGasPerBlock.Value;
}

public static int GetMaxBlobsPerBlock() => (int)(MaxBlobGasPerBlock / GasPerBlob);
public static ulong GetMaxBlobsPerBlock() => MaxBlobGasPerBlock / GasPerBlob;
}
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Core/IEip4844Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ public interface IEip4844Config
{
ulong MaxBlobGasPerBlock { get; }
ulong GasPerBlob { get; }
int GetMaxBlobsPerBlock();
ulong GetMaxBlobsPerBlock();
}

public class ConstantEip4844Config : IEip4844Config
{
public ulong MaxBlobGasPerBlock => Eip4844Constants.MaxBlobGasPerBlock;
public ulong GasPerBlob => Eip4844Constants.GasPerBlob;
public int GetMaxBlobsPerBlock() => Eip4844Constants.GetMaxBlobsPerBlock();
public ulong GetMaxBlobsPerBlock() => Eip4844Constants.GetMaxBlobsPerBlock();

static ConstantEip4844Config() => Instance = new ConstantEip4844Config();
private ConstantEip4844Config() { }
Expand Down
2 changes: 2 additions & 0 deletions src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ public interface IReleaseSpec : IEip1559Spec, IReceiptSpec
/// </summary>
bool IsRip7212Enabled { get; }

bool IsEip7742Enabled { get; }

/// OP Granite
bool IsOpGraniteEnabled { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class ReleaseSpecDecorator(IReleaseSpec spec) : IReleaseSpec
public virtual bool IsEip4895Enabled => spec.IsEip4895Enabled;
public virtual bool IsEip4844Enabled => spec.IsEip4844Enabled;
public virtual bool IsEip4788Enabled => spec.IsEip4788Enabled;
public virtual bool IsEip7742Enabled => spec.IsEip7742Enabled;
public virtual Address? Eip4788ContractAddress => spec.Eip4788ContractAddress;
public bool IsEip6110Enabled => spec.IsEip6110Enabled;
public Address DepositContractAddress => spec.DepositContractAddress;
Expand Down
92 changes: 57 additions & 35 deletions src/Nethermind/Nethermind.Evm.Test/BlobGasCalculatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,40 @@ namespace Nethermind.Evm.Test;
[TestFixture]
public class BlobGasCalculatorTests
{
private void TestExcessBlobGas(IReleaseSpec spec, bool areBlobsEnabled, (ulong parentExcessBlobGas, int parentBlobsCount, ulong expectedExcessBlobGas, ulong? targetBlobCount) testCase)
{
BlockHeader header = Build.A.BlockHeader
.WithTargetBlobCount(testCase.targetBlobCount).TestObject;

BlockHeader parentHeader = Build.A.BlockHeader
.WithBlobGasUsed(BlobGasCalculator.CalculateBlobGas(testCase.parentBlobsCount))
.WithExcessBlobGas(testCase.parentExcessBlobGas).TestObject;

Assert.That(BlobGasCalculator.CalculateExcessBlobGas(parentHeader, spec, header), Is.EqualTo(areBlobsEnabled ? testCase.expectedExcessBlobGas : null));
}

[TestCaseSource(nameof(ExcessBlobGasTestCaseSource))]
public void Excess_blob_gas_is_calculated_properly((ulong parentExcessBlobGas, int parentBlobsCount, ulong expectedExcessBlobGas) testCase)
public void Excess_blob_gas_is_calculated_properly((ulong parentExcessBlobGas, int parentBlobsCount, ulong expectedExcessBlobGas, ulong? targetBlobCount) testCase)
{
TestExcessBlobGas(Homestead.Instance, false, testCase);
TestExcessBlobGas(Frontier.Instance, false, testCase);
TestExcessBlobGas(SpuriousDragon.Instance, false, testCase);
TestExcessBlobGas(TangerineWhistle.Instance, false, testCase);
TestExcessBlobGas(Byzantium.Instance, false, testCase);
TestExcessBlobGas(Constantinople.Instance, false, testCase);
TestExcessBlobGas(ConstantinopleFix.Instance, false, testCase);
TestExcessBlobGas(Istanbul.Instance, false, testCase);
TestExcessBlobGas(MuirGlacier.Instance, false, testCase);
TestExcessBlobGas(Berlin.Instance, false, testCase);
TestExcessBlobGas(GrayGlacier.Instance, false, testCase);
TestExcessBlobGas(Shanghai.Instance, false, testCase);
TestExcessBlobGas(Cancun.Instance, true, testCase);
}

[TestCaseSource(nameof(ExcessBlobGasTestCaseSourceForEip7742))]
public void Excess_blob_gas_is_calculated_properly_for_eip7742((ulong parentExcessBlobGas, int parentBlobsCount, ulong expectedExcessBlobGas, ulong? targetBlobCount) testCase)
{
void Test(IReleaseSpec spec, bool areBlobsEnabled)
{
BlockHeader parentHeader = Build.A.BlockHeader
.WithBlobGasUsed(BlobGasCalculator.CalculateBlobGas(testCase.parentBlobsCount))
.WithExcessBlobGas(testCase.parentExcessBlobGas).TestObject;

Assert.That(BlobGasCalculator.CalculateExcessBlobGas(parentHeader, spec), Is.EqualTo(areBlobsEnabled ? testCase.expectedExcessBlobGas : null));
}

Test(Homestead.Instance, false);
Test(Frontier.Instance, false);
Test(SpuriousDragon.Instance, false);
Test(TangerineWhistle.Instance, false);
Test(Byzantium.Instance, false);
Test(Constantinople.Instance, false);
Test(ConstantinopleFix.Instance, false);
Test(Istanbul.Instance, false);
Test(MuirGlacier.Instance, false);
Test(Berlin.Instance, false);
Test(GrayGlacier.Instance, false);
Test(Shanghai.Instance, false);
Test(Cancun.Instance, true);
TestExcessBlobGas(Prague.Instance, true, testCase);
}

[TestCaseSource(nameof(BlobGasCostTestCaseSource))]
Expand All @@ -65,28 +74,41 @@ public void Blob_base_fee_may_overflow()
Assert.That(blobBaseFee, Is.EqualTo(UInt256.MaxValue));
}

public static IEnumerable<(ulong parentExcessBlobGas, int parentBlobsCount, ulong expectedExcessBlobGas)> ExcessBlobGasTestCaseSource()
public static IEnumerable<(ulong parentExcessBlobGas, int parentBlobsCount, ulong expectedExcessBlobGas, ulong? targetBlobCount)> ExcessBlobGasTestCaseSource()
{
yield return (0, 0, 0);
yield return (0, (int)(Eip4844Constants.TargetBlobGasPerBlock / Eip4844Constants.GasPerBlob) - 1, 0);
yield return (0, (int)(Eip4844Constants.TargetBlobGasPerBlock / Eip4844Constants.GasPerBlob), 0);
yield return (100000, (int)(Eip4844Constants.TargetBlobGasPerBlock / Eip4844Constants.GasPerBlob), 100000);
yield return (0, (int)(Eip4844Constants.TargetBlobGasPerBlock / Eip4844Constants.GasPerBlob) + 1, Eip4844Constants.GasPerBlob * 1);
yield return (Eip4844Constants.TargetBlobGasPerBlock, 1, Eip4844Constants.GasPerBlob * 1);
yield return (Eip4844Constants.TargetBlobGasPerBlock, 0, 0);
yield return (Eip4844Constants.TargetBlobGasPerBlock, 2, Eip4844Constants.GasPerBlob * 2);
yield return (Eip4844Constants.MaxBlobGasPerBlock, 1, Eip4844Constants.TargetBlobGasPerBlock + Eip4844Constants.GasPerBlob * 1);
yield return (0, 0, 0, null);
yield return (0, (int)(Eip4844Constants.TargetBlobGasPerBlock / Eip4844Constants.GasPerBlob) - 1, 0, null);
yield return (0, (int)(Eip4844Constants.TargetBlobGasPerBlock / Eip4844Constants.GasPerBlob), 0, null);
yield return (100000, (int)(Eip4844Constants.TargetBlobGasPerBlock / Eip4844Constants.GasPerBlob), 100000, null);
yield return (0, (int)(Eip4844Constants.TargetBlobGasPerBlock / Eip4844Constants.GasPerBlob) + 1, Eip4844Constants.GasPerBlob * 1, null);
yield return (Eip4844Constants.TargetBlobGasPerBlock, 1, Eip4844Constants.GasPerBlob * 1, null);
yield return (Eip4844Constants.TargetBlobGasPerBlock, 0, 0, null);
yield return (Eip4844Constants.TargetBlobGasPerBlock, 2, Eip4844Constants.GasPerBlob * 2, null);
yield return (Eip4844Constants.MaxBlobGasPerBlock, 1, Eip4844Constants.TargetBlobGasPerBlock + Eip4844Constants.GasPerBlob * 1, null);
yield return (
Eip4844Constants.MaxBlobGasPerBlock,
(int)(Eip4844Constants.TargetBlobGasPerBlock / Eip4844Constants.GasPerBlob),
Eip4844Constants.MaxBlobGasPerBlock);
Eip4844Constants.MaxBlobGasPerBlock, null);
yield return (
Eip4844Constants.MaxBlobGasPerBlock,
(int)(Eip4844Constants.MaxBlobGasPerBlock / Eip4844Constants.GasPerBlob),
Eip4844Constants.MaxBlobGasPerBlock * 2 - Eip4844Constants.TargetBlobGasPerBlock
Eip4844Constants.MaxBlobGasPerBlock * 2 - Eip4844Constants.TargetBlobGasPerBlock, null
);
}

public static IEnumerable<(ulong parentExcessBlobGas, int parentBlobsCount, ulong expectedExcessBlobGas, ulong? targetBlobCount)> ExcessBlobGasTestCaseSourceForEip7742()
{
yield return (
Eip4844Constants.MaxBlobGasPerBlock,
1,
Eip4844Constants.MaxBlobGasPerBlock, 1);
yield return (
Eip4844Constants.MaxBlobGasPerBlock,
2,
Eip4844Constants.MaxBlobGasPerBlock + Eip4844Constants.GasPerBlob, 1);
yield return (0, 1, 0, 2);
}

public static IEnumerable<(Transaction tx, ulong excessBlobGas, UInt256 expectedCost)> BlobGasCostTestCaseSource()
{
yield return (Build.A.Transaction.TestObject, 0, 0);
Expand Down
Loading
Loading