Skip to content

EIP-7594: PeerDAS #8417

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

Open
wants to merge 106 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
d859da9
calculate cell kzg proofs
marcindsobczak Mar 10, 2025
2a2ffb9
extent tx network wrapper
marcindsobczak Mar 10, 2025
8488009
add cell proofs to test tx builder
marcindsobczak Mar 10, 2025
db0be34
add test for blob txs with cell proofs
marcindsobczak Mar 10, 2025
c996ce0
add tx extension to supply both blob proofs and cell proofs
marcindsobczak Mar 10, 2025
f2c2e0c
Merge remote-tracking branch 'origin/master' into feature/peerdas
marcindsobczak Mar 10, 2025
5673dff
adjust tx builder to current master
marcindsobczak Mar 10, 2025
d1d4b9d
fix data length
marcindsobczak Mar 10, 2025
38614d1
adjust tx validator
marcindsobczak Mar 10, 2025
eed2bbd
extend test
marcindsobczak Mar 10, 2025
9f27431
simplify network wrapper
marcindsobczak Mar 10, 2025
387ad18
cosmetics
marcindsobczak Mar 10, 2025
1837a5f
hack decoder to accept optional blob proofs
marcindsobczak Mar 10, 2025
1c55da2
cleaning
marcindsobczak Mar 10, 2025
2d9e19f
add cell proofs verification
marcindsobczak Mar 10, 2025
a28bb56
fix
marcindsobczak Mar 10, 2025
86a980f
draft of translation logic
marcindsobczak Mar 10, 2025
3e86234
enable translation in tx validator
marcindsobczak Mar 10, 2025
714a83f
fix commitments
marcindsobczak Mar 11, 2025
c77b3e1
Merge remote-tracking branch 'origin/master' into feature/peerdas
marcindsobczak Mar 11, 2025
53da538
Send blobs update
flcl42 Mar 17, 2025
0092ef0
Add engine_getBlobsV2, Fusaka
flcl42 Mar 21, 2025
63374fa
Merge remote-tracking branch 'origin/master' into feature/peerdas-simple
flcl42 Mar 21, 2025
5cbe2d2
Fix proofs
flcl42 Mar 24, 2025
09629c7
drop BlobSender changes
marcindsobczak Mar 24, 2025
a574a1c
Fix encoding
flcl42 Mar 24, 2025
02492bf
Merge remote-tracking branch 'origin/feature/peerdas-simple' into fea…
marcindsobczak Mar 24, 2025
9d76548
undo remaining blob sender changes
marcindsobczak Mar 24, 2025
f29ddcd
Fix block production
flcl42 Mar 24, 2025
2b0d3f4
Merge remote-tracking branch 'origin/feature/peerdas-simple' into fea…
marcindsobczak Mar 24, 2025
690e68f
undo bs
marcindsobczak Mar 24, 2025
1ae89a5
Fix multiple blobs sending
flcl42 Mar 24, 2025
fc13d76
Add more structs and APIs
flcl42 Mar 25, 2025
54cb8ef
Merge remote-tracking branch 'origin/feature/peerdas-simple' into fea…
marcindsobczak Mar 25, 2025
89d3271
Split GetBlobsHandler file
flcl42 Mar 26, 2025
fbb5d61
cleaning
marcindsobczak Mar 26, 2025
411db8d
Merge branch 'feature/peerdas' of https://github.com/NethermindEth/ne…
marcindsobczak Mar 26, 2025
8d80bac
Merge remote-tracking branch 'origin/master' into feature/peerdas-ver…
marcindsobczak Mar 26, 2025
a1f0037
fix blob tx decoder
marcindsobczak Mar 26, 2025
63f907f
fix old proof length in transaction builder
marcindsobczak Mar 26, 2025
94e1da3
fix transaction builder
marcindsobczak Mar 26, 2025
215ad97
whitespaces, encoding
marcindsobczak Mar 26, 2025
a2dcf32
add getBlobsV2 to engine rpc capabilities
marcindsobczak Mar 26, 2025
aba1316
fix test
marcindsobczak Mar 26, 2025
3267fe2
fix proofs validation
marcindsobczak Mar 26, 2025
cdd3669
bring back Alexey's BlobSender changes
marcindsobczak Mar 26, 2025
5491fab
whitespace
marcindsobczak Mar 26, 2025
1442523
fix
marcindsobczak Mar 26, 2025
7658db5
Add manager(just PoC)
flcl42 Mar 26, 2025
412b2c0
Add osaka blobs settings change handling
flcl42 Mar 27, 2025
ae4a58a
add ProofVersion to ChainHeadInfoProvider and add SpecDrivenTxGossipP…
marcindsobczak Mar 27, 2025
d3a08ea
Fix some tests
flcl42 Mar 27, 2025
c4f6fb7
Merge branch 'feature/peerdas' of https://github.com/NethermindEth/ne…
marcindsobczak Mar 27, 2025
27e57bb
Fix V2 proofs
flcl42 Mar 27, 2025
56d386b
Merge branch 'feature/peerdas' of https://github.com/NethermindEth/ne…
marcindsobczak Mar 27, 2025
abf7c8c
fix file encoding
marcindsobczak Mar 27, 2025
f52c9a2
add error InvalidProofVersion
marcindsobczak Mar 27, 2025
d01ce14
invalidate if proof version is not correct
marcindsobczak Mar 27, 2025
8d72399
add test OsakaSpecProvider
marcindsobczak Mar 27, 2025
a6f0b55
adjust and extend test for cell proofs pre and post osaka
marcindsobczak Mar 27, 2025
71725a4
Fix APIs
flcl42 Mar 27, 2025
c3d12c7
Merge remote-tracking branch 'refs/remotes/origin/feature/peerdas' in…
flcl42 Mar 27, 2025
b499d53
Fix a test
flcl42 Mar 27, 2025
80cc653
Move name to spec to Spec project
flcl42 Mar 28, 2025
dbd867e
Fix build
flcl42 Mar 28, 2025
701978d
fix cancun caps
marcindsobczak Mar 28, 2025
aa481b4
Merge remote-tracking branch 'origin/master' into feature/peerdas-ver…
marcindsobczak Mar 31, 2025
5686869
Make tx pool return blob txs with applicable proof version
flcl42 Apr 1, 2025
b53b9b8
Change proof version
flcl42 Apr 1, 2025
3c59520
Display better error
flcl42 Apr 1, 2025
bfe8eab
add ProofsTranslationEnabled to config
marcindsobczak Apr 2, 2025
a78aed3
convert old proof to cell proofs if enabled and after fusaka
marcindsobczak Apr 2, 2025
aaa1421
add test
marcindsobczak Apr 2, 2025
e0d9445
allow replacement: new proofs for old proof
marcindsobczak Apr 2, 2025
32450cf
add regression test
marcindsobczak Apr 2, 2025
5efb156
fix transaction selector tests
marcindsobczak Apr 2, 2025
c0e3d10
Merge remote-tracking branch 'origin/master' into feature/peerdas-ver…
marcindsobczak Apr 3, 2025
d347bc1
Fix blob sender #2 and #3 breaks
flcl42 Apr 4, 2025
6a59ecb
fix engine_getBlobsV2 warning
marcindsobczak Apr 4, 2025
3c249c3
fix osaka caps activation
marcindsobczak Apr 4, 2025
5fd94c8
fix tests
marcindsobczak Apr 4, 2025
0d32024
extend test for blobs bundle v1
marcindsobczak Apr 7, 2025
8a5605f
add regression test for blobs bundle v2
marcindsobczak Apr 7, 2025
3377700
Merge remote-tracking branch 'origin/master' into feature/peerdas-ver…
marcindsobczak Apr 7, 2025
7fe9169
whitespaces
marcindsobczak Apr 7, 2025
ee46950
fix blobs bundle v2
marcindsobczak Apr 7, 2025
dcde3bc
cosmetic
marcindsobczak Apr 7, 2025
43e1dc3
fix versions
marcindsobczak Apr 8, 2025
c30efba
add AreBlobsAvailable
marcindsobczak Apr 8, 2025
a03d892
add metrics
marcindsobczak Apr 8, 2025
5f36da0
return empty array if not all blobs are available
marcindsobczak Apr 8, 2025
d3d8248
add tests, fix disposing issues
marcindsobczak Apr 8, 2025
68eb4ad
fix build
marcindsobczak Apr 8, 2025
878d27a
Dial back JsonRpc log spam
benaadams Apr 9, 2025
de77932
Merge remote-tracking branch 'origin/master' into feature/peerdas-ver…
marcindsobczak Apr 9, 2025
4bed57b
Merge remote-tracking branch 'origin/master' into feature/peerdas-ver…
marcindsobczak Apr 16, 2025
85f47f5
fix test
marcindsobczak Apr 16, 2025
52c12bb
default ProofsTranslationEnabled to false
marcindsobczak Apr 16, 2025
657ae12
fix test
marcindsobczak Apr 16, 2025
51d4c73
Rename proof versions for less confusion
flcl42 Apr 17, 2025
a3955e2
Fix naming change
flcl42 Apr 18, 2025
6bb2040
One does not simply rename an enum value
flcl42 Apr 18, 2025
b8044b2
Simplify proof version checkers
flcl42 Apr 18, 2025
6be4778
Clean up
flcl42 Apr 18, 2025
518a3d5
Merge master into feature/peerdas
flcl42 Apr 18, 2025
c4927b0
Ckzg.Ckzg -> Ckzg. (#8568)
flcl42 Apr 29, 2025
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/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.14.0" />
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.5.0" />
<PackageVersion Include="Ckzg.Bindings" Version="2.0.1.1258" />
<PackageVersion Include="Ckzg.Bindings" Version="2.1.1.1366" />
<PackageVersion Include="Colorful.Console" Version="1.2.15" />
<PackageVersion Include="CommunityToolkit.HighPerformance" Version="8.3.2" />
<PackageVersion Include="ConcurrentHashSet" Version="1.3.0" />
Expand Down
53 changes: 4 additions & 49 deletions src/Nethermind/Ethereum.Test.Base/JsonToEthereumTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,57 +16,12 @@
using Nethermind.Int256;
using Nethermind.Serialization.Json;
using Nethermind.Serialization.Rlp;
using Nethermind.Specs.Forks;
using Nethermind.Specs;

namespace Ethereum.Test.Base
{
public static class JsonToEthereumTest
{
public static IReleaseSpec ParseSpec(string network)
{
network = network.Replace("EIP150", "TangerineWhistle");
network = network.Replace("EIP158", "SpuriousDragon");
network = network.Replace("DAO", "Dao");
network = network.Replace("Merged", "Paris");
network = network.Replace("Merge", "Paris");
network = network.Replace("London+3540+3670", "Shanghai");
network = network.Replace("GrayGlacier+3540+3670", "Shanghai");
network = network.Replace("GrayGlacier+3860", "Shanghai");
network = network.Replace("GrayGlacier+3855", "Shanghai");
network = network.Replace("Merge+3540+3670", "Shanghai");
network = network.Replace("Shanghai+3855", "Shanghai");
network = network.Replace("Shanghai+3860", "Shanghai");
network = network.Replace("GrayGlacier+1153", "Cancun");
network = network.Replace("Merge+1153", "Cancun");
network = network.Replace("Shanghai+6780", "Cancun");
network = network.Replace("GrayGlacier+1153", "Cancun");
network = network.Replace("Merge+1153", "Cancun");
return network switch
{
"Frontier" => Frontier.Instance,
"Homestead" => Homestead.Instance,
"TangerineWhistle" => TangerineWhistle.Instance,
"SpuriousDragon" => SpuriousDragon.Instance,
"EIP150" => TangerineWhistle.Instance,
"EIP158" => SpuriousDragon.Instance,
"Dao" => Dao.Instance,
"Constantinople" => Constantinople.Instance,
"ConstantinopleFix" => ConstantinopleFix.Instance,
"Byzantium" => Byzantium.Instance,
"Istanbul" => Istanbul.Instance,
"Berlin" => Berlin.Instance,
"London" => London.Instance,
"ArrowGlacier" => ArrowGlacier.Instance,
"GrayGlacier" => GrayGlacier.Instance,
"Shanghai" => Shanghai.Instance,
"Cancun" => Cancun.Instance,
"Paris" => Paris.Instance,
"Prague" => Prague.Instance,
"Osaka" => Osaka.Instance,
_ => throw new NotSupportedException()
};
}

private static ForkActivation TransitionForkActivation(string transitionInfo)
{
const string timestampPrefix = "Time";
Expand Down Expand Up @@ -252,7 +207,7 @@ public static IEnumerable<GeneralStateTest> Convert(string name, string category
test.Category = category;

test.ForkName = postStateBySpec.Key;
test.Fork = ParseSpec(postStateBySpec.Key);
test.Fork = SpecNameParser.Parse(postStateBySpec.Key);
test.PreviousHash = testJson.Env.PreviousHash;
test.CurrentCoinbase = testJson.Env.CurrentCoinbase;
test.CurrentDifficulty = testJson.Env.CurrentDifficulty;
Expand Down Expand Up @@ -410,11 +365,11 @@ public static IEnumerable<BlockchainTest> ConvertToBlockchainTests(string json)
string[] transitionInfo = testSpec.Network.Split("At");
string[] networks = transitionInfo[0].Split("To");

testSpec.EthereumNetwork = ParseSpec(networks[0]);
testSpec.EthereumNetwork = SpecNameParser.Parse(networks[0]);
if (transitionInfo.Length > 1)
{
testSpec.TransitionForkActivation = TransitionForkActivation(transitionInfo[1]);
testSpec.EthereumNetworkAfterTransition = ParseSpec(networks[1]);
testSpec.EthereumNetworkAfterTransition = SpecNameParser.Parse(networks[1]);
}

(string name, string category) = GetNameAndCategory(testName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public static IEnumerable EnoughShardBlobTransactionsSelectedTestCases
tx.Type = TxType.Blob;
tx.BlobVersionedHashes = new byte[1][];
tx.MaxFeePerBlobGas = 1;
tx.NetworkWrapper = new ShardBlobNetworkWrapper(new byte[1][], new byte[1][], new byte[1][], ProofVersion.V0);
});
maxTransactionsSelected.Transactions[1].BlobVersionedHashes =
new byte[maxTransactionsSelected.ReleaseSpec.MaxBlobCount - 1][];
Expand All @@ -178,9 +179,13 @@ public static IEnumerable EnoughShardBlobTransactionsSelectedTestCases
expectedSelectedTransactions[0].BlobVersionedHashes =
new byte[enoughTransactionsSelected.ReleaseSpec.MaxBlobCount][];
expectedSelectedTransactions[0].MaxFeePerBlobGas = 1;
expectedSelectedTransactions[0].NetworkWrapper =
new ShardBlobNetworkWrapper(new byte[1][], new byte[1][], new byte[1][], ProofVersion.V0);
expectedSelectedTransactions[1].Type = TxType.Blob;
expectedSelectedTransactions[1].BlobVersionedHashes = new byte[1][];
expectedSelectedTransactions[1].MaxFeePerBlobGas = 1;
expectedSelectedTransactions[1].NetworkWrapper =
new ShardBlobNetworkWrapper(new byte[1][], new byte[1][], new byte[1][], ProofVersion.V0);
enoughTransactionsSelected.ExpectedSelectedTransactions.AddRange(
expectedSelectedTransactions.Where(static (_, index) => index != 1));
yield return new TestCaseData(enoughTransactionsSelected).SetName(
Expand Down Expand Up @@ -224,9 +229,13 @@ public static IEnumerable EnoughShardBlobTransactionsSelectedTestCases

static Transaction CreateBlobTransaction(Address address, PrivateKey key, UInt256 maxFee, int blobCount)
{
return Build.A.Transaction.WithSenderAddress(address).WithType(TxType.Blob).WithNonce(1)
.WithMaxFeePerGas(maxFee).WithMaxFeePerBlobGas(1).WithGasLimit(20)
.WithBlobVersionedHashes([.. Enumerable.Range(0, blobCount).Select(i => new byte[1] { 0 })])
return Build.A.Transaction
.WithSenderAddress(address)
.WithShardBlobTxTypeAndFields(blobCount)
.WithNonce(1)
.WithMaxFeePerGas(maxFee)
.WithMaxFeePerBlobGas(1)
.WithGasLimit(20)
.SignedAndResolved(key).TestObject;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited
// SPDX-FileCopyrightText: 2025 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using CkzgLib;
using FluentAssertions;
using Nethermind.Consensus.Messages;
using Nethermind.Consensus.Validators;
Expand Down Expand Up @@ -483,7 +484,7 @@ public void IsWellFormed_BlobTxHasBlobOverTheSizeLimit_ReturnFalse()
.SignedAndResolved();

Transaction tx = txBuilder.TestObject;
((ShardBlobNetworkWrapper)tx.NetworkWrapper!).Blobs[0] = new byte[Ckzg.Ckzg.BytesPerBlob + 1];
((ShardBlobNetworkWrapper)tx.NetworkWrapper!).Blobs[0] = new byte[Ckzg.BytesPerBlob + 1];
TxValidator txValidator = new(TestBlockchainIds.ChainId);

Assert.That(txValidator.IsWellFormed(tx, Cancun.Instance).AsBool(), Is.False);
Expand All @@ -500,7 +501,7 @@ public void IsWellFormed_BlobTxHasCommitmentOverTheSizeLimit_ReturnFalse()
.SignedAndResolved();

Transaction tx = txBuilder.TestObject;
((ShardBlobNetworkWrapper)tx.NetworkWrapper!).Commitments[0] = new byte[Ckzg.Ckzg.BytesPerCommitment + 1];
((ShardBlobNetworkWrapper)tx.NetworkWrapper!).Commitments[0] = new byte[Ckzg.BytesPerCommitment + 1];
TxValidator txValidator = new(TestBlockchainIds.ChainId);

Assert.That(txValidator.IsWellFormed(tx, Cancun.Instance).AsBool(), Is.False);
Expand All @@ -517,7 +518,7 @@ public void IsWellFormed_BlobTxHasProofOverTheSizeLimit_ReturnFalse()
.SignedAndResolved();

Transaction tx = txBuilder.TestObject;
((ShardBlobNetworkWrapper)tx.NetworkWrapper!).Proofs[0] = new byte[Ckzg.Ckzg.BytesPerProof + 1];
((ShardBlobNetworkWrapper)tx.NetworkWrapper!).Proofs[0] = new byte[Ckzg.BytesPerProof + 1];
TxValidator txValidator = new(TestBlockchainIds.ChainId);

Assert.That(txValidator.IsWellFormed(tx, Cancun.Instance).AsBool(), Is.False);
Expand Down
3 changes: 3 additions & 0 deletions src/Nethermind/Nethermind.Blockchain/ChainHeadInfoProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public ChainHeadInfoProvider(IChainHeadSpecProvider specProvider, IBlockTree blo

public UInt256 CurrentFeePerBlobGas { get; internal set; }

public ProofVersion CurrentProofVersion { get; private set; }

public bool IsSyncing
{
get
Expand All @@ -82,6 +84,7 @@ private void OnHeadChanged(object? sender, BlockReplacementEventArgs e)
BlobGasCalculator.TryCalculateFeePerBlobGas(e.Block.Header, spec.BlobBaseFeeUpdateFraction, out UInt256 currentFeePerBlobGas)
? currentFeePerBlobGas
: UInt256.Zero;
CurrentProofVersion = spec.BlobProofVersion;
HeadChanged?.Invoke(sender, e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private IComparer<Transaction> CreateTxPoolTxComparer(TxPriorityContract? txPrio
return CreateTxPoolTxComparer();
}

protected override TxPool.TxPool CreateTxPool(CodeInfoRepository codeInfoRepository)
protected override TxPool.TxPool CreateTxPool(IChainHeadInfoProvider chainHeadInfoProvider)
{
// This has to be different object than the _processingReadOnlyTransactionProcessorSource as this is in separate thread
TxPriorityContract txPriorityContract = TxAuRaFilterBuilders.CreateTxPrioritySources(_api);
Expand All @@ -260,7 +260,7 @@ protected override TxPool.TxPool CreateTxPool(CodeInfoRepository codeInfoReposit
return new TxPool.TxPool(
_api.EthereumEcdsa!,
_api.BlobTxStorage ?? NullBlobTxStorage.Instance,
new ChainHeadInfoProvider(_api.SpecProvider!, _api.BlockTree!, _api.StateReader!, codeInfoRepository),
chainHeadInfoProvider,
NethermindApi.Config<ITxPoolConfig>(),
_api.TxValidator!,
_api.LogManager,
Expand Down
26 changes: 13 additions & 13 deletions src/Nethermind/Nethermind.Consensus/Messages/TxErrorMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ public static string InvalidTxChainId(ulong expected, ulong? actual) =>
public const string NotAllowedBlobVersionedHashes =
"NotAllowedBlobVersionedHashes: Cannot be set.";

public const string InvalidTransaction =
public const string InvalidTransactionForm =
$"InvalidTransaction: Cannot be {nameof(ShardBlobNetworkWrapper)}.";

public const string NotAllowedCreateTransaction =
"NotAllowedCreateTransaction: To must be set.";


public const string BlobTxMissingMaxFeePerBlobGas =
"BlobTxMissingMaxFeePerBlobGas: Must be set.";

Expand All @@ -58,14 +59,19 @@ public static string BlobTxGasLimitExceeded(ulong totalDataGas, ulong maxBlobGas
public const string InvalidBlobVersionedHashVersion =
"InvalidBlobVersionedHashVersion: Blob version not supported.";

public static readonly string ExceededBlobSize =
$"ExceededBlobSize: Cannot be more than {Ckzg.Ckzg.BytesPerBlob}.";
public static readonly string InvalidBlobDataSize =
$"InvalidBlobDataSize: Blob data fields are of incorrect size.";

public const string InvalidBlobHashes =
"InvalidBlobProof: Hashes do not match the blobs.";

public const string InvalidBlobProofs =
"InvalidBlobProof: Proofs do not match the blobs.";

public const string InvalidProofVersion
= "InvalidTxProofVersion: Version of network wrapper is not supported.";

public static readonly string ExceededBlobCommitmentSize =
$"ExceededBlobCommitmentSize: Cannot be more than {Ckzg.Ckzg.BytesPerCommitment}.";

public static readonly string InvalidBlobProofSize =
$"InvalidBlobProofSize: Cannot be more than {Ckzg.Ckzg.BytesPerProof}.";

public const string NotAllowedAuthorizationList = $"NotAllowedAuthorizationList: Only transactions with type {nameof(TxType.SetCode)} can have authorization_list.";

Expand All @@ -76,12 +82,6 @@ public static string BlobTxGasLimitExceeded(ulong totalDataGas, ulong maxBlobGas
public const string InvalidBlobCommitmentHash =
"InvalidBlobCommitmentHash: Commitment hash does not match.";

public const string InvalidBlobProof =
"InvalidBlobProof: Proof does not match.";

public const string InvalidBlobData
= "InvalidTxBlobData: Number of blobs, hashes, commitments and proofs must match.";

public const string InvalidCreateTxData
= "InvalidCreateTxData: Legacy createTx cannot create Eof code";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public TxPoolTxSource(
public IEnumerable<Transaction> GetTransactions(BlockHeader parent, long gasLimit, PayloadAttributes? payloadAttributes = null, bool filterSource = false)
{
long blockNumber = parent.Number + 1;
IReleaseSpec spec = _specProvider.GetSpec(parent);
IReleaseSpec spec = payloadAttributes is not null ? _specProvider.GetSpec(new ForkActivation(parent.Number + 1, payloadAttributes.Timestamp)) : _specProvider.GetSpec(parent);
UInt256 baseFee = BaseFeeCalculator.Calculate(parent, spec);
IDictionary<AddressAsKey, Transaction[]> pendingTransactions = filterSource ?
_transactionPool.GetPendingTransactionsBySender(filterToReadyTx: true, baseFee) :
Expand Down Expand Up @@ -155,6 +155,13 @@ private void SelectBlobTransactions(IEnumerable<Transaction> blobTransactions, B
continue;
}

ProofVersion? proofVersion = (fullBlobTx.NetworkWrapper as ShardBlobNetworkWrapper)?.Version;
if (spec.BlobProofVersion != proofVersion)
{
if (_logger.IsTrace) _logger.Trace($"Declining {blobTx.ToShortString()}, {spec.BlobProofVersion} is wanted, but tx's proof version is {proofVersion}.");
continue;
}

if (txBlobCount == 1 && candidates is null)
{
selectedBlobTxs.Add(fullBlobTx);
Expand Down
50 changes: 15 additions & 35 deletions src/Nethermind/Nethermind.Consensus/Validators/TxValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using Nethermind.Crypto;
using Nethermind.Evm;
using Nethermind.Int256;
using System.Linq;

namespace Nethermind.Consensus.Validators;

Expand Down Expand Up @@ -164,7 +163,7 @@ private NonBlobFieldsTxValidator() { }
// Execution-payload version verification
{ MaxFeePerBlobGas: not null } => TxErrorMessages.NotAllowedMaxFeePerBlobGas,
{ BlobVersionedHashes: not null } => TxErrorMessages.NotAllowedBlobVersionedHashes,
{ NetworkWrapper: ShardBlobNetworkWrapper } => TxErrorMessages.InvalidTransaction,
{ NetworkWrapper: ShardBlobNetworkWrapper } => TxErrorMessages.InvalidTransactionForm,
_ => ValidationResult.Success
};
}
Expand Down Expand Up @@ -231,45 +230,26 @@ private MempoolBlobTxValidator() { }

public ValidationResult IsWellFormed(Transaction transaction, IReleaseSpec releaseSpec)
{
int blobCount = transaction.BlobVersionedHashes!.Length;
return transaction.NetworkWrapper is not ShardBlobNetworkWrapper wrapper ? ValidationResult.Success
: wrapper.Blobs.Length != blobCount ? TxErrorMessages.InvalidBlobData
: wrapper.Commitments.Length != blobCount ? TxErrorMessages.InvalidBlobData
: wrapper.Proofs.Length != blobCount ? TxErrorMessages.InvalidBlobData
: ValidateBlobs();
return transaction switch
{
{ NetworkWrapper: null } => ValidationResult.Success,
{ Type: TxType.Blob, NetworkWrapper: ShardBlobNetworkWrapper wrapper } => ValidateBlobs(transaction, wrapper, releaseSpec),
{ Type: TxType.Blob } or { NetworkWrapper: not null } => TxErrorMessages.InvalidTransactionForm,
};

ValidationResult ValidateBlobs()
static ValidationResult ValidateBlobs(Transaction transaction, ShardBlobNetworkWrapper wrapper, IReleaseSpec releaseSpec)
{
for (int i = 0; i < blobCount; i++)
if (wrapper.Version != releaseSpec.BlobProofVersion)
{
if (wrapper.Blobs[i].Length != Ckzg.Ckzg.BytesPerBlob)
{
return TxErrorMessages.ExceededBlobSize;
}

if (wrapper.Commitments[i].Length != Ckzg.Ckzg.BytesPerCommitment)
{
return TxErrorMessages.ExceededBlobCommitmentSize;
}

if (wrapper.Proofs[i].Length != Ckzg.Ckzg.BytesPerProof)
{
return TxErrorMessages.InvalidBlobProofSize;
}
return TxErrorMessages.InvalidProofVersion;
}

Span<byte> hash = stackalloc byte[32];
for (int i = 0; i < blobCount; i++)
{
if (!KzgPolynomialCommitments.TryComputeCommitmentHashV1(wrapper.Commitments[i].AsSpan(), hash) || !hash.SequenceEqual(transaction.BlobVersionedHashes[i]))
{
return TxErrorMessages.InvalidBlobCommitmentHash;
}
}
IBlobProofsManager proofsManager = IBlobProofsManager.For(wrapper.Version);

return !KzgPolynomialCommitments.AreProofsValid(wrapper.Blobs, wrapper.Commitments, wrapper.Proofs)
? TxErrorMessages.InvalidBlobProof
: ValidationResult.Success;
return !proofsManager.ValidateLengths(wrapper) ? TxErrorMessages.InvalidBlobDataSize :
!proofsManager.ValidateHashes(wrapper, transaction.BlobVersionedHashes) ? TxErrorMessages.InvalidBlobHashes :
!proofsManager.ValidateProofs(wrapper) ? TxErrorMessages.InvalidBlobProofs :
ValidationResult.Success;
}
}
}
Expand Down
Loading