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 84 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 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
a993d59
Merge branch 'master' into feature/eip-7742
yerke26 Oct 30, 2024
ba1a3de
Merge branch 'master' into feature/eip-7742
yerke26 Nov 4, 2024
87e721a
add eip7742 logic to TryCalculateFeePerBlobGas
yerke26 Nov 4, 2024
e52fc98
remove MaxBlobCount, pass Spec to BlobGasCalculator
yerke26 Nov 4, 2024
49424d9
Merge branch 'master' into feature/eip-7742
yerke26 Nov 4, 2024
2162240
resolve merge conflicts
yerke26 Nov 4, 2024
9d4ec74
add MaxBlobCount in PayloadAttributes, refactoring, resolve comments
yerke26 Nov 5, 2024
d8e088c
fix tests
yerke26 Nov 5, 2024
793d085
Merge branch 'master' into feature/eip-7742
yerke26 Nov 5, 2024
a4fd1ef
fix Evm tool
yerke26 Nov 5, 2024
d022c4f
fix Evm tool
yerke26 Nov 5, 2024
47437f2
Merge branch 'master' into feature/eip-7742
yerke26 Nov 25, 2024
020ceef
resolve merge conflicts
yerke26 Nov 25, 2024
5699ad4
fix some tests
yerke26 Nov 26, 2024
81fb376
Merge branch 'master' into feature/eip-7742
yerke26 Nov 26, 2024
332322d
fix tests
yerke26 Nov 27, 2024
91822aa
fix AuraTests
yerke26 Nov 28, 2024
b4790dd
fix tests
yerke26 Nov 28, 2024
36464ad
fix JsonRpcTests
yerke26 Nov 28, 2024
459ebb7
fix TraceRpcModuleTests
yerke26 Nov 28, 2024
71963b7
fix tests
yerke26 Nov 28, 2024
94a1e4d
fix tests
yerke26 Dec 2, 2024
35d29c5
fix whitespaces
yerke26 Dec 2, 2024
5fab184
Merge branch 'master' into feature/eip-7742
yerke26 Dec 3, 2024
f00d86a
Update src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs
yerke26 Dec 3, 2024
1b9b367
Merge remote-tracking branch 'origin/feature/eip-7742' into feature/e…
yerke26 Dec 4, 2024
f13d22f
Merge branch 'master' into feature/eip-7742
yerke26 Dec 4, 2024
9718087
refactoring of BlockExecutionContext, move blobFee calculation to Vir…
yerke26 Dec 8, 2024
7a70d04
refactoring
yerke26 Dec 8, 2024
1d0dcc1
fix compilation erros
yerke26 Dec 8, 2024
aba9f7c
fix tests
yerke26 Dec 8, 2024
36f635d
fix tests, refactoring
yerke26 Dec 8, 2024
34ec30c
change to const
yerke26 Dec 8, 2024
8657a8c
fix TxPoolTxSource
yerke26 Dec 8, 2024
bb63085
fix
yerke26 Dec 8, 2024
4a83375
revert blobGasCalculator changes
yerke26 Dec 9, 2024
aa8cc8b
fix evm build
yerke26 Dec 9, 2024
e876201
revert BlobGasCalculatorTests
yerke26 Dec 9, 2024
1d05358
revert BlockExecutionContext
yerke26 Dec 9, 2024
c60067c
revert BlockHeader implicit conversion
yerke26 Dec 9, 2024
ce81cbe
revert remaining implicit conversion of header
yerke26 Dec 9, 2024
77c82a6
remove unnecessary import
yerke26 Dec 9, 2024
b465739
Update src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs
yerke26 Dec 9, 2024
41703ec
Update src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs
yerke26 Dec 9, 2024
fc1832b
Update src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs
yerke26 Dec 9, 2024
a6c75cc
resolve comments
yerke26 Dec 10, 2024
981f9ee
fix
yerke26 Dec 10, 2024
4339472
fix
yerke26 Dec 10, 2024
c2abd4c
Fix TransactionProcessorFeeTests: add eip enabled/disabled tests
yerke26 Dec 10, 2024
d1b14e9
add MaxBlobCount to BlockHeader
yerke26 Dec 10, 2024
2eb9fee
Update src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs
yerke26 Dec 10, 2024
82f6f4b
Revert "add MaxBlobCount to BlockHeader"
yerke26 Dec 11, 2024
0303cfd
Merge remote-tracking branch 'origin/feature/eip-7742' into feature/e…
yerke26 Dec 11, 2024
f63e7ef
fix tests with TargetBlobCount = 1
yerke26 Dec 11, 2024
13b65bd
fix tests
yerke26 Dec 11, 2024
6475265
Update src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHi…
yerke26 Dec 11, 2024
dfe634e
fix whitespaces
yerke26 Dec 11, 2024
e231959
Merge branch 'master' into feature/eip-7742
yerke26 Dec 19, 2024
5c6dc2c
resolve merge conflicts
yerke26 Dec 19, 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
1 change: 1 addition & 0 deletions src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ protected EthereumTestResult RunTest(GeneralStateTest test, ITxTracer txTracer)
header.ExcessBlobGas = test.CurrentExcessBlobGas ?? (test.Fork is Cancun ? 0ul : null);
header.BlobGasUsed = BlobGasCalculator.CalculateBlobGas(test.Transaction);
header.RequestsHash = test.RequestsHash;
header.TargetBlobCount = test.Fork is Prague ? 0 : null;

Stopwatch stopwatch = Stopwatch.StartNew();
IReleaseSpec? spec = specProvider.GetSpec((ForkActivation)test.CurrentNumber);
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 @@ -397,7 +397,8 @@ private Block PrepareBlockForProcessing(Block suggestedBlock)
WithdrawalsRoot = bh.WithdrawalsRoot,
RequestsHash = bh.RequestsHash,
IsPostMerge = bh.IsPostMerge,
ParentBeaconBlockRoot = bh.ParentBeaconBlockRoot
ParentBeaconBlockRoot = bh.ParentBeaconBlockRoot,
TargetBlobCount = bh.TargetBlobCount,
};

if (!ShouldComputeStateRoot(bh))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ protected virtual BlockHeader PrepareBlockHeader(BlockHeader parent,
{
Author = blockAuthor,
MixHash = payloadAttributes?.PrevRandao,
ParentBeaconBlockRoot = payloadAttributes?.ParentBeaconBlockRoot
ParentBeaconBlockRoot = payloadAttributes?.ParentBeaconBlockRoot,
TargetBlobCount = payloadAttributes?.TargetBlobCount,
};

UInt256 difficulty = _difficultyCalculator.Calculate(header, parent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class BuildBlocksWhenRequested : IManualBlockProductionTrigger
BlockHeader? parentHeader = null,
CancellationToken? cancellationToken = null,
IBlockTracer? blockTracer = null,
PayloadAttributes payloadAttributes = null)
PayloadAttributes? payloadAttributes = null)
{
BlockProductionEventArgs args = new(parentHeader, cancellationToken, blockTracer, payloadAttributes);
TriggerBlockProduction?.Invoke(this, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public class PayloadAttributes

public Hash256? ParentBeaconBlockRoot { get; set; }

public ulong? TargetBlobCount { get; set; }
yerke26 marked this conversation as resolved.
Show resolved Hide resolved

public ulong? MaxBlobCount { get; set; }

public virtual long? GetGasLimit() => null;

public override string ToString() => ToString(string.Empty);
Expand All @@ -47,6 +51,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 All @@ -71,7 +85,9 @@ protected virtual int ComputePayloadIdMembersSize() =>
+ Keccak.Size // prev randao
+ Address.Size // suggested fee recipient
+ (Withdrawals is null ? 0 : Keccak.Size) // withdrawals root hash
+ (ParentBeaconBlockRoot is null ? 0 : Keccak.Size); // parent beacon block root
+ (ParentBeaconBlockRoot is null ? 0 : Keccak.Size) // parent beacon block root
+ (TargetBlobCount is null ? 0 : sizeof(ulong)) // target blob count
+ (MaxBlobCount is null ? 0 : sizeof(ulong)); // max blob count

protected static string ComputePayloadId(Span<byte> inputSpan)
{
Expand Down Expand Up @@ -110,6 +126,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 @@ -166,6 +194,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 @@ -174,6 +203,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
19 changes: 14 additions & 5 deletions src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ public IEnumerable<Transaction> GetTransactions(BlockHeader parent, long gasLimi

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

SelectBlobTransactions(blobTransactions, parent, spec, selectedBlobTxs);
using ArrayPoolList<Transaction> selectedBlobTxs = new((int)(payloadAttributes?.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock()));

if (!spec.IsEip7742Enabled || payloadAttributes?.MaxBlobCount is not null)
{
SelectBlobTransactions(blobTransactions, parent, spec, selectedBlobTxs);
Copy link
Contributor

Choose a reason for hiding this comment

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

You dont pass the PayloadAttributes

}

foreach (Transaction tx in transactions)
{
Expand Down Expand Up @@ -119,7 +123,7 @@ private static IEnumerable<Transaction> PickBlobTxsBetterThanCurrentTx(ArrayPool
}
}

private void SelectBlobTransactions(IEnumerable<Transaction> blobTransactions, BlockHeader parent, IReleaseSpec spec, ArrayPoolList<Transaction> selectedBlobTxs)
private void SelectBlobTransactions(IEnumerable<Transaction> blobTransactions, BlockHeader parent, IReleaseSpec spec, ArrayPoolList<Transaction> selectedBlobTxs, PayloadAttributes? payloadAttributes = null)
Copy link
Contributor

Choose a reason for hiding this comment

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

why is PayloadAttributes optional?

{
int checkedBlobTransactions = 0;
int selectedBlobTransactions = 0;
Expand All @@ -128,7 +132,10 @@ private void SelectBlobTransactions(IEnumerable<Transaction> blobTransactions, B

foreach (Transaction blobTx in blobTransactions)
{
if (blobGasCounter >= _eip4844Config.MaxBlobGasPerBlock)
UInt256 maxBlobGas = spec.IsEip7742Enabled
? payloadAttributes?.MaxBlobCount * Eip4844Constants.GasPerBlob ?? UInt256.Zero
: _eip4844Config.MaxBlobGasPerBlock;
if (blobGasCounter >= maxBlobGas)
{
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 +144,9 @@ private void SelectBlobTransactions(IEnumerable<Transaction> blobTransactions, B
checkedBlobTransactions++;

ulong txBlobGas = (ulong)(blobTx.BlobVersionedHashes?.Length ?? 0) * _eip4844Config.GasPerBlob;
if (txBlobGas > _eip4844Config.MaxBlobGasPerBlock - blobGasCounter)

UInt256 blobGasLeft = maxBlobGas - blobGasCounter;
if (txBlobGas > blobGasLeft)
{
if (_logger.IsTrace) _logger.Trace($"Declining {blobTx.ToShortString()}, not enough blob space.");
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ protected virtual bool ValidateEip4844Fields(Block block, IReleaseSpec spec, out

ulong blobGasUsed = BlobGasCalculator.CalculateBlobGas(blobsInBlock);

if (blobGasUsed > Eip4844Constants.MaxBlobGasPerBlock)
// no validation is needed when eip7742 is activated
if (!spec.IsEip7742Enabled && blobGasUsed > Eip4844Constants.MaxBlobGasPerBlock)
tanishqjasoria marked this conversation as resolved.
Show resolved Hide resolved
{
error = BlockErrorMessages.BlobGasUsedAboveBlockLimit;
if (_logger.IsDebug) _logger.Debug($"{Invalid(block)} {error}.");
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 @@ -189,15 +189,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
yerke26 marked this conversation as resolved.
Show resolved Hide resolved
&& BlobGasCalculator.CalculateBlobGas(blobCount) > Eip4844Constants.MaxBlobGasPerTransaction)
{
return TxErrorMessages.BlobTxGasLimitExceeded;
}

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

ValidationResult ValidateBlobVersionedHashes()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ protected virtual Block GetGenesisBlock()
genesisBlockBuilder.WithEmptyRequestsHash();
}

if (SpecProvider.GenesisSpec.IsEip7742Enabled)
{
genesisBlockBuilder.WithTargetBlobCount(0);
}

genesisBlockBuilder.WithStateRoot(State.StateRoot);
return genesisBlockBuilder.TestObject;
}
Expand Down Expand Up @@ -440,7 +445,7 @@ private async Task<AcceptTxResult[]> AddBlockInternal(params Transaction[] trans
Timestamper.Add(TimeSpan.FromSeconds(1));
var headProcessed = new SemaphoreSlim(0);
TxPool.TxPoolHeadChanged += (s, a) => headProcessed.Release();
await BlockProductionTrigger.BuildBlock().ConfigureAwait(false);
await BlockProductionTrigger.BuildBlock(payloadAttributes: new PayloadAttributes { TargetBlobCount = 1 }).ConfigureAwait(false);
await headProcessed.WaitAsync().ConfigureAwait(false);
return txResults;
}
Expand Down
6 changes: 6 additions & 0 deletions src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,5 +288,11 @@ public BlockBuilder WithParentBeaconBlockRoot(Hash256? parentBeaconBlockRoot)
TestObjectInternal.Header.ParentBeaconBlockRoot = parentBeaconBlockRoot;
return this;
}

public BlockBuilder WithTargetBlobCount(ulong? targetBlobCount)
{
TestObjectInternal.Header.TargetBlobCount = targetBlobCount;
return this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,10 @@ public BlockHeaderBuilder WithRequestsHash(Hash256? requestsHash)
TestObjectInternal.RequestsHash = requestsHash;
return this;
}

public BlockHeaderBuilder WithTargetBlobCount(ulong? targetBlobCount)
{
TestObjectInternal.TargetBlobCount = targetBlobCount;
return this;
}
}
2 changes: 2 additions & 0 deletions src/Nethermind/Nethermind.Core/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ public Transaction[] Transactions
[JsonIgnore]
public byte[][]? ExecutionRequests { get; set; }

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

[JsonIgnore]
public ArrayPoolList<AddressAsKey>? AccountChanges { get; set; }
[JsonIgnore]
Expand Down
1 change: 1 addition & 0 deletions src/Nethermind/Nethermind.Core/BlockHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public BlockHeader(

public string SealEngineType { get; set; } = Core.SealEngineType.Ethash;
public bool IsPostMerge { get; set; }
public ulong? TargetBlobCount { 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 @@ -323,6 +323,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 @@ -67,6 +67,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
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ public void Check_paid_fees_multiple_transactions(bool withFeeCollector)
tracer.BurntFees.Should().Be(84000);
}

[TestCase(false)]
[TestCase(true)]
public void Check_paid_fees_with_blob(bool withFeeCollector)
[TestCase(false, true)]
[TestCase(false, false)]
[TestCase(true, true)]
[TestCase(true, false)]
public void Check_paid_fees_with_blob(bool withFeeCollector, bool eip7742Enabled)
{
UInt256 initialBalance = 0;
if (withFeeCollector)
Expand All @@ -121,6 +123,9 @@ public void Check_paid_fees_with_blob(bool withFeeCollector)

BlockHeader header = Build.A.BlockHeader.WithExcessBlobGas(0).TestObject;

_spec.IsEip7742Enabled = eip7742Enabled;
if (eip7742Enabled) header.TargetBlobCount = 3;

Transaction tx = Build.A.Transaction
.SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA).WithType(TxType.Blob)
.WithBlobVersionedHashes(1).WithMaxFeePerBlobGas(1).TestObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ protected virtual Block BuildBlock(ForkActivation activation, SenderRecipientAnd
.WithExcessBlobGas(0)
.WithParentBeaconBlockRoot(TestItem.KeccakG)
.WithExcessBlobGas(excessBlobGas)
.WithTargetBlobCount(3)
yerke26 marked this conversation as resolved.
Show resolved Hide resolved
.TestObject;
}

Expand Down
1 change: 1 addition & 0 deletions src/Nethermind/Nethermind.Facade/BlockchainBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ private TransactionResult CallAndRestore(
}
callHeader.MixHash = blockHeader.MixHash;
callHeader.IsPostMerge = blockHeader.Difficulty == 0;
callHeader.TargetBlobCount = blockHeader.TargetBlobCount;
transaction.Hash = transaction.CalculateHash();
return scope.TransactionProcessor.CallAndRestore(transaction, new(callHeader), tracer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ private BlockHeader GetCallHeader(BlockStateCall<TransactionWithSourceDetails> b
MixHash = parent.MixHash,
IsPostMerge = parent.Difficulty == 0,
};
result.TargetBlobCount = parent.TargetBlobCount;
result.Timestamp = parent.Timestamp + 1;
result.BaseFeePerGas = block.BlockOverrides is { BaseFeePerGas: not null }
? block.BlockOverrides.BaseFeePerGas.Value
Expand Down
Loading
Loading