From de197653a55b733248dc3bb097799f83e5db7a92 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 30 Sep 2024 19:28:57 +0600 Subject: [PATCH 01/68] Get target_blob_count, max_blob_count from Engine Api --- .../Messages/BlockErrorMessages.cs | 4 --- .../Messages/TxErrorMessages.cs | 3 -- .../Producers/TxPoolTxSource.cs | 15 ++-------- .../Validators/BlockValidator.cs | 7 ----- .../Validators/HeaderValidator.cs | 2 +- .../Validators/TxValidator.cs | 4 +-- src/Nethermind/Nethermind.Core/BlockHeader.cs | 2 ++ .../Nethermind.Core/Eip4844Constants.cs | 30 +------------------ .../Nethermind.Core/IEip4844Config.cs | 4 --- .../Nethermind.Evm/BlobGasCalculator.cs | 6 ++-- .../Nethermind.Facade/BlockchainBridge.cs | 2 +- .../Simulate/SimulateBridgeHelper.cs | 4 ++- .../Eth/FeeHistory/FeeHistoryOracle.cs | 2 +- .../BlockProduction/PostMergeBlockProducer.cs | 2 +- .../Data/ExecutionPayload.cs | 8 +++++ .../ChainSpecBasedSpecProviderTests.cs | 4 --- .../ChainSpecStyle/ChainSpecLoader.cs | 4 +-- src/Nethermind/Nethermind.TxPool/TxPool.cs | 2 +- 18 files changed, 26 insertions(+), 79 deletions(-) diff --git a/src/Nethermind/Nethermind.Consensus/Messages/BlockErrorMessages.cs b/src/Nethermind/Nethermind.Consensus/Messages/BlockErrorMessages.cs index b40be7bc3aa..a128f98b247 100644 --- a/src/Nethermind/Nethermind.Consensus/Messages/BlockErrorMessages.cs +++ b/src/Nethermind/Nethermind.Consensus/Messages/BlockErrorMessages.cs @@ -95,10 +95,6 @@ public static string InvalidTxInBlock(int i) => public const string HeaderGasUsedMismatch = "HeaderGasUsedMismatch: Gas used in header does not match calculated."; - //Block's blob gas used in header is above the limit. - public static readonly string BlobGasUsedAboveBlockLimit = - $"BlockBlobGasExceeded: A block cannot have more than {Eip4844Constants.MaxBlobGasPerBlock} blob gas."; - //Block's excess blob gas in header is incorrect. public const string IncorrectExcessBlobGas = "HeaderExcessBlobGasMismatch: Excess blob gas in header does not match calculated."; diff --git a/src/Nethermind/Nethermind.Consensus/Messages/TxErrorMessages.cs b/src/Nethermind/Nethermind.Consensus/Messages/TxErrorMessages.cs index 8eab24494cf..a9379d02299 100644 --- a/src/Nethermind/Nethermind.Consensus/Messages/TxErrorMessages.cs +++ b/src/Nethermind/Nethermind.Consensus/Messages/TxErrorMessages.cs @@ -46,9 +46,6 @@ public static string InvalidTxChainId(ulong expected, ulong? actual) => public const string BlobTxMissingBlobVersionedHashes = "BlobTxMissingBlobVersionedHashes: Must be set."; - public static readonly string BlobTxGasLimitExceeded = - $"BlobTxGasLimitExceeded: Transaction exceeded {Eip4844Constants.MaxBlobGasPerTransaction}."; - public const string BlobTxMissingBlobs = "BlobTxMissingBlobs: Blob transaction must have blobs."; diff --git a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs index 6bf0215c54a..1185e4590cd 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs @@ -62,7 +62,7 @@ public IEnumerable GetTransactions(BlockHeader parent, long gasLimi int checkedTransactions = 0; int selectedTransactions = 0; - using ArrayPoolList selectedBlobTxs = new(_eip4844Config.GetMaxBlobsPerBlock()); + using ArrayPoolList selectedBlobTxs = new((int) parent.MaxBlobCount); SelectBlobTransactions(blobTransactions, parent, spec, selectedBlobTxs); @@ -128,20 +128,9 @@ private void SelectBlobTransactions(IEnumerable blobTransactions, B foreach (Transaction blobTx in blobTransactions) { - if (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; - } - checkedBlobTransactions++; ulong txBlobGas = (ulong)(blobTx.BlobVersionedHashes?.Length ?? 0) * _eip4844Config.GasPerBlob; - if (txBlobGas > _eip4844Config.MaxBlobGasPerBlock - blobGasCounter) - { - if (_logger.IsTrace) _logger.Trace($"Declining {blobTx.ToShortString()}, not enough blob space."); - continue; - } if (blobGasPrice.IsZero && !TryUpdateBlobGasPrice(blobTx, parent, spec, out blobGasPrice)) { @@ -188,7 +177,7 @@ private bool TryGetFullBlobTx(Transaction blobTx, [NotNullWhen(true)] out Transa private bool TryUpdateBlobGasPrice(Transaction lightBlobTx, BlockHeader parent, IReleaseSpec spec, out UInt256 blobGasPrice) { - 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."); diff --git a/src/Nethermind/Nethermind.Consensus/Validators/BlockValidator.cs b/src/Nethermind/Nethermind.Consensus/Validators/BlockValidator.cs index 5c75c77549c..a9717c6774f 100644 --- a/src/Nethermind/Nethermind.Consensus/Validators/BlockValidator.cs +++ b/src/Nethermind/Nethermind.Consensus/Validators/BlockValidator.cs @@ -405,13 +405,6 @@ private bool ValidateEip4844Fields(Block block, IReleaseSpec spec, out string? e ulong blobGasUsed = BlobGasCalculator.CalculateBlobGas(blobsInBlock); - if (blobGasUsed > Eip4844Constants.MaxBlobGasPerBlock) - { - error = BlockErrorMessages.BlobGasUsedAboveBlockLimit; - if (_logger.IsDebug) _logger.Debug($"{Invalid(block)} {error}."); - return false; - } - if (blobGasUsed != block.Header.BlobGasUsed) { error = BlockErrorMessages.HeaderBlobGasMismatch; diff --git a/src/Nethermind/Nethermind.Consensus/Validators/HeaderValidator.cs b/src/Nethermind/Nethermind.Consensus/Validators/HeaderValidator.cs index 368524c6bb1..2613148116e 100644 --- a/src/Nethermind/Nethermind.Consensus/Validators/HeaderValidator.cs +++ b/src/Nethermind/Nethermind.Consensus/Validators/HeaderValidator.cs @@ -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}."); diff --git a/src/Nethermind/Nethermind.Consensus/Validators/TxValidator.cs b/src/Nethermind/Nethermind.Consensus/Validators/TxValidator.cs index 5207135b109..74dfec97775 100644 --- a/src/Nethermind/Nethermind.Consensus/Validators/TxValidator.cs +++ b/src/Nethermind/Nethermind.Consensus/Validators/TxValidator.cs @@ -167,9 +167,7 @@ public ValidationResult IsWellFormed(Transaction transaction, IReleaseSpec relea private ValidationResult ValidateBlobFields(Transaction transaction) { int blobCount = transaction.BlobVersionedHashes!.Length; - ulong totalDataGas = BlobGasCalculator.CalculateBlobGas(blobCount); - return totalDataGas > Eip4844Constants.MaxBlobGasPerTransaction ? TxErrorMessages.BlobTxGasLimitExceeded - : blobCount < Eip4844Constants.MinBlobsPerTransaction ? TxErrorMessages.BlobTxMissingBlobs + return blobCount < Eip4844Constants.MinBlobsPerTransaction ? TxErrorMessages.BlobTxMissingBlobs : ValidateBlobVersionedHashes(); ValidationResult ValidateBlobVersionedHashes() diff --git a/src/Nethermind/Nethermind.Core/BlockHeader.cs b/src/Nethermind/Nethermind.Core/BlockHeader.cs index 1ddd19503b9..affee2fdb1e 100644 --- a/src/Nethermind/Nethermind.Core/BlockHeader.cs +++ b/src/Nethermind/Nethermind.Core/BlockHeader.cs @@ -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) { diff --git a/src/Nethermind/Nethermind.Core/Eip4844Constants.cs b/src/Nethermind/Nethermind.Core/Eip4844Constants.cs index e71de4ce77c..34a0047ddb3 100644 --- a/src/Nethermind/Nethermind.Core/Eip4844Constants.cs +++ b/src/Nethermind/Nethermind.Core/Eip4844Constants.cs @@ -18,24 +18,6 @@ public class Eip4844Constants /// Defaults to 131072. public const ulong GasPerBlob = 131072; - /// - /// Gets the MAX_BLOB_GAS_PER_BLOCK parameter. - /// - /// Defaults to 786432. - public static ulong MaxBlobGasPerBlock { get; private set; } = 786432; - - /// - /// Gets the MAX_BLOB_GAS_PER_BLOCK parameter. - /// - /// The same as . - public static ulong MaxBlobGasPerTransaction => MaxBlobGasPerBlock; - - /// - /// Gets the TARGET_BLOB_GAS_PER_BLOCK parameter. - /// - /// Defaults to 393216. - public static ulong TargetBlobGasPerBlock { get; private set; } = MaxBlobGasPerBlock / 2; - /// /// Gets the BLOB_GASPRICE_UPDATE_FRACTION parameter. /// @@ -52,22 +34,12 @@ public class Eip4844Constants // The parameter mutators are kept separate deliberately to ensure no accidental value changes. public static void OverrideIfAny( UInt256? blobGasPriceUpdateFraction = null, - ulong? maxBlobGasPerBlock = null, - UInt256? minBlobGasPrice = null, - ulong? targetBlobGasPerBlock = null) + UInt256? minBlobGasPrice = null) { if (blobGasPriceUpdateFraction.HasValue) BlobGasPriceUpdateFraction = blobGasPriceUpdateFraction.Value; - if (maxBlobGasPerBlock.HasValue) - MaxBlobGasPerBlock = maxBlobGasPerBlock.Value; - if (minBlobGasPrice.HasValue) MinBlobGasPrice = minBlobGasPrice.Value; - - if (targetBlobGasPerBlock.HasValue) - TargetBlobGasPerBlock = targetBlobGasPerBlock.Value; } - - public static int GetMaxBlobsPerBlock() => (int)(MaxBlobGasPerBlock / GasPerBlob); } diff --git a/src/Nethermind/Nethermind.Core/IEip4844Config.cs b/src/Nethermind/Nethermind.Core/IEip4844Config.cs index f2c76e77657..7db9bd6fe59 100644 --- a/src/Nethermind/Nethermind.Core/IEip4844Config.cs +++ b/src/Nethermind/Nethermind.Core/IEip4844Config.cs @@ -8,16 +8,12 @@ namespace Nethermind.Core; /// public interface IEip4844Config { - ulong MaxBlobGasPerBlock { get; } ulong GasPerBlob { get; } - int GetMaxBlobsPerBlock(); } public class ConstantEip4844Config : IEip4844Config { - public ulong MaxBlobGasPerBlock => Eip4844Constants.MaxBlobGasPerBlock; public ulong GasPerBlob => Eip4844Constants.GasPerBlob; - public int GetMaxBlobsPerBlock() => Eip4844Constants.GetMaxBlobsPerBlock(); static ConstantEip4844Config() => Instance = new ConstantEip4844Config(); private ConstantEip4844Config() { } diff --git a/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs b/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs index db129966dc7..6fba49924a2 100644 --- a/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs +++ b/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs @@ -88,7 +88,7 @@ static bool FakeExponentialOverflow(UInt256 factor, UInt256 num, UInt256 denomin return !FakeExponentialOverflow(Eip4844Constants.MinBlobGasPrice, excessBlobGas, Eip4844Constants.BlobGasPriceUpdateFraction, out blobGasPricePerUnit); } - public static ulong? CalculateExcessBlobGas(BlockHeader? parentBlockHeader, IReleaseSpec releaseSpec) + public static ulong? CalculateExcessBlobGas(BlockHeader? parentBlockHeader, IReleaseSpec releaseSpec, BlockHeader header) { if (!releaseSpec.IsEip4844Enabled) { @@ -102,8 +102,8 @@ static bool FakeExponentialOverflow(UInt256 factor, UInt256 num, UInt256 denomin ulong excessBlobGas = parentBlockHeader.ExcessBlobGas ?? 0; excessBlobGas += parentBlockHeader.BlobGasUsed ?? 0; - return excessBlobGas < Eip4844Constants.TargetBlobGasPerBlock + return excessBlobGas < header.TargetBlobCount * Eip4844Constants.GasPerBlob ? 0 - : (excessBlobGas - Eip4844Constants.TargetBlobGasPerBlock); + : (excessBlobGas - header.TargetBlobCount * Eip4844Constants.GasPerBlob); } } diff --git a/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs b/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs index b95f0646548..25906ec491e 100644 --- a/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs +++ b/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs @@ -288,7 +288,7 @@ private TransactionResult CallAndRestore( { callHeader.BlobGasUsed = BlobGasCalculator.CalculateBlobGas(transaction); callHeader.ExcessBlobGas = treatBlockHeaderAsParentBlock - ? BlobGasCalculator.CalculateExcessBlobGas(blockHeader, releaseSpec) + ? BlobGasCalculator.CalculateExcessBlobGas(blockHeader, releaseSpec, blockHeader) : blockHeader.ExcessBlobGas; } callHeader.MixHash = blockHeader.MixHash; diff --git a/src/Nethermind/Nethermind.Facade/Simulate/SimulateBridgeHelper.cs b/src/Nethermind/Nethermind.Facade/Simulate/SimulateBridgeHelper.cs index 59c97ea3c5c..d146efb14e8 100644 --- a/src/Nethermind/Nethermind.Facade/Simulate/SimulateBridgeHelper.cs +++ b/src/Nethermind/Nethermind.Facade/Simulate/SimulateBridgeHelper.cs @@ -288,6 +288,8 @@ private BlockHeader GetCallHeader(BlockStateCall b MixHash = parent.MixHash, IsPostMerge = parent.Difficulty == 0, }; + result.MaxBlobCount = parent.MaxBlobCount; + result.TargetBlobCount = parent.TargetBlobCount; result.Timestamp = parent.Timestamp + 1; result.BaseFeePerGas = block.BlockOverrides is { BaseFeePerGas: not null } ? block.BlockOverrides.BaseFeePerGas.Value @@ -295,7 +297,7 @@ private BlockHeader GetCallHeader(BlockStateCall b ? 0 : BaseFeeCalculator.Calculate(parent, spec); - result.ExcessBlobGas = spec.IsEip4844Enabled ? BlobGasCalculator.CalculateExcessBlobGas(parent, spec) : (ulong?)0; + result.ExcessBlobGas = spec.IsEip4844Enabled ? BlobGasCalculator.CalculateExcessBlobGas(parent, spec, result) : (ulong?)0; return result; } diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs index 6d319ab4f9c..3cf0b6de56c 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs @@ -115,7 +115,7 @@ BlockFeeHistorySearchInfo BlockFeeHistorySearchInfoFromBlock(Block b) BaseFeeCalculator.Calculate(b.Header, _specProvider.GetSpecFor1559(b.Number + 1)), blobGas == UInt256.MaxValue ? 0 : blobGas, b.GasUsed / (double)b.GasLimit, - (b.BlobGasUsed ?? 0) / (double)Eip4844Constants.MaxBlobGasPerBlock, + (b.BlobGasUsed ?? 0) / (double)block.Header.MaxBlobCount * Eip4844Constants.GasPerBlob, // TODO: which value should be used here? b.ParentHash, b.GasUsed, b.Transactions.Length, diff --git a/src/Nethermind/Nethermind.Merge.Plugin/BlockProduction/PostMergeBlockProducer.cs b/src/Nethermind/Nethermind.Merge.Plugin/BlockProduction/PostMergeBlockProducer.cs index 3c3e401de4d..127f56d62db 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/BlockProduction/PostMergeBlockProducer.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/BlockProduction/PostMergeBlockProducer.cs @@ -96,7 +96,7 @@ protected virtual void AmendHeader(BlockHeader blockHeader, BlockHeader parent) if (spec.IsEip4844Enabled) { blockHeader.BlobGasUsed = 0; - blockHeader.ExcessBlobGas = BlobGasCalculator.CalculateExcessBlobGas(parent, spec); + blockHeader.ExcessBlobGas = BlobGasCalculator.CalculateExcessBlobGas(parent, spec, blockHeader); } } } diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs index aeb2bda72fd..75ac85ae98c 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs @@ -111,6 +111,10 @@ public byte[][] Transactions [JsonIgnore] public Hash256? ParentBeaconBlockRoot { get; set; } + public ulong TargetBlobCount { get; set; } + + public ulong MaxBlobCount { get; set; } + public static ExecutionPayload Create(Block block) => Create(block); protected static TExecutionPayload Create(Block block) where TExecutionPayload : ExecutionPayload, new() @@ -131,6 +135,8 @@ public byte[][] Transactions Timestamp = block.Timestamp, BaseFeePerGas = block.BaseFeePerGas, Withdrawals = block.Withdrawals, + TargetBlobCount = block.Header.TargetBlobCount, + MaxBlobCount = block.Header.MaxBlobCount, }; executionPayload.SetTransactions(block.Transactions); return executionPayload; @@ -170,6 +176,8 @@ public virtual bool TryGetBlock([NotNullWhen(true)] out Block? block, UInt256? t TotalDifficulty = totalDifficulty, TxRoot = TxTrie.CalculateRoot(transactions), WithdrawalsRoot = Withdrawals is null ? null : new WithdrawalTrie(Withdrawals).RootHash, + TargetBlobCount = TargetBlobCount, + MaxBlobCount = MaxBlobCount }; block = new(header, transactions, Array.Empty(), Withdrawals); diff --git a/src/Nethermind/Nethermind.Specs.Test/ChainSpecStyle/ChainSpecBasedSpecProviderTests.cs b/src/Nethermind/Nethermind.Specs.Test/ChainSpecStyle/ChainSpecBasedSpecProviderTests.cs index 734b84f298f..4c941716179 100644 --- a/src/Nethermind/Nethermind.Specs.Test/ChainSpecStyle/ChainSpecBasedSpecProviderTests.cs +++ b/src/Nethermind/Nethermind.Specs.Test/ChainSpecStyle/ChainSpecBasedSpecProviderTests.cs @@ -271,9 +271,7 @@ private static void VerifyGnosisCancunSpecifics() Assert.Multiple(() => { Assert.That(Eip4844Constants.BlobGasPriceUpdateFraction, Is.EqualTo((UInt256)1112826)); - Assert.That(Eip4844Constants.MaxBlobGasPerBlock, Is.EqualTo(262144)); Assert.That(Eip4844Constants.MinBlobGasPrice, Is.EqualTo(1.GWei())); - Assert.That(Eip4844Constants.TargetBlobGasPerBlock, Is.EqualTo(131072)); }); } @@ -430,9 +428,7 @@ private static void CompareSpecs(IReleaseSpec expectedSpec, IReleaseSpec actualS // Skip EIP-4844 parameter validation .Where(p => p.Name != nameof(Eip4844Constants.BlobGasPriceUpdateFraction)) - .Where(p => p.Name != nameof(Eip4844Constants.MaxBlobGasPerBlock)) .Where(p => p.Name != nameof(Eip4844Constants.MinBlobGasPrice)) - .Where(p => p.Name != nameof(Eip4844Constants.TargetBlobGasPerBlock)) // handle gnosis specific exceptions .Where(p => !isGnosis || p.Name != nameof(IReleaseSpec.MaxCodeSize)) diff --git a/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecLoader.cs b/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecLoader.cs index d56d62f80c5..cff079b3355 100644 --- a/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecLoader.cs +++ b/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecLoader.cs @@ -182,9 +182,7 @@ bool GetForInnerPathExistence(KeyValuePair o) => Eip4844Constants.OverrideIfAny( chainSpec.Parameters.Eip4844BlobGasPriceUpdateFraction, - chainSpec.Parameters.Eip4844MaxBlobGasPerBlock, - chainSpec.Parameters.Eip4844MinBlobGasPrice, - chainSpec.Parameters.Eip4844TargetBlobGasPerBlock); + chainSpec.Parameters.Eip4844MinBlobGasPrice); } private static void ValidateParams(ChainSpecParamsJson parameters) diff --git a/src/Nethermind/Nethermind.TxPool/TxPool.cs b/src/Nethermind/Nethermind.TxPool/TxPool.cs index b79fce3ce91..6a6d3a4c03e 100644 --- a/src/Nethermind/Nethermind.TxPool/TxPool.cs +++ b/src/Nethermind/Nethermind.TxPool/TxPool.cs @@ -300,7 +300,7 @@ private void ReAddReorganisedTransactions(Block? previousBlock) private void RemoveProcessedTransactions(Block block) { Transaction[] blockTransactions = block.Transactions; - using ArrayPoolList blobTxsToSave = new(Eip4844Constants.GetMaxBlobsPerBlock()); + using ArrayPoolList blobTxsToSave = new((int) block.Header.MaxBlobCount); // TODO: MaxBlobCount is used only here? long discoveredForPendingTxs = 0; long discoveredForHashCache = 0; long eip1559Txs = 0; From eca6690822a797addbd5975a3767f0034ff36fc4 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Tue, 1 Oct 2024 17:02:24 +0600 Subject: [PATCH 02/68] fix HeaderDecoder, restore Eip4844 changes, Add Eip7742 --- .../Ethereum.Test.Base/GeneralTestBase.cs | 2 +- .../TestEip4844Config.cs | 2 +- .../Messages/BlockErrorMessages.cs | 4 +++ .../Messages/TxErrorMessages.cs | 3 ++ .../Producers/TxPoolTxSource.cs | 13 +++++++- .../Validators/BlockValidator.cs | 7 +++++ .../Validators/TxValidator.cs | 10 +++++-- src/Nethermind/Nethermind.Core/BlockHeader.cs | 4 +-- .../Nethermind.Core/Eip4844Constants.cs | 30 ++++++++++++++++++- .../Nethermind.Core/IEip4844Config.cs | 4 +++ .../Nethermind.Core/Specs/IReleaseSpec.cs | 2 ++ .../Specs/ReleaseSpecDecorator.cs | 1 + .../BlobGasCalculatorTests.cs | 2 +- .../Nethermind.Evm/BlobGasCalculator.cs | 10 +++++-- .../Eth/FeeHistory/FeeHistoryOracle.cs | 5 +++- .../Data/ExecutionPayload.cs | 4 +-- .../HeaderDecoder.cs | 18 ++++++++++- .../OverridableReleaseSpec.cs | 1 + .../ChainSpecStyle/ChainSpecLoader.cs | 4 ++- .../Nethermind.Specs/ReleaseSpec.cs | 1 + src/Nethermind/Nethermind.TxPool/TxPool.cs | 2 +- 21 files changed, 112 insertions(+), 17 deletions(-) diff --git a/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs b/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs index 99faa058359..e8717220c23 100644 --- a/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs +++ b/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs @@ -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; diff --git a/src/Nethermind/Nethermind.Blockchain.Test/TestEip4844Config.cs b/src/Nethermind/Nethermind.Blockchain.Test/TestEip4844Config.cs index 5a71b47deaf..340b163c004 100644 --- a/src/Nethermind/Nethermind.Blockchain.Test/TestEip4844Config.cs +++ b/src/Nethermind/Nethermind.Blockchain.Test/TestEip4844Config.cs @@ -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; } diff --git a/src/Nethermind/Nethermind.Consensus/Messages/BlockErrorMessages.cs b/src/Nethermind/Nethermind.Consensus/Messages/BlockErrorMessages.cs index a128f98b247..b40be7bc3aa 100644 --- a/src/Nethermind/Nethermind.Consensus/Messages/BlockErrorMessages.cs +++ b/src/Nethermind/Nethermind.Consensus/Messages/BlockErrorMessages.cs @@ -95,6 +95,10 @@ public static string InvalidTxInBlock(int i) => public const string HeaderGasUsedMismatch = "HeaderGasUsedMismatch: Gas used in header does not match calculated."; + //Block's blob gas used in header is above the limit. + public static readonly string BlobGasUsedAboveBlockLimit = + $"BlockBlobGasExceeded: A block cannot have more than {Eip4844Constants.MaxBlobGasPerBlock} blob gas."; + //Block's excess blob gas in header is incorrect. public const string IncorrectExcessBlobGas = "HeaderExcessBlobGasMismatch: Excess blob gas in header does not match calculated."; diff --git a/src/Nethermind/Nethermind.Consensus/Messages/TxErrorMessages.cs b/src/Nethermind/Nethermind.Consensus/Messages/TxErrorMessages.cs index a9379d02299..8eab24494cf 100644 --- a/src/Nethermind/Nethermind.Consensus/Messages/TxErrorMessages.cs +++ b/src/Nethermind/Nethermind.Consensus/Messages/TxErrorMessages.cs @@ -46,6 +46,9 @@ public static string InvalidTxChainId(ulong expected, ulong? actual) => public const string BlobTxMissingBlobVersionedHashes = "BlobTxMissingBlobVersionedHashes: Must be set."; + public static readonly string BlobTxGasLimitExceeded = + $"BlobTxGasLimitExceeded: Transaction exceeded {Eip4844Constants.MaxBlobGasPerTransaction}."; + public const string BlobTxMissingBlobs = "BlobTxMissingBlobs: Blob transaction must have blobs."; diff --git a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs index 1185e4590cd..a3859cc8818 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs @@ -62,7 +62,7 @@ public IEnumerable GetTransactions(BlockHeader parent, long gasLimi int checkedTransactions = 0; int selectedTransactions = 0; - using ArrayPoolList selectedBlobTxs = new((int) parent.MaxBlobCount); + using ArrayPoolList selectedBlobTxs = new((int)(parent.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock())); SelectBlobTransactions(blobTransactions, parent, spec, selectedBlobTxs); @@ -128,9 +128,20 @@ private void SelectBlobTransactions(IEnumerable blobTransactions, B foreach (Transaction blobTx in blobTransactions) { + 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; + } + checkedBlobTransactions++; ulong txBlobGas = (ulong)(blobTx.BlobVersionedHashes?.Length ?? 0) * _eip4844Config.GasPerBlob; + if (!spec.IsEip7742Enabled && txBlobGas > _eip4844Config.MaxBlobGasPerBlock - blobGasCounter) + { + if (_logger.IsTrace) _logger.Trace($"Declining {blobTx.ToShortString()}, not enough blob space."); + continue; + } if (blobGasPrice.IsZero && !TryUpdateBlobGasPrice(blobTx, parent, spec, out blobGasPrice)) { diff --git a/src/Nethermind/Nethermind.Consensus/Validators/BlockValidator.cs b/src/Nethermind/Nethermind.Consensus/Validators/BlockValidator.cs index a9717c6774f..d82fe6affe5 100644 --- a/src/Nethermind/Nethermind.Consensus/Validators/BlockValidator.cs +++ b/src/Nethermind/Nethermind.Consensus/Validators/BlockValidator.cs @@ -405,6 +405,13 @@ private bool ValidateEip4844Fields(Block block, IReleaseSpec spec, out string? e ulong blobGasUsed = BlobGasCalculator.CalculateBlobGas(blobsInBlock); + if (!spec.IsEip7742Enabled && blobGasUsed > Eip4844Constants.MaxBlobGasPerBlock) + { + error = BlockErrorMessages.BlobGasUsedAboveBlockLimit; + if (_logger.IsDebug) _logger.Debug($"{Invalid(block)} {error}."); + return false; + } + if (blobGasUsed != block.Header.BlobGasUsed) { error = BlockErrorMessages.HeaderBlobGasMismatch; diff --git a/src/Nethermind/Nethermind.Consensus/Validators/TxValidator.cs b/src/Nethermind/Nethermind.Consensus/Validators/TxValidator.cs index 74dfec97775..3c4f01abb59 100644 --- a/src/Nethermind/Nethermind.Consensus/Validators/TxValidator.cs +++ b/src/Nethermind/Nethermind.Consensus/Validators/TxValidator.cs @@ -161,12 +161,18 @@ 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; + if (!releaseSpec.IsEip7742Enabled + && BlobGasCalculator.CalculateBlobGas(blobCount) > Eip4844Constants.MaxBlobGasPerTransaction) + { + return TxErrorMessages.BlobTxGasLimitExceeded; + } + return blobCount < Eip4844Constants.MinBlobsPerTransaction ? TxErrorMessages.BlobTxMissingBlobs : ValidateBlobVersionedHashes(); diff --git a/src/Nethermind/Nethermind.Core/BlockHeader.cs b/src/Nethermind/Nethermind.Core/BlockHeader.cs index affee2fdb1e..ef1c799f6f2 100644 --- a/src/Nethermind/Nethermind.Core/BlockHeader.cs +++ b/src/Nethermind/Nethermind.Core/BlockHeader.cs @@ -84,8 +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 ulong? TargetBlobCount { get; set; } + public ulong? MaxBlobCount { get; set; } public string ToString(string indent) { diff --git a/src/Nethermind/Nethermind.Core/Eip4844Constants.cs b/src/Nethermind/Nethermind.Core/Eip4844Constants.cs index 34a0047ddb3..41f85186528 100644 --- a/src/Nethermind/Nethermind.Core/Eip4844Constants.cs +++ b/src/Nethermind/Nethermind.Core/Eip4844Constants.cs @@ -18,6 +18,24 @@ public class Eip4844Constants /// Defaults to 131072. public const ulong GasPerBlob = 131072; + /// + /// Gets the MAX_BLOB_GAS_PER_BLOCK parameter. + /// + /// Defaults to 786432. + public static ulong MaxBlobGasPerBlock { get; private set; } = 786432; + + /// + /// Gets the MAX_BLOB_GAS_PER_BLOCK parameter. + /// + /// The same as . + public static ulong MaxBlobGasPerTransaction => MaxBlobGasPerBlock; + + /// + /// Gets the TARGET_BLOB_GAS_PER_BLOCK parameter. + /// + /// Defaults to 393216. + public static ulong TargetBlobGasPerBlock { get; private set; } = MaxBlobGasPerBlock / 2; + /// /// Gets the BLOB_GASPRICE_UPDATE_FRACTION parameter. /// @@ -34,12 +52,22 @@ public class Eip4844Constants // The parameter mutators are kept separate deliberately to ensure no accidental value changes. public static void OverrideIfAny( UInt256? blobGasPriceUpdateFraction = null, - UInt256? minBlobGasPrice = null) + ulong? maxBlobGasPerBlock = null, + UInt256? minBlobGasPrice = null, + ulong? targetBlobGasPerBlock = null) { if (blobGasPriceUpdateFraction.HasValue) BlobGasPriceUpdateFraction = blobGasPriceUpdateFraction.Value; + if (maxBlobGasPerBlock.HasValue) + MaxBlobGasPerBlock = maxBlobGasPerBlock.Value; + if (minBlobGasPrice.HasValue) MinBlobGasPrice = minBlobGasPrice.Value; + + if (targetBlobGasPerBlock.HasValue) + TargetBlobGasPerBlock = targetBlobGasPerBlock.Value; } + + public static ulong GetMaxBlobsPerBlock() => MaxBlobGasPerBlock / GasPerBlob; } diff --git a/src/Nethermind/Nethermind.Core/IEip4844Config.cs b/src/Nethermind/Nethermind.Core/IEip4844Config.cs index 7db9bd6fe59..08c31abc062 100644 --- a/src/Nethermind/Nethermind.Core/IEip4844Config.cs +++ b/src/Nethermind/Nethermind.Core/IEip4844Config.cs @@ -8,12 +8,16 @@ namespace Nethermind.Core; /// public interface IEip4844Config { + ulong MaxBlobGasPerBlock { get; } ulong GasPerBlob { get; } + ulong GetMaxBlobsPerBlock(); } public class ConstantEip4844Config : IEip4844Config { + public ulong MaxBlobGasPerBlock => Eip4844Constants.MaxBlobGasPerBlock; public ulong GasPerBlob => Eip4844Constants.GasPerBlob; + public ulong GetMaxBlobsPerBlock() => Eip4844Constants.GetMaxBlobsPerBlock(); static ConstantEip4844Config() => Instance = new ConstantEip4844Config(); private ConstantEip4844Config() { } diff --git a/src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs b/src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs index dcd68614ec8..c86303159a5 100644 --- a/src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs +++ b/src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs @@ -303,6 +303,8 @@ public interface IReleaseSpec : IEip1559Spec, IReceiptSpec /// bool IsRip7212Enabled { get; } + bool IsEip7742Enabled { get; } + /// OP Granite bool IsOpGraniteEnabled { get; } diff --git a/src/Nethermind/Nethermind.Core/Specs/ReleaseSpecDecorator.cs b/src/Nethermind/Nethermind.Core/Specs/ReleaseSpecDecorator.cs index 86041606fc4..ba0f8fc6d34 100644 --- a/src/Nethermind/Nethermind.Core/Specs/ReleaseSpecDecorator.cs +++ b/src/Nethermind/Nethermind.Core/Specs/ReleaseSpecDecorator.cs @@ -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; diff --git a/src/Nethermind/Nethermind.Evm.Test/BlobGasCalculatorTests.cs b/src/Nethermind/Nethermind.Evm.Test/BlobGasCalculatorTests.cs index bb3ea55c503..41d53956d26 100644 --- a/src/Nethermind/Nethermind.Evm.Test/BlobGasCalculatorTests.cs +++ b/src/Nethermind/Nethermind.Evm.Test/BlobGasCalculatorTests.cs @@ -23,7 +23,7 @@ void Test(IReleaseSpec spec, bool areBlobsEnabled) .WithBlobGasUsed(BlobGasCalculator.CalculateBlobGas(testCase.parentBlobsCount)) .WithExcessBlobGas(testCase.parentExcessBlobGas).TestObject; - Assert.That(BlobGasCalculator.CalculateExcessBlobGas(parentHeader, spec), Is.EqualTo(areBlobsEnabled ? testCase.expectedExcessBlobGas : null)); + Assert.That(BlobGasCalculator.CalculateExcessBlobGas(parentHeader, spec, parentHeader), Is.EqualTo(areBlobsEnabled ? testCase.expectedExcessBlobGas : null)); } Test(Homestead.Instance, false); diff --git a/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs b/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs index 6fba49924a2..b02d0b536ab 100644 --- a/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs +++ b/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited // SPDX-License-Identifier: LGPL-3.0-only +using System.IO; using Nethermind.Core; using Nethermind.Core.Specs; using Nethermind.Int256; @@ -102,8 +103,13 @@ static bool FakeExponentialOverflow(UInt256 factor, UInt256 num, UInt256 denomin ulong excessBlobGas = parentBlockHeader.ExcessBlobGas ?? 0; excessBlobGas += parentBlockHeader.BlobGasUsed ?? 0; - return excessBlobGas < header.TargetBlobCount * Eip4844Constants.GasPerBlob + var targetBlobCount = releaseSpec.IsEip7742Enabled + ? header.TargetBlobCount * Eip4844Constants.GasPerBlob + ?? throw new InvalidDataException("header is missing target blob count") + : Eip4844Constants.TargetBlobGasPerBlock; + + return excessBlobGas < targetBlobCount ? 0 - : (excessBlobGas - header.TargetBlobCount * Eip4844Constants.GasPerBlob); + : excessBlobGas - targetBlobCount; } } diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs index 3cf0b6de56c..66db1369624 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs @@ -109,13 +109,16 @@ private readonly record struct BlockFeeHistorySearchInfo( BlockFeeHistorySearchInfo BlockFeeHistorySearchInfoFromBlock(Block b) { BlobGasCalculator.TryCalculateBlobGasPricePerUnit(b.Header, out UInt256 blobGas); + + var maxBlobGasPerBlock = (double)(block.Header.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock()) * Eip4844Constants.GasPerBlob; + return new( b.Number, b.BaseFeePerGas, BaseFeeCalculator.Calculate(b.Header, _specProvider.GetSpecFor1559(b.Number + 1)), blobGas == UInt256.MaxValue ? 0 : blobGas, b.GasUsed / (double)b.GasLimit, - (b.BlobGasUsed ?? 0) / (double)block.Header.MaxBlobCount * Eip4844Constants.GasPerBlob, // TODO: which value should be used here? + (b.BlobGasUsed ?? 0) / maxBlobGasPerBlock, b.ParentHash, b.GasUsed, b.Transactions.Length, diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs index 75ac85ae98c..30a71ee469b 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs @@ -111,9 +111,9 @@ public byte[][] Transactions [JsonIgnore] public Hash256? ParentBeaconBlockRoot { get; set; } - public ulong TargetBlobCount { get; set; } + public ulong? TargetBlobCount { get; set; } - public ulong MaxBlobCount { get; set; } + public ulong? MaxBlobCount { get; set; } public static ExecutionPayload Create(Block block) => Create(block); diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs index 98dce2b0610..e38153bef27 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs @@ -94,6 +94,11 @@ public class HeaderDecoder : IRlpValueDecoder, IRlpStreamDecoder= 6 && decoderContext.Position != headerCheck) + { + blockHeader.TargetBlobCount = decoderContext.DecodeULong(); + } } @@ -186,6 +191,11 @@ public class HeaderDecoder : IRlpValueDecoder, IRlpStreamDecoder= 6 && rlpStream.Position != headerCheck) + { + blockHeader.TargetBlobCount = rlpStream.DecodeULong(); + } } if ((rlpBehaviors & RlpBehaviors.AllowExtraBytes) != RlpBehaviors.AllowExtraBytes) @@ -260,6 +270,11 @@ public void Encode(RlpStream rlpStream, BlockHeader? header, RlpBehaviors rlpBeh { rlpStream.Encode(header.RequestsRoot); } + + if (header.TargetBlobCount is not null) + { + rlpStream.Encode(header.TargetBlobCount.GetValueOrDefault()); + } } public Rlp Encode(BlockHeader? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) @@ -302,7 +317,8 @@ private static int GetContentLength(BlockHeader? item, RlpBehaviors rlpBehaviors + (item.ParentBeaconBlockRoot is null ? 0 : Rlp.LengthOfKeccakRlp) + (item.BlobGasUsed is null ? 0 : Rlp.LengthOf(item.BlobGasUsed.Value)) + (item.ExcessBlobGas is null ? 0 : Rlp.LengthOf(item.ExcessBlobGas.Value)) - + (item.RequestsRoot is null ? 0 : Rlp.LengthOf(item.RequestsRoot)); + + (item.RequestsRoot is null ? 0 : Rlp.LengthOf(item.RequestsRoot)) + + Rlp.LengthOf(item.TargetBlobCount); if (notForSealing) { diff --git a/src/Nethermind/Nethermind.Specs.Test/OverridableReleaseSpec.cs b/src/Nethermind/Nethermind.Specs.Test/OverridableReleaseSpec.cs index 39c6d3c977f..419fa08699b 100644 --- a/src/Nethermind/Nethermind.Specs.Test/OverridableReleaseSpec.cs +++ b/src/Nethermind/Nethermind.Specs.Test/OverridableReleaseSpec.cs @@ -112,6 +112,7 @@ public OverridableReleaseSpec(IReleaseSpec spec) public bool IsEip3541Enabled => _spec.IsEip3541Enabled; public bool IsEip4844Enabled => _spec.IsEip4844Enabled; public bool IsRip7212Enabled => _spec.IsRip7212Enabled; + public bool IsEip7742Enabled => _spec.IsEip7742Enabled; public bool IsOpGraniteEnabled => _spec.IsOpGraniteEnabled; public bool IsEip3607Enabled { get; set; } diff --git a/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecLoader.cs b/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecLoader.cs index cff079b3355..d56d62f80c5 100644 --- a/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecLoader.cs +++ b/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecLoader.cs @@ -182,7 +182,9 @@ bool GetForInnerPathExistence(KeyValuePair o) => Eip4844Constants.OverrideIfAny( chainSpec.Parameters.Eip4844BlobGasPriceUpdateFraction, - chainSpec.Parameters.Eip4844MinBlobGasPrice); + chainSpec.Parameters.Eip4844MaxBlobGasPerBlock, + chainSpec.Parameters.Eip4844MinBlobGasPrice, + chainSpec.Parameters.Eip4844TargetBlobGasPerBlock); } private static void ValidateParams(ChainSpecParamsJson parameters) diff --git a/src/Nethermind/Nethermind.Specs/ReleaseSpec.cs b/src/Nethermind/Nethermind.Specs/ReleaseSpec.cs index de10ff6190b..8e8e7529dc1 100644 --- a/src/Nethermind/Nethermind.Specs/ReleaseSpec.cs +++ b/src/Nethermind/Nethermind.Specs/ReleaseSpec.cs @@ -82,6 +82,7 @@ public bool IsEip1559Enabled public bool IsEip4895Enabled { get; set; } public bool IsEip4844Enabled { get; set; } public bool IsRip7212Enabled { get; set; } + public bool IsEip7742Enabled { get; set; } public bool IsOpGraniteEnabled { get; set; } public bool IsEip5656Enabled { get; set; } public bool IsEip6780Enabled { get; set; } diff --git a/src/Nethermind/Nethermind.TxPool/TxPool.cs b/src/Nethermind/Nethermind.TxPool/TxPool.cs index 6a6d3a4c03e..b9e835ac7a2 100644 --- a/src/Nethermind/Nethermind.TxPool/TxPool.cs +++ b/src/Nethermind/Nethermind.TxPool/TxPool.cs @@ -300,7 +300,7 @@ private void ReAddReorganisedTransactions(Block? previousBlock) private void RemoveProcessedTransactions(Block block) { Transaction[] blockTransactions = block.Transactions; - using ArrayPoolList blobTxsToSave = new((int) block.Header.MaxBlobCount); // TODO: MaxBlobCount is used only here? + using ArrayPoolList blobTxsToSave = new((int)(block.Header.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock())); long discoveredForPendingTxs = 0; long discoveredForHashCache = 0; long eip1559Txs = 0; From 9be8a53ce54f4b55bc7ad35a288e1b0d4bdc930f Mon Sep 17 00:00:00 2001 From: yerke26 Date: Tue, 1 Oct 2024 23:38:21 +0600 Subject: [PATCH 03/68] fix HeaderDecoder --- .../Nethermind.Serialization.Rlp/HeaderDecoder.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs index e38153bef27..dbeab5c4489 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs @@ -313,12 +313,15 @@ private static int GetContentLength(BlockHeader? item, RlpBehaviors rlpBehaviors + Rlp.LengthOf(item.Timestamp) + Rlp.LengthOf(item.ExtraData) + (item.BaseFeePerGas.IsZero ? 0 : Rlp.LengthOf(item.BaseFeePerGas)) - + (item.WithdrawalsRoot is null && item.BlobGasUsed is null && item.ExcessBlobGas is null ? 0 : Rlp.LengthOfKeccakRlp) + + (item.WithdrawalsRoot is null && item.BlobGasUsed is null && + item.ExcessBlobGas is null + ? 0 + : Rlp.LengthOfKeccakRlp) + (item.ParentBeaconBlockRoot is null ? 0 : Rlp.LengthOfKeccakRlp) + (item.BlobGasUsed is null ? 0 : Rlp.LengthOf(item.BlobGasUsed.Value)) + (item.ExcessBlobGas is null ? 0 : Rlp.LengthOf(item.ExcessBlobGas.Value)) + (item.RequestsRoot is null ? 0 : Rlp.LengthOf(item.RequestsRoot)) - + Rlp.LengthOf(item.TargetBlobCount); + + (item.TargetBlobCount is null ? 0 : Rlp.LengthOf(item.TargetBlobCount)); if (notForSealing) { From c592412d8c6ac9ce1545869289acb6c41e6d1c3d Mon Sep 17 00:00:00 2001 From: yerke26 Date: Wed, 2 Oct 2024 00:27:31 +0600 Subject: [PATCH 04/68] move new params from ExecutionPayload to ExecutionPayloadV4 --- src/Nethermind/Nethermind.Core/Block.cs | 3 +++ .../Eth/FeeHistory/FeeHistoryOracle.cs | 2 +- .../Data/ExecutionPayload.cs | 20 +++++++++++-------- .../Data/ExecutionPayloadV4.cs | 19 +++++++++++++++--- src/Nethermind/Nethermind.TxPool/TxPool.cs | 2 +- 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/Nethermind/Nethermind.Core/Block.cs b/src/Nethermind/Nethermind.Core/Block.cs index b5d5049cccb..2cd993bfa18 100644 --- a/src/Nethermind/Nethermind.Core/Block.cs +++ b/src/Nethermind/Nethermind.Core/Block.cs @@ -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? AccountChanges { get; set; } [JsonIgnore] diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs index 66db1369624..239497001ab 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs @@ -110,7 +110,7 @@ BlockFeeHistorySearchInfo BlockFeeHistorySearchInfoFromBlock(Block b) { BlobGasCalculator.TryCalculateBlobGasPricePerUnit(b.Header, out UInt256 blobGas); - var maxBlobGasPerBlock = (double)(block.Header.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock()) * Eip4844Constants.GasPerBlob; + var maxBlobGasPerBlock = (double)(block.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock()) * Eip4844Constants.GasPerBlob; return new( b.Number, diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs index 30a71ee469b..e93e3c62139 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs @@ -111,9 +111,17 @@ public byte[][] Transactions [JsonIgnore] public Hash256? ParentBeaconBlockRoot { get; set; } - public ulong? TargetBlobCount { get; set; } + /// + /// Gets or sets as defined in + /// EIP-7742. + /// + public virtual ulong? TargetBlobCount { get; set; } - public ulong? MaxBlobCount { get; set; } + /// + /// Gets or sets as defined in + /// EIP-7742. + /// + public virtual ulong? MaxBlobCount { get; set; } public static ExecutionPayload Create(Block block) => Create(block); @@ -134,9 +142,7 @@ public byte[][] Transactions ExtraData = block.ExtraData!, Timestamp = block.Timestamp, BaseFeePerGas = block.BaseFeePerGas, - Withdrawals = block.Withdrawals, - TargetBlobCount = block.Header.TargetBlobCount, - MaxBlobCount = block.Header.MaxBlobCount, + Withdrawals = block.Withdrawals }; executionPayload.SetTransactions(block.Transactions); return executionPayload; @@ -175,9 +181,7 @@ public virtual bool TryGetBlock([NotNullWhen(true)] out Block? block, UInt256? t IsPostMerge = true, TotalDifficulty = totalDifficulty, TxRoot = TxTrie.CalculateRoot(transactions), - WithdrawalsRoot = Withdrawals is null ? null : new WithdrawalTrie(Withdrawals).RootHash, - TargetBlobCount = TargetBlobCount, - MaxBlobCount = MaxBlobCount + WithdrawalsRoot = Withdrawals is null ? null : new WithdrawalTrie(Withdrawals).RootHash }; block = new(header, transactions, Array.Empty(), Withdrawals); diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs index cef9b04c3fb..01b94700534 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs @@ -26,6 +26,9 @@ public class ExecutionPayloadV4 : ExecutionPayloadV3, IExecutionPayloadFactory(block); ConsensusRequest[]? blockRequests = block.Requests; (executionPayload.DepositRequests, executionPayload.WithdrawalRequests) = blockRequests?.SplitRequests() ?? ([], []); + + executionPayload.TargetBlobCount = block.TargetBlobCount; + executionPayload.MaxBlobCount = block.MaxBlobCount; return executionPayload; } @@ -64,6 +67,9 @@ public override bool TryGetBlock([NotNullWhen(true)] out Block? block, UInt256? block.Header.RequestsRoot = Keccak.EmptyTreeHash; } + block.Header.TargetBlobCount = TargetBlobCount; + block.Header.MaxBlobCount = MaxBlobCount; + return true; } @@ -79,9 +85,16 @@ public override bool ValidateFork(ISpecProvider specProvider) => public sealed override Deposit[]? DepositRequests { get; set; } /// - /// Gets or sets as defined in - /// EIP-7002. + /// Gets or sets as defined in + /// EIP-7742. + /// + [JsonRequired] + public sealed override ulong? TargetBlobCount { get; set; } + + /// + /// Gets or sets as defined in + /// EIP-7742. /// [JsonRequired] - public sealed override WithdrawalRequest[]? WithdrawalRequests { get; set; } + public sealed override ulong? MaxBlobCount { get; set; } } diff --git a/src/Nethermind/Nethermind.TxPool/TxPool.cs b/src/Nethermind/Nethermind.TxPool/TxPool.cs index b9e835ac7a2..ef631e050c8 100644 --- a/src/Nethermind/Nethermind.TxPool/TxPool.cs +++ b/src/Nethermind/Nethermind.TxPool/TxPool.cs @@ -300,7 +300,7 @@ private void ReAddReorganisedTransactions(Block? previousBlock) private void RemoveProcessedTransactions(Block block) { Transaction[] blockTransactions = block.Transactions; - using ArrayPoolList blobTxsToSave = new((int)(block.Header.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock())); + using ArrayPoolList blobTxsToSave = new((int)(block.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock())); long discoveredForPendingTxs = 0; long discoveredForHashCache = 0; long eip1559Txs = 0; From f6ae01cecef3a2a393905d5d99510997ea55ddda Mon Sep 17 00:00:00 2001 From: yerke26 Date: Wed, 2 Oct 2024 00:30:50 +0600 Subject: [PATCH 05/68] revert minor changes --- .../Nethermind.Merge.Plugin/Data/ExecutionPayload.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs index e93e3c62139..34f560e7e13 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs @@ -142,7 +142,7 @@ public byte[][] Transactions ExtraData = block.ExtraData!, Timestamp = block.Timestamp, BaseFeePerGas = block.BaseFeePerGas, - Withdrawals = block.Withdrawals + Withdrawals = block.Withdrawals, }; executionPayload.SetTransactions(block.Transactions); return executionPayload; @@ -181,7 +181,7 @@ public virtual bool TryGetBlock([NotNullWhen(true)] out Block? block, UInt256? t IsPostMerge = true, TotalDifficulty = totalDifficulty, TxRoot = TxTrie.CalculateRoot(transactions), - WithdrawalsRoot = Withdrawals is null ? null : new WithdrawalTrie(Withdrawals).RootHash + WithdrawalsRoot = Withdrawals is null ? null : new WithdrawalTrie(Withdrawals).RootHash, }; block = new(header, transactions, Array.Empty(), Withdrawals); From f8030971a047749ea0b3d63e3117044dacf2b10a Mon Sep 17 00:00:00 2001 From: yerke26 Date: Wed, 2 Oct 2024 00:52:00 +0600 Subject: [PATCH 06/68] added new params to PayloadAttributes --- .../Producers/BlockProducerBase.cs | 4 ++- .../Producers/PayloadAttributes.cs | 28 +++++++++++++++++++ .../Handlers/ForkchoiceUpdatedHandler.cs | 4 ++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerBase.cs b/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerBase.cs index d11d0190576..3d729c6593a 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerBase.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerBase.cs @@ -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); diff --git a/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs b/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs index d565349875e..319170e5376 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs @@ -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); @@ -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(); @@ -111,6 +125,18 @@ protected virtual int WritePayloadIdMembers(BlockHeader parentHeader, Span 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; } @@ -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 @@ -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 diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Handlers/ForkchoiceUpdatedHandler.cs b/src/Nethermind/Nethermind.Merge.Plugin/Handlers/ForkchoiceUpdatedHandler.cs index f5d95a00ac4..637b225074e 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Handlers/ForkchoiceUpdatedHandler.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Handlers/ForkchoiceUpdatedHandler.cs @@ -283,7 +283,9 @@ private ResultWrapper StartBuildingPayload(Block newH ParentBeaconBlockRoot = newHeadBlock.ParentHash, // it doesn't matter PrevRandao = newHeadBlock.ParentHash ?? Keccak.Zero, // it doesn't matter Withdrawals = Array.Empty(), - SuggestedFeeRecipient = Address.Zero + SuggestedFeeRecipient = Address.Zero, + TargetBlobCount = newHeadBlock.TargetBlobCount, + MaxBlobCount = newHeadBlock.MaxBlobCount, }; } From 7043124966cad02fddc305c94cc09e2101ea0dcc Mon Sep 17 00:00:00 2001 From: yerke26 Date: Wed, 2 Oct 2024 01:06:46 +0600 Subject: [PATCH 07/68] fix tests --- .../Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs index 01b94700534..61466bf2335 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs @@ -88,13 +88,13 @@ public override bool ValidateFork(ISpecProvider specProvider) => /// Gets or sets as defined in /// EIP-7742. /// - [JsonRequired] + // [JsonRequired] TODO: should be on ExecutionPayloadV4? public sealed override ulong? TargetBlobCount { get; set; } /// /// Gets or sets as defined in /// EIP-7742. /// - [JsonRequired] + // [JsonRequired] TODO: should be on ExecutionPayloadV4? public sealed override ulong? MaxBlobCount { get; set; } } From fef9cb227dbf961bf61baa73ba93e1b957cca387 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Wed, 2 Oct 2024 01:14:05 +0600 Subject: [PATCH 08/68] fix whitespaces --- .../Nethermind.Consensus/Producers/PayloadAttributes.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs b/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs index 319170e5376..f84e4f38f42 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs @@ -202,7 +202,7 @@ public static int GetVersion(this PayloadAttributes executionPayload) => public static int ExpectedPayloadAttributesVersion(this IReleaseSpec spec) => spec switch { - { IsEip7742Enabled: true} => EngineApiVersions.Prague, + { IsEip7742Enabled: true } => EngineApiVersions.Prague, { IsEip4844Enabled: true } => EngineApiVersions.Cancun, { WithdrawalsEnabled: true } => EngineApiVersions.Shanghai, _ => EngineApiVersions.Paris From cc02ce5d61c848ba7065af01837a7dbadc38f834 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Wed, 2 Oct 2024 17:21:31 +0600 Subject: [PATCH 09/68] add tests --- .../Builders/BlockHeaderBuilder.cs | 12 +++ .../BlobGasCalculatorTests.cs | 92 ++++++++++++------- .../Nethermind.Specs/Forks/18_Prague.cs | 1 + 3 files changed, 70 insertions(+), 35 deletions(-) diff --git a/src/Nethermind/Nethermind.Core.Test/Builders/BlockHeaderBuilder.cs b/src/Nethermind/Nethermind.Core.Test/Builders/BlockHeaderBuilder.cs index 81d12c7a463..91cc5db2caf 100644 --- a/src/Nethermind/Nethermind.Core.Test/Builders/BlockHeaderBuilder.cs +++ b/src/Nethermind/Nethermind.Core.Test/Builders/BlockHeaderBuilder.cs @@ -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; + } } diff --git a/src/Nethermind/Nethermind.Evm.Test/BlobGasCalculatorTests.cs b/src/Nethermind/Nethermind.Evm.Test/BlobGasCalculatorTests.cs index 41d53956d26..dd86d6c7745 100644 --- a/src/Nethermind/Nethermind.Evm.Test/BlobGasCalculatorTests.cs +++ b/src/Nethermind/Nethermind.Evm.Test/BlobGasCalculatorTests.cs @@ -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, parentHeader), 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))] @@ -65,28 +74,41 @@ public void Blob_gas_price_may_overflow() Assert.That(blobGasPrice, 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); diff --git a/src/Nethermind/Nethermind.Specs/Forks/18_Prague.cs b/src/Nethermind/Nethermind.Specs/Forks/18_Prague.cs index d88d482ea47..9cc8323c0ba 100644 --- a/src/Nethermind/Nethermind.Specs/Forks/18_Prague.cs +++ b/src/Nethermind/Nethermind.Specs/Forks/18_Prague.cs @@ -20,6 +20,7 @@ protected Prague() IsEip7002Enabled = true; IsRip7212Enabled = true; Eip2935ContractAddress = Eip2935Constants.BlockHashHistoryAddress; + IsEip7742Enabled = true; } public new static IReleaseSpec Instance => LazyInitializer.EnsureInitialized(ref _instance, () => new Prague()); From 9fbb9c19709dec1a832150d6826d00c2ecf933c9 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Fri, 4 Oct 2024 15:41:10 +0600 Subject: [PATCH 10/68] add missing fields --- .../Processing/BlockProcessor.cs | 4 +++- .../Nethermind.Core.Test/Builders/BlockBuilder.cs | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs index a152ed5e551..bbd8586c36e 100644 --- a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs +++ b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs @@ -391,7 +391,9 @@ private Block PrepareBlockForProcessing(Block suggestedBlock) WithdrawalsRoot = bh.WithdrawalsRoot, RequestsRoot = bh.RequestsRoot, IsPostMerge = bh.IsPostMerge, - ParentBeaconBlockRoot = bh.ParentBeaconBlockRoot + ParentBeaconBlockRoot = bh.ParentBeaconBlockRoot, + TargetBlobCount = bh.TargetBlobCount, + MaxBlobCount = bh.MaxBlobCount, }; if (!ShouldComputeStateRoot(bh)) diff --git a/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs b/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs index a43039ef8af..acd575985c5 100644 --- a/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs +++ b/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs @@ -303,5 +303,17 @@ public BlockBuilder WithParentBeaconBlockRoot(Hash256? parentBeaconBlockRoot) TestObjectInternal.Header.ParentBeaconBlockRoot = parentBeaconBlockRoot; return this; } + + public BlockBuilder WithTargetBlobCount(ulong? targetBlobCount) + { + TestObjectInternal.Header.TargetBlobCount = targetBlobCount; + return this; + } + + public BlockBuilder WithMaxBlobCount(ulong? maxBlobCount) + { + TestObjectInternal.Header.MaxBlobCount = maxBlobCount; + return this; + } } } From 8ada4e225e25a2db0e1b5e561f4f95f37bd46000 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 7 Oct 2024 16:43:25 +0600 Subject: [PATCH 11/68] fix PayloadAttributes --- .../Nethermind.Consensus/Producers/PayloadAttributes.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs b/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs index f84e4f38f42..dce252ea699 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs @@ -86,7 +86,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 inputSpan) { From 3ae0fed4fe3c3b9553cc322149330dd546d75030 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 7 Oct 2024 16:45:01 +0600 Subject: [PATCH 12/68] add engine_forkchoiceUpdatedV4 to EngineRpcModule.Prague --- .../Nethermind.Merge.Plugin/EngineRpcModule.Prague.cs | 4 ++++ .../Nethermind.Merge.Plugin/IEngineRpcModule.Prague.cs | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/Nethermind/Nethermind.Merge.Plugin/EngineRpcModule.Prague.cs b/src/Nethermind/Nethermind.Merge.Plugin/EngineRpcModule.Prague.cs index a787498000e..b1afa00b50e 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/EngineRpcModule.Prague.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/EngineRpcModule.Prague.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Nethermind.Consensus; +using Nethermind.Consensus.Producers; using Nethermind.Core.Crypto; using Nethermind.JsonRpc; using Nethermind.Merge.Plugin.Data; @@ -29,4 +30,7 @@ public Task> engine_newPayloadV4(ExecutionPayload public Task>> engine_getPayloadBodiesByRangeV2(long start, long count) => _executionGetPayloadBodiesByRangeV2Handler.Handle(start, count); + + public Task> engine_forkchoiceUpdatedV4(ForkchoiceStateV1 forkchoiceState, PayloadAttributes? payloadAttributes = null) + => ForkchoiceUpdated(forkchoiceState, payloadAttributes, EngineApiVersions.Prague); } diff --git a/src/Nethermind/Nethermind.Merge.Plugin/IEngineRpcModule.Prague.cs b/src/Nethermind/Nethermind.Merge.Plugin/IEngineRpcModule.Prague.cs index 15f3577ce42..9770130211c 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/IEngineRpcModule.Prague.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/IEngineRpcModule.Prague.cs @@ -36,4 +36,11 @@ public partial interface IEngineRpcModule : IRpcModule IsSharable = true, IsImplemented = true)] Task>> engine_getPayloadBodiesByRangeV2(long start, long count); + + [JsonRpcMethod( + Description = "Applies fork choice and starts building a new block if payload attributes are present.", + IsSharable = true, + IsImplemented = true)] + public Task> engine_forkchoiceUpdatedV4(ForkchoiceStateV1 forkchoiceState, + PayloadAttributes? payloadAttributes = null); } From 372868a537987e24b59f862d503721d6e11cd448 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 7 Oct 2024 16:48:50 +0600 Subject: [PATCH 13/68] change to engine_forkchoiceUpdatedV4 --- .../Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs index 3c3874b2f8f..a78ed2f236b 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs @@ -429,9 +429,11 @@ private async Task BuildAndGetPayloadResultV4( SuggestedFeeRecipient = feeRecipient, ParentBeaconBlockRoot = Keccak.Zero, Withdrawals = withdrawals, + TargetBlobCount = 0, + MaxBlobCount = 0, }; - ResultWrapper result = rpc.engine_forkchoiceUpdatedV3(forkchoiceState, payloadAttributes).Result; + ResultWrapper result = rpc.engine_forkchoiceUpdatedV4(forkchoiceState, payloadAttributes).Result; string? payloadId = result.Data.PayloadId; if (waitForBlockImprovement) From 4b5fbfc7a3e4b289410b215b784f7cc4574358ea Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 7 Oct 2024 17:43:46 +0600 Subject: [PATCH 14/68] add new fields to EngineModuleTests.V4 --- .../Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs index a78ed2f236b..101b2a8cfaf 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs @@ -240,7 +240,8 @@ private async Task BuildAndGetPayloadOnBranchV4( ulong timestamp, Hash256 random, Address feeRecipient) { PayloadAttributes payloadAttributes = - new() { Timestamp = timestamp, PrevRandao = random, SuggestedFeeRecipient = feeRecipient, ParentBeaconBlockRoot = Keccak.Zero, Withdrawals = [] }; + new() { Timestamp = timestamp, PrevRandao = random, SuggestedFeeRecipient = feeRecipient, + ParentBeaconBlockRoot = Keccak.Zero, Withdrawals = [], TargetBlobCount = 0, MaxBlobCount = 0 }; // we're using payloadService directly, because we can't use fcU for branch string payloadId = chain.PayloadPreparationService!.StartPreparingPayload(parentHeader, payloadAttributes)!; From 5078b768df63132f94840a94e6fa6c081a1242b5 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 7 Oct 2024 18:02:21 +0600 Subject: [PATCH 15/68] added new engine_forkchoiceUpdatedV4 to EngineRpcCapabilitiesProvider --- src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs | 2 +- .../Handlers/EngineRpcCapabilitiesProvider.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs b/src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs index a7459d04f82..444e68cc22b 100644 --- a/src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs +++ b/src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs @@ -398,6 +398,6 @@ public interface IReleaseSpec : IEip1559Spec, IReceiptSpec public bool BlobBaseFeeEnabled => IsEip4844Enabled; - public bool ConsensusRequestsEnabled => WithdrawalRequestsEnabled || DepositsEnabled; + public bool ConsensusRequestsEnabled => WithdrawalRequestsEnabled || DepositsEnabled; // TODO should add IsEip7742? } } diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Handlers/EngineRpcCapabilitiesProvider.cs b/src/Nethermind/Nethermind.Merge.Plugin/Handlers/EngineRpcCapabilitiesProvider.cs index e69773391e4..bdf19d9b4f6 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Handlers/EngineRpcCapabilitiesProvider.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Handlers/EngineRpcCapabilitiesProvider.cs @@ -53,6 +53,7 @@ public EngineRpcCapabilitiesProvider(ISpecProvider specProvider) _capabilities[nameof(IEngineRpcModule.engine_newPayloadV4)] = (spec.ConsensusRequestsEnabled, spec.ConsensusRequestsEnabled); _capabilities[nameof(IEngineRpcModule.engine_getPayloadBodiesByHashV2)] = (spec.ConsensusRequestsEnabled, false); _capabilities[nameof(IEngineRpcModule.engine_getPayloadBodiesByRangeV2)] = (spec.ConsensusRequestsEnabled, false); + _capabilities[nameof(IEngineRpcModule.engine_forkchoiceUpdatedV4)] = (spec.ConsensusRequestsEnabled, false); #endregion } From a92cddeb5bf500a8cfd6c22b6230238ffea87998 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Tue, 8 Oct 2024 13:17:30 +0600 Subject: [PATCH 16/68] fix test cases --- .../AuRaMergeEngineModuleTests.cs | 4 ++-- .../EngineModuleTests.V4.cs | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs b/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs index b2d1e4c26ab..44a21e0882c 100644 --- a/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs +++ b/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs @@ -62,9 +62,9 @@ int ErrorCode [TestCase( "0xe97d919a17fa5011ff3a08ffb07657ed9e1aaf5ff649888e5d7f605006caf598", - "0xdd9be69fe6ed616f44d53576f430c1c7720ed0e7bff59478539a4a43dbb3bf1f", + "0x97549f9f95d97a519112e5d12dddd9f8a9629b8d14e4ee52fc8425da694c2c68", "0xd75d320c3a98a02ec7fe2abdcb1769bd063fec04d73f1735810f365ac12bc4ba", - "0x3c6a8926870bdeff")] + "0xd4b4088d187939ee")] public override Task Should_process_block_as_expected_V4(string latestValidHash, string blockHash, string stateRoot, string payloadId) => base.Should_process_block_as_expected_V4(latestValidHash, blockHash, stateRoot, payloadId); diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs index 101b2a8cfaf..caca3b9d111 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs @@ -28,9 +28,9 @@ public partial class EngineModuleTests { [TestCase( "0x948f67f47376af5d09cc39ec25a84c84774f14b2e80289064c2de73db33cc573", - "0xb8e06e1a99d81358edd0a581fef980aff00cc9c316da8119bec7a13a6e6fa167", + "0x93b5a7c9023dacbec5db5034194dc759e2cff692f0e9d9a5899c190383bf42dc", "0xa272b2f949e4a0e411c9b45542bd5d0ef3c311b5f26c4ed6b7a8d4f605a91154", - "0x96b752d22831ad92")] + "0x3b94afaabd539312")] public virtual async Task Should_process_block_as_expected_V4(string latestValidHash, string blockHash, string stateRoot, string payloadId) { @@ -57,7 +57,9 @@ public virtual async Task Should_process_block_as_expected_V4(string latestValid prevRandao = prevRandao.ToString(), suggestedFeeRecipient = feeRecipient.ToString(), withdrawals, - parentBeaconBLockRoot = Keccak.Zero + parentBeaconBLockRoot = Keccak.Zero, + targetBlobCount = 0, + maxBlobCount = 0, }; string?[] @params = new string?[] { @@ -65,7 +67,7 @@ public virtual async Task Should_process_block_as_expected_V4(string latestValid }; string expectedPayloadId = payloadId; - string response = await RpcTest.TestSerializedRequest(rpc, "engine_forkchoiceUpdatedV3", @params!); + string response = await RpcTest.TestSerializedRequest(rpc, "engine_forkchoiceUpdatedV4", @params!); JsonRpcSuccessResponse? successResponse = chain.JsonSerializer.Deserialize(response); successResponse.Should().NotBeNull(); @@ -107,6 +109,8 @@ public virtual async Task Should_process_block_as_expected_V4(string latestValid ParentBeaconBlockRoot = Keccak.Zero, ReceiptsRoot = chain.BlockTree.Head!.ReceiptsRoot!, StateRoot = new(stateRoot), + MaxBlobCount = 0, + TargetBlobCount = 0, }, Array.Empty(), Array.Empty(), From 4ab5fda97c98bb3f148063450a3e372ae36286fb Mon Sep 17 00:00:00 2001 From: yerke26 Date: Tue, 8 Oct 2024 13:44:20 +0600 Subject: [PATCH 17/68] fix whitespace --- .../EngineModuleTests.V4.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs index f48c2316e43..0792f912b09 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs @@ -280,8 +280,16 @@ private async Task BuildAndGetPayloadOnBranchV4( ulong timestamp, Hash256 random, Address feeRecipient) { PayloadAttributes payloadAttributes = - new() { Timestamp = timestamp, PrevRandao = random, SuggestedFeeRecipient = feeRecipient, - ParentBeaconBlockRoot = Keccak.Zero, Withdrawals = [], TargetBlobCount = 0, MaxBlobCount = 0 }; + new() + { + Timestamp = timestamp, + PrevRandao = random, + SuggestedFeeRecipient = feeRecipient, + ParentBeaconBlockRoot = Keccak.Zero, + Withdrawals = [], + TargetBlobCount = 0, + MaxBlobCount = 0 + }; // we're using payloadService directly, because we can't use fcU for branch string payloadId = chain.PayloadPreparationService!.StartPreparingPayload(parentHeader, payloadAttributes)!; From 0ba200677e4fed4219e82817e7fa1060e1588632 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Tue, 8 Oct 2024 13:57:02 +0600 Subject: [PATCH 18/68] fix EngineRpcCapabilitiesProvider, revert ChainSpecBasedSpecProviderTests --- .../Handlers/EngineRpcCapabilitiesProvider.cs | 2 +- .../ChainSpecStyle/ChainSpecBasedSpecProviderTests.cs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Handlers/EngineRpcCapabilitiesProvider.cs b/src/Nethermind/Nethermind.Merge.Plugin/Handlers/EngineRpcCapabilitiesProvider.cs index 38d7f026440..6dc4cad1805 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Handlers/EngineRpcCapabilitiesProvider.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Handlers/EngineRpcCapabilitiesProvider.cs @@ -53,7 +53,7 @@ public EngineRpcCapabilitiesProvider(ISpecProvider specProvider) _capabilities[nameof(IEngineRpcModule.engine_newPayloadV4)] = (spec.RequestsEnabled, spec.RequestsEnabled); _capabilities[nameof(IEngineRpcModule.engine_getPayloadBodiesByHashV2)] = (spec.RequestsEnabled, false); _capabilities[nameof(IEngineRpcModule.engine_getPayloadBodiesByRangeV2)] = (spec.RequestsEnabled, false); - _capabilities[nameof(IEngineRpcModule.engine_forkchoiceUpdatedV4)] = (spec.RequestsEnabled, spec.IsEip7742Enabled); + _capabilities[nameof(IEngineRpcModule.engine_forkchoiceUpdatedV4)] = (spec.IsEip7742Enabled, spec.IsEip7742Enabled); #endregion } diff --git a/src/Nethermind/Nethermind.Specs.Test/ChainSpecStyle/ChainSpecBasedSpecProviderTests.cs b/src/Nethermind/Nethermind.Specs.Test/ChainSpecStyle/ChainSpecBasedSpecProviderTests.cs index 85ee0395710..ba794b320b1 100644 --- a/src/Nethermind/Nethermind.Specs.Test/ChainSpecStyle/ChainSpecBasedSpecProviderTests.cs +++ b/src/Nethermind/Nethermind.Specs.Test/ChainSpecStyle/ChainSpecBasedSpecProviderTests.cs @@ -271,7 +271,9 @@ private static void VerifyGnosisCancunSpecifics() Assert.Multiple(() => { Assert.That(Eip4844Constants.BlobGasPriceUpdateFraction, Is.EqualTo((UInt256)1112826)); + Assert.That(Eip4844Constants.MaxBlobGasPerBlock, Is.EqualTo(262144)); Assert.That(Eip4844Constants.MinBlobGasPrice, Is.EqualTo(1.GWei())); + Assert.That(Eip4844Constants.TargetBlobGasPerBlock, Is.EqualTo(131072)); }); } @@ -428,7 +430,9 @@ private static void CompareSpecs(IReleaseSpec expectedSpec, IReleaseSpec actualS // Skip EIP-4844 parameter validation .Where(p => p.Name != nameof(Eip4844Constants.BlobGasPriceUpdateFraction)) + .Where(p => p.Name != nameof(Eip4844Constants.MaxBlobGasPerBlock)) .Where(p => p.Name != nameof(Eip4844Constants.MinBlobGasPrice)) + .Where(p => p.Name != nameof(Eip4844Constants.TargetBlobGasPerBlock)) // handle gnosis specific exceptions .Where(p => !isGnosis || p.Name != nameof(IReleaseSpec.MaxCodeSize)) From 911d2322c8f3c2c5e7623b835dac18f2f7de3af4 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Tue, 8 Oct 2024 15:04:56 +0600 Subject: [PATCH 19/68] remove unnecessary comment --- src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs b/src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs index e062571956d..f02a46b0804 100644 --- a/src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs +++ b/src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs @@ -414,6 +414,6 @@ public interface IReleaseSpec : IEip1559Spec, IReceiptSpec bool IsAuthorizationListEnabled => IsEip7702Enabled; - public bool RequestsEnabled => ConsolidationRequestsEnabled || WithdrawalRequestsEnabled || DepositsEnabled; // TODO should add IsEip7742? + public bool RequestsEnabled => ConsolidationRequestsEnabled || WithdrawalRequestsEnabled || DepositsEnabled; } } From f806f228b7c5fbf6562b7675fe9f9563f3de03d6 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Tue, 8 Oct 2024 16:23:07 +0600 Subject: [PATCH 20/68] remove comments --- .../Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs index 97b73a0f2af..b3d5ad9982c 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs @@ -109,13 +109,13 @@ public override bool ValidateFork(ISpecProvider specProvider) => /// Gets or sets as defined in /// EIP-7742. /// - // [JsonRequired] TODO: should be on ExecutionPayloadV4? + [JsonRequired] public sealed override ulong? TargetBlobCount { get; set; } /// /// Gets or sets as defined in /// EIP-7742. /// - // [JsonRequired] TODO: should be on ExecutionPayloadV4? + [JsonRequired] public sealed override ulong? MaxBlobCount { get; set; } } From 87e721ae7262eead75f24e43a4f6f2220f37d708 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 4 Nov 2024 16:54:47 +0600 Subject: [PATCH 21/68] add eip7742 logic to TryCalculateFeePerBlobGas --- .../Nethermind.Evm/BlobGasCalculator.cs | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs b/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs index 21a66c4de67..b5c4e03a90f 100644 --- a/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs +++ b/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs @@ -30,9 +30,9 @@ public static ulong CalculateBlobGas(Transaction[] transactions) return CalculateBlobGas(blobCount); } - public static bool TryCalculateBlobBaseFee(BlockHeader header, Transaction transaction, out UInt256 blobBaseFee) + public static bool TryCalculateBlobBaseFee(BlockHeader header, Transaction transaction, out UInt256 blobBaseFee, IReleaseSpec spec) { - if (!TryCalculateFeePerBlobGas(header.ExcessBlobGas.Value, out UInt256 feePerBlobGas)) + if (!TryCalculateFeePerBlobGas(out UInt256 feePerBlobGas, header, spec)) { blobBaseFee = UInt256.MaxValue; return false; @@ -40,14 +40,12 @@ public static bool TryCalculateBlobBaseFee(BlockHeader header, Transaction trans return !UInt256.MultiplyOverflow(CalculateBlobGas(transaction), feePerBlobGas, out blobBaseFee); } - public static bool TryCalculateFeePerBlobGas(BlockHeader header, out UInt256 feePerBlobGas) + public static bool TryCalculateFeePerBlobGas(BlockHeader header, out UInt256 feePerBlobGas, IReleaseSpec spec) { - feePerBlobGas = UInt256.MaxValue; - return header.ExcessBlobGas is not null - && TryCalculateFeePerBlobGas(header.ExcessBlobGas.Value, out feePerBlobGas); + return TryCalculateFeePerBlobGas(out feePerBlobGas, header, spec); } - public static bool TryCalculateFeePerBlobGas(ulong excessBlobGas, out UInt256 feePerBlobGas) + public static bool TryCalculateFeePerBlobGas(out UInt256 feePerBlobGas, BlockHeader header, IReleaseSpec spec) { static bool FakeExponentialOverflow(UInt256 factor, UInt256 num, UInt256 denominator, out UInt256 feePerBlobGas) { @@ -86,7 +84,13 @@ static bool FakeExponentialOverflow(UInt256 factor, UInt256 num, UInt256 denomin return false; } - return !FakeExponentialOverflow(Eip4844Constants.MinBlobGasPrice, excessBlobGas, Eip4844Constants.BlobGasPriceUpdateFraction, out feePerBlobGas); + var denominator = spec.IsEip7742Enabled + ? Eip7742Constants.BlobGasPriceUpdateFraction * header.TargetBlobCount + ?? throw new InvalidDataException("header is missing target blob count") + : Eip4844Constants.BlobGasPriceUpdateFraction; + + feePerBlobGas = UInt256.MaxValue; + return header.ExcessBlobGas is not null && !FakeExponentialOverflow(Eip4844Constants.MinBlobGasPrice, header.ExcessBlobGas.Value, denominator, out feePerBlobGas); } public static ulong? CalculateExcessBlobGas(BlockHeader? parentBlockHeader, IReleaseSpec releaseSpec, BlockHeader header) From e52fc98b897173415c756fa3ca63f9cf1633b66d Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 4 Nov 2024 20:24:40 +0600 Subject: [PATCH 22/68] remove MaxBlobCount, pass Spec to BlobGasCalculator --- .../Contract/TxPriorityContractTests.cs | 2 +- .../BeaconBlockRoot/BeaconBlockRootHandler.cs | 3 ++- .../ChainHeadInfoProvider.cs | 2 +- .../Contracts/CallableContract.cs | 8 +++--- .../Contracts/Contract.cs | 10 ++++--- .../Nethermind.Blockchain/GenesisLoader.cs | 2 +- .../AuRaValidatorFactory.cs | 4 +-- .../Contracts/BlockGasLimitContract.cs | 6 +++-- .../Contracts/CertifierContract.cs | 6 +++-- .../Contracts/RandomContract.cs | 6 +++-- .../Contracts/RegisterBasedContract.cs | 4 ++- .../Contracts/RegisterContract.cs | 6 +++-- .../Contracts/ReportingValidatorContract.cs | 6 +++-- .../Contracts/RewardContract.cs | 5 ++-- .../TransactionPermissionContract.cs | 6 +++-- .../TransactionPermissionContractV1.cs | 9 ++++--- .../TransactionPermissionContractV2.cs | 6 +++-- .../TransactionPermissionContractV3.cs | 2 +- .../TransactionPermissionContractV4.cs | 2 +- .../Contracts/TxPriorityContract.cs | 6 +++-- .../Contracts/ValidatorContract.cs | 6 +++-- .../VersionedTransactionPermissionContract.cs | 18 ++++++++----- .../InitializeBlockchainAuRa.cs | 5 ++-- .../StartBlockProducerAuRa.cs | 6 +++-- .../TxAuRaFilterBuilders.cs | 10 +++---- .../Rewards/AuRaRewardCalculator.cs | 13 +++++---- .../Processing/BlockCachePreWarmer.cs | 2 +- ...cessor.BlockProductionTransactionPicker.cs | 2 +- ...sor.BlockProductionTransactionsExecutor.cs | 2 +- ...sor.BlockValidationTransactionsExecutor.cs | 4 +-- .../Processing/BlockProcessor.cs | 1 - .../Producers/BlockProducerBase.cs | 1 - .../Producers/PayloadAttributes.cs | 18 ++----------- .../Producers/TxPoolTxSource.cs | 5 ++-- .../Requests/RequestProcessor.cs | 2 +- .../Validators/BlockValidator.cs | 3 ++- .../Builders/BlockBuilder.cs | 6 ----- .../Builders/BlockHeaderBuilder.cs | 6 ----- src/Nethermind/Nethermind.Core/Block.cs | 1 - src/Nethermind/Nethermind.Core/BlockHeader.cs | 1 - .../Nethermind.Core/Eip7742Constants.cs | 15 +++++++++++ .../EvmPooledMemoryTests.cs | 2 +- .../Nethermind.Evm/BlobGasCalculator.cs | 17 +++++++----- .../Nethermind.Evm/BlockExecutionContext.cs | 11 +++++--- .../Nethermind.Evm/Tracing/GasEstimator.cs | 2 +- .../Nethermind.Evm/TransactionExtensions.cs | 5 ++-- .../ITransactionProcessor.cs | 27 +++++++++++++++++++ .../TransactionProcessor.cs | 24 +++++++++++++++-- .../Nethermind.Facade/BlockchainBridge.cs | 4 +-- .../BlockchainBridgeContract.cs | 3 ++- .../Simulate/SimulateBridgeHelper.cs | 1 - .../SimulateReadOnlyBlocksProcessingEnv.cs | 4 +-- .../Modules/Eth/EthRpcModule.cs | 3 ++- .../Eth/FeeHistory/FeeHistoryOracle.cs | 4 +-- .../Modules/Proof/ProofRpcModule.cs | 2 +- .../Modules/ReceiptFinderExtensions.cs | 2 +- .../AuRaMergeBlockProducerEnvFactory.cs | 2 +- .../Contracts/WithdrawalContract.cs | 6 +++-- .../InitializeBlockchainAuRaMerge.cs | 2 +- .../Withdrawals/WithdrawalContractFactory.cs | 7 +++-- .../EngineModuleTests.V4.cs | 3 --- .../Data/ExecutionPayloadV4.cs | 2 -- .../EngineRpcModule.cs | 2 +- .../Handlers/ForkchoiceUpdatedHandler.cs | 1 - .../Rpc/OptimismEthRpcModule.cs | 5 ++-- .../Contracts/KeyBroadcastContract.cs | 3 ++- .../Contracts/KeyperSetContract.cs | 3 ++- .../Contracts/KeyperSetManagerContract.cs | 3 ++- .../Contracts/SequencerContract.cs | 5 ++-- .../Contracts/ValidatorRegistryContract.cs | 7 ++--- .../Nethermind.Shutter/ShutterApi.cs | 9 ++++--- .../Nethermind.Shutter/ShutterBlockHandler.cs | 8 ++++-- .../Nethermind.Shutter/ShutterEon.cs | 10 ++++--- .../Nethermind.Shutter/ShutterTxLoader.cs | 2 +- .../BlockInvalidTxExecutor.cs | 2 +- .../Rpc/TaikoEngineRpcModule.cs | 2 +- src/Nethermind/Nethermind.TxPool/TxPool.cs | 2 +- 77 files changed, 263 insertions(+), 162 deletions(-) create mode 100644 src/Nethermind/Nethermind.Core/Eip7742Constants.cs diff --git a/src/Nethermind/Nethermind.AuRa.Test/Contract/TxPriorityContractTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Contract/TxPriorityContractTests.cs index 4e230c977c2..138718ef053 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Contract/TxPriorityContractTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Contract/TxPriorityContractTests.cs @@ -254,7 +254,7 @@ protected override TxPoolTxSource CreateTxPoolTxSource() TxPoolTxSource txPoolTxSource = base.CreateTxPoolTxSource(); TxPriorityContract = new TxPriorityContract(AbiEncoder.Instance, TestItem.AddressA, - new ReadOnlyTxProcessingEnv(WorldStateManager, BlockTree.AsReadOnly(), SpecProvider, LimboLogs.Instance)); + new ReadOnlyTxProcessingEnv(WorldStateManager, BlockTree.AsReadOnly(), SpecProvider, LimboLogs.Instance), SpecProvider); Priorities = new DictionaryContractDataStore( new TxPriorityContract.DestinationSortedListContractDataStoreCollection(), diff --git a/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs b/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs index e54c14c0c2b..222a85d74d0 100644 --- a/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs +++ b/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs @@ -5,6 +5,7 @@ using Nethermind.Core.Eip2930; using Nethermind.Core.Specs; using Nethermind.Crypto; +using Nethermind.Evm; using Nethermind.Evm.Tracing; using Nethermind.Evm.TransactionProcessing; using Nethermind.Int256; @@ -62,7 +63,7 @@ public void StoreBeaconRoot(Block block, IReleaseSpec spec, ITxTracer tracer) transaction.Hash = transaction.CalculateHash(); - processor.Execute(transaction, header, tracer); + processor.Execute(transaction, new BlockExecutionContext(header, spec), tracer); } } } diff --git a/src/Nethermind/Nethermind.Blockchain/ChainHeadInfoProvider.cs b/src/Nethermind/Nethermind.Blockchain/ChainHeadInfoProvider.cs index 3c90e3dc736..870713c1861 100644 --- a/src/Nethermind/Nethermind.Blockchain/ChainHeadInfoProvider.cs +++ b/src/Nethermind/Nethermind.Blockchain/ChainHeadInfoProvider.cs @@ -59,7 +59,7 @@ private void OnHeadChanged(object? sender, BlockReplacementEventArgs e) BlockGasLimit = e.Block!.GasLimit; CurrentBaseFee = e.Block.Header.BaseFeePerGas; CurrentFeePerBlobGas = - BlobGasCalculator.TryCalculateFeePerBlobGas(e.Block.Header, out UInt256 currentFeePerBlobGas) + BlobGasCalculator.TryCalculateFeePerBlobGas(e.Block.Header, out UInt256 currentFeePerBlobGas, SpecProvider) ? currentFeePerBlobGas : UInt256.Zero; HeadChanged?.Invoke(sender, e); diff --git a/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs b/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs index 54ddaf92945..2df49d11d1c 100644 --- a/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs +++ b/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs @@ -4,6 +4,7 @@ using System; using Nethermind.Abi; using Nethermind.Core; +using Nethermind.Core.Specs; using Nethermind.Int256; using Nethermind.Evm; using Nethermind.Evm.Tracing; @@ -24,7 +25,8 @@ public abstract class CallableContract : Contract /// Transaction processor on which all should be run on. /// Binary interface encoder/decoder. /// Address where contract is deployed. - protected CallableContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress) : base(abiEncoder, contractAddress) + /// Address where contract is deployed. + protected CallableContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress, ISpecProvider specProvider) : base(specProvider, abiEncoder, contractAddress) { _transactionProcessor = transactionProcessor ?? throw new ArgumentNullException(nameof(transactionProcessor)); } @@ -66,7 +68,7 @@ private bool TryCall(BlockHeader header, Transaction transaction, out byte[] res try { - _transactionProcessor.Execute(transaction, new BlockExecutionContext(header), tracer); + _transactionProcessor.Execute(transaction, new BlockExecutionContext(header, SpecProvider), tracer); result = tracer.ReturnValue; return tracer.StatusCode == StatusCode.Success; } @@ -87,7 +89,7 @@ private bool TryCall(BlockHeader header, Transaction transaction, out byte[] res /// Arguments to the function. /// true if function was otherwise false. protected bool TryCall(BlockHeader header, string functionName, Address sender, out object[] result, params object[] arguments) => - TryCall(header, functionName, sender, DefaultContractGasLimit, out result, arguments); + TryCall(header, functionName, sender, DefaultContractGasLimit, out result); /// /// Same as but returns false instead of throwing . diff --git a/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs b/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs index 3b4eec49104..15cf0d2425f 100644 --- a/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs +++ b/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs @@ -7,6 +7,7 @@ using Nethermind.Blockchain.Contracts.Json; using Nethermind.Core; using Nethermind.Core.Crypto; +using Nethermind.Core.Specs; using Nethermind.Crypto; using Nethermind.Int256; using Nethermind.Evm; @@ -36,18 +37,21 @@ public abstract partial class Contract protected IAbiEncoder AbiEncoder { get; } public AbiDefinition AbiDefinition { get; } public Address? ContractAddress { get; protected set; } + protected ISpecProvider SpecProvider { get; set; } /// /// Creates contract /// + /// Binary interface encoder/decoder. /// Binary interface encoder/decoder. /// Address where contract is deployed. /// Binary definition of contract. - protected Contract(IAbiEncoder? abiEncoder = null, Address? contractAddress = null, AbiDefinition? abiDefinition = null) + protected Contract(ISpecProvider specProvider, IAbiEncoder? abiEncoder = null, Address? contractAddress = null, AbiDefinition? abiDefinition = null) { AbiEncoder = abiEncoder ?? Abi.AbiEncoder.Instance; ContractAddress = contractAddress; AbiDefinition = abiDefinition ?? new AbiDefinitionParser().Parse(GetType()); + SpecProvider = specProvider; } protected virtual Transaction GenerateTransaction(Address? contractAddress, byte[] transactionData, Address sender, long gasLimit = DefaultContractGasLimit, BlockHeader header = null) @@ -178,11 +182,11 @@ protected byte[] CallCore(ITransactionProcessor transactionProcessor, BlockHeade { if (callAndRestore) { - transactionProcessor.CallAndRestore(transaction, new BlockExecutionContext(header), tracer); + transactionProcessor.CallAndRestore(transaction, new BlockExecutionContext(header, SpecProvider), tracer); } else { - transactionProcessor.Execute(transaction, new BlockExecutionContext(header), tracer); + transactionProcessor.Execute(transaction, new BlockExecutionContext(header, SpecProvider), tracer); } failure = tracer.StatusCode != StatusCode.Success; diff --git a/src/Nethermind/Nethermind.Blockchain/GenesisLoader.cs b/src/Nethermind/Nethermind.Blockchain/GenesisLoader.cs index 2c94e4d7c6d..50c5543a619 100644 --- a/src/Nethermind/Nethermind.Blockchain/GenesisLoader.cs +++ b/src/Nethermind/Nethermind.Blockchain/GenesisLoader.cs @@ -80,7 +80,7 @@ private void Preallocate(Block genesis) }; CallOutputTracer outputTracer = new(); - _transactionProcessor.Execute(constructorTransaction, new BlockExecutionContext(genesis.Header), outputTracer); + _transactionProcessor.Execute(constructorTransaction, new BlockExecutionContext(genesis.Header, _specProvider), outputTracer); if (outputTracer.StatusCode != StatusCode.Success) { diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/AuRaValidatorFactory.cs b/src/Nethermind/Nethermind.Consensus.AuRa/AuRaValidatorFactory.cs index 00db5435a80..49dc8e24689 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/AuRaValidatorFactory.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/AuRaValidatorFactory.cs @@ -80,8 +80,8 @@ public AuRaValidatorFactory(IAbiEncoder abiEncoder, public IAuRaValidator CreateValidatorProcessor(AuRaParameters.Validator validator, BlockHeader parentHeader = null, long? startBlock = null) { - IValidatorContract GetValidatorContract() => new ValidatorContract(_transactionProcessor, _abiEncoder, validator.GetContractAddress(), _stateProvider, _readOnlyTxProcessorSource, _signer); - IReportingValidatorContract GetReportingValidatorContract() => new ReportingValidatorContract(_abiEncoder, validator.GetContractAddress(), _signer); + IValidatorContract GetValidatorContract() => new ValidatorContract(_transactionProcessor, _abiEncoder, validator.GetContractAddress(), _stateProvider, _readOnlyTxProcessorSource, _signer, _specProvider); + IReportingValidatorContract GetReportingValidatorContract() => new ReportingValidatorContract(_abiEncoder, validator.GetContractAddress(), _signer, _specProvider); var validSealerStrategy = new ValidSealerStrategy(); long startBlockNumber = startBlock ?? AuRaValidatorBase.DefaultStartBlockNumber; diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/BlockGasLimitContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/BlockGasLimitContract.cs index 37954b6ca9a..b04304e16e3 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/BlockGasLimitContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/BlockGasLimitContract.cs @@ -5,6 +5,7 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; +using Nethermind.Core.Specs; using Nethermind.Int256; using Nethermind.Evm.TransactionProcessing; @@ -24,8 +25,9 @@ public BlockGasLimitContract( IAbiEncoder abiEncoder, Address contractAddress, long transitionBlock, - IReadOnlyTxProcessorSource readOnlyTxProcessorSource) - : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) + IReadOnlyTxProcessorSource readOnlyTxProcessorSource, + ISpecProvider specProvider) + : base(specProvider, abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) { Activation = transitionBlock; Constant = GetConstant(readOnlyTxProcessorSource); diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/CertifierContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/CertifierContract.cs index a5aa60a0c6c..40fac04475c 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/CertifierContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/CertifierContract.cs @@ -3,6 +3,7 @@ using Nethermind.Abi; using Nethermind.Core; +using Nethermind.Core.Specs; using Nethermind.Evm.TransactionProcessing; namespace Nethermind.Consensus.AuRa.Contracts @@ -22,8 +23,9 @@ public class CertifierContract : RegisterBasedContract, ICertifierContract public CertifierContract( IAbiEncoder abiEncoder, IRegisterContract registerContract, - IReadOnlyTxProcessorSource readOnlyTransactionProcessorSource) - : base(abiEncoder, registerContract, ServiceTransactionContractRegistryName) + IReadOnlyTxProcessorSource readOnlyTransactionProcessorSource, + ISpecProvider specProvider) + : base(abiEncoder, registerContract, ServiceTransactionContractRegistryName, specProvider) { Constant = GetConstant(readOnlyTransactionProcessorSource); } diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RandomContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RandomContract.cs index 18ada055792..51d086e2c29 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RandomContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RandomContract.cs @@ -5,6 +5,7 @@ using Nethermind.Abi; using Nethermind.Core; using Nethermind.Core.Crypto; +using Nethermind.Core.Specs; using Nethermind.Int256; using Nethermind.Evm.TransactionProcessing; @@ -81,8 +82,9 @@ public RandomContract( Address contractAddress, IReadOnlyTxProcessorSource readOnlyTxProcessorSource, long transitionBlock, - ISigner signer) - : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) + ISigner signer, + ISpecProvider specProvider) + : base(specProvider, abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) { _signer = signer; Activation = transitionBlock; diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RegisterBasedContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RegisterBasedContract.cs index 572563fb64a..70ac339bbaa 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RegisterBasedContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RegisterBasedContract.cs @@ -5,6 +5,7 @@ using Nethermind.Blockchain.Contracts; using Nethermind.Core; using Nethermind.Core.Crypto; +using Nethermind.Core.Specs; namespace Nethermind.Consensus.AuRa.Contracts { @@ -18,8 +19,9 @@ public RegisterBasedContract( IAbiEncoder abiEncoder, IRegisterContract registerContract, string registryKey, + ISpecProvider specProvider, AbiDefinition? abiDefinition = null) - : base(abiEncoder, abiDefinition: abiDefinition) + : base(specProvider, abiEncoder, abiDefinition: abiDefinition) { _registerContract = registerContract; _registryKey = registryKey; diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RegisterContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RegisterContract.cs index 6d7d3e67960..3e1c9cb02be 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RegisterContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RegisterContract.cs @@ -6,6 +6,7 @@ using Nethermind.Blockchain.Contracts; using Nethermind.Core; using Nethermind.Core.Crypto; +using Nethermind.Core.Specs; using Nethermind.Evm.TransactionProcessing; namespace Nethermind.Consensus.AuRa.Contracts @@ -33,8 +34,9 @@ public class RegisterContract : Contract, IRegisterContract public RegisterContract( IAbiEncoder abiEncoder, Address contractAddress, - IReadOnlyTxProcessorSource readOnlyTxProcessorSource) - : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) + IReadOnlyTxProcessorSource readOnlyTxProcessorSource, + ISpecProvider specProvider) + : base(specProvider, abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) { Constant = GetConstant(readOnlyTxProcessorSource); } diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/ReportingValidatorContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/ReportingValidatorContract.cs index 75041e9b453..9f41a42a970 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/ReportingValidatorContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/ReportingValidatorContract.cs @@ -5,6 +5,7 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; +using Nethermind.Core.Specs; using Nethermind.Int256; namespace Nethermind.Consensus.AuRa.Contracts @@ -47,8 +48,9 @@ public sealed class ReportingValidatorContract : Contract, IReportingValidatorCo public ReportingValidatorContract( IAbiEncoder abiEncoder, Address contractAddress, - ISigner signer) - : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) + ISigner signer, + ISpecProvider specProvider) + : base(specProvider, abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) { _signer = signer ?? throw new ArgumentNullException(nameof(signer)); } diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RewardContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RewardContract.cs index e78314f8d97..93440e4f84c 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RewardContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RewardContract.cs @@ -5,6 +5,7 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; +using Nethermind.Core.Specs; using Nethermind.Int256; using Nethermind.Evm.TransactionProcessing; @@ -34,8 +35,8 @@ public sealed class RewardContract : CallableContract, IRewardContract { public long Activation { get; } - public RewardContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress, long transitionBlock) - : base(transactionProcessor, abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) + public RewardContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress, long transitionBlock, ISpecProvider specProvider) + : base(transactionProcessor, abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress)), specProvider) { Activation = transitionBlock; } diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContract.cs index 28f57bded5d..9c276860eaa 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContract.cs @@ -5,6 +5,7 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; +using Nethermind.Core.Specs; using Nethermind.Int256; using Nethermind.Evm.TransactionProcessing; @@ -97,8 +98,9 @@ protected virtual (ITransactionPermissionContract.TxPermissions, bool) CallAllow protected TransactionPermissionContract( IAbiEncoder abiEncoder, Address contractAddress, - IReadOnlyTxProcessorSource readOnlyTxProcessorSource) - : base(abiEncoder, contractAddress) + IReadOnlyTxProcessorSource readOnlyTxProcessorSource, + ISpecProvider specProvider) + : base(specProvider, abiEncoder, contractAddress) { Constant = new PermissionConstantContract(this, readOnlyTxProcessorSource); } diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV1.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV1.cs index 7509c8a2f6b..8cbb6fcc09a 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV1.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV1.cs @@ -4,6 +4,7 @@ using System; using Nethermind.Abi; using Nethermind.Core; +using Nethermind.Core.Specs; using Nethermind.Int256; using Nethermind.Evm.TransactionProcessing; @@ -14,14 +15,16 @@ public sealed class TransactionPermissionContractV1 : TransactionPermissionContr public TransactionPermissionContractV1( IAbiEncoder abiEncoder, Address contractAddress, - IReadOnlyTxProcessorSource readOnlyTxProcessorSource) - : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress)), readOnlyTxProcessorSource) + IReadOnlyTxProcessorSource readOnlyTxProcessorSource, + ISpecProvider specProvider) + : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress)), readOnlyTxProcessorSource, specProvider) { } protected override object[] GetAllowedTxTypesParameters(Transaction tx, BlockHeader parentHeader) => new object[] { tx.SenderAddress }; - protected override (ITransactionPermissionContract.TxPermissions, bool) CallAllowedTxTypes(PermissionConstantContract.PermissionCallInfo callInfo) => + protected override (ITransactionPermissionContract.TxPermissions, bool) CallAllowedTxTypes( + PermissionConstantContract.PermissionCallInfo callInfo) => (Constant.Call(callInfo), true); public override UInt256 Version => UInt256.One; diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV2.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV2.cs index d5bbfa9299a..8fc239ae454 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV2.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV2.cs @@ -4,6 +4,7 @@ using System; using Nethermind.Abi; using Nethermind.Core; +using Nethermind.Core.Specs; using Nethermind.Int256; using Nethermind.Evm.TransactionProcessing; @@ -16,8 +17,9 @@ public sealed class TransactionPermissionContractV2 : TransactionPermissionContr public TransactionPermissionContractV2( IAbiEncoder abiEncoder, Address contractAddress, - IReadOnlyTxProcessorSource readOnlyTxProcessorSource) - : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress)), readOnlyTxProcessorSource) + IReadOnlyTxProcessorSource readOnlyTxProcessorSource, + ISpecProvider specProvider) + : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress)), readOnlyTxProcessorSource, specProvider) { } diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV3.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV3.cs index dd9afdcb38a..a960d469f4c 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV3.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV3.cs @@ -21,7 +21,7 @@ public TransactionPermissionContractV3( Address contractAddress, IReadOnlyTxProcessorSource readOnlyTxProcessorSource, ISpecProvider specProvider) - : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress)), readOnlyTxProcessorSource) + : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress)), readOnlyTxProcessorSource, specProvider) { _specProvider = specProvider; } diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV4.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV4.cs index 77ba9466d3d..00102d69d4b 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV4.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV4.cs @@ -22,7 +22,7 @@ public TransactionPermissionContractV4( Address contractAddress, IReadOnlyTxProcessorSource readOnlyTxProcessorSource, ISpecProvider specProvider) - : base(abiEncoder, contractAddress, readOnlyTxProcessorSource) + : base(abiEncoder, contractAddress, readOnlyTxProcessorSource, specProvider) { _specProvider = specProvider; } diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TxPriorityContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TxPriorityContract.cs index 2f6b9bd5c8d..8d097fb6961 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TxPriorityContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TxPriorityContract.cs @@ -7,6 +7,7 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; +using Nethermind.Core.Specs; using Nethermind.Evm.TransactionProcessing; using Nethermind.Facade; using Nethermind.Int256; @@ -28,8 +29,9 @@ public partial class TxPriorityContract : Contract public TxPriorityContract( IAbiEncoder abiEncoder, Address contractAddress, - IReadOnlyTxProcessorSource readOnlyTxProcessorSource) - : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) + IReadOnlyTxProcessorSource readOnlyTxProcessorSource, + ISpecProvider specProvider) + : base(specProvider, abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) { Constant = GetConstant(readOnlyTxProcessorSource); SendersWhitelist = new DataContract
(GetSendersWhitelist, SendersWhitelistSet); diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/ValidatorContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/ValidatorContract.cs index 7483dc283db..f84b082c8cd 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/ValidatorContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/ValidatorContract.cs @@ -5,6 +5,7 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; +using Nethermind.Core.Specs; using Nethermind.State; using Nethermind.Evm.TransactionProcessing; using Nethermind.Facade; @@ -60,8 +61,9 @@ public ValidatorContract( Address contractAddress, IWorldState stateProvider, IReadOnlyTxProcessorSource readOnlyTxProcessorSource, - ISigner signer) - : base(transactionProcessor, abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) + ISigner signer, + ISpecProvider specProvider) + : base(transactionProcessor, abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress)), specProvider) { _stateProvider = stateProvider ?? throw new ArgumentNullException(nameof(stateProvider)); _signer = signer ?? throw new ArgumentNullException(nameof(signer)); diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/VersionedTransactionPermissionContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/VersionedTransactionPermissionContract.cs index ad6b86eb354..03a1125af71 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/VersionedTransactionPermissionContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/VersionedTransactionPermissionContract.cs @@ -35,22 +35,26 @@ public VersionedTransactionPermissionContract(IAbiEncoder abiEncoder, private static TransactionPermissionContractV1 CreateV1(IAbiEncoder abiEncoder, Address contractAddress, - IReadOnlyTxProcessorSource readOnlyTxProcessorSource) + IReadOnlyTxProcessorSource readOnlyTxProcessorSource, + ISpecProvider specProvider) { return new( abiEncoder, contractAddress, - readOnlyTxProcessorSource); + readOnlyTxProcessorSource, + specProvider); } private static TransactionPermissionContractV2 CreateV2(IAbiEncoder abiEncoder, Address contractAddress, - IReadOnlyTxProcessorSource readOnlyTxProcessorSource) + IReadOnlyTxProcessorSource readOnlyTxProcessorSource, + ISpecProvider specProvider) { return new( abiEncoder, contractAddress, - readOnlyTxProcessorSource); + readOnlyTxProcessorSource, + specProvider); } private static TransactionPermissionContractV3 CreateV3(IAbiEncoder abiEncoder, @@ -89,13 +93,15 @@ private static Dictionary CreateAllVers UInt256.One, CreateV1(abiEncoder, contractAddress, - readOnlyTxProcessorSource) + readOnlyTxProcessorSource, + specProvider) }, { 2, CreateV2(abiEncoder, contractAddress, - readOnlyTxProcessorSource) + readOnlyTxProcessorSource, + specProvider) }, { 3, diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/InitializeBlockchainAuRa.cs b/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/InitializeBlockchainAuRa.cs index cf7ac81bbc7..2622e531047 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/InitializeBlockchainAuRa.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/InitializeBlockchainAuRa.cs @@ -177,7 +177,8 @@ protected IAuRaValidator CreateAuRaValidator() _api.AbiEncoder, blockGasLimitContractTransition.Value, blockGasLimitContractTransition.Key, - _api.CreateReadOnlyTransactionProcessorSource())) + _api.CreateReadOnlyTransactionProcessorSource(), + _api.SpecProvider!)) .ToArray(), _api.GasLimitCalculatorCache, _auraConfig.Minimum2MlnGasPerBlockWhenUsingBlockGasLimitContract, @@ -200,7 +201,7 @@ protected override void InitSealEngine() ValidSealerStrategy validSealerStrategy = new ValidSealerStrategy(); _api.SealValidator = _sealValidator = new AuRaSealValidator(_api.ChainSpec.AuRa, _auRaStepCalculator, _api.BlockTree, _api.ValidatorStore, validSealerStrategy, _api.EthereumEcdsa, _api.LogManager); - _api.RewardCalculatorSource = new AuRaRewardCalculator.AuRaRewardCalculatorSource(_api.ChainSpec.AuRa, _api.AbiEncoder); + _api.RewardCalculatorSource = new AuRaRewardCalculator.AuRaRewardCalculatorSource(_api.ChainSpec.AuRa, _api.AbiEncoder, _api.SpecProvider!); _api.Sealer = new AuRaSealer(_api.BlockTree, _api.ValidatorStore, _auRaStepCalculator, _api.EngineSigner, validSealerStrategy, _api.LogManager); } diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/StartBlockProducerAuRa.cs b/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/StartBlockProducerAuRa.cs index 2b62d16c021..9b2625204b9 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/StartBlockProducerAuRa.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/StartBlockProducerAuRa.cs @@ -298,7 +298,8 @@ IList GetRandomContracts( kvp.Value, txProcessorSource, kvp.Key, - signerLocal)) + signerLocal, + _api.SpecProvider!)) .ToArray(); if (randomnessContractAddress?.Any() == true) @@ -367,7 +368,8 @@ private static IGasLimitCalculator CreateGasLimitCalculator(AuRaNethermindApi ap api.AbiEncoder, blockGasLimitContractTransition.Value, blockGasLimitContractTransition.Key, - api.CreateReadOnlyTransactionProcessorSource())) + api.CreateReadOnlyTransactionProcessorSource(), + api.SpecProvider!)) .ToArray(), api.GasLimitCalculatorCache, api.Config().Minimum2MlnGasPerBlockWhenUsingBlockGasLimitContract == true, diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/TxAuRaFilterBuilders.cs b/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/TxAuRaFilterBuilders.cs index 6f3cfb20156..010c91cc910 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/TxAuRaFilterBuilders.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/TxAuRaFilterBuilders.cs @@ -48,8 +48,8 @@ private static ITxFilter CreateBaseAuRaTxFilter( Address? registrar = api.ChainSpec?.Parameters.Registrar; if (registrar is not null) { - RegisterContract registerContract = new(api.AbiEncoder, registrar, api.CreateReadOnlyTransactionProcessorSource()); - CertifierContract certifierContract = new(api.AbiEncoder, registerContract, api.CreateReadOnlyTransactionProcessorSource()); + RegisterContract registerContract = new(api.AbiEncoder, registrar, api.CreateReadOnlyTransactionProcessorSource(), specProvider); + CertifierContract certifierContract = new(api.AbiEncoder, registerContract, api.CreateReadOnlyTransactionProcessorSource(), specProvider); return CreateFilter(new TxCertifierFilter(certifierContract, gasPriceTxFilter, specProvider, api.LogManager), gasPriceTxFilter); } @@ -63,8 +63,8 @@ private static ITxFilter CreateBaseAuRaTxFilter( Address? registrar = api.ChainSpec?.Parameters.Registrar; if (registrar is not null) { - RegisterContract registerContract = new(api.AbiEncoder, registrar, api.CreateReadOnlyTransactionProcessorSource()); - CertifierContract certifierContract = new(api.AbiEncoder, registerContract, api.CreateReadOnlyTransactionProcessorSource()); + RegisterContract registerContract = new(api.AbiEncoder, registrar, api.CreateReadOnlyTransactionProcessorSource(), api.SpecProvider!); + CertifierContract certifierContract = new(api.AbiEncoder, registerContract, api.CreateReadOnlyTransactionProcessorSource(), api.SpecProvider!); return CreateFilter(new TxCertifierFilter(certifierContract, baseTxFilter, api.SpecProvider, api.LogManager)); } @@ -125,7 +125,7 @@ public static ITxFilter CreateAuRaTxFilter(AuRaNethermindApi api, ITxFilter base TxPriorityContract? txPriorityContract = null; if (usesTxPriorityContract) { - txPriorityContract = new TxPriorityContract(api.AbiEncoder, txPriorityContractAddress, api.CreateReadOnlyTransactionProcessorSource()); + txPriorityContract = new TxPriorityContract(api.AbiEncoder, txPriorityContractAddress, api.CreateReadOnlyTransactionProcessorSource(), api.SpecProvider!); } return txPriorityContract; diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Rewards/AuRaRewardCalculator.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Rewards/AuRaRewardCalculator.cs index 280741ec67c..a1f038da2e0 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Rewards/AuRaRewardCalculator.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Rewards/AuRaRewardCalculator.cs @@ -8,6 +8,7 @@ using Nethermind.Consensus.AuRa.Contracts; using Nethermind.Consensus.Rewards; using Nethermind.Core; +using Nethermind.Core.Specs; using Nethermind.Evm.TransactionProcessing; using Nethermind.Specs.ChainSpecStyle; @@ -18,7 +19,7 @@ public class AuRaRewardCalculator : IRewardCalculator private readonly StaticRewardCalculator _blockRewardCalculator; private readonly IList _contracts; - public AuRaRewardCalculator(AuRaParameters auRaParameters, IAbiEncoder abiEncoder, ITransactionProcessor transactionProcessor) + public AuRaRewardCalculator(AuRaParameters auRaParameters, IAbiEncoder abiEncoder, ITransactionProcessor transactionProcessor, ISpecProvider specProvider) { ArgumentNullException.ThrowIfNull(auRaParameters); ArgumentNullException.ThrowIfNull(abiEncoder); @@ -30,7 +31,7 @@ IList BuildTransitions() if (auRaParameters.BlockRewardContractTransitions is not null) { - contracts.AddRange(auRaParameters.BlockRewardContractTransitions.Select(t => new RewardContract(transactionProcessor, abiEncoder, t.Value, t.Key))); + contracts.AddRange(auRaParameters.BlockRewardContractTransitions.Select(t => new RewardContract(transactionProcessor, abiEncoder, t.Value, t.Key, specProvider))); contracts.Sort((a, b) => a.Activation.CompareTo(b.Activation)); } @@ -42,7 +43,7 @@ IList BuildTransitions() throw new ArgumentException($"{nameof(auRaParameters.BlockRewardContractTransition)} provided for {nameof(auRaParameters.BlockRewardContractAddress)} is higher than first {nameof(auRaParameters.BlockRewardContractTransitions)}."); } - contracts.Insert(0, new RewardContract(transactionProcessor, abiEncoder, auRaParameters.BlockRewardContractAddress, contractTransition)); + contracts.Insert(0, new RewardContract(transactionProcessor, abiEncoder, auRaParameters.BlockRewardContractAddress, contractTransition, specProvider)); } return contracts; @@ -108,14 +109,16 @@ public class AuRaRewardCalculatorSource : IRewardCalculatorSource { private readonly AuRaParameters _auRaParameters; private readonly IAbiEncoder _abiEncoder; + private readonly ISpecProvider _specProvider; - public AuRaRewardCalculatorSource(AuRaParameters auRaParameters, IAbiEncoder abiEncoder) + public AuRaRewardCalculatorSource(AuRaParameters auRaParameters, IAbiEncoder abiEncoder, ISpecProvider specProvider) { _auRaParameters = auRaParameters; _abiEncoder = abiEncoder; + _specProvider = specProvider; } - public IRewardCalculator Get(ITransactionProcessor processor) => new AuRaRewardCalculator(_auRaParameters, _abiEncoder, processor); + public IRewardCalculator Get(ITransactionProcessor processor) => new AuRaRewardCalculator(_auRaParameters, _abiEncoder, processor, _specProvider); } public static class BenefactorKind diff --git a/src/Nethermind/Nethermind.Consensus/Processing/BlockCachePreWarmer.cs b/src/Nethermind/Nethermind.Consensus/Processing/BlockCachePreWarmer.cs index ec2984d07e3..ffff4265fa8 100644 --- a/src/Nethermind/Nethermind.Consensus/Processing/BlockCachePreWarmer.cs +++ b/src/Nethermind/Nethermind.Consensus/Processing/BlockCachePreWarmer.cs @@ -169,7 +169,7 @@ private void WarmupTransactions(ParallelOptions parallelOptions, IReleaseSpec sp { scope.WorldState.WarmUp(tx.AccessList); // eip-2930 } - TransactionResult result = scope.TransactionProcessor.Warmup(systemTransaction, new BlockExecutionContext(block.Header.Clone()), NullTxTracer.Instance); + TransactionResult result = scope.TransactionProcessor.Warmup(systemTransaction, new BlockExecutionContext(block.Header.Clone(), spec), NullTxTracer.Instance); if (_logger.IsTrace) _logger.Trace($"Finished pre-warming cache for tx[{i}] {tx.Hash} with {result}"); } catch (Exception ex) when (ex is EvmException or OverflowException) diff --git a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionPicker.cs b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionPicker.cs index 9b9d1f49cba..8bdce8fce04 100644 --- a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionPicker.cs +++ b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionPicker.cs @@ -109,7 +109,7 @@ private static bool HasEnoughFounds(Transaction transaction, in UInt256 senderBa } if (transaction.SupportsBlobs && ( - !BlobGasCalculator.TryCalculateBlobBaseFee(block.Header, transaction, out UInt256 blobBaseFee) || + !BlobGasCalculator.TryCalculateBlobBaseFee(block.Header, transaction, out UInt256 blobBaseFee, releaseSpec) || senderBalance < (maxFee += blobBaseFee))) { e.Set(TxAction.Skip, $"{maxFee} is higher than sender balance ({senderBalance}), MaxFeePerGas: ({transaction.MaxFeePerGas}), GasLimit {transaction.GasLimit}, BlobBaseFee: {blobBaseFee}"); diff --git a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionsExecutor.cs b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionsExecutor.cs index 9725e29b7fd..cce2e733d59 100644 --- a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionsExecutor.cs +++ b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionsExecutor.cs @@ -70,7 +70,7 @@ public virtual TxReceipt[] ProcessTransactions(Block block, ProcessingOptions pr int i = 0; LinkedHashSet transactionsInBlock = new(ByHashTxComparer.Instance); - BlockExecutionContext blkCtx = new(block.Header); + BlockExecutionContext blkCtx = new(block.Header, spec); foreach (Transaction currentTx in transactions) { TxAction action = ProcessTransaction(block, in blkCtx, currentTx, i++, receiptsTracer, processingOptions, transactionsInBlock); diff --git a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockValidationTransactionsExecutor.cs b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockValidationTransactionsExecutor.cs index 6d2299ef920..cc300a1b520 100644 --- a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockValidationTransactionsExecutor.cs +++ b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockValidationTransactionsExecutor.cs @@ -33,7 +33,7 @@ public BlockValidationTransactionsExecutor(ITransactionProcessor transactionProc public TxReceipt[] ProcessTransactions(Block block, ProcessingOptions processingOptions, BlockReceiptsTracer receiptsTracer, IReleaseSpec spec) { Metrics.ResetBlockStats(); - BlockExecutionContext blkCtx = CreateBlockExecutionContext(block); + BlockExecutionContext blkCtx = CreateBlockExecutionContext(block, spec); for (int i = 0; i < block.Transactions.Length; i++) { block.TransactionProcessed = i; @@ -43,7 +43,7 @@ public TxReceipt[] ProcessTransactions(Block block, ProcessingOptions processing return receiptsTracer.TxReceipts.ToArray(); } - protected virtual BlockExecutionContext CreateBlockExecutionContext(Block block) => new(block.Header); + protected virtual BlockExecutionContext CreateBlockExecutionContext(Block block, IReleaseSpec spec) => new(block.Header, spec); protected virtual void ProcessTransaction(in BlockExecutionContext blkCtx, Transaction currentTx, int index, BlockReceiptsTracer receiptsTracer, ProcessingOptions processingOptions) { diff --git a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs index 23918b57ef1..6a17f2f8066 100644 --- a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs +++ b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs @@ -393,7 +393,6 @@ private Block PrepareBlockForProcessing(Block suggestedBlock) IsPostMerge = bh.IsPostMerge, ParentBeaconBlockRoot = bh.ParentBeaconBlockRoot, TargetBlobCount = bh.TargetBlobCount, - MaxBlobCount = bh.MaxBlobCount, }; if (!ShouldComputeStateRoot(bh)) diff --git a/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerBase.cs b/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerBase.cs index 3d729c6593a..86368663053 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerBase.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerBase.cs @@ -234,7 +234,6 @@ protected virtual BlockHeader PrepareBlockHeader(BlockHeader parent, MixHash = payloadAttributes?.PrevRandao, ParentBeaconBlockRoot = payloadAttributes?.ParentBeaconBlockRoot, TargetBlobCount = payloadAttributes?.TargetBlobCount, - MaxBlobCount = payloadAttributes?.MaxBlobCount, }; UInt256 difficulty = _difficultyCalculator.Calculate(header, parent); diff --git a/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs b/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs index 4888f407058..66c5942b8a6 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs @@ -28,8 +28,6 @@ public class PayloadAttributes public ulong? TargetBlobCount { get; set; } - public ulong? MaxBlobCount { get; set; } - public virtual long? GetGasLimit() => null; public override string ToString() => ToString(string.Empty); @@ -56,11 +54,6 @@ public string ToString(string indentation) sb.Append($", {nameof(TargetBlobCount)} : {TargetBlobCount}"); } - if (MaxBlobCount is not null) - { - sb.Append($", {nameof(MaxBlobCount)} : {MaxBlobCount}"); - } - sb.Append('}'); return sb.ToString(); @@ -86,8 +79,7 @@ protected virtual int ComputePayloadIdMembersSize() => + Address.Size // suggested fee recipient + (Withdrawals is null ? 0 : Keccak.Size) // withdrawals root hash + (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 + + (TargetBlobCount is null ? 0 : sizeof(ulong)); // target blob count protected static string ComputePayloadId(Span inputSpan) { @@ -132,12 +124,6 @@ protected virtual int WritePayloadIdMembers(BlockHeader parentHeader, Span position += sizeof(ulong); } - if (MaxBlobCount.HasValue) - { - BinaryPrimitives.WriteUInt64BigEndian(inputSpan.Slice(position, sizeof(ulong)), MaxBlobCount.Value); - position += sizeof(ulong); - } - return position; } @@ -194,7 +180,7 @@ public static class PayloadAttributesExtensions public static int GetVersion(this PayloadAttributes executionPayload) => executionPayload switch { - { MaxBlobCount: not null, TargetBlobCount: not null } => EngineApiVersions.Prague, + { TargetBlobCount: not null } => EngineApiVersions.Prague, { ParentBeaconBlockRoot: not null, Withdrawals: not null } => EngineApiVersions.Cancun, { Withdrawals: not null } => EngineApiVersions.Shanghai, _ => EngineApiVersions.Paris diff --git a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs index d12623ba9f2..091d71593a9 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs @@ -62,7 +62,7 @@ public IEnumerable GetTransactions(BlockHeader parent, long gasLimi int checkedTransactions = 0; int selectedTransactions = 0; - using ArrayPoolList selectedBlobTxs = new((int)(parent.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock())); + using ArrayPoolList selectedBlobTxs = new((int)(parent.TargetBlobCount * 2 ?? Eip4844Constants.GetMaxBlobsPerBlock())); SelectBlobTransactions(blobTransactions, parent, spec, selectedBlobTxs); @@ -137,6 +137,7 @@ private void SelectBlobTransactions(IEnumerable blobTransactions, B checkedBlobTransactions++; ulong txBlobGas = (ulong)(blobTx.BlobVersionedHashes?.Length ?? 0) * _eip4844Config.GasPerBlob; + // no validation is needed when eip7742 is activated if (!spec.IsEip7742Enabled && txBlobGas > _eip4844Config.MaxBlobGasPerBlock - blobGasCounter) { if (_logger.IsTrace) _logger.Trace($"Declining {blobTx.ToShortString()}, not enough blob space."); @@ -196,7 +197,7 @@ private bool TryUpdateFeePerBlobGas(Transaction lightBlobTx, BlockHeader parent, return false; } - if (!BlobGasCalculator.TryCalculateFeePerBlobGas(excessDataGas.Value, out feePerBlobGas)) + if (!BlobGasCalculator.TryCalculateFeePerBlobGas(excessDataGas.Value, out feePerBlobGas, parent.TargetBlobCount, spec)) { if (_logger.IsTrace) _logger.Trace($"Declining {lightBlobTx.ToShortString()}, failed to calculate data gas price."); feePerBlobGas = UInt256.Zero; diff --git a/src/Nethermind/Nethermind.Consensus/Requests/RequestProcessor.cs b/src/Nethermind/Nethermind.Consensus/Requests/RequestProcessor.cs index c9c40c8dcd1..20e12760c45 100644 --- a/src/Nethermind/Nethermind.Consensus/Requests/RequestProcessor.cs +++ b/src/Nethermind/Nethermind.Consensus/Requests/RequestProcessor.cs @@ -40,7 +40,7 @@ public IEnumerable ReadRequests(Block block, IWorldState state, IReleaseSpec }; transaction.Hash = transaction.CalculateHash(); - transactionProcessor.Execute(transaction, new BlockExecutionContext(block.Header), tracer); + transactionProcessor.Execute(transaction, new BlockExecutionContext(block.Header, spec), tracer); var result = tracer.ReturnValue; if (result == null || result.Length == 0) return Enumerable.Empty(); diff --git a/src/Nethermind/Nethermind.Consensus/Validators/BlockValidator.cs b/src/Nethermind/Nethermind.Consensus/Validators/BlockValidator.cs index 5232805c6ce..2a7fd053029 100644 --- a/src/Nethermind/Nethermind.Consensus/Validators/BlockValidator.cs +++ b/src/Nethermind/Nethermind.Consensus/Validators/BlockValidator.cs @@ -385,7 +385,7 @@ protected virtual bool ValidateEip4844Fields(Block block, IReleaseSpec spec, out if (feePerBlobGas.IsZero) { - if (!BlobGasCalculator.TryCalculateFeePerBlobGas(block.Header, out feePerBlobGas)) + if (!BlobGasCalculator.TryCalculateFeePerBlobGas(block.Header, out feePerBlobGas, spec)) { error = BlockErrorMessages.BlobGasPriceOverflow; if (_logger.IsDebug) _logger.Debug($"{Invalid(block)} {error}."); @@ -405,6 +405,7 @@ protected virtual bool ValidateEip4844Fields(Block block, IReleaseSpec spec, out ulong blobGasUsed = BlobGasCalculator.CalculateBlobGas(blobsInBlock); + // no validation is needed when eip7742 is activated if (!spec.IsEip7742Enabled && blobGasUsed > Eip4844Constants.MaxBlobGasPerBlock) { error = BlockErrorMessages.BlobGasUsedAboveBlockLimit; diff --git a/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs b/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs index 9f2e650a604..36940cd9783 100644 --- a/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs +++ b/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs @@ -309,11 +309,5 @@ public BlockBuilder WithTargetBlobCount(ulong? targetBlobCount) TestObjectInternal.Header.TargetBlobCount = targetBlobCount; return this; } - - public BlockBuilder WithMaxBlobCount(ulong? maxBlobCount) - { - TestObjectInternal.Header.MaxBlobCount = maxBlobCount; - return this; - } } } diff --git a/src/Nethermind/Nethermind.Core.Test/Builders/BlockHeaderBuilder.cs b/src/Nethermind/Nethermind.Core.Test/Builders/BlockHeaderBuilder.cs index 91cc5db2caf..bfce32f74b2 100644 --- a/src/Nethermind/Nethermind.Core.Test/Builders/BlockHeaderBuilder.cs +++ b/src/Nethermind/Nethermind.Core.Test/Builders/BlockHeaderBuilder.cs @@ -207,10 +207,4 @@ public BlockHeaderBuilder WithTargetBlobCount(ulong? targetBlobCount) TestObjectInternal.TargetBlobCount = targetBlobCount; return this; } - - public BlockHeaderBuilder WithMaxBlobCount(ulong? maxBlobCount) - { - TestObjectInternal.MaxBlobCount = maxBlobCount; - return this; - } } diff --git a/src/Nethermind/Nethermind.Core/Block.cs b/src/Nethermind/Nethermind.Core/Block.cs index 82a2482c100..bf6916281fa 100644 --- a/src/Nethermind/Nethermind.Core/Block.cs +++ b/src/Nethermind/Nethermind.Core/Block.cs @@ -123,7 +123,6 @@ public Transaction[] Transactions public ulong? TargetBlobCount => Header.TargetBlobCount; // do not add setter here - public ulong? MaxBlobCount => Header.MaxBlobCount; // do not add setter here [JsonIgnore] public ArrayPoolList? AccountChanges { get; set; } [JsonIgnore] diff --git a/src/Nethermind/Nethermind.Core/BlockHeader.cs b/src/Nethermind/Nethermind.Core/BlockHeader.cs index ef1c799f6f2..08060a5907a 100644 --- a/src/Nethermind/Nethermind.Core/BlockHeader.cs +++ b/src/Nethermind/Nethermind.Core/BlockHeader.cs @@ -85,7 +85,6 @@ 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) { diff --git a/src/Nethermind/Nethermind.Core/Eip7742Constants.cs b/src/Nethermind/Nethermind.Core/Eip7742Constants.cs new file mode 100644 index 00000000000..e808fcb239d --- /dev/null +++ b/src/Nethermind/Nethermind.Core/Eip7742Constants.cs @@ -0,0 +1,15 @@ +// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using Nethermind.Int256; + +namespace Nethermind.Core; + +public class Eip7742Constants +{ + /// + /// Gets the BLOB_GASPRICE_UPDATE_FRACTION parameter. + /// + /// Defaults to 3338477. + public static UInt256 BlobGasPriceUpdateFraction { get; private set; } = 1112825; +} diff --git a/src/Nethermind/Nethermind.Evm.Test/EvmPooledMemoryTests.cs b/src/Nethermind/Nethermind.Evm.Test/EvmPooledMemoryTests.cs index 33c7eb093cc..4e2a02c91e7 100644 --- a/src/Nethermind/Nethermind.Evm.Test/EvmPooledMemoryTests.cs +++ b/src/Nethermind/Nethermind.Evm.Test/EvmPooledMemoryTests.cs @@ -196,7 +196,7 @@ private static string Run(byte[] input) MyTracer tracer = new(); transactionProcessor.Execute( tx, - new BlockExecutionContext(block.Header), + new BlockExecutionContext(block.Header, specProvider), tracer); return tracer.lastmemline; } diff --git a/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs b/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs index b5c4e03a90f..ba59d49f2b8 100644 --- a/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs +++ b/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs @@ -32,7 +32,7 @@ public static ulong CalculateBlobGas(Transaction[] transactions) public static bool TryCalculateBlobBaseFee(BlockHeader header, Transaction transaction, out UInt256 blobBaseFee, IReleaseSpec spec) { - if (!TryCalculateFeePerBlobGas(out UInt256 feePerBlobGas, header, spec)) + if (!TryCalculateFeePerBlobGas(header.ExcessBlobGas, out UInt256 feePerBlobGas, header.TargetBlobCount, spec)) { blobBaseFee = UInt256.MaxValue; return false; @@ -42,10 +42,15 @@ public static bool TryCalculateBlobBaseFee(BlockHeader header, Transaction trans public static bool TryCalculateFeePerBlobGas(BlockHeader header, out UInt256 feePerBlobGas, IReleaseSpec spec) { - return TryCalculateFeePerBlobGas(out feePerBlobGas, header, spec); + return TryCalculateFeePerBlobGas(header.ExcessBlobGas, out feePerBlobGas, header.TargetBlobCount, spec); } - public static bool TryCalculateFeePerBlobGas(out UInt256 feePerBlobGas, BlockHeader header, IReleaseSpec spec) + public static bool TryCalculateFeePerBlobGas(BlockHeader header, out UInt256 feePerBlobGas, ISpecProvider specProvider) + { + return TryCalculateFeePerBlobGas(header.ExcessBlobGas, out feePerBlobGas, header.TargetBlobCount, specProvider.GetSpec(header)); + } + + public static bool TryCalculateFeePerBlobGas(ulong? excessBlobGas, out UInt256 feePerBlobGas, UInt256? targetBlobCount, IReleaseSpec? spec) { static bool FakeExponentialOverflow(UInt256 factor, UInt256 num, UInt256 denominator, out UInt256 feePerBlobGas) { @@ -84,13 +89,13 @@ static bool FakeExponentialOverflow(UInt256 factor, UInt256 num, UInt256 denomin return false; } - var denominator = spec.IsEip7742Enabled - ? Eip7742Constants.BlobGasPriceUpdateFraction * header.TargetBlobCount + var denominator = spec?.IsEip7742Enabled ?? false + ? Eip7742Constants.BlobGasPriceUpdateFraction * targetBlobCount ?? throw new InvalidDataException("header is missing target blob count") : Eip4844Constants.BlobGasPriceUpdateFraction; feePerBlobGas = UInt256.MaxValue; - return header.ExcessBlobGas is not null && !FakeExponentialOverflow(Eip4844Constants.MinBlobGasPrice, header.ExcessBlobGas.Value, denominator, out feePerBlobGas); + return excessBlobGas is not null && !FakeExponentialOverflow(Eip4844Constants.MinBlobGasPrice, excessBlobGas.Value, denominator, out feePerBlobGas); } public static ulong? CalculateExcessBlobGas(BlockHeader? parentBlockHeader, IReleaseSpec releaseSpec, BlockHeader header) diff --git a/src/Nethermind/Nethermind.Evm/BlockExecutionContext.cs b/src/Nethermind/Nethermind.Evm/BlockExecutionContext.cs index 2bd0b7456b9..053910c4d32 100644 --- a/src/Nethermind/Nethermind.Evm/BlockExecutionContext.cs +++ b/src/Nethermind/Nethermind.Evm/BlockExecutionContext.cs @@ -3,6 +3,7 @@ using System; using Nethermind.Core; +using Nethermind.Core.Specs; using Nethermind.Int256; namespace Nethermind.Evm; @@ -12,12 +13,12 @@ public readonly struct BlockExecutionContext public BlockHeader Header { get; } public UInt256? BlobBaseFee { get; } - public BlockExecutionContext(BlockHeader blockHeader) + public BlockExecutionContext(BlockHeader blockHeader, IReleaseSpec spec) { Header = blockHeader; if (blockHeader?.ExcessBlobGas is not null) { - if (!BlobGasCalculator.TryCalculateFeePerBlobGas(blockHeader.ExcessBlobGas.Value, out UInt256 feePerBlobGas)) + if (!BlobGasCalculator.TryCalculateFeePerBlobGas(blockHeader, out UInt256 feePerBlobGas, spec)) { throw new OverflowException("Blob gas price calculation led to overflow."); } @@ -25,11 +26,15 @@ public BlockExecutionContext(BlockHeader blockHeader) } } + public BlockExecutionContext(BlockHeader blockHeader, ISpecProvider specProvider) : this(blockHeader, + specProvider.GetSpec(blockHeader)) + { + } + public BlockExecutionContext(BlockHeader blockHeader, UInt256 forceBlobBaseFee) { Header = blockHeader; BlobBaseFee = forceBlobBaseFee; } - public static implicit operator BlockExecutionContext(BlockHeader header) => new(header); } diff --git a/src/Nethermind/Nethermind.Evm/Tracing/GasEstimator.cs b/src/Nethermind/Nethermind.Evm/Tracing/GasEstimator.cs index a673ef8b657..b75c58548ac 100644 --- a/src/Nethermind/Nethermind.Evm/Tracing/GasEstimator.cs +++ b/src/Nethermind/Nethermind.Evm/Tracing/GasEstimator.cs @@ -114,7 +114,7 @@ private bool TryExecutableTransaction(Transaction transaction, BlockHeader block transaction.GasLimit = gasLimit; - BlockExecutionContext blCtx = new(block); + BlockExecutionContext blCtx = new(block, _specProvider); _transactionProcessor.CallAndRestore(transaction, in blCtx, tracer.WithCancellation(token)); transaction.GasLimit = originalGasLimit; diff --git a/src/Nethermind/Nethermind.Evm/TransactionExtensions.cs b/src/Nethermind/Nethermind.Evm/TransactionExtensions.cs index 0bb04c021fd..f22d02b40c8 100644 --- a/src/Nethermind/Nethermind.Evm/TransactionExtensions.cs +++ b/src/Nethermind/Nethermind.Evm/TransactionExtensions.cs @@ -3,6 +3,7 @@ using System; using Nethermind.Core; +using Nethermind.Core.Specs; using Nethermind.Int256; namespace Nethermind.Evm @@ -14,7 +15,7 @@ public static class TransactionExtensions ? tx.SenderAddress : ContractAddress.From(tx.SenderAddress, nonce > 0 ? nonce - 1 : nonce)); - public static TxGasInfo GetGasInfo(this Transaction tx, bool is1559Enabled, BlockHeader header) + public static TxGasInfo GetGasInfo(this Transaction tx, bool is1559Enabled, BlockHeader header, IReleaseSpec spec) { UInt256 effectiveGasPrice = tx.CalculateEffectiveGasPrice(is1559Enabled, header.BaseFeePerGas); @@ -25,7 +26,7 @@ public static TxGasInfo GetGasInfo(this Transaction tx, bool is1559Enabled, Bloc throw new ArgumentException($"Block that contains Shard Blob Transactions should have {nameof(header.ExcessBlobGas)} set.", nameof(header.ExcessBlobGas)); } - if (!BlobGasCalculator.TryCalculateFeePerBlobGas(header, out UInt256 feePerBlobGas)) + if (!BlobGasCalculator.TryCalculateFeePerBlobGas(header, out UInt256 feePerBlobGas, spec)) { throw new OverflowException("Blob gas price calculation led to overflow."); } diff --git a/src/Nethermind/Nethermind.Evm/TransactionProcessing/ITransactionProcessor.cs b/src/Nethermind/Nethermind.Evm/TransactionProcessing/ITransactionProcessor.cs index e347490cb11..25c0e2c9ac6 100644 --- a/src/Nethermind/Nethermind.Evm/TransactionProcessing/ITransactionProcessor.cs +++ b/src/Nethermind/Nethermind.Evm/TransactionProcessing/ITransactionProcessor.cs @@ -34,4 +34,31 @@ public interface ITransactionProcessor /// Will NOT charge gas from sender account ///
TransactionResult Warmup(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer); + + /// + /// Execute transaction, commit state + /// + TransactionResult Execute(Transaction transaction, in BlockHeader blockHeader, ITxTracer txTracer); + + /// + /// Call transaction, rollback state + /// + TransactionResult CallAndRestore(Transaction transaction, in BlockHeader blockHeader, ITxTracer txTracer); + + /// + /// Execute transaction, keep the state uncommitted + /// + TransactionResult BuildUp(Transaction transaction, in BlockHeader blockHeader, ITxTracer txTracer); + + /// + /// Call transaction, no validations, commit state + /// Will NOT charge gas from sender account, so stateDiff will miss gas fee + /// + TransactionResult Trace(Transaction transaction, in BlockHeader blockHeader, ITxTracer txTracer); + + /// + /// Call transaction, no validations, don't commit state + /// Will NOT charge gas from sender account + /// + TransactionResult Warmup(Transaction transaction, in BlockHeader blockHeader, ITxTracer txTracer); } diff --git a/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs b/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs index f914553a832..eada805a2c0 100644 --- a/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs +++ b/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs @@ -101,9 +101,20 @@ protected TransactionProcessorBase( _logManager = logManager; } + public TransactionResult CallAndRestore(Transaction transaction, in BlockHeader header, ITxTracer txTracer) => + ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider), txTracer, ExecutionOptions.CommitAndRestore); + public TransactionResult CallAndRestore(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer) => ExecuteCore(transaction, in blCtx, txTracer, ExecutionOptions.CommitAndRestore); + public TransactionResult BuildUp(Transaction transaction, in BlockHeader header, ITxTracer txTracer) + { + // we need to treat the result of previous transaction as the original value of next transaction + // when we do not commit + WorldState.TakeSnapshot(true); + return ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider), txTracer, ExecutionOptions.None); + } + public TransactionResult BuildUp(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer) { // we need to treat the result of previous transaction as the original value of next transaction @@ -112,12 +123,21 @@ public TransactionResult BuildUp(Transaction transaction, in BlockExecutionConte return ExecuteCore(transaction, in blCtx, txTracer, ExecutionOptions.None); } + public TransactionResult Execute(Transaction transaction, in BlockHeader header, ITxTracer txTracer) => + ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider), txTracer, ExecutionOptions.Commit); + public TransactionResult Execute(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer) => ExecuteCore(transaction, in blCtx, txTracer, ExecutionOptions.Commit); + public TransactionResult Trace(Transaction transaction, in BlockHeader header, ITxTracer txTracer) => + ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider), txTracer, ExecutionOptions.NoValidation); + public TransactionResult Trace(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer) => ExecuteCore(transaction, in blCtx, txTracer, ExecutionOptions.NoValidation); + public TransactionResult Warmup(Transaction transaction, in BlockHeader header, ITxTracer txTracer) => + ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider), txTracer, ExecutionOptions.Warmup); + public TransactionResult Warmup(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer) => ExecuteCore(transaction, in blCtx, txTracer, ExecutionOptions.Warmup); @@ -126,7 +146,7 @@ private TransactionResult ExecuteCore(Transaction tx, in BlockExecutionContext b if (tx.IsSystem()) { _systemTransactionProcessor ??= new SystemTransactionProcessor(SpecProvider, WorldState, VirtualMachine, _codeInfoRepository, _logManager); - return _systemTransactionProcessor.Execute(tx, blCtx.Header, tracer, opts); + return _systemTransactionProcessor.Execute(tx, new BlockExecutionContext(blCtx.Header, SpecProvider), tracer, opts); } return Execute(tx, in blCtx, tracer, opts); @@ -502,7 +522,7 @@ protected virtual TransactionResult BuyGas(Transaction tx, BlockHeader header, I overflows = UInt256.MultiplyOverflow((UInt256)tx.GasLimit, effectiveGasPrice, out senderReservedGasPayment); if (!overflows && tx.SupportsBlobs) { - overflows = !BlobGasCalculator.TryCalculateBlobBaseFee(header, tx, out blobBaseFee); + overflows = !BlobGasCalculator.TryCalculateBlobBaseFee(header, tx, out blobBaseFee, spec); if (!overflows) { overflows = UInt256.AddOverflow(senderReservedGasPayment, blobBaseFee, out senderReservedGasPayment); diff --git a/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs b/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs index 9194d5eca09..c4b1b5cc163 100644 --- a/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs +++ b/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs @@ -129,7 +129,7 @@ private bool TryGetCanonicalTransaction( { int logIndexStart = txReceipts.GetBlockLogFirstIndex(txReceipt.Index); bool is1559Enabled = _specProvider.GetSpecFor1559(block.Number).IsEip1559Enabled; - return (txReceipt, tx.GetGasInfo(is1559Enabled, block.Header), logIndexStart); + return (txReceipt, tx.GetGasInfo(is1559Enabled, block.Header, _specProvider.GetSpec(block.Header)), logIndexStart); } return (null, null, 0); @@ -298,7 +298,7 @@ private TransactionResult CallAndRestore( callHeader.MixHash = blockHeader.MixHash; callHeader.IsPostMerge = blockHeader.Difficulty == 0; transaction.Hash = transaction.CalculateHash(); - return scope.TransactionProcessor.CallAndRestore(transaction, new(callHeader), tracer); + return scope.TransactionProcessor.CallAndRestore(transaction, callHeader, tracer); } public ulong GetChainId() diff --git a/src/Nethermind/Nethermind.Facade/BlockchainBridgeContract.cs b/src/Nethermind/Nethermind.Facade/BlockchainBridgeContract.cs index abe697c2540..451a62d40cb 100644 --- a/src/Nethermind/Nethermind.Facade/BlockchainBridgeContract.cs +++ b/src/Nethermind/Nethermind.Facade/BlockchainBridgeContract.cs @@ -6,12 +6,13 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; +using Nethermind.Core.Specs; namespace Nethermind.Facade { public abstract class BlockchainBridgeContract : Contract { - public BlockchainBridgeContract(IAbiEncoder abiEncoder, Address contractAddress, AbiDefinition? abiDefinition = null) : base(abiEncoder, contractAddress, abiDefinition) + public BlockchainBridgeContract(IAbiEncoder abiEncoder, Address contractAddress, ISpecProvider specProvider, AbiDefinition? abiDefinition = null) : base(specProvider, abiEncoder, contractAddress, abiDefinition) { } diff --git a/src/Nethermind/Nethermind.Facade/Simulate/SimulateBridgeHelper.cs b/src/Nethermind/Nethermind.Facade/Simulate/SimulateBridgeHelper.cs index d146efb14e8..dcf74e43e01 100644 --- a/src/Nethermind/Nethermind.Facade/Simulate/SimulateBridgeHelper.cs +++ b/src/Nethermind/Nethermind.Facade/Simulate/SimulateBridgeHelper.cs @@ -288,7 +288,6 @@ private BlockHeader GetCallHeader(BlockStateCall b MixHash = parent.MixHash, IsPostMerge = parent.Difficulty == 0, }; - result.MaxBlobCount = parent.MaxBlobCount; result.TargetBlobCount = parent.TargetBlobCount; result.Timestamp = parent.Timestamp + 1; result.BaseFeePerGas = block.BlockOverrides is { BaseFeePerGas: not null } diff --git a/src/Nethermind/Nethermind.Facade/Simulate/SimulateReadOnlyBlocksProcessingEnv.cs b/src/Nethermind/Nethermind.Facade/Simulate/SimulateReadOnlyBlocksProcessingEnv.cs index 151f64efb11..4c62b4de488 100644 --- a/src/Nethermind/Nethermind.Facade/Simulate/SimulateReadOnlyBlocksProcessingEnv.cs +++ b/src/Nethermind/Nethermind.Facade/Simulate/SimulateReadOnlyBlocksProcessingEnv.cs @@ -29,8 +29,8 @@ public class SimulateBlockValidationTransactionsExecutor( UInt256? blobBaseFeeOverride) : BlockValidationTransactionsExecutor(transactionProcessor, stateProvider) { - protected override BlockExecutionContext CreateBlockExecutionContext(Block block) => - blobBaseFeeOverride is not null ? new BlockExecutionContext(block.Header, blobBaseFeeOverride.Value) : base.CreateBlockExecutionContext(block); + protected override BlockExecutionContext CreateBlockExecutionContext(Block block, IReleaseSpec spec) => + blobBaseFeeOverride is not null ? new BlockExecutionContext(block.Header, blobBaseFeeOverride.Value) : base.CreateBlockExecutionContext(block, spec); protected override void ProcessTransaction(in BlockExecutionContext blkCtx, Transaction currentTx, int index, BlockReceiptsTracer receiptsTracer, ProcessingOptions processingOptions) { diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs index 70f06eeb6b0..5d4dc2b30b6 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs @@ -112,8 +112,9 @@ public ResultWrapper
eth_coinbase() { return ResultWrapper.Success(UInt256.Zero); } + IReleaseSpec? spec = _blockFinder.Head?.Header is null ? null : specProvider.GetSpec(_blockFinder.Head.Header); if (!BlobGasCalculator.TryCalculateFeePerBlobGas(_blockFinder.Head?.Header?.ExcessBlobGas ?? 0, - out UInt256 feePerBlobGas)) + out UInt256 feePerBlobGas, _blockFinder.Head?.Header.TargetBlobCount, spec)) { return ResultWrapper.Fail("Unable to calculate the current blob base fee"); } diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs index 0d360133431..703af3eb611 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs @@ -108,9 +108,9 @@ private readonly record struct BlockFeeHistorySearchInfo( { BlockFeeHistorySearchInfo BlockFeeHistorySearchInfoFromBlock(Block b) { - BlobGasCalculator.TryCalculateFeePerBlobGas(b.Header, out UInt256 feePerBlobGas); + BlobGasCalculator.TryCalculateFeePerBlobGas(b.Header, out UInt256 feePerBlobGas, _specProvider.GetSpec(block.Header)); - var maxBlobGasPerBlock = (double)(block.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock()) * Eip4844Constants.GasPerBlob; + var maxBlobGasPerBlock = (double)(block.TargetBlobCount * 2 ?? Eip4844Constants.GetMaxBlobsPerBlock()) * Eip4844Constants.GasPerBlob; return new( b.Number, diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Proof/ProofRpcModule.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Proof/ProofRpcModule.cs index 5818849ea3a..2d652ba8001 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Proof/ProofRpcModule.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Proof/ProofRpcModule.cs @@ -160,7 +160,7 @@ public ResultWrapper proof_getTransactionReceipt(Hash256 txHas int logIndexStart = _receiptFinder.Get(block).GetBlockLogFirstIndex(receipt.Index); - receiptWithProof.Receipt = new ReceiptForRpc(txHash, receipt, tx?.GetGasInfo(isEip1559Enabled, block.Header) ?? new(), logIndexStart); + receiptWithProof.Receipt = new ReceiptForRpc(txHash, receipt, tx?.GetGasInfo(isEip1559Enabled, block.Header, _specProvider.GetSpec(block.Header)) ?? new(), logIndexStart); receiptWithProof.ReceiptProof = BuildReceiptProofs(block.Header, receipts, receipt.Index); receiptWithProof.TxProof = BuildTxProofs(txs, _specProvider.GetSpec(block.Header), receipt.Index); diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/ReceiptFinderExtensions.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/ReceiptFinderExtensions.cs index 7ebf603cfcc..51829e0102f 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/ReceiptFinderExtensions.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/ReceiptFinderExtensions.cs @@ -37,7 +37,7 @@ public static ResultWrapper GetBlockReceipts(this IReceiptFinde IEnumerable result = receipts .Zip(block.Transactions, (r, t) => { - return new ReceiptForRpc(t.Hash, r, t.GetGasInfo(isEip1559Enabled, block.Header), receipts.GetBlockLogFirstIndex(r.Index)); + return new ReceiptForRpc(t.Hash, r, t.GetGasInfo(isEip1559Enabled, block.Header, specProvider.GetSpec(block.Header)), receipts.GetBlockLogFirstIndex(r.Index)); }); ReceiptForRpc[] resultAsArray = result.ToArray(); return ResultWrapper.Success(resultAsArray); diff --git a/src/Nethermind/Nethermind.Merge.AuRa/AuRaMergeBlockProducerEnvFactory.cs b/src/Nethermind/Nethermind.Merge.AuRa/AuRaMergeBlockProducerEnvFactory.cs index faf77f16d32..fd783e8037d 100644 --- a/src/Nethermind/Nethermind.Merge.AuRa/AuRaMergeBlockProducerEnvFactory.cs +++ b/src/Nethermind/Nethermind.Merge.AuRa/AuRaMergeBlockProducerEnvFactory.cs @@ -66,7 +66,7 @@ protected override BlockProcessor CreateBlockProcessor( ILogManager logManager, IBlocksConfig blocksConfig) { - var withdrawalContractFactory = new WithdrawalContractFactory(_auraApi.ChainSpec!.AuRa, _auraApi.AbiEncoder); + var withdrawalContractFactory = new WithdrawalContractFactory(_auraApi.ChainSpec!.AuRa, _auraApi.AbiEncoder, specProvider); return new AuRaMergeBlockProcessor( specProvider, diff --git a/src/Nethermind/Nethermind.Merge.AuRa/Contracts/WithdrawalContract.cs b/src/Nethermind/Nethermind.Merge.AuRa/Contracts/WithdrawalContract.cs index 4f6b82d7595..3a3007370f5 100644 --- a/src/Nethermind/Nethermind.Merge.AuRa/Contracts/WithdrawalContract.cs +++ b/src/Nethermind/Nethermind.Merge.AuRa/Contracts/WithdrawalContract.cs @@ -6,6 +6,7 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; +using Nethermind.Core.Specs; using Nethermind.Evm.TransactionProcessing; using Nethermind.Int256; @@ -23,8 +24,9 @@ public class WithdrawalContract : CallableContract, IWithdrawalContract public WithdrawalContract( ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, - Address contractAddress) - : base(transactionProcessor, abiEncoder, contractAddress) { } + Address contractAddress, + ISpecProvider specProvider) + : base(transactionProcessor, abiEncoder, contractAddress, specProvider) { } public void ExecuteWithdrawals(BlockHeader blockHeader, UInt256 failedMaxCount, IList amounts, IList
addresses) { diff --git a/src/Nethermind/Nethermind.Merge.AuRa/InitializationSteps/InitializeBlockchainAuRaMerge.cs b/src/Nethermind/Nethermind.Merge.AuRa/InitializationSteps/InitializeBlockchainAuRaMerge.cs index 6fec278699c..5161923d8d2 100644 --- a/src/Nethermind/Nethermind.Merge.AuRa/InitializationSteps/InitializeBlockchainAuRaMerge.cs +++ b/src/Nethermind/Nethermind.Merge.AuRa/InitializationSteps/InitializeBlockchainAuRaMerge.cs @@ -32,7 +32,7 @@ protected override AuRaBlockProcessor NewAuraBlockProcessor(ITxFilter txFilter, IDictionary> rewriteBytecode = _api.ChainSpec.AuRa.RewriteBytecode; ContractRewriter? contractRewriter = rewriteBytecode?.Count > 0 ? new ContractRewriter(rewriteBytecode) : null; - WithdrawalContractFactory withdrawalContractFactory = new WithdrawalContractFactory(_api.ChainSpec!.AuRa, _api.AbiEncoder); + WithdrawalContractFactory withdrawalContractFactory = new WithdrawalContractFactory(_api.ChainSpec!.AuRa, _api.AbiEncoder, _api.SpecProvider!); IWorldState worldState = _api.WorldState!; ITransactionProcessor transactionProcessor = _api.TransactionProcessor!; diff --git a/src/Nethermind/Nethermind.Merge.AuRa/Withdrawals/WithdrawalContractFactory.cs b/src/Nethermind/Nethermind.Merge.AuRa/Withdrawals/WithdrawalContractFactory.cs index d52616916f2..df16e047de4 100644 --- a/src/Nethermind/Nethermind.Merge.AuRa/Withdrawals/WithdrawalContractFactory.cs +++ b/src/Nethermind/Nethermind.Merge.AuRa/Withdrawals/WithdrawalContractFactory.cs @@ -4,6 +4,7 @@ using System; using Nethermind.Abi; using Nethermind.Core; +using Nethermind.Core.Specs; using Nethermind.Evm.TransactionProcessing; using Nethermind.Merge.AuRa.Contracts; using Nethermind.Specs.ChainSpecStyle; @@ -14,19 +15,21 @@ public class WithdrawalContractFactory : IWithdrawalContractFactory { private readonly IAbiEncoder _abiEncoder; private readonly Address _contractAddress; + private readonly ISpecProvider _specProvider; - public WithdrawalContractFactory(AuRaParameters parameters, IAbiEncoder abiEncoder) + public WithdrawalContractFactory(AuRaParameters parameters, IAbiEncoder abiEncoder, ISpecProvider specProvider) { ArgumentNullException.ThrowIfNull(parameters); _abiEncoder = abiEncoder ?? throw new ArgumentNullException(nameof(abiEncoder)); _contractAddress = parameters.WithdrawalContractAddress; + _specProvider = specProvider ?? throw new ArgumentNullException(nameof(specProvider)); } public IWithdrawalContract Create(ITransactionProcessor processor) { ArgumentNullException.ThrowIfNull(processor); - return new WithdrawalContract(processor, _abiEncoder, _contractAddress); + return new WithdrawalContract(processor, _abiEncoder, _contractAddress, _specProvider); } } diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs index 0792f912b09..7e48641c9ec 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs @@ -109,7 +109,6 @@ public virtual async Task Should_process_block_as_expected_V4(string latestValid ParentBeaconBlockRoot = Keccak.Zero, ReceiptsRoot = chain.BlockTree.Head!.ReceiptsRoot!, StateRoot = new(stateRoot), - MaxBlobCount = 0, TargetBlobCount = 0, }, Array.Empty(), @@ -288,7 +287,6 @@ private async Task BuildAndGetPayloadOnBranchV4( ParentBeaconBlockRoot = Keccak.Zero, Withdrawals = [], TargetBlobCount = 0, - MaxBlobCount = 0 }; // we're using payloadService directly, because we can't use fcU for branch @@ -483,7 +481,6 @@ private async Task BuildAndGetPayloadResultV4( ParentBeaconBlockRoot = Keccak.Zero, Withdrawals = withdrawals, TargetBlobCount = 0, - MaxBlobCount = 0, }; ResultWrapper result = rpc.engine_forkchoiceUpdatedV4(forkchoiceState, payloadAttributes).Result; diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs index b3d5ad9982c..6da49b70fba 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs @@ -28,7 +28,6 @@ public class ExecutionPayloadV4 : ExecutionPayloadV3, IExecutionPayloadFactory, IEnumerable> _capabilitiesHandler; - private readonly ISpecProvider _specProvider; + protected readonly ISpecProvider _specProvider; protected readonly ILogger _logger; public EngineRpcModule( diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Handlers/ForkchoiceUpdatedHandler.cs b/src/Nethermind/Nethermind.Merge.Plugin/Handlers/ForkchoiceUpdatedHandler.cs index 2d2e04ecea5..5bde22c1fa9 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Handlers/ForkchoiceUpdatedHandler.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Handlers/ForkchoiceUpdatedHandler.cs @@ -317,7 +317,6 @@ private ResultWrapper StartBuildingPayload(Block newH Withdrawals = Array.Empty(), SuggestedFeeRecipient = Address.Zero, TargetBlobCount = newHeadBlock.TargetBlobCount, - MaxBlobCount = newHeadBlock.MaxBlobCount, }; } diff --git a/src/Nethermind/Nethermind.Optimism/Rpc/OptimismEthRpcModule.cs b/src/Nethermind/Nethermind.Optimism/Rpc/OptimismEthRpcModule.cs index e5933bb58f6..866083b87dd 100644 --- a/src/Nethermind/Nethermind.Optimism/Rpc/OptimismEthRpcModule.cs +++ b/src/Nethermind/Nethermind.Optimism/Rpc/OptimismEthRpcModule.cs @@ -92,14 +92,15 @@ public OptimismEthRpcModule( Block? block = searchResult.Object!; OptimismTxReceipt[] receipts = receiptFinder.Get(block).Cast().ToArray() ?? new OptimismTxReceipt[block.Transactions.Length]; - bool isEip1559Enabled = specProvider.GetSpec(block.Header).IsEip1559Enabled; + IReleaseSpec spec = specProvider.GetSpec(block.Header); + bool isEip1559Enabled = spec.IsEip1559Enabled; L1BlockGasInfo l1BlockGasInfo = new(block, opSpecHelper); OptimismReceiptForRpc[]? result = [.. receipts .Zip(block.Transactions, (r, t) => { - return new OptimismReceiptForRpc(t.Hash!, r, t.GetGasInfo(isEip1559Enabled, block.Header), l1BlockGasInfo.GetTxGasInfo(t), receipts.GetBlockLogFirstIndex(r.Index)); + return new OptimismReceiptForRpc(t.Hash!, r, t.GetGasInfo(isEip1559Enabled, block.Header, spec), l1BlockGasInfo.GetTxGasInfo(t), receipts.GetBlockLogFirstIndex(r.Index)); })]; return ResultWrapper.Success(result); } diff --git a/src/Nethermind/Nethermind.Shutter/Contracts/KeyBroadcastContract.cs b/src/Nethermind/Nethermind.Shutter/Contracts/KeyBroadcastContract.cs index b73ff06897e..7cf337d80b2 100644 --- a/src/Nethermind/Nethermind.Shutter/Contracts/KeyBroadcastContract.cs +++ b/src/Nethermind/Nethermind.Shutter/Contracts/KeyBroadcastContract.cs @@ -4,11 +4,12 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; +using Nethermind.Core.Specs; using Nethermind.Evm.TransactionProcessing; namespace Nethermind.Shutter.Contracts; -public class KeyBroadcastContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress) : CallableContract(transactionProcessor, abiEncoder, contractAddress), IKeyBroadcastContract +public class KeyBroadcastContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress, ISpecProvider specProvider) : CallableContract(transactionProcessor, abiEncoder, contractAddress, specProvider), IKeyBroadcastContract { public byte[] GetEonKey(BlockHeader blockHeader, in ulong eon) { diff --git a/src/Nethermind/Nethermind.Shutter/Contracts/KeyperSetContract.cs b/src/Nethermind/Nethermind.Shutter/Contracts/KeyperSetContract.cs index aba64940166..af3f9ba7a35 100644 --- a/src/Nethermind/Nethermind.Shutter/Contracts/KeyperSetContract.cs +++ b/src/Nethermind/Nethermind.Shutter/Contracts/KeyperSetContract.cs @@ -4,11 +4,12 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; +using Nethermind.Core.Specs; using Nethermind.Evm.TransactionProcessing; namespace Nethermind.Shutter.Contracts; -public class KeyperSetContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress) : CallableContract(transactionProcessor, abiEncoder, contractAddress), IKeyperSetContract +public class KeyperSetContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress, ISpecProvider specProvider) : CallableContract(transactionProcessor, abiEncoder, contractAddress, specProvider), IKeyperSetContract { public bool IsFinalized(BlockHeader blockHeader) { diff --git a/src/Nethermind/Nethermind.Shutter/Contracts/KeyperSetManagerContract.cs b/src/Nethermind/Nethermind.Shutter/Contracts/KeyperSetManagerContract.cs index 8f49d1fc81a..890680a37e7 100644 --- a/src/Nethermind/Nethermind.Shutter/Contracts/KeyperSetManagerContract.cs +++ b/src/Nethermind/Nethermind.Shutter/Contracts/KeyperSetManagerContract.cs @@ -4,11 +4,12 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; +using Nethermind.Core.Specs; using Nethermind.Evm.TransactionProcessing; namespace Nethermind.Shutter.Contracts; -public class KeyperSetManagerContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress) : CallableContract(transactionProcessor, abiEncoder, contractAddress), IKeyperSetManagerContract +public class KeyperSetManagerContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress, ISpecProvider specProvider) : CallableContract(transactionProcessor, abiEncoder, contractAddress, specProvider), IKeyperSetManagerContract { public Address GetKeyperSetAddress(BlockHeader blockHeader, in ulong index) { diff --git a/src/Nethermind/Nethermind.Shutter/Contracts/SequencerContract.cs b/src/Nethermind/Nethermind.Shutter/Contracts/SequencerContract.cs index 115b27d9b2e..e43e84c1ae7 100644 --- a/src/Nethermind/Nethermind.Shutter/Contracts/SequencerContract.cs +++ b/src/Nethermind/Nethermind.Shutter/Contracts/SequencerContract.cs @@ -4,6 +4,7 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; +using Nethermind.Core.Specs; namespace Nethermind.Shutter.Contracts; @@ -12,8 +13,8 @@ public class SequencerContract : Contract, ISequencerContract public AbiEncodingInfo TransactionSubmittedAbi { get => _transactionSubmittedAbi; } private readonly AbiEncodingInfo _transactionSubmittedAbi; - public SequencerContract(Address address) - : base(null, address) + public SequencerContract(Address address, ISpecProvider specProvider) + : base(specProvider, null, address) { _transactionSubmittedAbi = AbiDefinition.GetEvent(nameof(ISequencerContract.TransactionSubmitted)).GetCallInfo(AbiEncodingStyle.None); } diff --git a/src/Nethermind/Nethermind.Shutter/Contracts/ValidatorRegistryContract.cs b/src/Nethermind/Nethermind.Shutter/Contracts/ValidatorRegistryContract.cs index 1c72f1ea222..33f2fa4ef8e 100644 --- a/src/Nethermind/Nethermind.Shutter/Contracts/ValidatorRegistryContract.cs +++ b/src/Nethermind/Nethermind.Shutter/Contracts/ValidatorRegistryContract.cs @@ -14,7 +14,7 @@ using Nethermind.Crypto; using Nethermind.Shutter.Config; using System.Linq; - +using Nethermind.Core.Specs; using Update = (byte[] Message, byte[] Signature); namespace Nethermind.Shutter.Contracts; @@ -25,8 +25,9 @@ public class ValidatorRegistryContract( Address contractAddress, ILogManager logManager, ulong chainId, - ulong messageVersion) - : CallableContract(transactionProcessor, abiEncoder, contractAddress), IValidatorRegistryContract + ulong messageVersion, + ISpecProvider specProvider) + : CallableContract(transactionProcessor, abiEncoder, contractAddress, specProvider), IValidatorRegistryContract { private readonly ILogger _logger = logManager.GetClassLogger(); diff --git a/src/Nethermind/Nethermind.Shutter/ShutterApi.cs b/src/Nethermind/Nethermind.Shutter/ShutterApi.cs index 72e6968a31b..15d90e5b050 100644 --- a/src/Nethermind/Nethermind.Shutter/ShutterApi.cs +++ b/src/Nethermind/Nethermind.Shutter/ShutterApi.cs @@ -83,7 +83,7 @@ IPAddress ip Time = InitTime(specProvider, timestamper); TxLoader = new(logFinder, _cfg, Time, specProvider, ecdsa, abiEncoder, logManager); - Eon = InitEon(); + Eon = InitEon(specProvider); BlockHandler = new ShutterBlockHandler( specProvider.ChainId, _cfg, @@ -97,7 +97,8 @@ IPAddress ip Time, logManager, _slotLength, - BlockWaitCutoff); + BlockWaitCutoff, + specProvider); TxSource = new ShutterTxSource(TxLoader, _cfg, Time, logManager); @@ -154,8 +155,8 @@ protected virtual void InitP2P(IPAddress ip) P2P = new ShutterP2P(_cfg, _logManager, _fileSystem, _keyStoreConfig, ip); } - protected virtual IShutterEon InitEon() - => new ShutterEon(_readOnlyBlockTree, _txProcessingEnvFactory, _abiEncoder, _cfg, _logManager); + protected virtual IShutterEon InitEon(ISpecProvider specProvider) + => new ShutterEon(_readOnlyBlockTree, _txProcessingEnvFactory, _abiEncoder, _cfg, _logManager, specProvider); protected virtual ShutterTime InitTime(ISpecProvider specProvider, ITimestamper timestamper) => new(specProvider.BeaconChainGenesisTimestamp!.Value * 1000, timestamper, _slotLength, _blockUpToDateCutoff); diff --git a/src/Nethermind/Nethermind.Shutter/ShutterBlockHandler.cs b/src/Nethermind/Nethermind.Shutter/ShutterBlockHandler.cs index 68f4c7d1e3c..8ffcd5067b1 100644 --- a/src/Nethermind/Nethermind.Shutter/ShutterBlockHandler.cs +++ b/src/Nethermind/Nethermind.Shutter/ShutterBlockHandler.cs @@ -16,6 +16,7 @@ using Nethermind.Core.Crypto; using Nethermind.Blockchain; using Nethermind.Core.Collections; +using Nethermind.Core.Specs; using Nethermind.Shutter.Config; namespace Nethermind.Shutter; @@ -42,6 +43,7 @@ public class ShutterBlockHandler : IShutterBlockHandler private readonly Dictionary> _blockWaitTasks = []; private readonly LruCache _slotToBlockHash = new(5, "Slot to block hash mapping"); private readonly object _syncObject = new(); + private readonly ISpecProvider _specProvider; public ShutterBlockHandler( ulong chainId, @@ -56,7 +58,8 @@ public ShutterBlockHandler( ShutterTime time, ILogManager logManager, TimeSpan slotLength, - TimeSpan blockWaitCutoff) + TimeSpan blockWaitCutoff, + ISpecProvider specProvider) { _chainId = chainId; _cfg = cfg; @@ -73,6 +76,7 @@ public ShutterBlockHandler( _envFactory = envFactory; _slotLength = slotLength; _blockWaitCutoff = blockWaitCutoff; + _specProvider = specProvider; _blockTree.NewHeadBlock += OnNewHeadBlock; } @@ -200,7 +204,7 @@ private void CheckAllValidatorsRegistered(in BlockHeader parent, in ShutterValid IReadOnlyTxProcessingScope scope = _envFactory.Create().Build(parent.StateRoot!); ITransactionProcessor processor = scope.TransactionProcessor; - ValidatorRegistryContract validatorRegistryContract = new(processor, _abiEncoder, new(_cfg.ValidatorRegistryContractAddress!), _logManager, _chainId, _cfg.ValidatorRegistryMessageVersion!); + ValidatorRegistryContract validatorRegistryContract = new(processor, _abiEncoder, new(_cfg.ValidatorRegistryContractAddress!), _logManager, _chainId, _cfg.ValidatorRegistryMessageVersion!, _specProvider); if (validatorRegistryContract.IsRegistered(parent, validatorsInfo, out HashSet unregistered)) { if (_logger.IsInfo) _logger.Info($"All Shutter validator keys are registered."); diff --git a/src/Nethermind/Nethermind.Shutter/ShutterEon.cs b/src/Nethermind/Nethermind.Shutter/ShutterEon.cs index b330d36be26..60a6d681656 100644 --- a/src/Nethermind/Nethermind.Shutter/ShutterEon.cs +++ b/src/Nethermind/Nethermind.Shutter/ShutterEon.cs @@ -11,6 +11,7 @@ using Nethermind.Shutter.Config; using Nethermind.Consensus.Processing; using Nethermind.Core.Crypto; +using Nethermind.Core.Specs; namespace Nethermind.Shutter; @@ -19,7 +20,8 @@ public class ShutterEon( ReadOnlyTxProcessingEnvFactory envFactory, IAbiEncoder abiEncoder, IShutterConfig shutterConfig, - ILogManager logManager) : IShutterEon + ILogManager logManager, + ISpecProvider specProvider) : IShutterEon { private IShutterEon.Info? _currentInfo; private readonly Address _keyBroadcastContractAddress = new(shutterConfig.KeyBroadcastContractAddress!); @@ -36,20 +38,20 @@ public void Update(BlockHeader header) try { - KeyperSetManagerContract keyperSetManagerContract = new(processor, abiEncoder, _keyperSetManagerContractAddress); + KeyperSetManagerContract keyperSetManagerContract = new(processor, abiEncoder, _keyperSetManagerContractAddress, specProvider); ulong eon = keyperSetManagerContract.GetKeyperSetIndexByBlock(header, (ulong)header.Number + 1); if (_currentInfo is null || _currentInfo.Value.Eon != eon) { Address keyperSetContractAddress = keyperSetManagerContract.GetKeyperSetAddress(header, eon); - KeyperSetContract keyperSetContract = new(processor, abiEncoder, keyperSetContractAddress); + KeyperSetContract keyperSetContract = new(processor, abiEncoder, keyperSetContractAddress, specProvider); if (keyperSetContract.IsFinalized(header)) { ulong threshold = keyperSetContract.GetThreshold(header); Address[] addresses = keyperSetContract.GetMembers(header); - KeyBroadcastContract keyBroadcastContract = new(processor, abiEncoder, _keyBroadcastContractAddress); + KeyBroadcastContract keyBroadcastContract = new(processor, abiEncoder, _keyBroadcastContractAddress, specProvider); byte[] eonKey = keyBroadcastContract.GetEonKey(blockTree.Head!.Header, eon); // update atomically diff --git a/src/Nethermind/Nethermind.Shutter/ShutterTxLoader.cs b/src/Nethermind/Nethermind.Shutter/ShutterTxLoader.cs index 0e8d2f814b3..f38ab883b9a 100644 --- a/src/Nethermind/Nethermind.Shutter/ShutterTxLoader.cs +++ b/src/Nethermind/Nethermind.Shutter/ShutterTxLoader.cs @@ -33,7 +33,7 @@ public class ShutterTxLoader( ILogManager logManager) { private readonly ShutterLogScanner _logScanner = new( - new(new Address(cfg.SequencerContractAddress!)), + new(new Address(cfg.SequencerContractAddress!), specProvider), logFinder, logManager, abiEncoder); diff --git a/src/Nethermind/Nethermind.Taiko/BlockInvalidTxExecutor.cs b/src/Nethermind/Nethermind.Taiko/BlockInvalidTxExecutor.cs index 3577d9a4479..2a49f1bc937 100644 --- a/src/Nethermind/Nethermind.Taiko/BlockInvalidTxExecutor.cs +++ b/src/Nethermind/Nethermind.Taiko/BlockInvalidTxExecutor.cs @@ -32,7 +32,7 @@ public TxReceipt[] ProcessTransactions(Block block, ProcessingOptions processing block.Transactions[0].IsAnchorTx = true; - BlockExecutionContext blkCtx = new(block.Header); + BlockExecutionContext blkCtx = new(block.Header, spec); using ArrayPoolList correctTransactions = new(block.Transactions.Length); for (int i = 0; i < block.Transactions.Length; i++) diff --git a/src/Nethermind/Nethermind.Taiko/Rpc/TaikoEngineRpcModule.cs b/src/Nethermind/Nethermind.Taiko/Rpc/TaikoEngineRpcModule.cs index 32a3e1e8d46..53081672f97 100644 --- a/src/Nethermind/Nethermind.Taiko/Rpc/TaikoEngineRpcModule.cs +++ b/src/Nethermind/Nethermind.Taiko/Rpc/TaikoEngineRpcModule.cs @@ -162,7 +162,7 @@ void CommitAndDisposeBatch(Batch batch) batch.Dispose(); } - BlockExecutionContext blkCtx = new(blockHeader); + BlockExecutionContext blkCtx = new(blockHeader, _specProvider); worldState.StateRoot = blockHeader.StateRoot; Batch batch = new(maxBytesPerTxList, txSource.Length, txDecoder); diff --git a/src/Nethermind/Nethermind.TxPool/TxPool.cs b/src/Nethermind/Nethermind.TxPool/TxPool.cs index e3fc02d3368..d5da02b0b75 100644 --- a/src/Nethermind/Nethermind.TxPool/TxPool.cs +++ b/src/Nethermind/Nethermind.TxPool/TxPool.cs @@ -302,7 +302,7 @@ private void ReAddReorganisedTransactions(Block? previousBlock) private void RemoveProcessedTransactions(Block block) { Transaction[] blockTransactions = block.Transactions; - using ArrayPoolList blobTxsToSave = new((int)(block.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock())); + using ArrayPoolList blobTxsToSave = new((int)(block.TargetBlobCount * 2 ?? Eip4844Constants.GetMaxBlobsPerBlock())); long discoveredForPendingTxs = 0; long discoveredForHashCache = 0; long eip1559Txs = 0; From 21622407e75d38c380b7f9aa6860b9d1ee630ac1 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 4 Nov 2024 20:30:34 +0600 Subject: [PATCH 23/68] resolve merge conflicts --- .../Withdrawals/WithdrawalContractFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Nethermind/Nethermind.Merge.AuRa/Withdrawals/WithdrawalContractFactory.cs b/src/Nethermind/Nethermind.Merge.AuRa/Withdrawals/WithdrawalContractFactory.cs index c3886e61483..ee515f79deb 100644 --- a/src/Nethermind/Nethermind.Merge.AuRa/Withdrawals/WithdrawalContractFactory.cs +++ b/src/Nethermind/Nethermind.Merge.AuRa/Withdrawals/WithdrawalContractFactory.cs @@ -6,10 +6,8 @@ using Nethermind.Consensus.AuRa.Config; using Nethermind.Core; using Nethermind.Core.Specs; -using Nethermind.Core.Specs; using Nethermind.Evm.TransactionProcessing; using Nethermind.Merge.AuRa.Contracts; -using Nethermind.Specs.ChainSpecStyle; namespace Nethermind.Merge.AuRa.Withdrawals; From 9d4ec74891457a92cd6b988ff8d5593d6d89298f Mon Sep 17 00:00:00 2001 From: yerke26 Date: Tue, 5 Nov 2024 13:14:00 +0600 Subject: [PATCH 24/68] add MaxBlobCount in PayloadAttributes, refactoring, resolve comments --- .../ChainHeadInfoProvider.cs | 3 ++- .../Contracts/CallableContract.cs | 2 +- .../Contracts/Contract.cs | 4 ++-- .../Nethermind.Blockchain/GenesisLoader.cs | 2 +- .../Producers/PayloadAttributes.cs | 18 ++++++++++++++++-- .../Producers/TxPoolTxSource.cs | 2 +- .../Nethermind.Evm/BlobGasCalculator.cs | 5 ----- .../Nethermind.Evm/BlockExecutionContext.cs | 5 ----- .../Nethermind.Evm/Tracing/GasEstimator.cs | 2 +- .../TransactionProcessor.cs | 12 ++++++------ .../Data/ExecutionPayload.cs | 6 ------ .../Data/ExecutionPayloadV4.cs | 7 ------- .../Rpc/TaikoEngineRpcModule.cs | 2 +- src/Nethermind/Nethermind.TxPool/TxPool.cs | 2 +- 14 files changed, 32 insertions(+), 40 deletions(-) diff --git a/src/Nethermind/Nethermind.Blockchain/ChainHeadInfoProvider.cs b/src/Nethermind/Nethermind.Blockchain/ChainHeadInfoProvider.cs index 870713c1861..90a356fdf4b 100644 --- a/src/Nethermind/Nethermind.Blockchain/ChainHeadInfoProvider.cs +++ b/src/Nethermind/Nethermind.Blockchain/ChainHeadInfoProvider.cs @@ -59,7 +59,8 @@ private void OnHeadChanged(object? sender, BlockReplacementEventArgs e) BlockGasLimit = e.Block!.GasLimit; CurrentBaseFee = e.Block.Header.BaseFeePerGas; CurrentFeePerBlobGas = - BlobGasCalculator.TryCalculateFeePerBlobGas(e.Block.Header, out UInt256 currentFeePerBlobGas, SpecProvider) + BlobGasCalculator.TryCalculateFeePerBlobGas(e.Block.Header, out UInt256 currentFeePerBlobGas, + SpecProvider.GetSpec(e.Block.Header)) ? currentFeePerBlobGas : UInt256.Zero; HeadChanged?.Invoke(sender, e); diff --git a/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs b/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs index 2df49d11d1c..52aefe6f9ff 100644 --- a/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs +++ b/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs @@ -68,7 +68,7 @@ private bool TryCall(BlockHeader header, Transaction transaction, out byte[] res try { - _transactionProcessor.Execute(transaction, new BlockExecutionContext(header, SpecProvider), tracer); + _transactionProcessor.Execute(transaction, new BlockExecutionContext(header, SpecProvider.GetSpec(header)), tracer); result = tracer.ReturnValue; return tracer.StatusCode == StatusCode.Success; } diff --git a/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs b/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs index 15cf0d2425f..134aa2f6f35 100644 --- a/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs +++ b/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs @@ -182,11 +182,11 @@ protected byte[] CallCore(ITransactionProcessor transactionProcessor, BlockHeade { if (callAndRestore) { - transactionProcessor.CallAndRestore(transaction, new BlockExecutionContext(header, SpecProvider), tracer); + transactionProcessor.CallAndRestore(transaction, new BlockExecutionContext(header, SpecProvider.GetSpec(header)), tracer); } else { - transactionProcessor.Execute(transaction, new BlockExecutionContext(header, SpecProvider), tracer); + transactionProcessor.Execute(transaction, new BlockExecutionContext(header, SpecProvider.GetSpec(header)), tracer); } failure = tracer.StatusCode != StatusCode.Success; diff --git a/src/Nethermind/Nethermind.Blockchain/GenesisLoader.cs b/src/Nethermind/Nethermind.Blockchain/GenesisLoader.cs index 50c5543a619..6479fe07cb7 100644 --- a/src/Nethermind/Nethermind.Blockchain/GenesisLoader.cs +++ b/src/Nethermind/Nethermind.Blockchain/GenesisLoader.cs @@ -80,7 +80,7 @@ private void Preallocate(Block genesis) }; CallOutputTracer outputTracer = new(); - _transactionProcessor.Execute(constructorTransaction, new BlockExecutionContext(genesis.Header, _specProvider), outputTracer); + _transactionProcessor.Execute(constructorTransaction, new BlockExecutionContext(genesis.Header, _specProvider.GetSpec(genesis.Header)), outputTracer); if (outputTracer.StatusCode != StatusCode.Success) { diff --git a/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs b/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs index 66c5942b8a6..4888f407058 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs @@ -28,6 +28,8 @@ public class PayloadAttributes public ulong? TargetBlobCount { get; set; } + public ulong? MaxBlobCount { get; set; } + public virtual long? GetGasLimit() => null; public override string ToString() => ToString(string.Empty); @@ -54,6 +56,11 @@ public string ToString(string indentation) sb.Append($", {nameof(TargetBlobCount)} : {TargetBlobCount}"); } + if (MaxBlobCount is not null) + { + sb.Append($", {nameof(MaxBlobCount)} : {MaxBlobCount}"); + } + sb.Append('}'); return sb.ToString(); @@ -79,7 +86,8 @@ protected virtual int ComputePayloadIdMembersSize() => + Address.Size // suggested fee recipient + (Withdrawals is null ? 0 : Keccak.Size) // withdrawals root hash + (ParentBeaconBlockRoot is null ? 0 : Keccak.Size) // parent beacon block root - + (TargetBlobCount is null ? 0 : sizeof(ulong)); // target blob count + + (TargetBlobCount is null ? 0 : sizeof(ulong)) // target blob count + + (MaxBlobCount is null ? 0 : sizeof(ulong)); // max blob count protected static string ComputePayloadId(Span inputSpan) { @@ -124,6 +132,12 @@ protected virtual int WritePayloadIdMembers(BlockHeader parentHeader, Span position += sizeof(ulong); } + if (MaxBlobCount.HasValue) + { + BinaryPrimitives.WriteUInt64BigEndian(inputSpan.Slice(position, sizeof(ulong)), MaxBlobCount.Value); + position += sizeof(ulong); + } + return position; } @@ -180,7 +194,7 @@ public static class PayloadAttributesExtensions public static int GetVersion(this PayloadAttributes executionPayload) => executionPayload switch { - { TargetBlobCount: not null } => EngineApiVersions.Prague, + { MaxBlobCount: not null, TargetBlobCount: not null } => EngineApiVersions.Prague, { ParentBeaconBlockRoot: not null, Withdrawals: not null } => EngineApiVersions.Cancun, { Withdrawals: not null } => EngineApiVersions.Shanghai, _ => EngineApiVersions.Paris diff --git a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs index 091d71593a9..233b44315c2 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs @@ -62,7 +62,7 @@ public IEnumerable GetTransactions(BlockHeader parent, long gasLimi int checkedTransactions = 0; int selectedTransactions = 0; - using ArrayPoolList selectedBlobTxs = new((int)(parent.TargetBlobCount * 2 ?? Eip4844Constants.GetMaxBlobsPerBlock())); + using ArrayPoolList selectedBlobTxs = new((int)(payloadAttributes?.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock())); SelectBlobTransactions(blobTransactions, parent, spec, selectedBlobTxs); diff --git a/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs b/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs index ba59d49f2b8..ae8a5fc51de 100644 --- a/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs +++ b/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs @@ -45,11 +45,6 @@ public static bool TryCalculateFeePerBlobGas(BlockHeader header, out UInt256 fee return TryCalculateFeePerBlobGas(header.ExcessBlobGas, out feePerBlobGas, header.TargetBlobCount, spec); } - public static bool TryCalculateFeePerBlobGas(BlockHeader header, out UInt256 feePerBlobGas, ISpecProvider specProvider) - { - return TryCalculateFeePerBlobGas(header.ExcessBlobGas, out feePerBlobGas, header.TargetBlobCount, specProvider.GetSpec(header)); - } - public static bool TryCalculateFeePerBlobGas(ulong? excessBlobGas, out UInt256 feePerBlobGas, UInt256? targetBlobCount, IReleaseSpec? spec) { static bool FakeExponentialOverflow(UInt256 factor, UInt256 num, UInt256 denominator, out UInt256 feePerBlobGas) diff --git a/src/Nethermind/Nethermind.Evm/BlockExecutionContext.cs b/src/Nethermind/Nethermind.Evm/BlockExecutionContext.cs index 053910c4d32..8af467bbb14 100644 --- a/src/Nethermind/Nethermind.Evm/BlockExecutionContext.cs +++ b/src/Nethermind/Nethermind.Evm/BlockExecutionContext.cs @@ -26,11 +26,6 @@ public BlockExecutionContext(BlockHeader blockHeader, IReleaseSpec spec) } } - public BlockExecutionContext(BlockHeader blockHeader, ISpecProvider specProvider) : this(blockHeader, - specProvider.GetSpec(blockHeader)) - { - } - public BlockExecutionContext(BlockHeader blockHeader, UInt256 forceBlobBaseFee) { Header = blockHeader; diff --git a/src/Nethermind/Nethermind.Evm/Tracing/GasEstimator.cs b/src/Nethermind/Nethermind.Evm/Tracing/GasEstimator.cs index b75c58548ac..e05eeb5234b 100644 --- a/src/Nethermind/Nethermind.Evm/Tracing/GasEstimator.cs +++ b/src/Nethermind/Nethermind.Evm/Tracing/GasEstimator.cs @@ -114,7 +114,7 @@ private bool TryExecutableTransaction(Transaction transaction, BlockHeader block transaction.GasLimit = gasLimit; - BlockExecutionContext blCtx = new(block, _specProvider); + BlockExecutionContext blCtx = new(block, _specProvider.GetSpec(block)); _transactionProcessor.CallAndRestore(transaction, in blCtx, tracer.WithCancellation(token)); transaction.GasLimit = originalGasLimit; diff --git a/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs b/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs index eada805a2c0..5b9c745bc39 100644 --- a/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs +++ b/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs @@ -102,7 +102,7 @@ protected TransactionProcessorBase( } public TransactionResult CallAndRestore(Transaction transaction, in BlockHeader header, ITxTracer txTracer) => - ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider), txTracer, ExecutionOptions.CommitAndRestore); + ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider.GetSpec(header)), txTracer, ExecutionOptions.CommitAndRestore); public TransactionResult CallAndRestore(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer) => ExecuteCore(transaction, in blCtx, txTracer, ExecutionOptions.CommitAndRestore); @@ -112,7 +112,7 @@ public TransactionResult BuildUp(Transaction transaction, in BlockHeader header, // we need to treat the result of previous transaction as the original value of next transaction // when we do not commit WorldState.TakeSnapshot(true); - return ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider), txTracer, ExecutionOptions.None); + return ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider.GetSpec(header)), txTracer, ExecutionOptions.None); } public TransactionResult BuildUp(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer) @@ -124,19 +124,19 @@ public TransactionResult BuildUp(Transaction transaction, in BlockExecutionConte } public TransactionResult Execute(Transaction transaction, in BlockHeader header, ITxTracer txTracer) => - ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider), txTracer, ExecutionOptions.Commit); + ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider.GetSpec(header)), txTracer, ExecutionOptions.Commit); public TransactionResult Execute(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer) => ExecuteCore(transaction, in blCtx, txTracer, ExecutionOptions.Commit); public TransactionResult Trace(Transaction transaction, in BlockHeader header, ITxTracer txTracer) => - ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider), txTracer, ExecutionOptions.NoValidation); + ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider.GetSpec(header)), txTracer, ExecutionOptions.NoValidation); public TransactionResult Trace(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer) => ExecuteCore(transaction, in blCtx, txTracer, ExecutionOptions.NoValidation); public TransactionResult Warmup(Transaction transaction, in BlockHeader header, ITxTracer txTracer) => - ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider), txTracer, ExecutionOptions.Warmup); + ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider.GetSpec(header)), txTracer, ExecutionOptions.Warmup); public TransactionResult Warmup(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer) => ExecuteCore(transaction, in blCtx, txTracer, ExecutionOptions.Warmup); @@ -146,7 +146,7 @@ private TransactionResult ExecuteCore(Transaction tx, in BlockExecutionContext b if (tx.IsSystem()) { _systemTransactionProcessor ??= new SystemTransactionProcessor(SpecProvider, WorldState, VirtualMachine, _codeInfoRepository, _logManager); - return _systemTransactionProcessor.Execute(tx, new BlockExecutionContext(blCtx.Header, SpecProvider), tracer, opts); + return _systemTransactionProcessor.Execute(tx, new BlockExecutionContext(blCtx.Header, SpecProvider.GetSpec(blCtx.Header)), tracer, opts); } return Execute(tx, in blCtx, tracer, opts); diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs index 6160db547db..54614d4b82d 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs @@ -123,12 +123,6 @@ public byte[][] Transactions /// public virtual ulong? TargetBlobCount { get; set; } - /// - /// Gets or sets as defined in - /// EIP-7742. - /// - public virtual ulong? MaxBlobCount { get; set; } - public static ExecutionPayload Create(Block block) => Create(block); protected static TExecutionPayload Create(Block block) where TExecutionPayload : ExecutionPayload, new() diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs index 6da49b70fba..1d0643c96aa 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV4.cs @@ -109,11 +109,4 @@ public override bool ValidateFork(ISpecProvider specProvider) => /// [JsonRequired] public sealed override ulong? TargetBlobCount { get; set; } - - /// - /// Gets or sets as defined in - /// EIP-7742. - /// - [JsonRequired] - public sealed override ulong? MaxBlobCount { get; set; } } diff --git a/src/Nethermind/Nethermind.Taiko/Rpc/TaikoEngineRpcModule.cs b/src/Nethermind/Nethermind.Taiko/Rpc/TaikoEngineRpcModule.cs index 53081672f97..0c784d67b51 100644 --- a/src/Nethermind/Nethermind.Taiko/Rpc/TaikoEngineRpcModule.cs +++ b/src/Nethermind/Nethermind.Taiko/Rpc/TaikoEngineRpcModule.cs @@ -162,7 +162,7 @@ void CommitAndDisposeBatch(Batch batch) batch.Dispose(); } - BlockExecutionContext blkCtx = new(blockHeader, _specProvider); + BlockExecutionContext blkCtx = new(blockHeader, _specProvider.GetSpec(blockHeader)); worldState.StateRoot = blockHeader.StateRoot; Batch batch = new(maxBytesPerTxList, txSource.Length, txDecoder); diff --git a/src/Nethermind/Nethermind.TxPool/TxPool.cs b/src/Nethermind/Nethermind.TxPool/TxPool.cs index d5da02b0b75..29ea5e63d80 100644 --- a/src/Nethermind/Nethermind.TxPool/TxPool.cs +++ b/src/Nethermind/Nethermind.TxPool/TxPool.cs @@ -302,7 +302,7 @@ private void ReAddReorganisedTransactions(Block? previousBlock) private void RemoveProcessedTransactions(Block block) { Transaction[] blockTransactions = block.Transactions; - using ArrayPoolList blobTxsToSave = new((int)(block.TargetBlobCount * 2 ?? Eip4844Constants.GetMaxBlobsPerBlock())); + using ArrayPoolList blobTxsToSave = new(blockTransactions.Length); long discoveredForPendingTxs = 0; long discoveredForHashCache = 0; long eip1559Txs = 0; From d8e088c72a78f52d9a7c4552a7b16d09793f0cbc Mon Sep 17 00:00:00 2001 From: yerke26 Date: Tue, 5 Nov 2024 13:32:12 +0600 Subject: [PATCH 25/68] fix tests --- .../Ethereum.Test.Base/GeneralTestBase.cs | 2 +- .../AuRaContractGasLimitOverrideTests.cs | 3 +- .../ReportingValidatorContractTests.cs | 5 ++-- .../Contract/ValidatorContractTests.cs | 7 +++-- .../Reward/AuRaRewardCalculatorTests.cs | 21 +++++++------- .../Transactions/TxCertifierFilterTests.cs | 7 +++-- .../Validators/ContractBasedValidatorTests.cs | 2 +- .../Nethermind.Evm.Benchmark/EvmBenchmarks.cs | 2 +- .../MultipleUnsignedOperations.cs | 2 +- .../StaticCallBenchmarks.cs | 2 +- .../EvmPooledMemoryTests.cs | 2 +- .../Nethermind.Evm/BlobGasCalculator.cs | 6 ++-- .../AuRaMergeEngineModuleTests.cs | 2 +- .../ShutterApiSimulator.cs | 2 +- .../ShutterEventSimulator.cs | 7 +++-- .../ShutterTestsCommon.cs | 3 +- .../ShutterTxLoaderTests.cs | 29 ++++--------------- .../ShutterValidatorRegistryTests.cs | 5 ++-- 18 files changed, 51 insertions(+), 58 deletions(-) diff --git a/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs b/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs index f3fdea2b98c..d3db46da9c8 100644 --- a/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs +++ b/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs @@ -136,7 +136,7 @@ protected EthereumTestResult RunTest(GeneralStateTest test, ITxTracer txTracer) if (txIsValid) { - transactionProcessor.Execute(test.Transaction, new BlockExecutionContext(header), txTracer); + transactionProcessor.Execute(test.Transaction, new BlockExecutionContext(header, spec), txTracer); } else { diff --git a/src/Nethermind/Nethermind.AuRa.Test/Contract/AuRaContractGasLimitOverrideTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Contract/AuRaContractGasLimitOverrideTests.cs index 079f507fe05..d07a2242f5e 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Contract/AuRaContractGasLimitOverrideTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Contract/AuRaContractGasLimitOverrideTests.cs @@ -90,7 +90,8 @@ protected override BlockProcessor CreateBlockProcessor() blockGasLimitContractTransition.Key, new ReadOnlyTxProcessingEnv( WorldStateManager, - BlockTree.AsReadOnly(), SpecProvider, LimboLogs.Instance)); + BlockTree.AsReadOnly(), SpecProvider, LimboLogs.Instance), + SpecProvider); GasLimitOverrideCache = new AuRaContractGasLimitOverride.Cache(); GasLimitCalculator = new AuRaContractGasLimitOverride(new[] { gasLimitContract }, GasLimitOverrideCache, false, new FollowOtherMiners(SpecProvider), LimboLogs.Instance); diff --git a/src/Nethermind/Nethermind.AuRa.Test/Contract/ReportingValidatorContractTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Contract/ReportingValidatorContractTests.cs index b24804531f2..4ace626cfec 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Contract/ReportingValidatorContractTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Contract/ReportingValidatorContractTests.cs @@ -7,6 +7,7 @@ using Nethermind.Consensus.AuRa.Contracts; using Nethermind.Core; using Nethermind.Core.Extensions; +using Nethermind.Specs; using NSubstitute; using NUnit.Framework; @@ -17,7 +18,7 @@ public class ReportingValidatorContractTests [Test] public void Should_generate_malicious_transaction() { - ReportingValidatorContract contract = new(AbiEncoder.Instance, new Address("0x1000000000000000000000000000000000000001"), Substitute.For()); + ReportingValidatorContract contract = new(AbiEncoder.Instance, new Address("0x1000000000000000000000000000000000000001"), Substitute.For(), TestSpecProvider.Instance); Transaction transaction = contract.ReportMalicious(new Address("0x75df42383afe6bf5194aa8fa0e9b3d5f9e869441"), 10, new byte[0]); transaction.Data.AsArray().ToHexString().Should().Be("c476dd4000000000000000000000000075df42383afe6bf5194aa8fa0e9b3d5f9e869441000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000"); } @@ -25,7 +26,7 @@ public void Should_generate_malicious_transaction() [Test] public void Should_generate_benign_transaction() { - ReportingValidatorContract contract = new(AbiEncoder.Instance, new Address("0x1000000000000000000000000000000000000001"), Substitute.For()); + ReportingValidatorContract contract = new(AbiEncoder.Instance, new Address("0x1000000000000000000000000000000000000001"), Substitute.For(), TestSpecProvider.Instance); Transaction transaction = contract.ReportBenign(new Address("0x75df42383afe6bf5194aa8fa0e9b3d5f9e869441"), 10); transaction.Data.AsArray().ToHexString().Should().Be("d69f13bb00000000000000000000000075df42383afe6bf5194aa8fa0e9b3d5f9e869441000000000000000000000000000000000000000000000000000000000000000a"); } diff --git a/src/Nethermind/Nethermind.AuRa.Test/Contract/ValidatorContractTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Contract/ValidatorContractTests.cs index ae1a5040a4f..7b6b345fcaa 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Contract/ValidatorContractTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Contract/ValidatorContractTests.cs @@ -16,6 +16,7 @@ using Nethermind.Evm.Tracing; using Nethermind.Evm.TransactionProcessing; using Nethermind.Logging; +using Nethermind.Specs; using Nethermind.State; using NSubstitute; using NUnit.Framework; @@ -52,7 +53,8 @@ public void constructor_throws_ArgumentNullException_on_null_contractAddress() null, _stateProvider, _readOnlyTxProcessorSource, - new Signer(0, TestItem.PrivateKeyD, LimboLogs.Instance)); + new Signer(0, TestItem.PrivateKeyD, LimboLogs.Instance), + TestSpecProvider.Instance); action.Should().Throw(); } @@ -78,7 +80,8 @@ public void finalize_change_should_call_correct_transaction() _contractAddress, _stateProvider, _readOnlyTxProcessorSource, - new Signer(0, TestItem.PrivateKeyD, LimboLogs.Instance)); + new Signer(0, TestItem.PrivateKeyD, LimboLogs.Instance), + TestSpecProvider.Instance); contract.FinalizeChange(_block.Header); diff --git a/src/Nethermind/Nethermind.AuRa.Test/Reward/AuRaRewardCalculatorTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Reward/AuRaRewardCalculatorTests.cs index c83e8d09827..b1341c74ba1 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Reward/AuRaRewardCalculatorTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Reward/AuRaRewardCalculatorTests.cs @@ -21,6 +21,7 @@ using NSubstitute; using NUnit.Framework; using Nethermind.Evm; +using Nethermind.Specs; namespace Nethermind.AuRa.Test.Reward { @@ -61,21 +62,21 @@ public void SetUp() [Test] public void constructor_throws_ArgumentNullException_on_null_auraParameters() { - Action action = () => new AuRaRewardCalculator(null, _abiEncoder, _transactionProcessor); + Action action = () => new AuRaRewardCalculator(null, _abiEncoder, _transactionProcessor, TestSpecProvider.Instance); action.Should().Throw(); } [Test] public void constructor_throws_ArgumentNullException_on_null_encoder() { - Action action = () => new AuRaRewardCalculator(_auraParameters, null, _transactionProcessor); + Action action = () => new AuRaRewardCalculator(_auraParameters, null, _transactionProcessor, TestSpecProvider.Instance); action.Should().Throw(); } [Test] public void constructor_throws_ArgumentNullException_on_null_transactionProcessor() { - Action action = () => new AuRaRewardCalculator(_auraParameters, _abiEncoder, null); + Action action = () => new AuRaRewardCalculator(_auraParameters, _abiEncoder, null, TestSpecProvider.Instance); action.Should().Throw(); } @@ -87,7 +88,7 @@ public void constructor_throws_ArgumentException_on_BlockRewardContractTransitio {2, Address.FromNumber(2)} }; - Action action = () => new AuRaRewardCalculator(_auraParameters, _abiEncoder, _transactionProcessor); + Action action = () => new AuRaRewardCalculator(_auraParameters, _abiEncoder, _transactionProcessor, TestSpecProvider.Instance); action.Should().Throw(); } @@ -97,7 +98,7 @@ public void constructor_throws_ArgumentException_on_BlockRewardContractTransitio public void calculates_rewards_correctly_before_contract_transition(long blockNumber, ulong expectedReward) { _block.Header.Number = blockNumber; - AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor); + AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor, TestSpecProvider.Instance); BlockReward[] result = calculator.CalculateRewards(_block); result.Should().BeEquivalentTo(new BlockReward(_block.Beneficiary, expectedReward)); } @@ -106,7 +107,7 @@ public void calculates_rewards_correctly_before_contract_transition(long blockNu public void calculates_rewards_correctly_for_genesis() { _block.Header.Number = 0; - AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor); + AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor, TestSpecProvider.Instance); BlockReward[] result = calculator.CalculateRewards(_block); result.Should().BeEmpty(); } @@ -118,7 +119,7 @@ public void calculates_rewards_correctly_after_contract_transition(long blockNum _block.Header.Number = blockNumber; BlockReward expected = new(_block.Beneficiary, expectedReward, BlockRewardType.External); SetupBlockRewards(new Dictionary() { { _address10, new[] { expected } } }); - AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor); + AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor, TestSpecProvider.Instance); BlockReward[] result = calculator.CalculateRewards(_block); result.Should().BeEquivalentTo(expected); } @@ -144,7 +145,7 @@ public void calculates_rewards_correctly_after_subsequent_contract_transitions(l _block.Header.Number = blockNumber; BlockReward expected = new(_block.Beneficiary, expectedReward, BlockRewardType.External); SetupBlockRewards(new Dictionary() { { address, new[] { expected } } }); - AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor); + AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor, TestSpecProvider.Instance); BlockReward[] result = calculator.CalculateRewards(_block); result.Should().BeEquivalentTo(expected); } @@ -167,7 +168,7 @@ public void calculates_rewards_correctly_for_uncles(long blockNumber, ulong expe }; SetupBlockRewards(new Dictionary() { { _address10, expected } }); - AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor); + AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor, TestSpecProvider.Instance); BlockReward[] result = calculator.CalculateRewards(_block); result.Should().BeEquivalentTo(expected); } @@ -190,7 +191,7 @@ public void calculates_rewards_correctly_for_external_addresses() }; SetupBlockRewards(new Dictionary() { { _address10, expected } }); - AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor); + AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor, TestSpecProvider.Instance); BlockReward[] result = calculator.CalculateRewards(_block); result.Should().BeEquivalentTo(expected); } diff --git a/src/Nethermind/Nethermind.AuRa.Test/Transactions/TxCertifierFilterTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Transactions/TxCertifierFilterTests.cs index cda399944da..879c76b5a58 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Transactions/TxCertifierFilterTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Transactions/TxCertifierFilterTests.cs @@ -124,7 +124,7 @@ public async Task registry_contract_returns_not_found_when_key_doesnt_exist() public async Task registry_contract_returns_not_found_when_contract_doesnt_exist() { using TestTxPermissionsBlockchain chain = await TestContractBlockchain.ForTest(); - RegisterContract contract = new(AbiEncoder.Instance, Address.FromNumber(1000), chain.ReadOnlyTransactionProcessorSource); + RegisterContract contract = new(AbiEncoder.Instance, Address.FromNumber(1000), chain.ReadOnlyTransactionProcessorSource, _specProvider); contract.TryGetAddress(chain.BlockTree.Head.Header, CertifierContract.ServiceTransactionContractRegistryName, out Address _).Should().BeFalse(); } @@ -141,11 +141,12 @@ protected override BlockProcessor CreateBlockProcessor() WorldStateManager, BlockTree.AsReadOnly(), SpecProvider, LimboLogs.Instance); - RegisterContract = new RegisterContract(abiEncoder, ChainSpec.Parameters.Registrar, ReadOnlyTransactionProcessorSource); + RegisterContract = new RegisterContract(abiEncoder, ChainSpec.Parameters.Registrar, ReadOnlyTransactionProcessorSource, Substitute.For()); CertifierContract = new CertifierContract( abiEncoder, RegisterContract, - ReadOnlyTransactionProcessorSource); + ReadOnlyTransactionProcessorSource, + Substitute.For()); return new AuRaBlockProcessor( SpecProvider, diff --git a/src/Nethermind/Nethermind.AuRa.Test/Validators/ContractBasedValidatorTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Validators/ContractBasedValidatorTests.cs index 6448452b0a3..e8d0a80184d 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Validators/ContractBasedValidatorTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Validators/ContractBasedValidatorTests.cs @@ -90,7 +90,7 @@ public void SetUp() .Encode(AbiEncodingStyle.IncludeSignature, Arg.Is(s => s.Name == "finalizeChange"), Arg.Any()) .Returns(_finalizeChangeData.TransactionData); - _validatorContract = new ValidatorContract(_transactionProcessor, _abiEncoder, _contractAddress, _stateProvider, _readOnlyTxProcessorSource, new Signer(0, TestItem.PrivateKeyD, LimboLogs.Instance)); + _validatorContract = new ValidatorContract(_transactionProcessor, _abiEncoder, _contractAddress, _stateProvider, _readOnlyTxProcessorSource, new Signer(0, TestItem.PrivateKeyD, LimboLogs.Instance), TestSpecProvider.Instance); } [TearDown] diff --git a/src/Nethermind/Nethermind.Evm.Benchmark/EvmBenchmarks.cs b/src/Nethermind/Nethermind.Evm.Benchmark/EvmBenchmarks.cs index b29fcf00088..368fc710537 100644 --- a/src/Nethermind/Nethermind.Evm.Benchmark/EvmBenchmarks.cs +++ b/src/Nethermind/Nethermind.Evm.Benchmark/EvmBenchmarks.cs @@ -54,7 +54,7 @@ public void GlobalSetup() codeInfo: new CodeInfo(ByteCode), value: 0, transferValue: 0, - txExecutionContext: new TxExecutionContext(_header, Address.Zero, 0, null, codeInfoRepository), + txExecutionContext: new TxExecutionContext(new BlockExecutionContext(_header, _spec), Address.Zero, 0, null, codeInfoRepository), inputData: default ); diff --git a/src/Nethermind/Nethermind.Evm.Benchmark/MultipleUnsignedOperations.cs b/src/Nethermind/Nethermind.Evm.Benchmark/MultipleUnsignedOperations.cs index 97d0d9e6cf8..04a0964cc57 100644 --- a/src/Nethermind/Nethermind.Evm.Benchmark/MultipleUnsignedOperations.cs +++ b/src/Nethermind/Nethermind.Evm.Benchmark/MultipleUnsignedOperations.cs @@ -87,7 +87,7 @@ public void GlobalSetup() codeInfo: new CodeInfo(_bytecode.Concat(_bytecode).Concat(_bytecode).Concat(_bytecode).ToArray()), value: 0, transferValue: 0, - txExecutionContext: new TxExecutionContext(_header, Address.Zero, 0, null, codeInfoRepository), + txExecutionContext: new TxExecutionContext(new BlockExecutionContext(_header, _spec), Address.Zero, 0, null, codeInfoRepository), inputData: default ); diff --git a/src/Nethermind/Nethermind.Evm.Benchmark/StaticCallBenchmarks.cs b/src/Nethermind/Nethermind.Evm.Benchmark/StaticCallBenchmarks.cs index b7b8d39945b..ec3e37c276f 100644 --- a/src/Nethermind/Nethermind.Evm.Benchmark/StaticCallBenchmarks.cs +++ b/src/Nethermind/Nethermind.Evm.Benchmark/StaticCallBenchmarks.cs @@ -98,7 +98,7 @@ public void GlobalSetup() codeInfo: new CodeInfo(Bytecode), value: 0, transferValue: 0, - txExecutionContext: new TxExecutionContext(_header, Address.Zero, 0, null, codeInfoRepository), + txExecutionContext: new TxExecutionContext(new BlockExecutionContext(_header, _spec), Address.Zero, 0, null, codeInfoRepository), inputData: default ); diff --git a/src/Nethermind/Nethermind.Evm.Test/EvmPooledMemoryTests.cs b/src/Nethermind/Nethermind.Evm.Test/EvmPooledMemoryTests.cs index 4e2a02c91e7..73124ae837f 100644 --- a/src/Nethermind/Nethermind.Evm.Test/EvmPooledMemoryTests.cs +++ b/src/Nethermind/Nethermind.Evm.Test/EvmPooledMemoryTests.cs @@ -196,7 +196,7 @@ private static string Run(byte[] input) MyTracer tracer = new(); transactionProcessor.Execute( tx, - new BlockExecutionContext(block.Header, specProvider), + new BlockExecutionContext(block.Header, specProvider.GetSpec(block.Header)), tracer); return tracer.lastmemline; } diff --git a/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs b/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs index ae8a5fc51de..6502db59b7d 100644 --- a/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs +++ b/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs @@ -30,7 +30,7 @@ public static ulong CalculateBlobGas(Transaction[] transactions) return CalculateBlobGas(blobCount); } - public static bool TryCalculateBlobBaseFee(BlockHeader header, Transaction transaction, out UInt256 blobBaseFee, IReleaseSpec spec) + public static bool TryCalculateBlobBaseFee(BlockHeader header, Transaction transaction, out UInt256 blobBaseFee, IReleaseSpec? spec = null) { if (!TryCalculateFeePerBlobGas(header.ExcessBlobGas, out UInt256 feePerBlobGas, header.TargetBlobCount, spec)) { @@ -40,12 +40,12 @@ public static bool TryCalculateBlobBaseFee(BlockHeader header, Transaction trans return !UInt256.MultiplyOverflow(CalculateBlobGas(transaction), feePerBlobGas, out blobBaseFee); } - public static bool TryCalculateFeePerBlobGas(BlockHeader header, out UInt256 feePerBlobGas, IReleaseSpec spec) + public static bool TryCalculateFeePerBlobGas(BlockHeader header, out UInt256 feePerBlobGas, IReleaseSpec? spec = null) { return TryCalculateFeePerBlobGas(header.ExcessBlobGas, out feePerBlobGas, header.TargetBlobCount, spec); } - public static bool TryCalculateFeePerBlobGas(ulong? excessBlobGas, out UInt256 feePerBlobGas, UInt256? targetBlobCount, IReleaseSpec? spec) + public static bool TryCalculateFeePerBlobGas(ulong? excessBlobGas, out UInt256 feePerBlobGas, UInt256? targetBlobCount = null, IReleaseSpec? spec = null) { static bool FakeExponentialOverflow(UInt256 factor, UInt256 num, UInt256 denominator, out UInt256 feePerBlobGas) { diff --git a/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs b/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs index 23386d27d4e..36ee70dae5a 100644 --- a/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs +++ b/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs @@ -141,7 +141,7 @@ protected override IBlockProcessor CreateBlockProcessor() }; WithdrawalContractFactory withdrawalContractFactory = new(_api.ChainSpec!.EngineChainSpecParametersProvider - .GetChainSpecParameters(), _api.AbiEncoder); + .GetChainSpecParameters(), _api.AbiEncoder, _api.SpecProvider); WithdrawalProcessor = new AuraWithdrawalProcessor( withdrawalContractFactory.Create(TxProcessor), LogManager diff --git a/src/Nethermind/Nethermind.Shutter.Test/ShutterApiSimulator.cs b/src/Nethermind/Nethermind.Shutter.Test/ShutterApiSimulator.cs index 68616f48c68..33f7f1fca0d 100644 --- a/src/Nethermind/Nethermind.Shutter.Test/ShutterApiSimulator.cs +++ b/src/Nethermind/Nethermind.Shutter.Test/ShutterApiSimulator.cs @@ -121,7 +121,7 @@ protected override void InitP2P(IPAddress _) P2P = Substitute.For(); } - protected override IShutterEon InitEon() + protected override IShutterEon InitEon(ISpecProvider specProvider) { IShutterEon eon = Substitute.For(); eon.GetCurrentEonInfo().Returns(_ => eventSimulator.GetCurrentEonInfo()); diff --git a/src/Nethermind/Nethermind.Shutter.Test/ShutterEventSimulator.cs b/src/Nethermind/Nethermind.Shutter.Test/ShutterEventSimulator.cs index 06460d48b08..5198dd6b357 100644 --- a/src/Nethermind/Nethermind.Shutter.Test/ShutterEventSimulator.cs +++ b/src/Nethermind/Nethermind.Shutter.Test/ShutterEventSimulator.cs @@ -14,7 +14,7 @@ using Nethermind.Serialization.Rlp; using Nethermind.Core.Test.Builders; using Nethermind.Abi; - +using Nethermind.Core.Specs; using G1 = Nethermind.Crypto.Bls.P1; using G2 = Nethermind.Crypto.Bls.P2; using EncryptedMessage = Nethermind.Shutter.ShutterCrypto.EncryptedMessage; @@ -45,7 +45,8 @@ public ShutterEventSimulator( ulong threshold, ulong slot, IAbiEncoder abiEncoder, - Address sequencerContractAddress + Address sequencerContractAddress, + ISpecProvider specProvider ) { _rnd = rnd; @@ -56,7 +57,7 @@ Address sequencerContractAddress _threshold = threshold; _abiEncoder = abiEncoder; _sequencerContractAddress = sequencerContractAddress; - _transactionSubmittedAbi = new SequencerContract(sequencerContractAddress).TransactionSubmittedAbi; + _transactionSubmittedAbi = new SequencerContract(sequencerContractAddress, specProvider).TransactionSubmittedAbi; _defaultMaxKeyCount = (int)Math.Floor((decimal)ShutterTestsCommon.Cfg.EncryptedGasLimit / DefaultGasLimit); _eventSource = EmitEvents(); diff --git a/src/Nethermind/Nethermind.Shutter.Test/ShutterTestsCommon.cs b/src/Nethermind/Nethermind.Shutter.Test/ShutterTestsCommon.cs index 5f0689493b0..f1557c73531 100644 --- a/src/Nethermind/Nethermind.Shutter.Test/ShutterTestsCommon.cs +++ b/src/Nethermind/Nethermind.Shutter.Test/ShutterTestsCommon.cs @@ -78,7 +78,8 @@ public static ShutterEventSimulator InitEventSimulator(Random rnd) Threshold, InitialSlot, AbiEncoder, - new(Cfg.SequencerContractAddress!) + new(Cfg.SequencerContractAddress!), + SpecProvider ); public static Timestamper InitTimestamper(ulong slotTimestamp, ulong offsetMs) diff --git a/src/Nethermind/Nethermind.Shutter.Test/ShutterTxLoaderTests.cs b/src/Nethermind/Nethermind.Shutter.Test/ShutterTxLoaderTests.cs index fa428ea8694..e81cbc8b40f 100644 --- a/src/Nethermind/Nethermind.Shutter.Test/ShutterTxLoaderTests.cs +++ b/src/Nethermind/Nethermind.Shutter.Test/ShutterTxLoaderTests.cs @@ -9,6 +9,7 @@ using Nethermind.Merge.Plugin; using Nethermind.Merge.Plugin.Data; using Nethermind.Abi; +using Nethermind.Core.Specs; using Nethermind.Core.Test.Builders; using Nethermind.Merge.Plugin.Test; @@ -17,27 +18,7 @@ namespace Nethermind.Shutter.Test; [TestFixture] class ShutterTxLoaderTests : EngineModuleTests { - private class ShutterEventSimulatorHalfInvalid(Random rnd, ulong chainId, ulong threshold, ulong slot, IAbiEncoder abiEncoder, Address sequencerContractAddress) : ShutterEventSimulator(rnd, chainId, threshold, slot, abiEncoder, sequencerContractAddress) - { - private readonly Transaction _validTx = Build.A.Transaction.WithChainId(chainId).Signed().TestObject; - private readonly Transaction _invalidTx = Build.A.Transaction.TestObject; - protected override IEnumerable EmitEvents() - { - IEnumerable EmitHalfInvalid() - { - bool valid = false; - while (true) - { - valid = !valid; - yield return valid ? _validTx : _invalidTx; - } - } - - return EmitEvents(EmitDefaultEons(), EmitHalfInvalid()); - } - } - - private class ShutterEventSimulatorHalfNextEon(Random rnd, ulong chainId, ulong threshold, ulong slot, IAbiEncoder abiEncoder, Address sequencerContractAddress) : ShutterEventSimulator(rnd, chainId, threshold, slot, abiEncoder, sequencerContractAddress) + private class ShutterEventSimulatorHalfNextEon(Random rnd, ulong chainId, ulong threshold, ulong slot, IAbiEncoder abiEncoder, Address sequencerContractAddress, ISpecProvider specProvider) : ShutterEventSimulator(rnd, chainId, threshold, slot, abiEncoder, sequencerContractAddress, specProvider) { protected override IEnumerable EmitEvents() { @@ -86,7 +67,8 @@ public async Task Can_load_and_filter_transactions() ShutterTestsCommon.Threshold, ShutterTestsCommon.InitialSlot, ShutterTestsCommon.AbiEncoder, - new(ShutterTestsCommon.Cfg.SequencerContractAddress!) + new(ShutterTestsCommon.Cfg.SequencerContractAddress!), + ShutterTestsCommon.SpecProvider ); using var chain = (ShutterTestBlockchain)await new ShutterTestBlockchain(rnd, null, eventSimulator).Build(ShutterTestsCommon.SpecProvider); @@ -199,7 +181,8 @@ public async Task Can_load_transactions_with_overlapping_eons() ShutterTestsCommon.Threshold, ShutterTestsCommon.InitialSlot, ShutterTestsCommon.AbiEncoder, - new(ShutterTestsCommon.Cfg.SequencerContractAddress!) + new(ShutterTestsCommon.Cfg.SequencerContractAddress!), + ShutterTestsCommon.SpecProvider ); using var chain = (ShutterTestBlockchain)await new ShutterTestBlockchain(rnd, null, eventSimulator).Build(ShutterTestsCommon.SpecProvider); diff --git a/src/Nethermind/Nethermind.Shutter.Test/ShutterValidatorRegistryTests.cs b/src/Nethermind/Nethermind.Shutter.Test/ShutterValidatorRegistryTests.cs index 0a41c7bbd03..e84e68845df 100644 --- a/src/Nethermind/Nethermind.Shutter.Test/ShutterValidatorRegistryTests.cs +++ b/src/Nethermind/Nethermind.Shutter.Test/ShutterValidatorRegistryTests.cs @@ -12,7 +12,7 @@ using Nethermind.Shutter.Config; using Nethermind.Crypto; using Nethermind.Core.Crypto; - +using Nethermind.Core.Specs; using Update = (byte[] Message, byte[] Signature); using G1 = Nethermind.Crypto.Bls.P1; @@ -32,7 +32,8 @@ public void Can_check_if_registered() Address.Zero, LimboLogs.Instance, ShutterTestsCommon.ChainId, - 1); + 1, + Substitute.For()); ShutterValidatorsInfo validatorsInfo = new(); List<(uint, Update)> updates = []; From a4fd1efd608570aad98013dc70073628734c8f31 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Tue, 5 Nov 2024 13:36:56 +0600 Subject: [PATCH 26/68] fix Evm tool --- tools/Evm/T8n/T8nExecutor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Evm/T8n/T8nExecutor.cs b/tools/Evm/T8n/T8nExecutor.cs index a1ed85939f9..520fad40ed4 100644 --- a/tools/Evm/T8n/T8nExecutor.cs +++ b/tools/Evm/T8n/T8nExecutor.cs @@ -102,7 +102,7 @@ public static T8nResult Execute(T8nCommandArguments arguments) blockReceiptsTracer.StartNewTxTrace(transaction); TransactionResult transactionResult = transactionProcessor - .Execute(transaction, new BlockExecutionContext(block.Header), blockReceiptsTracer); + .Execute(transaction, new BlockExecutionContext(block.Header, test.Spec), blockReceiptsTracer); blockReceiptsTracer.EndTxTrace(); transactionExecutionReport.ValidTransactions.Add(transaction); From d022c4f1462d3dfd97d068c9968731f12ac9aff5 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Tue, 5 Nov 2024 13:39:52 +0600 Subject: [PATCH 27/68] fix Evm tool --- tools/Evm/T8n/T8nTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Evm/T8n/T8nTest.cs b/tools/Evm/T8n/T8nTest.cs index 6d88aae73b4..90d6e287da0 100644 --- a/tools/Evm/T8n/T8nTest.cs +++ b/tools/Evm/T8n/T8nTest.cs @@ -65,7 +65,7 @@ private BlockHeader ConstructBlockHeader() .WithExcessBlobGas((ulong)ParentExcessBlobGas) .WithBlobGasUsed((ulong)ParentBlobGasUsed) .TestObject; - header.ExcessBlobGas = BlobGasCalculator.CalculateExcessBlobGas(parentHeader, Spec); + header.ExcessBlobGas = BlobGasCalculator.CalculateExcessBlobGas(parentHeader, Spec, header); } header.BlobGasUsed = BlobGasCalculator.CalculateBlobGas(Transactions); header.IsPostMerge = Spec is Paris; From 020ceefb3c4dedaa81fcf67a17f4cdc15ad0c659 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 25 Nov 2024 18:15:26 +0500 Subject: [PATCH 28/68] resolve merge conflicts --- .../ExecutionRequests/ExecutionRequestProcessor.cs | 2 +- .../Nethermind.Merge.Plugin/IEngineRpcModule.Prague.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Consensus/ExecutionRequests/ExecutionRequestProcessor.cs b/src/Nethermind/Nethermind.Consensus/ExecutionRequests/ExecutionRequestProcessor.cs index 7d79e8950df..8f1d5d62621 100644 --- a/src/Nethermind/Nethermind.Consensus/ExecutionRequests/ExecutionRequestProcessor.cs +++ b/src/Nethermind/Nethermind.Consensus/ExecutionRequests/ExecutionRequestProcessor.cs @@ -119,7 +119,7 @@ private byte[] ReadRequests(Block block, IWorldState state, IReleaseSpec spec, A CallOutputTracer tracer = new(); - _transactionProcessor.Execute(isWithdrawalRequests ? _withdrawalTransaction : _consolidationTransaction, new BlockExecutionContext(block.Header), tracer); + _transactionProcessor.Execute(isWithdrawalRequests ? _withdrawalTransaction : _consolidationTransaction, new BlockExecutionContext(block.Header, spec), tracer); if (tracer.ReturnValue is null || tracer.ReturnValue.Length == 0) { diff --git a/src/Nethermind/Nethermind.Merge.Plugin/IEngineRpcModule.Prague.cs b/src/Nethermind/Nethermind.Merge.Plugin/IEngineRpcModule.Prague.cs index 8363b084631..b46a3313181 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/IEngineRpcModule.Prague.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/IEngineRpcModule.Prague.cs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: LGPL-3.0-only using System.Threading.Tasks; +using Nethermind.Consensus.Producers; using Nethermind.Core.Crypto; using Nethermind.JsonRpc; using Nethermind.JsonRpc.Modules; From 5699ad496956d368d9b225063d48c39622e12b39 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Tue, 26 Nov 2024 13:25:12 +0500 Subject: [PATCH 29/68] fix some tests --- .../Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs | 2 +- .../Nethermind.Evm.Test/TransactionProcessorFeeTests.cs | 2 +- src/Nethermind/Nethermind.Evm.Test/VirtualMachineTestsBase.cs | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs b/src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs index 15001bfdf46..086fc48ad09 100644 --- a/src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs +++ b/src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs @@ -149,6 +149,6 @@ public void Test_StoreBeaconRoot_AccessListNotNull() transaction.Hash = transaction.CalculateHash(); _transactionProcessor.Received().Execute(Arg.Is(t => - t.Hash == transaction.Hash), header, NullTxTracer.Instance); + t.Hash == transaction.Hash), new BlockExecutionContext(header, Cancun.Instance), NullTxTracer.Instance); } } diff --git a/src/Nethermind/Nethermind.Evm.Test/TransactionProcessorFeeTests.cs b/src/Nethermind/Nethermind.Evm.Test/TransactionProcessorFeeTests.cs index 1fcc3537729..0426687faaf 100644 --- a/src/Nethermind/Nethermind.Evm.Test/TransactionProcessorFeeTests.cs +++ b/src/Nethermind/Nethermind.Evm.Test/TransactionProcessorFeeTests.cs @@ -119,7 +119,7 @@ public void Check_paid_fees_with_blob(bool withFeeCollector) initialBalance = _stateProvider.GetBalance(TestItem.AddressC); } - BlockHeader header = Build.A.BlockHeader.WithExcessBlobGas(0).TestObject; + BlockHeader header = Build.A.BlockHeader.WithExcessBlobGas(0).WithTargetBlobCount(3).TestObject; Transaction tx = Build.A.Transaction .SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA).WithType(TxType.Blob) diff --git a/src/Nethermind/Nethermind.Evm.Test/VirtualMachineTestsBase.cs b/src/Nethermind/Nethermind.Evm.Test/VirtualMachineTestsBase.cs index c84f7145fa1..7815e186e72 100644 --- a/src/Nethermind/Nethermind.Evm.Test/VirtualMachineTestsBase.cs +++ b/src/Nethermind/Nethermind.Evm.Test/VirtualMachineTestsBase.cs @@ -335,6 +335,7 @@ protected virtual Block BuildBlock(ForkActivation activation, SenderRecipientAnd .WithExcessBlobGas(0) .WithParentBeaconBlockRoot(TestItem.KeccakG) .WithExcessBlobGas(excessBlobGas) + .WithTargetBlobCount(3) .TestObject; } From 332322de22b4009770914c5a4cc50e7d3833149b Mon Sep 17 00:00:00 2001 From: yerke26 Date: Wed, 27 Nov 2024 11:40:41 +0500 Subject: [PATCH 30/68] fix tests --- .../Nethermind.Core.Test/Blockchain/TestBlockchain.cs | 5 +++++ .../EngineModuleTests.HelperFunctions.cs | 1 + .../Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs | 8 ++++---- .../Nethermind.Merge.Plugin/Data/ExecutionPayload.cs | 2 ++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs b/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs index d8411dcd46d..37ac6bdfedc 100644 --- a/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs +++ b/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs @@ -368,6 +368,11 @@ protected virtual Block GetGenesisBlock() genesisBlockBuilder.WithEmptyRequestsHash(); } + if (SpecProvider.GenesisSpec.IsEip7742Enabled) + { + genesisBlockBuilder.WithTargetBlobCount(0); + } + genesisBlockBuilder.WithStateRoot(State.StateRoot); return genesisBlockBuilder.TestObject; } diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.HelperFunctions.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.HelperFunctions.cs index 95e50537657..eb163e997bc 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.HelperFunctions.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.HelperFunctions.cs @@ -96,6 +96,7 @@ protected ExecutionPayload CreateParentBlockRequestOnHead(IBlockTree blockTree) GasLimit = head.GasLimit, Timestamp = head.Timestamp, BaseFeePerGas = head.BaseFeePerGas, + TargetBlobCount = head.TargetBlobCount, }; } diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs index d383bc2dbbe..8416f435a3e 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs @@ -24,10 +24,10 @@ namespace Nethermind.Merge.Plugin.Test; public partial class EngineModuleTests { [TestCase( - "0xd7e58364f16b4a329b959b166f9c32323cb135669335db5dadd0344568f8dc9a", - "0xfafb92e8ece12d5fcfa867df9ae6865c5bd8aaf0b277c244552bfe869f61fb26", + "0xffcfa58bd573f32084c9e33f52be0c07f26f2b416aeb3a564f75a5b3b2702d6c", + "0xc07d3d9dc7ba2d475938961a90e4317b8109942241edc1201c2a44085c274b38", "0xa272b2f949e4a0e411c9b45542bd5d0ef3c311b5f26c4ed6b7a8d4f605a91154", - "0x774c6aff527bbc68")] + "0x039cc417630de68a")] public virtual async Task Should_process_block_as_expected_V4(string latestValidHash, string blockHash, string stateRoot, string payloadId) { @@ -283,7 +283,7 @@ private async Task BuildAndGetPayloadOnBranchV4( SuggestedFeeRecipient = feeRecipient, ParentBeaconBlockRoot = Keccak.Zero, Withdrawals = [], - TargetBlobCount = 0, + TargetBlobCount = parentHeader.TargetBlobCount, }; // we're using payloadService directly, because we can't use fcU for branch diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs index 1a5ad3c9266..0912948082d 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs @@ -131,6 +131,7 @@ public byte[][] Transactions Timestamp = block.Timestamp, BaseFeePerGas = block.BaseFeePerGas, Withdrawals = block.Withdrawals, + TargetBlobCount = block.TargetBlobCount, }; executionPayload.SetTransactions(block.Transactions); return executionPayload; @@ -170,6 +171,7 @@ public virtual bool TryGetBlock([NotNullWhen(true)] out Block? block, UInt256? t TotalDifficulty = totalDifficulty, TxRoot = TxTrie.CalculateRoot(transactions), WithdrawalsRoot = Withdrawals is null ? null : new WithdrawalTrie(Withdrawals).RootHash, + TargetBlobCount = TargetBlobCount, }; block = new(header, transactions, Array.Empty(), Withdrawals); From 91822aa8d67021701cef8d487dd852cb1a6fc12b Mon Sep 17 00:00:00 2001 From: yerke26 Date: Thu, 28 Nov 2024 16:58:26 +0500 Subject: [PATCH 31/68] fix AuraTests --- .../Contract/ValidatorContractTests.cs | 2 +- .../Reward/AuRaRewardCalculatorTests.cs | 2 +- .../Validators/ContractBasedValidatorTests.cs | 8 ++++---- .../Contracts/CallableContract.cs | 2 +- .../Nethermind.Blockchain/Contracts/Contract.cs | 4 ++-- .../Nethermind.Facade.Test/BlockchainBridgeTests.cs | 10 +++++----- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Nethermind/Nethermind.AuRa.Test/Contract/ValidatorContractTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Contract/ValidatorContractTests.cs index 7b6b345fcaa..09d920e1f17 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Contract/ValidatorContractTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Contract/ValidatorContractTests.cs @@ -86,7 +86,7 @@ public void finalize_change_should_call_correct_transaction() contract.FinalizeChange(_block.Header); _transactionProcessor.Received().Execute( - Arg.Is(t => IsEquivalentTo(expectation, t)), Arg.Is(blkCtx => blkCtx.Header.Equals(_block.Header)), Arg.Any()); + Arg.Is(t => IsEquivalentTo(expectation, t)), Arg.Is(blockHeader => blockHeader.Equals(_block.Header)), Arg.Any()); } private static bool IsEquivalentTo(Transaction expected, Transaction item) diff --git a/src/Nethermind/Nethermind.AuRa.Test/Reward/AuRaRewardCalculatorTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Reward/AuRaRewardCalculatorTests.cs index 8a13ded0020..00eb2a777ec 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Reward/AuRaRewardCalculatorTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Reward/AuRaRewardCalculatorTests.cs @@ -199,7 +199,7 @@ private void SetupBlockRewards(IDictionary rewards) { _transactionProcessor.When(x => x.Execute( Arg.Is(t => CheckTransaction(t, rewards.Keys, _rewardData)), - Arg.Is(blkCtx => blkCtx.Header.Equals(_block.Header)), + Arg.Is(header => header.Equals(_block.Header)), Arg.Is(t => t is CallOutputTracer))) .Do(args => { diff --git a/src/Nethermind/Nethermind.AuRa.Test/Validators/ContractBasedValidatorTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Validators/ContractBasedValidatorTests.cs index cf7a466f97b..777c651afc7 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Validators/ContractBasedValidatorTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Validators/ContractBasedValidatorTests.cs @@ -184,13 +184,13 @@ public void loads_initial_validators_from_contract(long blockNumber) _transactionProcessor.Received() .CallAndRestore( Arg.Is(t => CheckTransaction(t, _getValidatorsData)), - Arg.Is(blkCtx => blkCtx.Header.Equals(_parentHeader)), + Arg.Is(blockHeader => blockHeader.Equals(_parentHeader)), Arg.Is(t => t is CallOutputTracer)); // finalizeChange should be called _transactionProcessor.Received(finalizeChangeCalled ? 1 : 0) .Execute(Arg.Is(t => CheckTransaction(t, _finalizeChangeData)), - Arg.Is(blkCtx => blkCtx.Header.Equals(block.Header)), + Arg.Is(blockHeader => blockHeader.Equals(block.Header)), Arg.Is(t => t is CallOutputTracer)); // initial validator should be true @@ -603,7 +603,7 @@ private void ValidateFinalizationForChain(ConsecutiveInitiateChangeTestParameter // finalizeChange should be called or not based on test spec _transactionProcessor.Received(chain.ExpectedFinalizationCount) .Execute(Arg.Is(t => CheckTransaction(t, _finalizeChangeData)), - Arg.Is(blkCtx => blkCtx.Header.Equals(_block.Header)), + Arg.Is(header => header.Equals(_block.Header)), Arg.Is(t => t is CallOutputTracer)); _transactionProcessor.ClearReceivedCalls(); @@ -634,7 +634,7 @@ private void SetupInitialValidators(BlockHeader header, BlockHeader parentHeader _transactionProcessor.When(x => x.CallAndRestore( Arg.Is(t => CheckTransaction(t, _getValidatorsData)), - Arg.Any(), + Arg.Any(), Arg.Is(t => t is CallOutputTracer))) .Do(args => args.Arg().MarkAsSuccess( diff --git a/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs b/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs index 52aefe6f9ff..ad43f8cd9a6 100644 --- a/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs +++ b/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs @@ -68,7 +68,7 @@ private bool TryCall(BlockHeader header, Transaction transaction, out byte[] res try { - _transactionProcessor.Execute(transaction, new BlockExecutionContext(header, SpecProvider.GetSpec(header)), tracer); + _transactionProcessor.Execute(transaction, header, tracer); result = tracer.ReturnValue; return tracer.StatusCode == StatusCode.Success; } diff --git a/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs b/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs index e9fe5e04935..8f90bd18b18 100644 --- a/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs +++ b/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs @@ -182,11 +182,11 @@ protected byte[] CallCore(ITransactionProcessor transactionProcessor, BlockHeade { if (callAndRestore) { - transactionProcessor.CallAndRestore(transaction, new BlockExecutionContext(header, SpecProvider.GetSpec(header)), tracer); + transactionProcessor.CallAndRestore(transaction, header, tracer); } else { - transactionProcessor.Execute(transaction, new BlockExecutionContext(header, SpecProvider.GetSpec(header)), tracer); + transactionProcessor.Execute(transaction, header, tracer); } failure = tracer.StatusCode != StatusCode.Success; diff --git a/src/Nethermind/Nethermind.Facade.Test/BlockchainBridgeTests.cs b/src/Nethermind/Nethermind.Facade.Test/BlockchainBridgeTests.cs index 9986a989509..4cad78d270a 100644 --- a/src/Nethermind/Nethermind.Facade.Test/BlockchainBridgeTests.cs +++ b/src/Nethermind/Nethermind.Facade.Test/BlockchainBridgeTests.cs @@ -153,8 +153,8 @@ public void Call_uses_valid_post_merge_and_random_value() _blockchainBridge.Call(header, tx); _transactionProcessor.Received().CallAndRestore( tx, - Arg.Is(blkCtx => - blkCtx.Header.IsPostMerge && blkCtx.Header.Random == TestItem.KeccakA), + Arg.Is(blockHeader => + blockHeader.IsPostMerge && blockHeader.Random == TestItem.KeccakA), Arg.Any()); } @@ -169,7 +169,7 @@ public void Call_uses_valid_block_number() _blockchainBridge.Call(header, tx); _transactionProcessor.Received().CallAndRestore( tx, - Arg.Is(blkCtx => blkCtx.Header.Number == 10), + Arg.Is(blockHeader => blockHeader.Number == 10), Arg.Any()); } @@ -184,7 +184,7 @@ public void Call_uses_valid_mix_hash() _blockchainBridge.Call(header, tx); _transactionProcessor.Received().CallAndRestore( tx, - Arg.Is(blkCtx => blkCtx.Header.MixHash == TestItem.KeccakA), + Arg.Is(blockHeader => blockHeader.MixHash == TestItem.KeccakA), Arg.Any()); } @@ -199,7 +199,7 @@ public void Call_uses_valid_beneficiary() _blockchainBridge.Call(header, tx); _transactionProcessor.Received().CallAndRestore( tx, - Arg.Is(blkCtx => blkCtx.Header.Beneficiary == TestItem.AddressB), + Arg.Is(blockHeader => blockHeader.Beneficiary == TestItem.AddressB), Arg.Any()); } From b4790dde16cad65d079cb9864b2935827b83afb9 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Thu, 28 Nov 2024 17:12:25 +0500 Subject: [PATCH 32/68] fix tests --- src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs | 1 + .../AuRaMergeEngineModuleTests.cs | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs b/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs index 0a206cfa020..fbad6560b67 100644 --- a/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs +++ b/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs @@ -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; + if (test.Fork is Prague) header.TargetBlobCount = 0; Stopwatch stopwatch = Stopwatch.StartNew(); IReleaseSpec? spec = specProvider.GetSpec((ForkActivation)test.CurrentNumber); diff --git a/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs b/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs index 5df5fba8711..4066dac41c2 100644 --- a/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs +++ b/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs @@ -62,10 +62,10 @@ int ErrorCode => base.forkchoiceUpdatedV2_should_validate_withdrawals(input); [TestCase( - "0xd25128557a58fe7bb6346d779cfc86a1f5bd9bff4786a118097aebdf3128f46d", - "0xcbf0d15de352e744aba609aca74846ede5fc3ffd00ca506914b498b00470cbf8", + "0x8c991b526ff658e90a4a4d4c1e83dd55aee17c5467e71599690967c83c0b9c2f", + "0x445476686cccd0ee909b5e514b15389b7b6ddb01ab8048c30f4f9f130286f3fb", "0xd75d320c3a98a02ec7fe2abdcb1769bd063fec04d73f1735810f365ac12bc4ba", - "0xc9763e9904d3fe5b")] + "0x99ac9270a267569a")] public override Task Should_process_block_as_expected_V4(string latestValidHash, string blockHash, string stateRoot, string payloadId) => base.Should_process_block_as_expected_V4(latestValidHash, blockHash, stateRoot, payloadId); From 36464add21de30567340a3bf934f0c457fc96ee6 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Thu, 28 Nov 2024 19:08:51 +0500 Subject: [PATCH 33/68] fix JsonRpcTests --- .../Nethermind.Consensus/Producers/BuildBlocksWhenRequested.cs | 2 +- .../Nethermind.Core.Test/Blockchain/TestBlockchain.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nethermind/Nethermind.Consensus/Producers/BuildBlocksWhenRequested.cs b/src/Nethermind/Nethermind.Consensus/Producers/BuildBlocksWhenRequested.cs index 90e4d26acd9..71384811ac9 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/BuildBlocksWhenRequested.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/BuildBlocksWhenRequested.cs @@ -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); diff --git a/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs b/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs index 37ac6bdfedc..ff89eb204a3 100644 --- a/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs +++ b/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs @@ -445,7 +445,7 @@ private async Task 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 = 0}).ConfigureAwait(false); await headProcessed.WaitAsync().ConfigureAwait(false); return txResults; } From 459ebb76e8b9e8065ed419b6a0feb6af67b8d34e Mon Sep 17 00:00:00 2001 From: yerke26 Date: Thu, 28 Nov 2024 23:29:49 +0500 Subject: [PATCH 34/68] fix TraceRpcModuleTests --- .../Nethermind.JsonRpc.Test/Modules/TraceRpcModuleTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/TraceRpcModuleTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/TraceRpcModuleTests.cs index d429cac1300..4c11a390ecc 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/TraceRpcModuleTests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/TraceRpcModuleTests.cs @@ -89,7 +89,7 @@ public async Task Tx_positions_are_fine() string serialized = await RpcTest.TestSerializedRequest( context.TraceRpcModule, "trace_block", "latest"); - Assert.That(serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":[{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xa1e0e640b433d5a8931881b8eee7b1a125474b04e430c0bf8afff52584c53273\",\"transactionPosition\":0,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x5cf5d4a0a93000beb1cfb373508ce4c0153ab491be99b3c927f482346c86a0e1\",\"transactionPosition\":1,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x02d2cde9120e37722f607771ebaa0d4e98c5d99a8a9e7df6872e8c8c9f5c0bc5\",\"transactionPosition\":2,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xe50a2a2d170011b1f9ee080c3810bed0c63dbb1b2b2c541c78ada5b222cc3fd2\",\"transactionPosition\":3,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xff0d4524d379fc15c41a9b0444b943e1a530779b7d09c8863858267c5ef92b24\",\"transactionPosition\":4,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xf9b69366c82084e3799dc4a7ad87dc173ef4923d853bc250de86b81786f2972a\",\"transactionPosition\":5,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x28171c29b23cd96f032fe43f444402af4555ee5f074d5d0d0a1089d940f136e7\",\"transactionPosition\":6,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x09b01caf4b7ecfe9d02251b2e478f2da0fdf08412e3fa1ff963fa80635dab031\",\"transactionPosition\":7,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xd82382905afbe4ca4c2b8e54cea43818c91e0014c3827e3020fbd82b732b8239\",\"transactionPosition\":8,\"type\":\"call\"},{\"action\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"rewardType\":\"block\",\"value\":\"0x1bc16d674ec80000\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"subtraces\":0,\"traceAddress\":[],\"type\":\"reward\"}],\"id\":67}")); + Assert.That(serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":[{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xa1e0e640b433d5a8931881b8eee7b1a125474b04e430c0bf8afff52584c53273\",\"transactionPosition\":0,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x5cf5d4a0a93000beb1cfb373508ce4c0153ab491be99b3c927f482346c86a0e1\",\"transactionPosition\":1,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x02d2cde9120e37722f607771ebaa0d4e98c5d99a8a9e7df6872e8c8c9f5c0bc5\",\"transactionPosition\":2,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xe50a2a2d170011b1f9ee080c3810bed0c63dbb1b2b2c541c78ada5b222cc3fd2\",\"transactionPosition\":3,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xff0d4524d379fc15c41a9b0444b943e1a530779b7d09c8863858267c5ef92b24\",\"transactionPosition\":4,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xf9b69366c82084e3799dc4a7ad87dc173ef4923d853bc250de86b81786f2972a\",\"transactionPosition\":5,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x28171c29b23cd96f032fe43f444402af4555ee5f074d5d0d0a1089d940f136e7\",\"transactionPosition\":6,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x09b01caf4b7ecfe9d02251b2e478f2da0fdf08412e3fa1ff963fa80635dab031\",\"transactionPosition\":7,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xd82382905afbe4ca4c2b8e54cea43818c91e0014c3827e3020fbd82b732b8239\",\"transactionPosition\":8,\"type\":\"call\"},{\"action\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"rewardType\":\"block\",\"value\":\"0x1bc16d674ec80000\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"subtraces\":0,\"traceAddress\":[],\"type\":\"reward\"}],\"id\":67}")); } [Test] @@ -141,7 +141,7 @@ public async Task Trace_filter_return_expected_json() context.TraceRpcModule, "trace_filter", new EthereumJsonSerializer().Serialize(traceFilterRequest)); - Assert.That(serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":[{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xa1e0e640b433d5a8931881b8eee7b1a125474b04e430c0bf8afff52584c53273\",\"transactionPosition\":0,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x5cf5d4a0a93000beb1cfb373508ce4c0153ab491be99b3c927f482346c86a0e1\",\"transactionPosition\":1,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x02d2cde9120e37722f607771ebaa0d4e98c5d99a8a9e7df6872e8c8c9f5c0bc5\",\"transactionPosition\":2,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xe50a2a2d170011b1f9ee080c3810bed0c63dbb1b2b2c541c78ada5b222cc3fd2\",\"transactionPosition\":3,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xff0d4524d379fc15c41a9b0444b943e1a530779b7d09c8863858267c5ef92b24\",\"transactionPosition\":4,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xf9b69366c82084e3799dc4a7ad87dc173ef4923d853bc250de86b81786f2972a\",\"transactionPosition\":5,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x28171c29b23cd96f032fe43f444402af4555ee5f074d5d0d0a1089d940f136e7\",\"transactionPosition\":6,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x09b01caf4b7ecfe9d02251b2e478f2da0fdf08412e3fa1ff963fa80635dab031\",\"transactionPosition\":7,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xd82382905afbe4ca4c2b8e54cea43818c91e0014c3827e3020fbd82b732b8239\",\"transactionPosition\":8,\"type\":\"call\"},{\"action\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"rewardType\":\"block\",\"value\":\"0x1bc16d674ec80000\"},\"blockHash\":\"0xcd3d2c10309822aec4cbbfa80ba905ba1de62834a3b40f8012520734db2763ca\",\"blockNumber\":15,\"subtraces\":0,\"traceAddress\":[],\"type\":\"reward\"}],\"id\":67}"), serialized.Replace("\"", "\\\"")); + Assert.That(serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":[{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xa1e0e640b433d5a8931881b8eee7b1a125474b04e430c0bf8afff52584c53273\",\"transactionPosition\":0,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x5cf5d4a0a93000beb1cfb373508ce4c0153ab491be99b3c927f482346c86a0e1\",\"transactionPosition\":1,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x02d2cde9120e37722f607771ebaa0d4e98c5d99a8a9e7df6872e8c8c9f5c0bc5\",\"transactionPosition\":2,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xe50a2a2d170011b1f9ee080c3810bed0c63dbb1b2b2c541c78ada5b222cc3fd2\",\"transactionPosition\":3,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xff0d4524d379fc15c41a9b0444b943e1a530779b7d09c8863858267c5ef92b24\",\"transactionPosition\":4,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xf9b69366c82084e3799dc4a7ad87dc173ef4923d853bc250de86b81786f2972a\",\"transactionPosition\":5,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x28171c29b23cd96f032fe43f444402af4555ee5f074d5d0d0a1089d940f136e7\",\"transactionPosition\":6,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x09b01caf4b7ecfe9d02251b2e478f2da0fdf08412e3fa1ff963fa80635dab031\",\"transactionPosition\":7,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xd82382905afbe4ca4c2b8e54cea43818c91e0014c3827e3020fbd82b732b8239\",\"transactionPosition\":8,\"type\":\"call\"},{\"action\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"rewardType\":\"block\",\"value\":\"0x1bc16d674ec80000\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"subtraces\":0,\"traceAddress\":[],\"type\":\"reward\"}],\"id\":67}"), serialized.Replace("\"", "\\\"")); } [Test] @@ -523,7 +523,7 @@ public async Task Trace_transaction_with_error_reverted() traces.Data.ElementAt(0).TransactionHash.Should().Be(transaction2.Hash!); string serialized = new EthereumJsonSerializer().Serialize(traces.Data); - Assert.That(serialized, Is.EqualTo("[{\"action\":{\"creationMethod\":\"create\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x9a6c\",\"init\":\"0x60006000600060006000736b5887043de753ecfa6269f947129068263ffbe261c350f160006000600060006000736b5887043de753ecfa6269f947129068263ffbe261c350f1fd\",\"value\":\"0x1\"},\"blockHash\":\"0xeb0d05efb43e565c4a677e64dde4cd1339459310afe8f578acab57ad45dd8f44\",\"blockNumber\":18,\"subtraces\":2,\"traceAddress\":[],\"transactionHash\":\"0x787616b8756424622f162fc3817331517ef941366f28db452defc0214bc36b22\",\"transactionPosition\":0,\"type\":\"create\",\"error\":\"Reverted\"},{\"action\":{\"callType\":\"call\",\"from\":\"0xd6a48bcd4c5ad5adacfab677519c25ce7b2805a5\",\"gas\":\"0x8def\",\"input\":\"0x\",\"to\":\"0x6b5887043de753ecfa6269f947129068263ffbe2\",\"value\":\"0x0\"},\"blockHash\":\"0xeb0d05efb43e565c4a677e64dde4cd1339459310afe8f578acab57ad45dd8f44\",\"blockNumber\":18,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[0],\"transactionHash\":\"0x787616b8756424622f162fc3817331517ef941366f28db452defc0214bc36b22\",\"transactionPosition\":0,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0xd6a48bcd4c5ad5adacfab677519c25ce7b2805a5\",\"gas\":\"0x8d78\",\"input\":\"0x\",\"to\":\"0x6b5887043de753ecfa6269f947129068263ffbe2\",\"value\":\"0x0\"},\"blockHash\":\"0xeb0d05efb43e565c4a677e64dde4cd1339459310afe8f578acab57ad45dd8f44\",\"blockNumber\":18,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[1],\"transactionHash\":\"0x787616b8756424622f162fc3817331517ef941366f28db452defc0214bc36b22\",\"transactionPosition\":0,\"type\":\"call\"}]"), serialized.Replace("\"", "\\\"")); + Assert.That(serialized, Is.EqualTo("[{\"action\":{\"creationMethod\":\"create\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x9a6c\",\"init\":\"0x60006000600060006000736b5887043de753ecfa6269f947129068263ffbe261c350f160006000600060006000736b5887043de753ecfa6269f947129068263ffbe261c350f1fd\",\"value\":\"0x1\"},\"blockHash\":\"0x69f380ee1f366db2573819bf624f34c1c669f907f348ff4d405c749c56570882\",\"blockNumber\":18,\"subtraces\":2,\"traceAddress\":[],\"transactionHash\":\"0x787616b8756424622f162fc3817331517ef941366f28db452defc0214bc36b22\",\"transactionPosition\":0,\"type\":\"create\",\"error\":\"Reverted\"},{\"action\":{\"callType\":\"call\",\"from\":\"0xd6a48bcd4c5ad5adacfab677519c25ce7b2805a5\",\"gas\":\"0x8def\",\"input\":\"0x\",\"to\":\"0x6b5887043de753ecfa6269f947129068263ffbe2\",\"value\":\"0x0\"},\"blockHash\":\"0x69f380ee1f366db2573819bf624f34c1c669f907f348ff4d405c749c56570882\",\"blockNumber\":18,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[0],\"transactionHash\":\"0x787616b8756424622f162fc3817331517ef941366f28db452defc0214bc36b22\",\"transactionPosition\":0,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0xd6a48bcd4c5ad5adacfab677519c25ce7b2805a5\",\"gas\":\"0x8d78\",\"input\":\"0x\",\"to\":\"0x6b5887043de753ecfa6269f947129068263ffbe2\",\"value\":\"0x0\"},\"blockHash\":\"0x69f380ee1f366db2573819bf624f34c1c669f907f348ff4d405c749c56570882\",\"blockNumber\":18,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[1],\"transactionHash\":\"0x787616b8756424622f162fc3817331517ef941366f28db452defc0214bc36b22\",\"transactionPosition\":0,\"type\":\"call\"}]"), serialized.Replace("\"", "\\\"")); } [Test] public async Task trace_timeout_is_separate_for_rpc_calls() From 71963b7be963c00729b559979400036f3f0dfd15 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Thu, 28 Nov 2024 23:51:07 +0500 Subject: [PATCH 35/68] fix tests --- .../Modules/Eth/EthRpcModuleTests.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs index aabb47ea439..c1243f3ba1e 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs @@ -69,7 +69,7 @@ public async Task Eth_get_eth_feeHistory() { using Context ctx = await Context.Create(); string serialized = await ctx.Test.TestEthRpc("eth_feeHistory", "0x1", "latest", "[20,50,90]"); - Assert.That(serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x0\",\"0x0\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0105],\"blobGasUsedRatio\":[0.0],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x1\",\"0x1\",\"0x1\"]]},\"id\":67}")); + Assert.That(serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x0\",\"0x0\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0105],\"blobGasUsedRatio\":[NaN],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x1\",\"0x1\",\"0x1\"]]},\"id\":67}")); } [Test] @@ -77,7 +77,7 @@ public async Task Eth_get_transaction_by_block_hash_and_index() { using Context ctx = await Context.Create(); string serialized = await ctx.Test.TestEthRpc("eth_getTransactionByBlockHashAndIndex", ctx.Test.BlockTree.FindHeadBlock()!.Hash!.ToString(), "1"); - JToken.Parse(serialized).Should().BeEquivalentTo("""{"jsonrpc":"2.0","result":{"hash":"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b","nonce":"0x2","blockHash":"0x29f141925d2d8e357ae5b6040c97aa12d7ac6dfcbe2b20e7b616d8907ac8e1f3","blockNumber":"0x3","transactionIndex":"0x1","from":"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099","to":"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358","value":"0x1","gasPrice":"0x1","gas":"0x5208","input":"0x","type":"0x0","v":"0x25","s":"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb","r":"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd"},"id":67}"""); + JToken.Parse(serialized).Should().BeEquivalentTo("""{"jsonrpc":"2.0","result":{"hash":"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b","nonce":"0x2","blockHash":"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47","blockNumber":"0x3","transactionIndex":"0x1","from":"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099","to":"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358","value":"0x1","gasPrice":"0x1","gas":"0x5208","input":"0x","type":"0x0","v":"0x25","s":"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb","r":"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd"},"id":67}"""); } [Test] @@ -85,7 +85,7 @@ public async Task Eth_get_transaction_by_hash() { using Context ctx = await Context.Create(); string serialized = await ctx.Test.TestEthRpc("eth_getTransactionByHash", ctx.Test.BlockTree.FindHeadBlock()!.Transactions.Last().Hash!.ToString()); - JToken.Parse(serialized).Should().BeEquivalentTo("""{"jsonrpc":"2.0","result":{"hash":"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b","nonce":"0x2","blockHash":"0x29f141925d2d8e357ae5b6040c97aa12d7ac6dfcbe2b20e7b616d8907ac8e1f3","blockNumber":"0x3","transactionIndex":"0x1","from":"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099","to":"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358","value":"0x1","gasPrice":"0x1","gas":"0x5208","input":"0x","type":"0x0","v":"0x25","s":"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb","r":"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd"},"id":67}"""); + JToken.Parse(serialized).Should().BeEquivalentTo("""{"jsonrpc":"2.0","result":{"hash":"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b","nonce":"0x2","blockHash":"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47","blockNumber":"0x3","transactionIndex":"0x1","from":"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099","to":"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358","value":"0x1","gasPrice":"0x1","gas":"0x5208","input":"0x","type":"0x0","v":"0x25","s":"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb","r":"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd"},"id":67}"""); } [Test] @@ -137,7 +137,7 @@ public async Task Eth_getBlockReceipts() { using Context ctx = await Context.Create(); string serialized = await ctx.Test.TestEthRpc("eth_getBlockReceipts", "latest"); - string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":[{\"transactionHash\":\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"transactionIndex\":\"0x0\",\"blockHash\":\"0x29f141925d2d8e357ae5b6040c97aa12d7ac6dfcbe2b20e7b616d8907ac8e1f3\",\"blockNumber\":\"0x3\",\"cumulativeGasUsed\":\"0x5208\",\"gasUsed\":\"0x5208\",\"effectiveGasPrice\":\"0x1\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"contractAddress\":null,\"logs\":[],\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"status\":\"0x1\",\"type\":\"0x0\"},{\"transactionHash\":\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\",\"transactionIndex\":\"0x1\",\"blockHash\":\"0x29f141925d2d8e357ae5b6040c97aa12d7ac6dfcbe2b20e7b616d8907ac8e1f3\",\"blockNumber\":\"0x3\",\"cumulativeGasUsed\":\"0xa410\",\"gasUsed\":\"0x5208\",\"effectiveGasPrice\":\"0x1\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"contractAddress\":null,\"logs\":[],\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"status\":\"0x1\",\"type\":\"0x0\"}],\"id\":67}"; + string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":[{\"transactionHash\":\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"transactionIndex\":\"0x0\",\"blockHash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"blockNumber\":\"0x3\",\"cumulativeGasUsed\":\"0x5208\",\"gasUsed\":\"0x5208\",\"effectiveGasPrice\":\"0x1\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"contractAddress\":null,\"logs\":[],\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"status\":\"0x1\",\"type\":\"0x0\"},{\"transactionHash\":\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\",\"transactionIndex\":\"0x1\",\"blockHash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"blockNumber\":\"0x3\",\"cumulativeGasUsed\":\"0xa410\",\"gasUsed\":\"0x5208\",\"effectiveGasPrice\":\"0x1\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"contractAddress\":null,\"logs\":[],\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"status\":\"0x1\",\"type\":\"0x0\"}],\"id\":67}"; Assert.That(serialized, Is.EqualTo(expectedResult)); } @@ -146,7 +146,7 @@ public async Task Eth_get_transaction_by_block_number_and_index() { using Context ctx = await Context.Create(); string serialized = await ctx.Test.TestEthRpc("eth_getTransactionByBlockNumberAndIndex", ctx.Test.BlockTree.FindHeadBlock()!.Number.ToString(), "1"); - JToken.Parse(serialized).Should().BeEquivalentTo("""{"jsonrpc":"2.0","result":{"hash":"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b","nonce":"0x2","blockHash":"0x29f141925d2d8e357ae5b6040c97aa12d7ac6dfcbe2b20e7b616d8907ac8e1f3","blockNumber":"0x3","transactionIndex":"0x1","from":"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099","to":"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358","value":"0x1","gasPrice":"0x1","gas":"0x5208","input":"0x","type":"0x0","v":"0x25","s":"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb","r":"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd"},"id":67}"""); + JToken.Parse(serialized).Should().BeEquivalentTo("""{"jsonrpc":"2.0","result":{"hash":"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b","nonce":"0x2","blockHash":"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47","blockNumber":"0x3","transactionIndex":"0x1","from":"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099","to":"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358","value":"0x1","gasPrice":"0x1","gas":"0x5208","input":"0x","type":"0x0","v":"0x25","s":"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb","r":"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd"},"id":67}"""); } [TestCase(false, "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x0000000000000000000000000000000000000000\",\"difficulty\":\"0xf4240\",\"extraData\":\"0x010203\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0x0\",\"hash\":\"0xa2a9f03b9493046696099d27b2612b99497aa1f392ec966716ab393c715a5bb6\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x0000000000000000000000000000000000000000\",\"mixHash\":\"0x2ba5557a4c62a513c7e56d1bf13373e0da6bec016755483e91589fe1c6d212e2\",\"nonce\":\"0x00000000000003e8\",\"number\":\"0x0\",\"parentHash\":\"0xff483e972a04a9a62bb4b7d04ae403c615604e4090521ecc5bb7af67f71be09c\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x201\",\"stateRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"totalDifficulty\":\"0x0\",\"timestamp\":\"0xf4240\",\"transactions\":[],\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"uncles\":[]},\"id\":67}")] @@ -289,7 +289,7 @@ public async Task Eth_get_filter_changes_with_block() await ctx.Test.AddBlock(); string serialized2 = await ctx.Test.TestEthRpc("eth_getFilterChanges", "0"); - Assert.That(serialized2, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":[\"0x166781de9c5f3328b7fc59c32e1dd1ec892021d95578258004ee221863a817a0\"],\"id\":67}"), serialized2.Replace("\"", "\\\"")); + Assert.That(serialized2, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":[\"0xa174bdcf7b2b3e2a855b98d3d585d399c8a122004ae5da3c88d9beaa803fc42b\"],\"id\":67}"), serialized2.Replace("\"", "\\\"")); } [Test] @@ -326,7 +326,7 @@ void handleNewBlock(object? sender, BlockEventArgs e) //expect new transaction logs string getFilterLogsSerialized2 = await test.TestEthRpc("eth_getFilterChanges", (newFilterResp as JsonRpcSuccessResponse)!.Result?.ToString() ?? "0x0"); - getFilterLogsSerialized2.Should().Be("{\"jsonrpc\":\"2.0\",\"result\":[{\"address\":\"0x0ffd3e46594919c04bcfd4e146203c8255670828\",\"blockHash\":\"0xf9fc52a47b7da4e8227cd60e9c368fa7d44df7f3226d5163005eec015588d64b\",\"blockNumber\":\"0x4\",\"data\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"logIndex\":\"0x0\",\"removed\":false,\"topics\":[],\"transactionHash\":\"0x8c9c109bff7969c8aed8e51ab4ea35c6f835a0c3266bc5c5721821a38cbf5445\",\"transactionIndex\":\"0x0\",\"transactionLogIndex\":\"0x0\"}],\"id\":67}"); + getFilterLogsSerialized2.Should().Be("{\"jsonrpc\":\"2.0\",\"result\":[{\"address\":\"0x0ffd3e46594919c04bcfd4e146203c8255670828\",\"blockHash\":\"0xe1efdb179e29ec3d8bb8ebf3f17a3655805b3be3cf02e936ef588bc93ba9bc21\",\"blockNumber\":\"0x4\",\"data\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"logIndex\":\"0x0\",\"removed\":false,\"topics\":[],\"transactionHash\":\"0x8c9c109bff7969c8aed8e51ab4ea35c6f835a0c3266bc5c5721821a38cbf5445\",\"transactionIndex\":\"0x0\",\"transactionLogIndex\":\"0x0\"}],\"id\":67}"); //expect empty - previous call cleans logs string getFilterLogsSerialized3 = await test.TestEthRpc("eth_getFilterChanges", (newFilterResp as JsonRpcSuccessResponse)!.Result?.ToString() ?? "0x0"); From 94a1e4d681f027943c1d77e51fa7dfec89a5685a Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 2 Dec 2024 05:16:25 +0500 Subject: [PATCH 36/68] fix tests --- .../Nethermind.Facade/BlockchainBridge.cs | 1 + .../Modules/Eth/EthRpcModuleTests.FeeHistory.cs | 6 +++--- .../Modules/Eth/EthRpcModuleTests.cs | 14 +++++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs b/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs index c4b1b5cc163..2dfb98051c0 100644 --- a/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs +++ b/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs @@ -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, callHeader, tracer); } diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.FeeHistory.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.FeeHistory.cs index 6f03257123c..bbf2a86480e 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.FeeHistory.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.FeeHistory.cs @@ -25,9 +25,9 @@ namespace Nethermind.JsonRpc.Test.Modules.Eth; public partial class EthRpcModuleTests { - [TestCase(1, "latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x2da282a8\",\"0x27ee3253\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[0.0],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] - [TestCase(1, "pending", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x2da282a8\",\"0x27ee3253\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[0.0],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] - [TestCase(2, "0x01", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x0\",\"0x3b9aca00\",\"0x342770c0\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0,0.0],\"blobGasUsedRatio\":[0.0,0.0],\"oldestBlock\":\"0x0\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"],[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] + [TestCase(1, "latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x2da282a8\",\"0x27ee3253\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[NaN],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] + [TestCase(1, "pending", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x2da282a8\",\"0x27ee3253\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[NaN],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] + [TestCase(2, "0x01", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x0\",\"0x3b9aca00\",\"0x342770c0\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0,0.0],\"blobGasUsedRatio\":[0.0,NaN],\"oldestBlock\":\"0x0\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"],[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] [TestCase(2, "earliest", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x0\",\"0x3b9aca00\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[0.0],\"oldestBlock\":\"0x0\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] public async Task Eth_feeHistory(long blockCount, string blockParameter, string expected) { diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs index c1243f3ba1e..700a5d7bfcd 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs @@ -643,8 +643,8 @@ public async Task Eth_get_block_by_hash_null() Assert.That(serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":null,\"id\":67}")); } - [TestCase("0x71eac5e72c3b64431c246173352a8c625c8434d944eb5f3f58204fec3ec36b54", false, "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x29f141925d2d8e357ae5b6040c97aa12d7ac6dfcbe2b20e7b616d8907ac8e1f3\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0x49e7d7466be0927347ff2f654c014a768b5a5fcd8c483635210466dd0d6d204c\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2cb\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x5e47e919\",\"transactions\":[\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\"],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] - [TestCase("0x71eac5e72c3b64431c246173352a8c625c8434d944eb5f3f58204fec3ec36b54", true, "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x29f141925d2d8e357ae5b6040c97aa12d7ac6dfcbe2b20e7b616d8907ac8e1f3\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0x49e7d7466be0927347ff2f654c014a768b5a5fcd8c483635210466dd0d6d204c\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2cb\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x5e47e919\",\"transactions\":[{\"hash\":\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"nonce\":\"0x1\",\"blockHash\":\"0x29f141925d2d8e357ae5b6040c97aa12d7ac6dfcbe2b20e7b616d8907ac8e1f3\",\"blockNumber\":\"0x3\",\"transactionIndex\":\"0x0\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"value\":\"0x1\",\"gasPrice\":\"0x1\",\"gas\":\"0x5208\",\"input\":\"0x\",\"type\":\"0x0\",\"v\":\"0x25\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\"},{\"hash\":\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\",\"nonce\":\"0x2\",\"blockHash\":\"0x29f141925d2d8e357ae5b6040c97aa12d7ac6dfcbe2b20e7b616d8907ac8e1f3\",\"blockNumber\":\"0x3\",\"transactionIndex\":\"0x1\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"value\":\"0x1\",\"gasPrice\":\"0x1\",\"gas\":\"0x5208\",\"input\":\"0x\",\"type\":\"0x0\",\"v\":\"0x25\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\"}],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] + [TestCase("0x71eac5e72c3b64431c246173352a8c625c8434d944eb5f3f58204fec3ec36b54", false, "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0xdb2fc4f70fc54c923b94ee0767901815685a5ff608e112c19e754316a9b8c97a\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2c8\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"transactions\":[\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\"],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] + [TestCase("0x71eac5e72c3b64431c246173352a8c625c8434d944eb5f3f58204fec3ec36b54", true, "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0xdb2fc4f70fc54c923b94ee0767901815685a5ff608e112c19e754316a9b8c97a\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2c8\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"transactions\":[{\"hash\":\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"nonce\":\"0x1\",\"blockHash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"blockNumber\":\"0x3\",\"transactionIndex\":\"0x0\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"value\":\"0x1\",\"gasPrice\":\"0x1\",\"gas\":\"0x5208\",\"input\":\"0x\",\"type\":\"0x0\",\"v\":\"0x25\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\"},{\"hash\":\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\",\"nonce\":\"0x2\",\"blockHash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"blockNumber\":\"0x3\",\"transactionIndex\":\"0x1\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"value\":\"0x1\",\"gasPrice\":\"0x1\",\"gas\":\"0x5208\",\"input\":\"0x\",\"type\":\"0x0\",\"v\":\"0x25\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\"}],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] public async Task Eth_get_block_by_hash_with_tx(string blockParameter, bool withTxData, string expectedResult) { using Context ctx = await Context.Create(); @@ -653,11 +653,11 @@ public async Task Eth_get_block_by_hash_with_tx(string blockParameter, bool with } [TestCase(false, "earliest", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x0000000000000000000000000000000000000000\",\"difficulty\":\"0xf4240\",\"extraData\":\"0x010203\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0x0\",\"hash\":\"0x2167088a0f0de66028d2b728235af6d467108c1750c3e11a8f6e6cd60fddb0e4\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x0000000000000000000000000000000000000000\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x00000000000003e8\",\"number\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x201\",\"stateRoot\":\"0x1ef7300d8961797263939a3d29bbba4ccf1702fabf02d8ad7a20b454edb6fd2f\",\"totalDifficulty\":\"0xf4240\",\"timestamp\":\"0xf4240\",\"transactions\":[],\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"uncles\":[]},\"id\":67}")] - [TestCase(false, "latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x29f141925d2d8e357ae5b6040c97aa12d7ac6dfcbe2b20e7b616d8907ac8e1f3\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0x49e7d7466be0927347ff2f654c014a768b5a5fcd8c483635210466dd0d6d204c\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2cb\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x5e47e919\",\"transactions\":[{\"hash\":\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"nonce\":\"0x1\",\"blockHash\":\"0x29f141925d2d8e357ae5b6040c97aa12d7ac6dfcbe2b20e7b616d8907ac8e1f3\",\"blockNumber\":\"0x3\",\"transactionIndex\":\"0x0\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"value\":\"0x1\",\"gasPrice\":\"0x1\",\"gas\":\"0x5208\",\"input\":\"0x\",\"type\":\"0x0\",\"v\":\"0x25\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\"},{\"hash\":\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\",\"nonce\":\"0x2\",\"blockHash\":\"0x29f141925d2d8e357ae5b6040c97aa12d7ac6dfcbe2b20e7b616d8907ac8e1f3\",\"blockNumber\":\"0x3\",\"transactionIndex\":\"0x1\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"value\":\"0x1\",\"gasPrice\":\"0x1\",\"gas\":\"0x5208\",\"input\":\"0x\",\"type\":\"0x0\",\"v\":\"0x25\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\"}],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] - [TestCase(false, "pending", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x29f141925d2d8e357ae5b6040c97aa12d7ac6dfcbe2b20e7b616d8907ac8e1f3\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0x49e7d7466be0927347ff2f654c014a768b5a5fcd8c483635210466dd0d6d204c\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2cb\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x5e47e919\",\"transactions\":[{\"hash\":\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"nonce\":\"0x1\",\"blockHash\":\"0x29f141925d2d8e357ae5b6040c97aa12d7ac6dfcbe2b20e7b616d8907ac8e1f3\",\"blockNumber\":\"0x3\",\"transactionIndex\":\"0x0\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"value\":\"0x1\",\"gasPrice\":\"0x1\",\"gas\":\"0x5208\",\"input\":\"0x\",\"type\":\"0x0\",\"v\":\"0x25\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\"},{\"hash\":\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\",\"nonce\":\"0x2\",\"blockHash\":\"0x29f141925d2d8e357ae5b6040c97aa12d7ac6dfcbe2b20e7b616d8907ac8e1f3\",\"blockNumber\":\"0x3\",\"transactionIndex\":\"0x1\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"value\":\"0x1\",\"gasPrice\":\"0x1\",\"gas\":\"0x5208\",\"input\":\"0x\",\"type\":\"0x0\",\"v\":\"0x25\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\"}],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] + [TestCase(false, "latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0xdb2fc4f70fc54c923b94ee0767901815685a5ff608e112c19e754316a9b8c97a\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2c8\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"transactions\":[{\"hash\":\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"nonce\":\"0x1\",\"blockHash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"blockNumber\":\"0x3\",\"transactionIndex\":\"0x0\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"value\":\"0x1\",\"gasPrice\":\"0x1\",\"gas\":\"0x5208\",\"input\":\"0x\",\"type\":\"0x0\",\"v\":\"0x25\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\"},{\"hash\":\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\",\"nonce\":\"0x2\",\"blockHash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"blockNumber\":\"0x3\",\"transactionIndex\":\"0x1\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"value\":\"0x1\",\"gasPrice\":\"0x1\",\"gas\":\"0x5208\",\"input\":\"0x\",\"type\":\"0x0\",\"v\":\"0x25\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\"}],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] + [TestCase(false, "pending", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0xdb2fc4f70fc54c923b94ee0767901815685a5ff608e112c19e754316a9b8c97a\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2c8\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"transactions\":[{\"hash\":\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"nonce\":\"0x1\",\"blockHash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"blockNumber\":\"0x3\",\"transactionIndex\":\"0x0\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"value\":\"0x1\",\"gasPrice\":\"0x1\",\"gas\":\"0x5208\",\"input\":\"0x\",\"type\":\"0x0\",\"v\":\"0x25\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\"},{\"hash\":\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\",\"nonce\":\"0x2\",\"blockHash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"blockNumber\":\"0x3\",\"transactionIndex\":\"0x1\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"value\":\"0x1\",\"gasPrice\":\"0x1\",\"gas\":\"0x5208\",\"input\":\"0x\",\"type\":\"0x0\",\"v\":\"0x25\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\"}],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] [TestCase(false, "0x0", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x0000000000000000000000000000000000000000\",\"difficulty\":\"0xf4240\",\"extraData\":\"0x010203\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0x0\",\"hash\":\"0x2167088a0f0de66028d2b728235af6d467108c1750c3e11a8f6e6cd60fddb0e4\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x0000000000000000000000000000000000000000\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x00000000000003e8\",\"number\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x201\",\"stateRoot\":\"0x1ef7300d8961797263939a3d29bbba4ccf1702fabf02d8ad7a20b454edb6fd2f\",\"totalDifficulty\":\"0xf4240\",\"timestamp\":\"0xf4240\",\"transactions\":[],\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"uncles\":[]},\"id\":67}")] [TestCase(true, "earliest", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x0000000000000000000000000000000000000000\",\"difficulty\":\"0xf4240\",\"extraData\":\"0x010203\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0x0\",\"hash\":\"0x2167088a0f0de66028d2b728235af6d467108c1750c3e11a8f6e6cd60fddb0e4\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x0000000000000000000000000000000000000000\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x00000000000003e8\",\"number\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x201\",\"stateRoot\":\"0x1ef7300d8961797263939a3d29bbba4ccf1702fabf02d8ad7a20b454edb6fd2f\",\"totalDifficulty\":\"0xf4240\",\"timestamp\":\"0xf4240\",\"baseFeePerGas\":\"0x0\",\"transactions\":[],\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"uncles\":[]},\"id\":67}")] - [TestCase(true, "latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x7a1200\",\"gasUsed\":\"0x0\",\"hash\":\"0x16b111d85efa64c1c8e27f1e59c8ccd6bb6643b1999628ac37294c31158e2245\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0x761cfe357802c8a2a68e37ad8325607920e72ce19b5b0d3e1ba01840f7e905ec\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x20b\",\"stateRoot\":\"0x1ef7300d8961797263939a3d29bbba4ccf1702fabf02d8ad7a20b454edb6fd2f\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x5e47e919\",\"baseFeePerGas\":\"0x2da282a8\",\"transactions\":[],\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"uncles\":[]},\"id\":67}")] + [TestCase(true, "latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x7a1200\",\"gasUsed\":\"0x0\",\"hash\":\"0x042fb755f4e325060234433ab0339847ea70615911336b641530bbcf69d86e03\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0x5dbe3f5334cdbbe1b356007965b4ac8b6b1c59efc340e651c18b8539adbec5b7\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x208\",\"stateRoot\":\"0x1ef7300d8961797263939a3d29bbba4ccf1702fabf02d8ad7a20b454edb6fd2f\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"baseFeePerGas\":\"0x2da282a8\",\"transactions\":[],\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"uncles\":[]},\"id\":67}")] [TestCase(true, "0x0", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x0000000000000000000000000000000000000000\",\"difficulty\":\"0xf4240\",\"extraData\":\"0x010203\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0x0\",\"hash\":\"0x2167088a0f0de66028d2b728235af6d467108c1750c3e11a8f6e6cd60fddb0e4\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x0000000000000000000000000000000000000000\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x00000000000003e8\",\"number\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x201\",\"stateRoot\":\"0x1ef7300d8961797263939a3d29bbba4ccf1702fabf02d8ad7a20b454edb6fd2f\",\"totalDifficulty\":\"0xf4240\",\"timestamp\":\"0xf4240\",\"baseFeePerGas\":\"0x0\",\"transactions\":[],\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"uncles\":[]},\"id\":67}")] [TestCase(false, "0x20", "{\"jsonrpc\":\"2.0\",\"result\":null,\"id\":67}")] public async Task Eth_get_block_by_number(bool eip1559, string blockParameter, string expectedResult) @@ -668,8 +668,8 @@ public async Task Eth_get_block_by_number(bool eip1559, string blockParameter, s } [TestCase("earliest", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x0000000000000000000000000000000000000000\",\"difficulty\":\"0xf4240\",\"extraData\":\"0x010203\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0x0\",\"hash\":\"0x2167088a0f0de66028d2b728235af6d467108c1750c3e11a8f6e6cd60fddb0e4\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x0000000000000000000000000000000000000000\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x00000000000003e8\",\"number\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x201\",\"stateRoot\":\"0x1ef7300d8961797263939a3d29bbba4ccf1702fabf02d8ad7a20b454edb6fd2f\",\"totalDifficulty\":\"0xf4240\",\"timestamp\":\"0xf4240\",\"transactions\":[],\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"uncles\":[]},\"id\":67}")] - [TestCase("latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x29f141925d2d8e357ae5b6040c97aa12d7ac6dfcbe2b20e7b616d8907ac8e1f3\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0x49e7d7466be0927347ff2f654c014a768b5a5fcd8c483635210466dd0d6d204c\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2cb\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x5e47e919\",\"transactions\":[\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\"],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] - [TestCase("pending", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x29f141925d2d8e357ae5b6040c97aa12d7ac6dfcbe2b20e7b616d8907ac8e1f3\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0x49e7d7466be0927347ff2f654c014a768b5a5fcd8c483635210466dd0d6d204c\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2cb\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x5e47e919\",\"transactions\":[\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\"],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] + [TestCase("latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0xdb2fc4f70fc54c923b94ee0767901815685a5ff608e112c19e754316a9b8c97a\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2c8\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"transactions\":[\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\"],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] + [TestCase("pending", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0xdb2fc4f70fc54c923b94ee0767901815685a5ff608e112c19e754316a9b8c97a\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2c8\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"transactions\":[\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\"],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] [TestCase("0x0", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x0000000000000000000000000000000000000000\",\"difficulty\":\"0xf4240\",\"extraData\":\"0x010203\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0x0\",\"hash\":\"0x2167088a0f0de66028d2b728235af6d467108c1750c3e11a8f6e6cd60fddb0e4\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x0000000000000000000000000000000000000000\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x00000000000003e8\",\"number\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x201\",\"stateRoot\":\"0x1ef7300d8961797263939a3d29bbba4ccf1702fabf02d8ad7a20b454edb6fd2f\",\"totalDifficulty\":\"0xf4240\",\"timestamp\":\"0xf4240\",\"transactions\":[],\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"uncles\":[]},\"id\":67}")] [TestCase("0x20", "{\"jsonrpc\":\"2.0\",\"result\":null,\"id\":67}")] public async Task Eth_get_block_by_number_no_details(string blockParameter, string expectedResult) From 35d29c5f19a0d1333e00c03ada234912097b7267 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 2 Dec 2024 06:24:03 +0500 Subject: [PATCH 37/68] fix whitespaces --- .../Nethermind.Core.Test/Blockchain/TestBlockchain.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs b/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs index ff89eb204a3..0fb37a4673b 100644 --- a/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs +++ b/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs @@ -445,7 +445,7 @@ private async Task AddBlockInternal(params Transaction[] trans Timestamper.Add(TimeSpan.FromSeconds(1)); var headProcessed = new SemaphoreSlim(0); TxPool.TxPoolHeadChanged += (s, a) => headProcessed.Release(); - await BlockProductionTrigger.BuildBlock(payloadAttributes: new PayloadAttributes {TargetBlobCount = 0}).ConfigureAwait(false); + await BlockProductionTrigger.BuildBlock(payloadAttributes: new PayloadAttributes { TargetBlobCount = 0 }).ConfigureAwait(false); await headProcessed.WaitAsync().ConfigureAwait(false); return txResults; } From f00d86ad3ed7b9df89a3aacddaffbe37dcdbae40 Mon Sep 17 00:00:00 2001 From: yerke26 <160018032+yerke26@users.noreply.github.com> Date: Tue, 3 Dec 2024 17:46:32 +0500 Subject: [PATCH 38/68] Update src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs Co-authored-by: Lukasz Rozmej --- src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs b/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs index fbad6560b67..9d8fb992fcb 100644 --- a/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs +++ b/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs @@ -107,7 +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; - if (test.Fork is Prague) header.TargetBlobCount = 0; + header.TargetBlobCount = test.Fork is Prague ? 0 : null; Stopwatch stopwatch = Stopwatch.StartNew(); IReleaseSpec? spec = specProvider.GetSpec((ForkActivation)test.CurrentNumber); From 97180870a09717feee50f2295d932e0fd285ffa8 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Sun, 8 Dec 2024 15:19:30 +0500 Subject: [PATCH 39/68] refactoring of BlockExecutionContext, move blobFee calculation to VirtualMachine --- .../BeaconBlockRootHandlerTests.cs | 2 +- .../BeaconBlockRoot/BeaconBlockRootHandler.cs | 2 +- .../Nethermind.Blockchain/GenesisLoader.cs | 2 +- .../ExecutionRequestProcessor.cs | 2 +- .../Processing/BlockCachePreWarmer.cs | 2 +- ...sor.BlockProductionTransactionsExecutor.cs | 3 +-- ...sor.BlockValidationTransactionsExecutor.cs | 4 +-- .../EvmPooledMemoryTests.cs | 2 +- .../Nethermind.Evm/BlockExecutionContext.cs | 13 ++------- .../Nethermind.Evm/Tracing/GasEstimator.cs | 3 +-- .../ITransactionProcessor.cs | 27 ------------------- .../TransactionProcessor.cs | 22 +-------------- .../Nethermind.Evm/VirtualMachine.cs | 16 +++++++++-- .../SimulateReadOnlyBlocksProcessingEnv.cs | 4 +-- .../BlockInvalidTxExecutor.cs | 3 +-- .../Rpc/TaikoEngineRpcModule.cs | 3 +-- 16 files changed, 31 insertions(+), 79 deletions(-) diff --git a/src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs b/src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs index 086fc48ad09..15001bfdf46 100644 --- a/src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs +++ b/src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs @@ -149,6 +149,6 @@ public void Test_StoreBeaconRoot_AccessListNotNull() transaction.Hash = transaction.CalculateHash(); _transactionProcessor.Received().Execute(Arg.Is(t => - t.Hash == transaction.Hash), new BlockExecutionContext(header, Cancun.Instance), NullTxTracer.Instance); + t.Hash == transaction.Hash), header, NullTxTracer.Instance); } } diff --git a/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs b/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs index b9b56ab9240..d856300961d 100644 --- a/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs +++ b/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs @@ -66,7 +66,7 @@ public void StoreBeaconRoot(Block block, IReleaseSpec spec, ITxTracer tracer) transaction.Hash = transaction.CalculateHash(); - processor.Execute(transaction, new BlockExecutionContext(header, spec), tracer); + processor.Execute(transaction, header, tracer); } } } diff --git a/src/Nethermind/Nethermind.Blockchain/GenesisLoader.cs b/src/Nethermind/Nethermind.Blockchain/GenesisLoader.cs index 6479fe07cb7..3663d52e31a 100644 --- a/src/Nethermind/Nethermind.Blockchain/GenesisLoader.cs +++ b/src/Nethermind/Nethermind.Blockchain/GenesisLoader.cs @@ -80,7 +80,7 @@ private void Preallocate(Block genesis) }; CallOutputTracer outputTracer = new(); - _transactionProcessor.Execute(constructorTransaction, new BlockExecutionContext(genesis.Header, _specProvider.GetSpec(genesis.Header)), outputTracer); + _transactionProcessor.Execute(constructorTransaction, genesis.Header, outputTracer); if (outputTracer.StatusCode != StatusCode.Success) { diff --git a/src/Nethermind/Nethermind.Consensus/ExecutionRequests/ExecutionRequestProcessor.cs b/src/Nethermind/Nethermind.Consensus/ExecutionRequests/ExecutionRequestProcessor.cs index 8f1d5d62621..6b6d78ad22f 100644 --- a/src/Nethermind/Nethermind.Consensus/ExecutionRequests/ExecutionRequestProcessor.cs +++ b/src/Nethermind/Nethermind.Consensus/ExecutionRequests/ExecutionRequestProcessor.cs @@ -119,7 +119,7 @@ private byte[] ReadRequests(Block block, IWorldState state, IReleaseSpec spec, A CallOutputTracer tracer = new(); - _transactionProcessor.Execute(isWithdrawalRequests ? _withdrawalTransaction : _consolidationTransaction, new BlockExecutionContext(block.Header, spec), tracer); + _transactionProcessor.Execute(isWithdrawalRequests ? _withdrawalTransaction : _consolidationTransaction, block.Header, tracer); if (tracer.ReturnValue is null || tracer.ReturnValue.Length == 0) { diff --git a/src/Nethermind/Nethermind.Consensus/Processing/BlockCachePreWarmer.cs b/src/Nethermind/Nethermind.Consensus/Processing/BlockCachePreWarmer.cs index 2c0c46bfb40..7ba634d102e 100644 --- a/src/Nethermind/Nethermind.Consensus/Processing/BlockCachePreWarmer.cs +++ b/src/Nethermind/Nethermind.Consensus/Processing/BlockCachePreWarmer.cs @@ -170,7 +170,7 @@ private void WarmupTransactions(ParallelOptions parallelOptions, IReleaseSpec sp { scope.WorldState.WarmUp(tx.AccessList); // eip-2930 } - TransactionResult result = scope.TransactionProcessor.Warmup(systemTransaction, new BlockExecutionContext(state.Block.Header.Clone(), spec), NullTxTracer.Instance); + TransactionResult result = scope.TransactionProcessor.Warmup(systemTransaction, new BlockExecutionContext(state.Block.Header.Clone()), NullTxTracer.Instance); if (state.PreWarmer._logger.IsTrace) state.PreWarmer._logger.Trace($"Finished pre-warming cache for tx[{i}] {tx.Hash} with {result}"); } catch (Exception ex) when (ex is EvmException or OverflowException) diff --git a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionsExecutor.cs b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionsExecutor.cs index cce2e733d59..fb13a8f7912 100644 --- a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionsExecutor.cs +++ b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionsExecutor.cs @@ -70,10 +70,9 @@ public virtual TxReceipt[] ProcessTransactions(Block block, ProcessingOptions pr int i = 0; LinkedHashSet transactionsInBlock = new(ByHashTxComparer.Instance); - BlockExecutionContext blkCtx = new(block.Header, spec); foreach (Transaction currentTx in transactions) { - TxAction action = ProcessTransaction(block, in blkCtx, currentTx, i++, receiptsTracer, processingOptions, transactionsInBlock); + TxAction action = ProcessTransaction(block, block.Header, currentTx, i++, receiptsTracer, processingOptions, transactionsInBlock); if (action == TxAction.Stop) break; } diff --git a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockValidationTransactionsExecutor.cs b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockValidationTransactionsExecutor.cs index cc300a1b520..6d2299ef920 100644 --- a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockValidationTransactionsExecutor.cs +++ b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockValidationTransactionsExecutor.cs @@ -33,7 +33,7 @@ public BlockValidationTransactionsExecutor(ITransactionProcessor transactionProc public TxReceipt[] ProcessTransactions(Block block, ProcessingOptions processingOptions, BlockReceiptsTracer receiptsTracer, IReleaseSpec spec) { Metrics.ResetBlockStats(); - BlockExecutionContext blkCtx = CreateBlockExecutionContext(block, spec); + BlockExecutionContext blkCtx = CreateBlockExecutionContext(block); for (int i = 0; i < block.Transactions.Length; i++) { block.TransactionProcessed = i; @@ -43,7 +43,7 @@ public TxReceipt[] ProcessTransactions(Block block, ProcessingOptions processing return receiptsTracer.TxReceipts.ToArray(); } - protected virtual BlockExecutionContext CreateBlockExecutionContext(Block block, IReleaseSpec spec) => new(block.Header, spec); + protected virtual BlockExecutionContext CreateBlockExecutionContext(Block block) => new(block.Header); protected virtual void ProcessTransaction(in BlockExecutionContext blkCtx, Transaction currentTx, int index, BlockReceiptsTracer receiptsTracer, ProcessingOptions processingOptions) { diff --git a/src/Nethermind/Nethermind.Evm.Test/EvmPooledMemoryTests.cs b/src/Nethermind/Nethermind.Evm.Test/EvmPooledMemoryTests.cs index 73124ae837f..69fce9e4e46 100644 --- a/src/Nethermind/Nethermind.Evm.Test/EvmPooledMemoryTests.cs +++ b/src/Nethermind/Nethermind.Evm.Test/EvmPooledMemoryTests.cs @@ -196,7 +196,7 @@ private static string Run(byte[] input) MyTracer tracer = new(); transactionProcessor.Execute( tx, - new BlockExecutionContext(block.Header, specProvider.GetSpec(block.Header)), + block.Header, tracer); return tracer.lastmemline; } diff --git a/src/Nethermind/Nethermind.Evm/BlockExecutionContext.cs b/src/Nethermind/Nethermind.Evm/BlockExecutionContext.cs index 8af467bbb14..9826d4d94b7 100644 --- a/src/Nethermind/Nethermind.Evm/BlockExecutionContext.cs +++ b/src/Nethermind/Nethermind.Evm/BlockExecutionContext.cs @@ -1,9 +1,7 @@ // SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited // SPDX-License-Identifier: LGPL-3.0-only -using System; using Nethermind.Core; -using Nethermind.Core.Specs; using Nethermind.Int256; namespace Nethermind.Evm; @@ -13,17 +11,9 @@ public readonly struct BlockExecutionContext public BlockHeader Header { get; } public UInt256? BlobBaseFee { get; } - public BlockExecutionContext(BlockHeader blockHeader, IReleaseSpec spec) + public BlockExecutionContext(BlockHeader blockHeader) { Header = blockHeader; - if (blockHeader?.ExcessBlobGas is not null) - { - if (!BlobGasCalculator.TryCalculateFeePerBlobGas(blockHeader, out UInt256 feePerBlobGas, spec)) - { - throw new OverflowException("Blob gas price calculation led to overflow."); - } - BlobBaseFee = feePerBlobGas; - } } public BlockExecutionContext(BlockHeader blockHeader, UInt256 forceBlobBaseFee) @@ -32,4 +22,5 @@ public BlockExecutionContext(BlockHeader blockHeader, UInt256 forceBlobBaseFee) BlobBaseFee = forceBlobBaseFee; } + public static implicit operator BlockExecutionContext(BlockHeader header) => new(header); } diff --git a/src/Nethermind/Nethermind.Evm/Tracing/GasEstimator.cs b/src/Nethermind/Nethermind.Evm/Tracing/GasEstimator.cs index e05eeb5234b..c3eb80143c6 100644 --- a/src/Nethermind/Nethermind.Evm/Tracing/GasEstimator.cs +++ b/src/Nethermind/Nethermind.Evm/Tracing/GasEstimator.cs @@ -114,8 +114,7 @@ private bool TryExecutableTransaction(Transaction transaction, BlockHeader block transaction.GasLimit = gasLimit; - BlockExecutionContext blCtx = new(block, _specProvider.GetSpec(block)); - _transactionProcessor.CallAndRestore(transaction, in blCtx, tracer.WithCancellation(token)); + _transactionProcessor.CallAndRestore(transaction, block, tracer.WithCancellation(token)); transaction.GasLimit = originalGasLimit; return !tracer.OutOfGas; diff --git a/src/Nethermind/Nethermind.Evm/TransactionProcessing/ITransactionProcessor.cs b/src/Nethermind/Nethermind.Evm/TransactionProcessing/ITransactionProcessor.cs index 25c0e2c9ac6..e347490cb11 100644 --- a/src/Nethermind/Nethermind.Evm/TransactionProcessing/ITransactionProcessor.cs +++ b/src/Nethermind/Nethermind.Evm/TransactionProcessing/ITransactionProcessor.cs @@ -34,31 +34,4 @@ public interface ITransactionProcessor /// Will NOT charge gas from sender account /// TransactionResult Warmup(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer); - - /// - /// Execute transaction, commit state - /// - TransactionResult Execute(Transaction transaction, in BlockHeader blockHeader, ITxTracer txTracer); - - /// - /// Call transaction, rollback state - /// - TransactionResult CallAndRestore(Transaction transaction, in BlockHeader blockHeader, ITxTracer txTracer); - - /// - /// Execute transaction, keep the state uncommitted - /// - TransactionResult BuildUp(Transaction transaction, in BlockHeader blockHeader, ITxTracer txTracer); - - /// - /// Call transaction, no validations, commit state - /// Will NOT charge gas from sender account, so stateDiff will miss gas fee - /// - TransactionResult Trace(Transaction transaction, in BlockHeader blockHeader, ITxTracer txTracer); - - /// - /// Call transaction, no validations, don't commit state - /// Will NOT charge gas from sender account - /// - TransactionResult Warmup(Transaction transaction, in BlockHeader blockHeader, ITxTracer txTracer); } diff --git a/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs b/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs index 594a682938e..ec4ee8d9708 100644 --- a/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs +++ b/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs @@ -100,20 +100,9 @@ protected TransactionProcessorBase( _logManager = logManager; } - public TransactionResult CallAndRestore(Transaction transaction, in BlockHeader header, ITxTracer txTracer) => - ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider.GetSpec(header)), txTracer, ExecutionOptions.CommitAndRestore); - public TransactionResult CallAndRestore(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer) => ExecuteCore(transaction, in blCtx, txTracer, ExecutionOptions.CommitAndRestore); - public TransactionResult BuildUp(Transaction transaction, in BlockHeader header, ITxTracer txTracer) - { - // we need to treat the result of previous transaction as the original value of next transaction - // when we do not commit - WorldState.TakeSnapshot(true); - return ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider.GetSpec(header)), txTracer, ExecutionOptions.None); - } - public TransactionResult BuildUp(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer) { // we need to treat the result of previous transaction as the original value of next transaction @@ -122,21 +111,12 @@ public TransactionResult BuildUp(Transaction transaction, in BlockExecutionConte return ExecuteCore(transaction, in blCtx, txTracer, ExecutionOptions.None); } - public TransactionResult Execute(Transaction transaction, in BlockHeader header, ITxTracer txTracer) => - ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider.GetSpec(header)), txTracer, ExecutionOptions.Commit); - public TransactionResult Execute(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer) => ExecuteCore(transaction, in blCtx, txTracer, ExecutionOptions.Commit); - public TransactionResult Trace(Transaction transaction, in BlockHeader header, ITxTracer txTracer) => - ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider.GetSpec(header)), txTracer, ExecutionOptions.NoValidation); - public TransactionResult Trace(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer) => ExecuteCore(transaction, in blCtx, txTracer, ExecutionOptions.NoValidation); - public TransactionResult Warmup(Transaction transaction, in BlockHeader header, ITxTracer txTracer) => - ExecuteCore(transaction, new BlockExecutionContext(header, SpecProvider.GetSpec(header)), txTracer, ExecutionOptions.Warmup); - public TransactionResult Warmup(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer) => ExecuteCore(transaction, in blCtx, txTracer, ExecutionOptions.Warmup); @@ -145,7 +125,7 @@ private TransactionResult ExecuteCore(Transaction tx, in BlockExecutionContext b if (tx.IsSystem()) { _systemTransactionProcessor ??= new SystemTransactionProcessor(SpecProvider, WorldState, VirtualMachine, _codeInfoRepository, _logManager); - return _systemTransactionProcessor.Execute(tx, new BlockExecutionContext(blCtx.Header, SpecProvider.GetSpec(blCtx.Header)), tracer, opts); + return _systemTransactionProcessor.Execute(tx, blCtx, tracer, opts); } return Execute(tx, in blCtx, tracer, opts); diff --git a/src/Nethermind/Nethermind.Evm/VirtualMachine.cs b/src/Nethermind/Nethermind.Evm/VirtualMachine.cs index 2d12fccfef9..e909bf46ae2 100644 --- a/src/Nethermind/Nethermind.Evm/VirtualMachine.cs +++ b/src/Nethermind/Nethermind.Evm/VirtualMachine.cs @@ -1515,11 +1515,23 @@ private CallResult ExecuteCode - blobBaseFeeOverride is not null ? new BlockExecutionContext(block.Header, blobBaseFeeOverride.Value) : base.CreateBlockExecutionContext(block, spec); + protected override BlockExecutionContext CreateBlockExecutionContext(Block block) => + blobBaseFeeOverride is not null ? new BlockExecutionContext(block.Header, blobBaseFeeOverride.Value) : base.CreateBlockExecutionContext(block); protected override void ProcessTransaction(in BlockExecutionContext blkCtx, Transaction currentTx, int index, BlockReceiptsTracer receiptsTracer, ProcessingOptions processingOptions) { diff --git a/src/Nethermind/Nethermind.Taiko/BlockInvalidTxExecutor.cs b/src/Nethermind/Nethermind.Taiko/BlockInvalidTxExecutor.cs index 2a49f1bc937..24785ebaaa1 100644 --- a/src/Nethermind/Nethermind.Taiko/BlockInvalidTxExecutor.cs +++ b/src/Nethermind/Nethermind.Taiko/BlockInvalidTxExecutor.cs @@ -32,7 +32,6 @@ public TxReceipt[] ProcessTransactions(Block block, ProcessingOptions processing block.Transactions[0].IsAnchorTx = true; - BlockExecutionContext blkCtx = new(block.Header, spec); using ArrayPoolList correctTransactions = new(block.Transactions.Length); for (int i = 0; i < block.Transactions.Length; i++) @@ -50,7 +49,7 @@ public TxReceipt[] ProcessTransactions(Block block, ProcessingOptions processing try { - if (!_txProcessor.Execute(tx, in blkCtx, receiptsTracer)) + if (!_txProcessor.Execute(tx, block.Header, receiptsTracer)) { // if the transaction was invalid, we ignore it and continue _worldState.Restore(snap); diff --git a/src/Nethermind/Nethermind.Taiko/Rpc/TaikoEngineRpcModule.cs b/src/Nethermind/Nethermind.Taiko/Rpc/TaikoEngineRpcModule.cs index 14e6b588f9c..b85976738fd 100644 --- a/src/Nethermind/Nethermind.Taiko/Rpc/TaikoEngineRpcModule.cs +++ b/src/Nethermind/Nethermind.Taiko/Rpc/TaikoEngineRpcModule.cs @@ -158,7 +158,6 @@ void CommitAndDisposeBatch(Batch batch) batch.Dispose(); } - BlockExecutionContext blkCtx = new(blockHeader, _specProvider.GetSpec(blockHeader)); worldState.StateRoot = blockHeader.StateRoot; Batch batch = new(maxBytesPerTxList, txSource.Length, txDecoder); @@ -172,7 +171,7 @@ void CommitAndDisposeBatch(Batch batch) try { - TransactionResult executionResult = txProcessor.Execute(tx, in blkCtx, NullTxTracer.Instance); + TransactionResult executionResult = txProcessor.Execute(tx, blockHeader, NullTxTracer.Instance); if (!executionResult) { From 7a70d04ec7946c1d48df3d9d127276c7645c6ec6 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Sun, 8 Dec 2024 15:51:45 +0500 Subject: [PATCH 40/68] refactoring --- .../AuRaContractGasLimitOverrideTests.cs | 3 +-- .../ReportingValidatorContractTests.cs | 4 ++-- .../Contract/TxPriorityContractTests.cs | 2 +- .../Contract/ValidatorContractTests.cs | 7 ++----- .../Reward/AuRaRewardCalculatorTests.cs | 21 +++++++++---------- .../Transactions/TxCertifierFilterTests.cs | 7 +++---- .../Validators/ContractBasedValidatorTests.cs | 2 +- .../BeaconBlockRoot/BeaconBlockRootHandler.cs | 1 - .../Contracts/CallableContract.cs | 6 ++---- .../Contracts/Contract.cs | 5 +---- .../AuRaValidatorFactory.cs | 4 ++-- .../Contracts/BlockGasLimitContract.cs | 6 ++---- .../Contracts/CertifierContract.cs | 6 ++---- .../Contracts/RandomContract.cs | 6 ++---- .../Contracts/RegisterBasedContract.cs | 4 +--- .../Contracts/RegisterContract.cs | 6 ++---- .../Contracts/ReportingValidatorContract.cs | 6 ++---- .../Contracts/RewardContract.cs | 5 ++--- .../TransactionPermissionContract.cs | 6 ++---- .../TransactionPermissionContractV1.cs | 5 ++--- .../TransactionPermissionContractV2.cs | 6 ++---- .../TransactionPermissionContractV3.cs | 2 +- .../TransactionPermissionContractV4.cs | 2 +- .../Contracts/TxPriorityContract.cs | 6 ++---- .../Contracts/ValidatorContract.cs | 6 ++---- .../VersionedTransactionPermissionContract.cs | 18 ++++++---------- .../InitializeBlockchainAuRa.cs | 5 ++--- .../StartBlockProducerAuRa.cs | 6 ++---- .../TxAuRaFilterBuilders.cs | 10 ++++----- .../Rewards/AuRaRewardCalculator.cs | 13 +++++------- .../BlockchainBridgeContract.cs | 3 +-- .../AuRaMergeEngineModuleTests.cs | 2 +- .../AuRaMergeBlockProducerEnvFactory.cs | 2 +- .../Contracts/WithdrawalContract.cs | 6 ++---- .../InitializeBlockchainAuRaMerge.cs | 2 +- .../Withdrawals/WithdrawalContractFactory.cs | 7 ++----- .../ShutterApiSimulator.cs | 2 +- .../ShutterEventSimulator.cs | 6 ++---- .../ShutterTestsCommon.cs | 3 +-- .../ShutterTxLoaderTests.cs | 9 +++----- .../ShutterValidatorRegistryTests.cs | 4 +--- .../Contracts/KeyBroadcastContract.cs | 3 +-- .../Contracts/KeyperSetContract.cs | 3 +-- .../Contracts/KeyperSetManagerContract.cs | 3 +-- .../Contracts/SequencerContract.cs | 5 ++--- .../Contracts/ValidatorRegistryContract.cs | 6 ++---- .../Nethermind.Shutter/ShutterApi.cs | 9 ++++---- .../Nethermind.Shutter/ShutterBlockHandler.cs | 8 ++----- .../Nethermind.Shutter/ShutterEon.cs | 10 ++++----- .../Nethermind.Shutter/ShutterTxLoader.cs | 2 +- 50 files changed, 104 insertions(+), 177 deletions(-) diff --git a/src/Nethermind/Nethermind.AuRa.Test/Contract/AuRaContractGasLimitOverrideTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Contract/AuRaContractGasLimitOverrideTests.cs index d07a2242f5e..079f507fe05 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Contract/AuRaContractGasLimitOverrideTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Contract/AuRaContractGasLimitOverrideTests.cs @@ -90,8 +90,7 @@ protected override BlockProcessor CreateBlockProcessor() blockGasLimitContractTransition.Key, new ReadOnlyTxProcessingEnv( WorldStateManager, - BlockTree.AsReadOnly(), SpecProvider, LimboLogs.Instance), - SpecProvider); + BlockTree.AsReadOnly(), SpecProvider, LimboLogs.Instance)); GasLimitOverrideCache = new AuRaContractGasLimitOverride.Cache(); GasLimitCalculator = new AuRaContractGasLimitOverride(new[] { gasLimitContract }, GasLimitOverrideCache, false, new FollowOtherMiners(SpecProvider), LimboLogs.Instance); diff --git a/src/Nethermind/Nethermind.AuRa.Test/Contract/ReportingValidatorContractTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Contract/ReportingValidatorContractTests.cs index d43dd5504a3..3d5d52e2dcf 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Contract/ReportingValidatorContractTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Contract/ReportingValidatorContractTests.cs @@ -18,7 +18,7 @@ public class ReportingValidatorContractTests [Test] public void Should_generate_malicious_transaction() { - ReportingValidatorContract contract = new(AbiEncoder.Instance, new Address("0x1000000000000000000000000000000000000001"), Substitute.For(), TestSpecProvider.Instance); + ReportingValidatorContract contract = new(AbiEncoder.Instance, new Address("0x1000000000000000000000000000000000000001"), Substitute.For()); Transaction transaction = contract.ReportMalicious(new Address("0x75df42383afe6bf5194aa8fa0e9b3d5f9e869441"), 10, []); transaction.Data.AsArray().ToHexString().Should().Be("c476dd4000000000000000000000000075df42383afe6bf5194aa8fa0e9b3d5f9e869441000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000"); } @@ -26,7 +26,7 @@ public void Should_generate_malicious_transaction() [Test] public void Should_generate_benign_transaction() { - ReportingValidatorContract contract = new(AbiEncoder.Instance, new Address("0x1000000000000000000000000000000000000001"), Substitute.For(), TestSpecProvider.Instance); + ReportingValidatorContract contract = new(AbiEncoder.Instance, new Address("0x1000000000000000000000000000000000000001"), Substitute.For()); Transaction transaction = contract.ReportBenign(new Address("0x75df42383afe6bf5194aa8fa0e9b3d5f9e869441"), 10); transaction.Data.AsArray().ToHexString().Should().Be("d69f13bb00000000000000000000000075df42383afe6bf5194aa8fa0e9b3d5f9e869441000000000000000000000000000000000000000000000000000000000000000a"); } diff --git a/src/Nethermind/Nethermind.AuRa.Test/Contract/TxPriorityContractTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Contract/TxPriorityContractTests.cs index 91b0067d859..31d9053833b 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Contract/TxPriorityContractTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Contract/TxPriorityContractTests.cs @@ -254,7 +254,7 @@ protected override TxPoolTxSource CreateTxPoolTxSource() TxPoolTxSource txPoolTxSource = base.CreateTxPoolTxSource(); TxPriorityContract = new TxPriorityContract(AbiEncoder.Instance, TestItem.AddressA, - new ReadOnlyTxProcessingEnv(WorldStateManager, BlockTree.AsReadOnly(), SpecProvider, LimboLogs.Instance), SpecProvider); + new ReadOnlyTxProcessingEnv(WorldStateManager, BlockTree.AsReadOnly(), SpecProvider, LimboLogs.Instance)); Priorities = new DictionaryContractDataStore( new TxPriorityContract.DestinationSortedListContractDataStoreCollection(), diff --git a/src/Nethermind/Nethermind.AuRa.Test/Contract/ValidatorContractTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Contract/ValidatorContractTests.cs index 09d920e1f17..282e2827875 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Contract/ValidatorContractTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Contract/ValidatorContractTests.cs @@ -16,7 +16,6 @@ using Nethermind.Evm.Tracing; using Nethermind.Evm.TransactionProcessing; using Nethermind.Logging; -using Nethermind.Specs; using Nethermind.State; using NSubstitute; using NUnit.Framework; @@ -53,8 +52,7 @@ public void constructor_throws_ArgumentNullException_on_null_contractAddress() null, _stateProvider, _readOnlyTxProcessorSource, - new Signer(0, TestItem.PrivateKeyD, LimboLogs.Instance), - TestSpecProvider.Instance); + new Signer(0, TestItem.PrivateKeyD, LimboLogs.Instance)); action.Should().Throw(); } @@ -80,8 +78,7 @@ public void finalize_change_should_call_correct_transaction() _contractAddress, _stateProvider, _readOnlyTxProcessorSource, - new Signer(0, TestItem.PrivateKeyD, LimboLogs.Instance), - TestSpecProvider.Instance); + new Signer(0, TestItem.PrivateKeyD, LimboLogs.Instance)); contract.FinalizeChange(_block.Header); diff --git a/src/Nethermind/Nethermind.AuRa.Test/Reward/AuRaRewardCalculatorTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Reward/AuRaRewardCalculatorTests.cs index 00eb2a777ec..9ed0eb7caaf 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Reward/AuRaRewardCalculatorTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Reward/AuRaRewardCalculatorTests.cs @@ -20,7 +20,6 @@ using NSubstitute; using NUnit.Framework; using Nethermind.Evm; -using Nethermind.Specs; namespace Nethermind.AuRa.Test.Reward { @@ -61,21 +60,21 @@ public void SetUp() [Test] public void constructor_throws_ArgumentNullException_on_null_auraParameters() { - Action action = () => new AuRaRewardCalculator(null, _abiEncoder, _transactionProcessor, TestSpecProvider.Instance); + Action action = () => new AuRaRewardCalculator(null, _abiEncoder, _transactionProcessor); action.Should().Throw(); } [Test] public void constructor_throws_ArgumentNullException_on_null_encoder() { - Action action = () => new AuRaRewardCalculator(_auraParameters, null, _transactionProcessor, TestSpecProvider.Instance); + Action action = () => new AuRaRewardCalculator(_auraParameters, null, _transactionProcessor); action.Should().Throw(); } [Test] public void constructor_throws_ArgumentNullException_on_null_transactionProcessor() { - Action action = () => new AuRaRewardCalculator(_auraParameters, _abiEncoder, null, TestSpecProvider.Instance); + Action action = () => new AuRaRewardCalculator(_auraParameters, _abiEncoder, null); action.Should().Throw(); } @@ -87,7 +86,7 @@ public void constructor_throws_ArgumentException_on_BlockRewardContractTransitio {2, Address.FromNumber(2)} }; - Action action = () => new AuRaRewardCalculator(_auraParameters, _abiEncoder, _transactionProcessor, TestSpecProvider.Instance); + Action action = () => new AuRaRewardCalculator(_auraParameters, _abiEncoder, _transactionProcessor); action.Should().Throw(); } @@ -97,7 +96,7 @@ public void constructor_throws_ArgumentException_on_BlockRewardContractTransitio public void calculates_rewards_correctly_before_contract_transition(long blockNumber, ulong expectedReward) { _block.Header.Number = blockNumber; - AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor, TestSpecProvider.Instance); + AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor); BlockReward[] result = calculator.CalculateRewards(_block); result.Should().BeEquivalentTo(new BlockReward(_block.Beneficiary, expectedReward)); } @@ -106,7 +105,7 @@ public void calculates_rewards_correctly_before_contract_transition(long blockNu public void calculates_rewards_correctly_for_genesis() { _block.Header.Number = 0; - AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor, TestSpecProvider.Instance); + AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor); BlockReward[] result = calculator.CalculateRewards(_block); result.Should().BeEmpty(); } @@ -118,7 +117,7 @@ public void calculates_rewards_correctly_after_contract_transition(long blockNum _block.Header.Number = blockNumber; BlockReward expected = new(_block.Beneficiary, expectedReward, BlockRewardType.External); SetupBlockRewards(new Dictionary() { { _address10, new[] { expected } } }); - AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor, TestSpecProvider.Instance); + AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor); BlockReward[] result = calculator.CalculateRewards(_block); result.Should().BeEquivalentTo(expected); } @@ -144,7 +143,7 @@ public void calculates_rewards_correctly_after_subsequent_contract_transitions(l _block.Header.Number = blockNumber; BlockReward expected = new(_block.Beneficiary, expectedReward, BlockRewardType.External); SetupBlockRewards(new Dictionary() { { address, new[] { expected } } }); - AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor, TestSpecProvider.Instance); + AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor); BlockReward[] result = calculator.CalculateRewards(_block); result.Should().BeEquivalentTo(expected); } @@ -167,7 +166,7 @@ public void calculates_rewards_correctly_for_uncles(long blockNumber, ulong expe }; SetupBlockRewards(new Dictionary() { { _address10, expected } }); - AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor, TestSpecProvider.Instance); + AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor); BlockReward[] result = calculator.CalculateRewards(_block); result.Should().BeEquivalentTo(expected); } @@ -190,7 +189,7 @@ public void calculates_rewards_correctly_for_external_addresses() }; SetupBlockRewards(new Dictionary() { { _address10, expected } }); - AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor, TestSpecProvider.Instance); + AuRaRewardCalculator calculator = new(_auraParameters, _abiEncoder, _transactionProcessor); BlockReward[] result = calculator.CalculateRewards(_block); result.Should().BeEquivalentTo(expected); } diff --git a/src/Nethermind/Nethermind.AuRa.Test/Transactions/TxCertifierFilterTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Transactions/TxCertifierFilterTests.cs index 879c76b5a58..cda399944da 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Transactions/TxCertifierFilterTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Transactions/TxCertifierFilterTests.cs @@ -124,7 +124,7 @@ public async Task registry_contract_returns_not_found_when_key_doesnt_exist() public async Task registry_contract_returns_not_found_when_contract_doesnt_exist() { using TestTxPermissionsBlockchain chain = await TestContractBlockchain.ForTest(); - RegisterContract contract = new(AbiEncoder.Instance, Address.FromNumber(1000), chain.ReadOnlyTransactionProcessorSource, _specProvider); + RegisterContract contract = new(AbiEncoder.Instance, Address.FromNumber(1000), chain.ReadOnlyTransactionProcessorSource); contract.TryGetAddress(chain.BlockTree.Head.Header, CertifierContract.ServiceTransactionContractRegistryName, out Address _).Should().BeFalse(); } @@ -141,12 +141,11 @@ protected override BlockProcessor CreateBlockProcessor() WorldStateManager, BlockTree.AsReadOnly(), SpecProvider, LimboLogs.Instance); - RegisterContract = new RegisterContract(abiEncoder, ChainSpec.Parameters.Registrar, ReadOnlyTransactionProcessorSource, Substitute.For()); + RegisterContract = new RegisterContract(abiEncoder, ChainSpec.Parameters.Registrar, ReadOnlyTransactionProcessorSource); CertifierContract = new CertifierContract( abiEncoder, RegisterContract, - ReadOnlyTransactionProcessorSource, - Substitute.For()); + ReadOnlyTransactionProcessorSource); return new AuRaBlockProcessor( SpecProvider, diff --git a/src/Nethermind/Nethermind.AuRa.Test/Validators/ContractBasedValidatorTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Validators/ContractBasedValidatorTests.cs index 777c651afc7..d1f780f9072 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Validators/ContractBasedValidatorTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Validators/ContractBasedValidatorTests.cs @@ -89,7 +89,7 @@ public void SetUp() .Encode(AbiEncodingStyle.IncludeSignature, Arg.Is(s => s.Name == "finalizeChange"), Arg.Any()) .Returns(_finalizeChangeData.TransactionData); - _validatorContract = new ValidatorContract(_transactionProcessor, _abiEncoder, _contractAddress, _stateProvider, _readOnlyTxProcessorSource, new Signer(0, TestItem.PrivateKeyD, LimboLogs.Instance), TestSpecProvider.Instance); + _validatorContract = new ValidatorContract(_transactionProcessor, _abiEncoder, _contractAddress, _stateProvider, _readOnlyTxProcessorSource, new Signer(0, TestItem.PrivateKeyD, LimboLogs.Instance)); } [TearDown] diff --git a/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs b/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs index d856300961d..068b6bc0985 100644 --- a/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs +++ b/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs @@ -5,7 +5,6 @@ using Nethermind.Core.Eip2930; using Nethermind.Core.Specs; using Nethermind.Crypto; -using Nethermind.Evm; using Nethermind.Evm.Tracing; using Nethermind.Evm.TransactionProcessing; using Nethermind.Int256; diff --git a/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs b/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs index ad43f8cd9a6..02088df3fd8 100644 --- a/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs +++ b/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs @@ -4,7 +4,6 @@ using System; using Nethermind.Abi; using Nethermind.Core; -using Nethermind.Core.Specs; using Nethermind.Int256; using Nethermind.Evm; using Nethermind.Evm.Tracing; @@ -25,8 +24,7 @@ public abstract class CallableContract : Contract /// Transaction processor on which all should be run on. /// Binary interface encoder/decoder. /// Address where contract is deployed. - /// Address where contract is deployed. - protected CallableContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress, ISpecProvider specProvider) : base(specProvider, abiEncoder, contractAddress) + protected CallableContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress) : base(abiEncoder, contractAddress) { _transactionProcessor = transactionProcessor ?? throw new ArgumentNullException(nameof(transactionProcessor)); } @@ -89,7 +87,7 @@ private bool TryCall(BlockHeader header, Transaction transaction, out byte[] res /// Arguments to the function. /// true if function was otherwise false. protected bool TryCall(BlockHeader header, string functionName, Address sender, out object[] result, params object[] arguments) => - TryCall(header, functionName, sender, DefaultContractGasLimit, out result); + TryCall(header, functionName, sender, DefaultContractGasLimit, out result, arguments); /// /// Same as but returns false instead of throwing . diff --git a/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs b/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs index 8f90bd18b18..f06ed66e541 100644 --- a/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs +++ b/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs @@ -37,21 +37,18 @@ public abstract partial class Contract protected IAbiEncoder AbiEncoder { get; } public AbiDefinition AbiDefinition { get; } public Address? ContractAddress { get; protected set; } - protected ISpecProvider SpecProvider { get; set; } /// /// Creates contract /// - /// Binary interface encoder/decoder. /// Binary interface encoder/decoder. /// Address where contract is deployed. /// Binary definition of contract. - protected Contract(ISpecProvider specProvider, IAbiEncoder? abiEncoder = null, Address? contractAddress = null, AbiDefinition? abiDefinition = null) + protected Contract(IAbiEncoder? abiEncoder = null, Address? contractAddress = null, AbiDefinition? abiDefinition = null) { AbiEncoder = abiEncoder ?? Abi.AbiEncoder.Instance; ContractAddress = contractAddress; AbiDefinition = abiDefinition ?? new AbiDefinitionParser().Parse(GetType()); - SpecProvider = specProvider; } protected virtual Transaction GenerateTransaction(Address? contractAddress, byte[] transactionData, Address sender, long gasLimit = DefaultContractGasLimit, BlockHeader header = null) diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/AuRaValidatorFactory.cs b/src/Nethermind/Nethermind.Consensus.AuRa/AuRaValidatorFactory.cs index 7a130b41a03..927b327f6ed 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/AuRaValidatorFactory.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/AuRaValidatorFactory.cs @@ -79,8 +79,8 @@ public AuRaValidatorFactory(IAbiEncoder abiEncoder, public IAuRaValidator CreateValidatorProcessor(AuRaParameters.Validator validator, BlockHeader parentHeader = null, long? startBlock = null) { - IValidatorContract GetValidatorContract() => new ValidatorContract(_transactionProcessor, _abiEncoder, validator.GetContractAddress(), _stateProvider, _readOnlyTxProcessorSource, _signer, _specProvider); - IReportingValidatorContract GetReportingValidatorContract() => new ReportingValidatorContract(_abiEncoder, validator.GetContractAddress(), _signer, _specProvider); + IValidatorContract GetValidatorContract() => new ValidatorContract(_transactionProcessor, _abiEncoder, validator.GetContractAddress(), _stateProvider, _readOnlyTxProcessorSource, _signer); + IReportingValidatorContract GetReportingValidatorContract() => new ReportingValidatorContract(_abiEncoder, validator.GetContractAddress(), _signer); var validSealerStrategy = new ValidSealerStrategy(); long startBlockNumber = startBlock ?? AuRaValidatorBase.DefaultStartBlockNumber; diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/BlockGasLimitContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/BlockGasLimitContract.cs index b04304e16e3..37954b6ca9a 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/BlockGasLimitContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/BlockGasLimitContract.cs @@ -5,7 +5,6 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; -using Nethermind.Core.Specs; using Nethermind.Int256; using Nethermind.Evm.TransactionProcessing; @@ -25,9 +24,8 @@ public BlockGasLimitContract( IAbiEncoder abiEncoder, Address contractAddress, long transitionBlock, - IReadOnlyTxProcessorSource readOnlyTxProcessorSource, - ISpecProvider specProvider) - : base(specProvider, abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) + IReadOnlyTxProcessorSource readOnlyTxProcessorSource) + : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) { Activation = transitionBlock; Constant = GetConstant(readOnlyTxProcessorSource); diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/CertifierContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/CertifierContract.cs index 40fac04475c..a5aa60a0c6c 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/CertifierContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/CertifierContract.cs @@ -3,7 +3,6 @@ using Nethermind.Abi; using Nethermind.Core; -using Nethermind.Core.Specs; using Nethermind.Evm.TransactionProcessing; namespace Nethermind.Consensus.AuRa.Contracts @@ -23,9 +22,8 @@ public class CertifierContract : RegisterBasedContract, ICertifierContract public CertifierContract( IAbiEncoder abiEncoder, IRegisterContract registerContract, - IReadOnlyTxProcessorSource readOnlyTransactionProcessorSource, - ISpecProvider specProvider) - : base(abiEncoder, registerContract, ServiceTransactionContractRegistryName, specProvider) + IReadOnlyTxProcessorSource readOnlyTransactionProcessorSource) + : base(abiEncoder, registerContract, ServiceTransactionContractRegistryName) { Constant = GetConstant(readOnlyTransactionProcessorSource); } diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RandomContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RandomContract.cs index 51d086e2c29..18ada055792 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RandomContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RandomContract.cs @@ -5,7 +5,6 @@ using Nethermind.Abi; using Nethermind.Core; using Nethermind.Core.Crypto; -using Nethermind.Core.Specs; using Nethermind.Int256; using Nethermind.Evm.TransactionProcessing; @@ -82,9 +81,8 @@ public RandomContract( Address contractAddress, IReadOnlyTxProcessorSource readOnlyTxProcessorSource, long transitionBlock, - ISigner signer, - ISpecProvider specProvider) - : base(specProvider, abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) + ISigner signer) + : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) { _signer = signer; Activation = transitionBlock; diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RegisterBasedContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RegisterBasedContract.cs index 70ac339bbaa..572563fb64a 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RegisterBasedContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RegisterBasedContract.cs @@ -5,7 +5,6 @@ using Nethermind.Blockchain.Contracts; using Nethermind.Core; using Nethermind.Core.Crypto; -using Nethermind.Core.Specs; namespace Nethermind.Consensus.AuRa.Contracts { @@ -19,9 +18,8 @@ public RegisterBasedContract( IAbiEncoder abiEncoder, IRegisterContract registerContract, string registryKey, - ISpecProvider specProvider, AbiDefinition? abiDefinition = null) - : base(specProvider, abiEncoder, abiDefinition: abiDefinition) + : base(abiEncoder, abiDefinition: abiDefinition) { _registerContract = registerContract; _registryKey = registryKey; diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RegisterContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RegisterContract.cs index 3e1c9cb02be..6d7d3e67960 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RegisterContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RegisterContract.cs @@ -6,7 +6,6 @@ using Nethermind.Blockchain.Contracts; using Nethermind.Core; using Nethermind.Core.Crypto; -using Nethermind.Core.Specs; using Nethermind.Evm.TransactionProcessing; namespace Nethermind.Consensus.AuRa.Contracts @@ -34,9 +33,8 @@ public class RegisterContract : Contract, IRegisterContract public RegisterContract( IAbiEncoder abiEncoder, Address contractAddress, - IReadOnlyTxProcessorSource readOnlyTxProcessorSource, - ISpecProvider specProvider) - : base(specProvider, abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) + IReadOnlyTxProcessorSource readOnlyTxProcessorSource) + : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) { Constant = GetConstant(readOnlyTxProcessorSource); } diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/ReportingValidatorContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/ReportingValidatorContract.cs index 9f41a42a970..75041e9b453 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/ReportingValidatorContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/ReportingValidatorContract.cs @@ -5,7 +5,6 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; -using Nethermind.Core.Specs; using Nethermind.Int256; namespace Nethermind.Consensus.AuRa.Contracts @@ -48,9 +47,8 @@ public sealed class ReportingValidatorContract : Contract, IReportingValidatorCo public ReportingValidatorContract( IAbiEncoder abiEncoder, Address contractAddress, - ISigner signer, - ISpecProvider specProvider) - : base(specProvider, abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) + ISigner signer) + : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) { _signer = signer ?? throw new ArgumentNullException(nameof(signer)); } diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RewardContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RewardContract.cs index 93440e4f84c..e78314f8d97 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RewardContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/RewardContract.cs @@ -5,7 +5,6 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; -using Nethermind.Core.Specs; using Nethermind.Int256; using Nethermind.Evm.TransactionProcessing; @@ -35,8 +34,8 @@ public sealed class RewardContract : CallableContract, IRewardContract { public long Activation { get; } - public RewardContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress, long transitionBlock, ISpecProvider specProvider) - : base(transactionProcessor, abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress)), specProvider) + public RewardContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress, long transitionBlock) + : base(transactionProcessor, abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) { Activation = transitionBlock; } diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContract.cs index 9c276860eaa..28f57bded5d 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContract.cs @@ -5,7 +5,6 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; -using Nethermind.Core.Specs; using Nethermind.Int256; using Nethermind.Evm.TransactionProcessing; @@ -98,9 +97,8 @@ protected virtual (ITransactionPermissionContract.TxPermissions, bool) CallAllow protected TransactionPermissionContract( IAbiEncoder abiEncoder, Address contractAddress, - IReadOnlyTxProcessorSource readOnlyTxProcessorSource, - ISpecProvider specProvider) - : base(specProvider, abiEncoder, contractAddress) + IReadOnlyTxProcessorSource readOnlyTxProcessorSource) + : base(abiEncoder, contractAddress) { Constant = new PermissionConstantContract(this, readOnlyTxProcessorSource); } diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV1.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV1.cs index 8cbb6fcc09a..6d47bd5314b 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV1.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV1.cs @@ -15,9 +15,8 @@ public sealed class TransactionPermissionContractV1 : TransactionPermissionContr public TransactionPermissionContractV1( IAbiEncoder abiEncoder, Address contractAddress, - IReadOnlyTxProcessorSource readOnlyTxProcessorSource, - ISpecProvider specProvider) - : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress)), readOnlyTxProcessorSource, specProvider) + IReadOnlyTxProcessorSource readOnlyTxProcessorSource) + : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress)), readOnlyTxProcessorSource) { } diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV2.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV2.cs index 8fc239ae454..d5bbfa9299a 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV2.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV2.cs @@ -4,7 +4,6 @@ using System; using Nethermind.Abi; using Nethermind.Core; -using Nethermind.Core.Specs; using Nethermind.Int256; using Nethermind.Evm.TransactionProcessing; @@ -17,9 +16,8 @@ public sealed class TransactionPermissionContractV2 : TransactionPermissionContr public TransactionPermissionContractV2( IAbiEncoder abiEncoder, Address contractAddress, - IReadOnlyTxProcessorSource readOnlyTxProcessorSource, - ISpecProvider specProvider) - : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress)), readOnlyTxProcessorSource, specProvider) + IReadOnlyTxProcessorSource readOnlyTxProcessorSource) + : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress)), readOnlyTxProcessorSource) { } diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV3.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV3.cs index a5ad74f0f2d..b000814b50d 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV3.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV3.cs @@ -21,7 +21,7 @@ public TransactionPermissionContractV3( Address contractAddress, IReadOnlyTxProcessorSource readOnlyTxProcessorSource, ISpecProvider specProvider) - : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress)), readOnlyTxProcessorSource, specProvider) + : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress)), readOnlyTxProcessorSource) { _specProvider = specProvider; } diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV4.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV4.cs index c1b5fa08922..4413b7f9491 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV4.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV4.cs @@ -21,7 +21,7 @@ public TransactionPermissionContractV4( Address contractAddress, IReadOnlyTxProcessorSource readOnlyTxProcessorSource, ISpecProvider specProvider) - : base(abiEncoder, contractAddress, readOnlyTxProcessorSource, specProvider) + : base(abiEncoder, contractAddress, readOnlyTxProcessorSource) { _specProvider = specProvider; } diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TxPriorityContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TxPriorityContract.cs index 5dbe55cf32a..b15cebf9d34 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TxPriorityContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TxPriorityContract.cs @@ -7,7 +7,6 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; -using Nethermind.Core.Specs; using Nethermind.Evm.TransactionProcessing; using Nethermind.Facade; using Nethermind.Int256; @@ -29,9 +28,8 @@ public partial class TxPriorityContract : Contract public TxPriorityContract( IAbiEncoder abiEncoder, Address contractAddress, - IReadOnlyTxProcessorSource readOnlyTxProcessorSource, - ISpecProvider specProvider) - : base(specProvider, abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) + IReadOnlyTxProcessorSource readOnlyTxProcessorSource) + : base(abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) { Constant = GetConstant(readOnlyTxProcessorSource); SendersWhitelist = new DataContract
(GetSendersWhitelist, SendersWhitelistSet); diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/ValidatorContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/ValidatorContract.cs index f84b082c8cd..7483dc283db 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/ValidatorContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/ValidatorContract.cs @@ -5,7 +5,6 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; -using Nethermind.Core.Specs; using Nethermind.State; using Nethermind.Evm.TransactionProcessing; using Nethermind.Facade; @@ -61,9 +60,8 @@ public ValidatorContract( Address contractAddress, IWorldState stateProvider, IReadOnlyTxProcessorSource readOnlyTxProcessorSource, - ISigner signer, - ISpecProvider specProvider) - : base(transactionProcessor, abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress)), specProvider) + ISigner signer) + : base(transactionProcessor, abiEncoder, contractAddress ?? throw new ArgumentNullException(nameof(contractAddress))) { _stateProvider = stateProvider ?? throw new ArgumentNullException(nameof(stateProvider)); _signer = signer ?? throw new ArgumentNullException(nameof(signer)); diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/VersionedTransactionPermissionContract.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/VersionedTransactionPermissionContract.cs index 03a1125af71..ad6b86eb354 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/VersionedTransactionPermissionContract.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/VersionedTransactionPermissionContract.cs @@ -35,26 +35,22 @@ public VersionedTransactionPermissionContract(IAbiEncoder abiEncoder, private static TransactionPermissionContractV1 CreateV1(IAbiEncoder abiEncoder, Address contractAddress, - IReadOnlyTxProcessorSource readOnlyTxProcessorSource, - ISpecProvider specProvider) + IReadOnlyTxProcessorSource readOnlyTxProcessorSource) { return new( abiEncoder, contractAddress, - readOnlyTxProcessorSource, - specProvider); + readOnlyTxProcessorSource); } private static TransactionPermissionContractV2 CreateV2(IAbiEncoder abiEncoder, Address contractAddress, - IReadOnlyTxProcessorSource readOnlyTxProcessorSource, - ISpecProvider specProvider) + IReadOnlyTxProcessorSource readOnlyTxProcessorSource) { return new( abiEncoder, contractAddress, - readOnlyTxProcessorSource, - specProvider); + readOnlyTxProcessorSource); } private static TransactionPermissionContractV3 CreateV3(IAbiEncoder abiEncoder, @@ -93,15 +89,13 @@ private static Dictionary CreateAllVers UInt256.One, CreateV1(abiEncoder, contractAddress, - readOnlyTxProcessorSource, - specProvider) + readOnlyTxProcessorSource) }, { 2, CreateV2(abiEncoder, contractAddress, - readOnlyTxProcessorSource, - specProvider) + readOnlyTxProcessorSource) }, { 3, diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/InitializeBlockchainAuRa.cs b/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/InitializeBlockchainAuRa.cs index fbc762be516..c4a85476e3a 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/InitializeBlockchainAuRa.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/InitializeBlockchainAuRa.cs @@ -181,8 +181,7 @@ protected IAuRaValidator CreateAuRaValidator() _api.AbiEncoder, blockGasLimitContractTransition.Value, blockGasLimitContractTransition.Key, - _api.CreateReadOnlyTransactionProcessorSource(), - _api.SpecProvider!)) + _api.CreateReadOnlyTransactionProcessorSource())) .ToArray(), _api.GasLimitCalculatorCache, _auraConfig.Minimum2MlnGasPerBlockWhenUsingBlockGasLimitContract, @@ -205,7 +204,7 @@ protected override void InitSealEngine() ValidSealerStrategy validSealerStrategy = new ValidSealerStrategy(); _api.SealValidator = _sealValidator = new AuRaSealValidator(_parameters, _auRaStepCalculator, _api.BlockTree, _api.ValidatorStore, validSealerStrategy, _api.EthereumEcdsa, _api.LogManager); - _api.RewardCalculatorSource = new AuRaRewardCalculator.AuRaRewardCalculatorSource(_parameters, _api.AbiEncoder, _api.SpecProvider!); + _api.RewardCalculatorSource = new AuRaRewardCalculator.AuRaRewardCalculatorSource(_parameters, _api.AbiEncoder); _api.Sealer = new AuRaSealer(_api.BlockTree, _api.ValidatorStore, _auRaStepCalculator, _api.EngineSigner, validSealerStrategy, _api.LogManager); } diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/StartBlockProducerAuRa.cs b/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/StartBlockProducerAuRa.cs index 620a9da51e8..6ab1105f81d 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/StartBlockProducerAuRa.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/StartBlockProducerAuRa.cs @@ -298,8 +298,7 @@ IList GetRandomContracts( kvp.Value, txProcessorSource, kvp.Key, - signerLocal, - _api.SpecProvider!)) + signerLocal)) .ToArray(); if (randomnessContractAddress?.Any() == true) @@ -368,8 +367,7 @@ private static IGasLimitCalculator CreateGasLimitCalculator(AuRaNethermindApi ap api.AbiEncoder, blockGasLimitContractTransition.Value, blockGasLimitContractTransition.Key, - api.CreateReadOnlyTransactionProcessorSource(), - api.SpecProvider!)) + api.CreateReadOnlyTransactionProcessorSource())) .ToArray(), api.GasLimitCalculatorCache, api.Config().Minimum2MlnGasPerBlockWhenUsingBlockGasLimitContract == true, diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/TxAuRaFilterBuilders.cs b/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/TxAuRaFilterBuilders.cs index 010c91cc910..6f3cfb20156 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/TxAuRaFilterBuilders.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/TxAuRaFilterBuilders.cs @@ -48,8 +48,8 @@ private static ITxFilter CreateBaseAuRaTxFilter( Address? registrar = api.ChainSpec?.Parameters.Registrar; if (registrar is not null) { - RegisterContract registerContract = new(api.AbiEncoder, registrar, api.CreateReadOnlyTransactionProcessorSource(), specProvider); - CertifierContract certifierContract = new(api.AbiEncoder, registerContract, api.CreateReadOnlyTransactionProcessorSource(), specProvider); + RegisterContract registerContract = new(api.AbiEncoder, registrar, api.CreateReadOnlyTransactionProcessorSource()); + CertifierContract certifierContract = new(api.AbiEncoder, registerContract, api.CreateReadOnlyTransactionProcessorSource()); return CreateFilter(new TxCertifierFilter(certifierContract, gasPriceTxFilter, specProvider, api.LogManager), gasPriceTxFilter); } @@ -63,8 +63,8 @@ private static ITxFilter CreateBaseAuRaTxFilter( Address? registrar = api.ChainSpec?.Parameters.Registrar; if (registrar is not null) { - RegisterContract registerContract = new(api.AbiEncoder, registrar, api.CreateReadOnlyTransactionProcessorSource(), api.SpecProvider!); - CertifierContract certifierContract = new(api.AbiEncoder, registerContract, api.CreateReadOnlyTransactionProcessorSource(), api.SpecProvider!); + RegisterContract registerContract = new(api.AbiEncoder, registrar, api.CreateReadOnlyTransactionProcessorSource()); + CertifierContract certifierContract = new(api.AbiEncoder, registerContract, api.CreateReadOnlyTransactionProcessorSource()); return CreateFilter(new TxCertifierFilter(certifierContract, baseTxFilter, api.SpecProvider, api.LogManager)); } @@ -125,7 +125,7 @@ public static ITxFilter CreateAuRaTxFilter(AuRaNethermindApi api, ITxFilter base TxPriorityContract? txPriorityContract = null; if (usesTxPriorityContract) { - txPriorityContract = new TxPriorityContract(api.AbiEncoder, txPriorityContractAddress, api.CreateReadOnlyTransactionProcessorSource(), api.SpecProvider!); + txPriorityContract = new TxPriorityContract(api.AbiEncoder, txPriorityContractAddress, api.CreateReadOnlyTransactionProcessorSource()); } return txPriorityContract; diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Rewards/AuRaRewardCalculator.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Rewards/AuRaRewardCalculator.cs index aca69c49d18..83dc02b25b2 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Rewards/AuRaRewardCalculator.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Rewards/AuRaRewardCalculator.cs @@ -9,7 +9,6 @@ using Nethermind.Consensus.AuRa.Contracts; using Nethermind.Consensus.Rewards; using Nethermind.Core; -using Nethermind.Core.Specs; using Nethermind.Evm.TransactionProcessing; namespace Nethermind.Consensus.AuRa.Rewards @@ -19,7 +18,7 @@ public class AuRaRewardCalculator : IRewardCalculator private readonly StaticRewardCalculator _blockRewardCalculator; private readonly IList _contracts; - public AuRaRewardCalculator(AuRaChainSpecEngineParameters auRaParameters, IAbiEncoder abiEncoder, ITransactionProcessor transactionProcessor, ISpecProvider specProvider) + public AuRaRewardCalculator(AuRaChainSpecEngineParameters auRaParameters, IAbiEncoder abiEncoder, ITransactionProcessor transactionProcessor) { ArgumentNullException.ThrowIfNull(auRaParameters); ArgumentNullException.ThrowIfNull(abiEncoder); @@ -31,7 +30,7 @@ IList BuildTransitions() if (auRaParameters.BlockRewardContractTransitions is not null) { - contracts.AddRange(auRaParameters.BlockRewardContractTransitions.Select(t => new RewardContract(transactionProcessor, abiEncoder, t.Value, t.Key, specProvider))); + contracts.AddRange(auRaParameters.BlockRewardContractTransitions.Select(t => new RewardContract(transactionProcessor, abiEncoder, t.Value, t.Key))); contracts.Sort((a, b) => a.Activation.CompareTo(b.Activation)); } @@ -43,7 +42,7 @@ IList BuildTransitions() throw new ArgumentException($"{nameof(auRaParameters.BlockRewardContractTransition)} provided for {nameof(auRaParameters.BlockRewardContractAddress)} is higher than first {nameof(auRaParameters.BlockRewardContractTransitions)}."); } - contracts.Insert(0, new RewardContract(transactionProcessor, abiEncoder, auRaParameters.BlockRewardContractAddress, contractTransition, specProvider)); + contracts.Insert(0, new RewardContract(transactionProcessor, abiEncoder, auRaParameters.BlockRewardContractAddress, contractTransition)); } return contracts; @@ -109,16 +108,14 @@ public class AuRaRewardCalculatorSource : IRewardCalculatorSource { private readonly AuRaChainSpecEngineParameters _auRaParameters; private readonly IAbiEncoder _abiEncoder; - private readonly ISpecProvider _specProvider; - public AuRaRewardCalculatorSource(AuRaChainSpecEngineParameters auRaParameters, IAbiEncoder abiEncoder, ISpecProvider specProvider) + public AuRaRewardCalculatorSource(AuRaChainSpecEngineParameters auRaParameters, IAbiEncoder abiEncoder) { _auRaParameters = auRaParameters; _abiEncoder = abiEncoder; - _specProvider = specProvider; } - public IRewardCalculator Get(ITransactionProcessor processor) => new AuRaRewardCalculator(_auRaParameters, _abiEncoder, processor, _specProvider); + public IRewardCalculator Get(ITransactionProcessor processor) => new AuRaRewardCalculator(_auRaParameters, _abiEncoder, processor); } public static class BenefactorKind diff --git a/src/Nethermind/Nethermind.Facade/BlockchainBridgeContract.cs b/src/Nethermind/Nethermind.Facade/BlockchainBridgeContract.cs index 11228815dc5..9e87f5e5ec2 100644 --- a/src/Nethermind/Nethermind.Facade/BlockchainBridgeContract.cs +++ b/src/Nethermind/Nethermind.Facade/BlockchainBridgeContract.cs @@ -5,13 +5,12 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; -using Nethermind.Core.Specs; namespace Nethermind.Facade { public abstract class BlockchainBridgeContract : Contract { - public BlockchainBridgeContract(IAbiEncoder abiEncoder, Address contractAddress, ISpecProvider specProvider, AbiDefinition? abiDefinition = null) : base(specProvider, abiEncoder, contractAddress, abiDefinition) + public BlockchainBridgeContract(IAbiEncoder abiEncoder, Address contractAddress, AbiDefinition? abiDefinition = null) : base(abiEncoder, contractAddress, abiDefinition) { } diff --git a/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs b/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs index 71ca7df6e79..7aed634bac3 100644 --- a/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs +++ b/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs @@ -143,7 +143,7 @@ protected override IBlockProcessor CreateBlockProcessor() }; WithdrawalContractFactory withdrawalContractFactory = new(_api.ChainSpec!.EngineChainSpecParametersProvider - .GetChainSpecParameters(), _api.AbiEncoder, _api.SpecProvider); + .GetChainSpecParameters(), _api.AbiEncoder); WithdrawalProcessor = new AuraWithdrawalProcessor( withdrawalContractFactory.Create(TxProcessor), LogManager diff --git a/src/Nethermind/Nethermind.Merge.AuRa/AuRaMergeBlockProducerEnvFactory.cs b/src/Nethermind/Nethermind.Merge.AuRa/AuRaMergeBlockProducerEnvFactory.cs index bb1a751ce87..7a01e984cfc 100644 --- a/src/Nethermind/Nethermind.Merge.AuRa/AuRaMergeBlockProducerEnvFactory.cs +++ b/src/Nethermind/Nethermind.Merge.AuRa/AuRaMergeBlockProducerEnvFactory.cs @@ -68,7 +68,7 @@ protected override BlockProcessor CreateBlockProcessor( { var withdrawalContractFactory = new WithdrawalContractFactory( _auraApi.ChainSpec.EngineChainSpecParametersProvider - .GetChainSpecParameters(), _auraApi.AbiEncoder, specProvider); + .GetChainSpecParameters(), _auraApi.AbiEncoder); return new AuRaMergeBlockProcessor( specProvider, diff --git a/src/Nethermind/Nethermind.Merge.AuRa/Contracts/WithdrawalContract.cs b/src/Nethermind/Nethermind.Merge.AuRa/Contracts/WithdrawalContract.cs index 3a3007370f5..4f6b82d7595 100644 --- a/src/Nethermind/Nethermind.Merge.AuRa/Contracts/WithdrawalContract.cs +++ b/src/Nethermind/Nethermind.Merge.AuRa/Contracts/WithdrawalContract.cs @@ -6,7 +6,6 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; -using Nethermind.Core.Specs; using Nethermind.Evm.TransactionProcessing; using Nethermind.Int256; @@ -24,9 +23,8 @@ public class WithdrawalContract : CallableContract, IWithdrawalContract public WithdrawalContract( ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, - Address contractAddress, - ISpecProvider specProvider) - : base(transactionProcessor, abiEncoder, contractAddress, specProvider) { } + Address contractAddress) + : base(transactionProcessor, abiEncoder, contractAddress) { } public void ExecuteWithdrawals(BlockHeader blockHeader, UInt256 failedMaxCount, IList amounts, IList
addresses) { diff --git a/src/Nethermind/Nethermind.Merge.AuRa/InitializationSteps/InitializeBlockchainAuRaMerge.cs b/src/Nethermind/Nethermind.Merge.AuRa/InitializationSteps/InitializeBlockchainAuRaMerge.cs index 11ce1e4f2c0..1bcb350888c 100644 --- a/src/Nethermind/Nethermind.Merge.AuRa/InitializationSteps/InitializeBlockchainAuRaMerge.cs +++ b/src/Nethermind/Nethermind.Merge.AuRa/InitializationSteps/InitializeBlockchainAuRaMerge.cs @@ -33,7 +33,7 @@ protected override AuRaBlockProcessor NewAuraBlockProcessor(ITxFilter txFilter, IDictionary> rewriteBytecode = _parameters.RewriteBytecode; ContractRewriter? contractRewriter = rewriteBytecode?.Count > 0 ? new ContractRewriter(rewriteBytecode) : null; - WithdrawalContractFactory withdrawalContractFactory = new WithdrawalContractFactory(_parameters, _api.AbiEncoder, _api.SpecProvider!); + WithdrawalContractFactory withdrawalContractFactory = new WithdrawalContractFactory(_parameters, _api.AbiEncoder); IWorldState worldState = _api.WorldState!; ITransactionProcessor transactionProcessor = _api.TransactionProcessor!; diff --git a/src/Nethermind/Nethermind.Merge.AuRa/Withdrawals/WithdrawalContractFactory.cs b/src/Nethermind/Nethermind.Merge.AuRa/Withdrawals/WithdrawalContractFactory.cs index ee515f79deb..8bcff3cfad8 100644 --- a/src/Nethermind/Nethermind.Merge.AuRa/Withdrawals/WithdrawalContractFactory.cs +++ b/src/Nethermind/Nethermind.Merge.AuRa/Withdrawals/WithdrawalContractFactory.cs @@ -5,7 +5,6 @@ using Nethermind.Abi; using Nethermind.Consensus.AuRa.Config; using Nethermind.Core; -using Nethermind.Core.Specs; using Nethermind.Evm.TransactionProcessing; using Nethermind.Merge.AuRa.Contracts; @@ -15,21 +14,19 @@ public class WithdrawalContractFactory : IWithdrawalContractFactory { private readonly IAbiEncoder _abiEncoder; private readonly Address _contractAddress; - private readonly ISpecProvider _specProvider; - public WithdrawalContractFactory(AuRaChainSpecEngineParameters parameters, IAbiEncoder abiEncoder, ISpecProvider specProvider) + public WithdrawalContractFactory(AuRaChainSpecEngineParameters parameters, IAbiEncoder abiEncoder) { ArgumentNullException.ThrowIfNull(parameters); _abiEncoder = abiEncoder ?? throw new ArgumentNullException(nameof(abiEncoder)); _contractAddress = parameters.WithdrawalContractAddress; - _specProvider = specProvider ?? throw new ArgumentNullException(nameof(specProvider)); } public IWithdrawalContract Create(ITransactionProcessor processor) { ArgumentNullException.ThrowIfNull(processor); - return new WithdrawalContract(processor, _abiEncoder, _contractAddress, _specProvider); + return new WithdrawalContract(processor, _abiEncoder, _contractAddress); } } diff --git a/src/Nethermind/Nethermind.Shutter.Test/ShutterApiSimulator.cs b/src/Nethermind/Nethermind.Shutter.Test/ShutterApiSimulator.cs index 33f7f1fca0d..68616f48c68 100644 --- a/src/Nethermind/Nethermind.Shutter.Test/ShutterApiSimulator.cs +++ b/src/Nethermind/Nethermind.Shutter.Test/ShutterApiSimulator.cs @@ -121,7 +121,7 @@ protected override void InitP2P(IPAddress _) P2P = Substitute.For(); } - protected override IShutterEon InitEon(ISpecProvider specProvider) + protected override IShutterEon InitEon() { IShutterEon eon = Substitute.For(); eon.GetCurrentEonInfo().Returns(_ => eventSimulator.GetCurrentEonInfo()); diff --git a/src/Nethermind/Nethermind.Shutter.Test/ShutterEventSimulator.cs b/src/Nethermind/Nethermind.Shutter.Test/ShutterEventSimulator.cs index 5198dd6b357..c6009bb761c 100644 --- a/src/Nethermind/Nethermind.Shutter.Test/ShutterEventSimulator.cs +++ b/src/Nethermind/Nethermind.Shutter.Test/ShutterEventSimulator.cs @@ -14,7 +14,6 @@ using Nethermind.Serialization.Rlp; using Nethermind.Core.Test.Builders; using Nethermind.Abi; -using Nethermind.Core.Specs; using G1 = Nethermind.Crypto.Bls.P1; using G2 = Nethermind.Crypto.Bls.P2; using EncryptedMessage = Nethermind.Shutter.ShutterCrypto.EncryptedMessage; @@ -45,8 +44,7 @@ public ShutterEventSimulator( ulong threshold, ulong slot, IAbiEncoder abiEncoder, - Address sequencerContractAddress, - ISpecProvider specProvider + Address sequencerContractAddress ) { _rnd = rnd; @@ -57,7 +55,7 @@ ISpecProvider specProvider _threshold = threshold; _abiEncoder = abiEncoder; _sequencerContractAddress = sequencerContractAddress; - _transactionSubmittedAbi = new SequencerContract(sequencerContractAddress, specProvider).TransactionSubmittedAbi; + _transactionSubmittedAbi = new SequencerContract(sequencerContractAddress).TransactionSubmittedAbi; _defaultMaxKeyCount = (int)Math.Floor((decimal)ShutterTestsCommon.Cfg.EncryptedGasLimit / DefaultGasLimit); _eventSource = EmitEvents(); diff --git a/src/Nethermind/Nethermind.Shutter.Test/ShutterTestsCommon.cs b/src/Nethermind/Nethermind.Shutter.Test/ShutterTestsCommon.cs index f1557c73531..5f0689493b0 100644 --- a/src/Nethermind/Nethermind.Shutter.Test/ShutterTestsCommon.cs +++ b/src/Nethermind/Nethermind.Shutter.Test/ShutterTestsCommon.cs @@ -78,8 +78,7 @@ public static ShutterEventSimulator InitEventSimulator(Random rnd) Threshold, InitialSlot, AbiEncoder, - new(Cfg.SequencerContractAddress!), - SpecProvider + new(Cfg.SequencerContractAddress!) ); public static Timestamper InitTimestamper(ulong slotTimestamp, ulong offsetMs) diff --git a/src/Nethermind/Nethermind.Shutter.Test/ShutterTxLoaderTests.cs b/src/Nethermind/Nethermind.Shutter.Test/ShutterTxLoaderTests.cs index e81cbc8b40f..decd53ded26 100644 --- a/src/Nethermind/Nethermind.Shutter.Test/ShutterTxLoaderTests.cs +++ b/src/Nethermind/Nethermind.Shutter.Test/ShutterTxLoaderTests.cs @@ -9,7 +9,6 @@ using Nethermind.Merge.Plugin; using Nethermind.Merge.Plugin.Data; using Nethermind.Abi; -using Nethermind.Core.Specs; using Nethermind.Core.Test.Builders; using Nethermind.Merge.Plugin.Test; @@ -18,7 +17,7 @@ namespace Nethermind.Shutter.Test; [TestFixture] class ShutterTxLoaderTests : EngineModuleTests { - private class ShutterEventSimulatorHalfNextEon(Random rnd, ulong chainId, ulong threshold, ulong slot, IAbiEncoder abiEncoder, Address sequencerContractAddress, ISpecProvider specProvider) : ShutterEventSimulator(rnd, chainId, threshold, slot, abiEncoder, sequencerContractAddress, specProvider) + private class ShutterEventSimulatorHalfNextEon(Random rnd, ulong chainId, ulong threshold, ulong slot, IAbiEncoder abiEncoder, Address sequencerContractAddress) : ShutterEventSimulator(rnd, chainId, threshold, slot, abiEncoder, sequencerContractAddress) { protected override IEnumerable EmitEvents() { @@ -67,8 +66,7 @@ public async Task Can_load_and_filter_transactions() ShutterTestsCommon.Threshold, ShutterTestsCommon.InitialSlot, ShutterTestsCommon.AbiEncoder, - new(ShutterTestsCommon.Cfg.SequencerContractAddress!), - ShutterTestsCommon.SpecProvider + new(ShutterTestsCommon.Cfg.SequencerContractAddress!) ); using var chain = (ShutterTestBlockchain)await new ShutterTestBlockchain(rnd, null, eventSimulator).Build(ShutterTestsCommon.SpecProvider); @@ -181,8 +179,7 @@ public async Task Can_load_transactions_with_overlapping_eons() ShutterTestsCommon.Threshold, ShutterTestsCommon.InitialSlot, ShutterTestsCommon.AbiEncoder, - new(ShutterTestsCommon.Cfg.SequencerContractAddress!), - ShutterTestsCommon.SpecProvider + new(ShutterTestsCommon.Cfg.SequencerContractAddress!) ); using var chain = (ShutterTestBlockchain)await new ShutterTestBlockchain(rnd, null, eventSimulator).Build(ShutterTestsCommon.SpecProvider); diff --git a/src/Nethermind/Nethermind.Shutter.Test/ShutterValidatorRegistryTests.cs b/src/Nethermind/Nethermind.Shutter.Test/ShutterValidatorRegistryTests.cs index df0193d18b3..87bfdf69fcd 100644 --- a/src/Nethermind/Nethermind.Shutter.Test/ShutterValidatorRegistryTests.cs +++ b/src/Nethermind/Nethermind.Shutter.Test/ShutterValidatorRegistryTests.cs @@ -12,7 +12,6 @@ using Nethermind.Shutter.Config; using Nethermind.Crypto; using Nethermind.Core.Crypto; -using Nethermind.Core.Specs; using Update = (byte[] Message, byte[] Signature); using G1 = Nethermind.Crypto.Bls.P1; @@ -32,8 +31,7 @@ public void Can_check_if_registered() Address.Zero, LimboLogs.Instance, ShutterTestsCommon.ChainId, - 1, - Substitute.For()); + 1); ShutterValidatorsInfo validatorsInfo = new(); List<(uint, Update)> updates = []; diff --git a/src/Nethermind/Nethermind.Shutter/Contracts/KeyBroadcastContract.cs b/src/Nethermind/Nethermind.Shutter/Contracts/KeyBroadcastContract.cs index 7cf337d80b2..b73ff06897e 100644 --- a/src/Nethermind/Nethermind.Shutter/Contracts/KeyBroadcastContract.cs +++ b/src/Nethermind/Nethermind.Shutter/Contracts/KeyBroadcastContract.cs @@ -4,12 +4,11 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; -using Nethermind.Core.Specs; using Nethermind.Evm.TransactionProcessing; namespace Nethermind.Shutter.Contracts; -public class KeyBroadcastContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress, ISpecProvider specProvider) : CallableContract(transactionProcessor, abiEncoder, contractAddress, specProvider), IKeyBroadcastContract +public class KeyBroadcastContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress) : CallableContract(transactionProcessor, abiEncoder, contractAddress), IKeyBroadcastContract { public byte[] GetEonKey(BlockHeader blockHeader, in ulong eon) { diff --git a/src/Nethermind/Nethermind.Shutter/Contracts/KeyperSetContract.cs b/src/Nethermind/Nethermind.Shutter/Contracts/KeyperSetContract.cs index af3f9ba7a35..aba64940166 100644 --- a/src/Nethermind/Nethermind.Shutter/Contracts/KeyperSetContract.cs +++ b/src/Nethermind/Nethermind.Shutter/Contracts/KeyperSetContract.cs @@ -4,12 +4,11 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; -using Nethermind.Core.Specs; using Nethermind.Evm.TransactionProcessing; namespace Nethermind.Shutter.Contracts; -public class KeyperSetContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress, ISpecProvider specProvider) : CallableContract(transactionProcessor, abiEncoder, contractAddress, specProvider), IKeyperSetContract +public class KeyperSetContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress) : CallableContract(transactionProcessor, abiEncoder, contractAddress), IKeyperSetContract { public bool IsFinalized(BlockHeader blockHeader) { diff --git a/src/Nethermind/Nethermind.Shutter/Contracts/KeyperSetManagerContract.cs b/src/Nethermind/Nethermind.Shutter/Contracts/KeyperSetManagerContract.cs index 890680a37e7..8f49d1fc81a 100644 --- a/src/Nethermind/Nethermind.Shutter/Contracts/KeyperSetManagerContract.cs +++ b/src/Nethermind/Nethermind.Shutter/Contracts/KeyperSetManagerContract.cs @@ -4,12 +4,11 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; -using Nethermind.Core.Specs; using Nethermind.Evm.TransactionProcessing; namespace Nethermind.Shutter.Contracts; -public class KeyperSetManagerContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress, ISpecProvider specProvider) : CallableContract(transactionProcessor, abiEncoder, contractAddress, specProvider), IKeyperSetManagerContract +public class KeyperSetManagerContract(ITransactionProcessor transactionProcessor, IAbiEncoder abiEncoder, Address contractAddress) : CallableContract(transactionProcessor, abiEncoder, contractAddress), IKeyperSetManagerContract { public Address GetKeyperSetAddress(BlockHeader blockHeader, in ulong index) { diff --git a/src/Nethermind/Nethermind.Shutter/Contracts/SequencerContract.cs b/src/Nethermind/Nethermind.Shutter/Contracts/SequencerContract.cs index e43e84c1ae7..115b27d9b2e 100644 --- a/src/Nethermind/Nethermind.Shutter/Contracts/SequencerContract.cs +++ b/src/Nethermind/Nethermind.Shutter/Contracts/SequencerContract.cs @@ -4,7 +4,6 @@ using Nethermind.Abi; using Nethermind.Blockchain.Contracts; using Nethermind.Core; -using Nethermind.Core.Specs; namespace Nethermind.Shutter.Contracts; @@ -13,8 +12,8 @@ public class SequencerContract : Contract, ISequencerContract public AbiEncodingInfo TransactionSubmittedAbi { get => _transactionSubmittedAbi; } private readonly AbiEncodingInfo _transactionSubmittedAbi; - public SequencerContract(Address address, ISpecProvider specProvider) - : base(specProvider, null, address) + public SequencerContract(Address address) + : base(null, address) { _transactionSubmittedAbi = AbiDefinition.GetEvent(nameof(ISequencerContract.TransactionSubmitted)).GetCallInfo(AbiEncodingStyle.None); } diff --git a/src/Nethermind/Nethermind.Shutter/Contracts/ValidatorRegistryContract.cs b/src/Nethermind/Nethermind.Shutter/Contracts/ValidatorRegistryContract.cs index 247259ccc29..9b1e887590b 100644 --- a/src/Nethermind/Nethermind.Shutter/Contracts/ValidatorRegistryContract.cs +++ b/src/Nethermind/Nethermind.Shutter/Contracts/ValidatorRegistryContract.cs @@ -14,7 +14,6 @@ using Nethermind.Crypto; using Nethermind.Shutter.Config; using System.Linq; -using Nethermind.Core.Specs; using Update = (byte[] Message, byte[] Signature); namespace Nethermind.Shutter.Contracts; @@ -25,9 +24,8 @@ public class ValidatorRegistryContract( Address contractAddress, ILogManager logManager, ulong chainId, - ulong messageVersion, - ISpecProvider specProvider) - : CallableContract(transactionProcessor, abiEncoder, contractAddress, specProvider), IValidatorRegistryContract + ulong messageVersion) + : CallableContract(transactionProcessor, abiEncoder, contractAddress), IValidatorRegistryContract { private readonly ILogger _logger = logManager.GetClassLogger(); diff --git a/src/Nethermind/Nethermind.Shutter/ShutterApi.cs b/src/Nethermind/Nethermind.Shutter/ShutterApi.cs index 15d90e5b050..72e6968a31b 100644 --- a/src/Nethermind/Nethermind.Shutter/ShutterApi.cs +++ b/src/Nethermind/Nethermind.Shutter/ShutterApi.cs @@ -83,7 +83,7 @@ IPAddress ip Time = InitTime(specProvider, timestamper); TxLoader = new(logFinder, _cfg, Time, specProvider, ecdsa, abiEncoder, logManager); - Eon = InitEon(specProvider); + Eon = InitEon(); BlockHandler = new ShutterBlockHandler( specProvider.ChainId, _cfg, @@ -97,8 +97,7 @@ IPAddress ip Time, logManager, _slotLength, - BlockWaitCutoff, - specProvider); + BlockWaitCutoff); TxSource = new ShutterTxSource(TxLoader, _cfg, Time, logManager); @@ -155,8 +154,8 @@ protected virtual void InitP2P(IPAddress ip) P2P = new ShutterP2P(_cfg, _logManager, _fileSystem, _keyStoreConfig, ip); } - protected virtual IShutterEon InitEon(ISpecProvider specProvider) - => new ShutterEon(_readOnlyBlockTree, _txProcessingEnvFactory, _abiEncoder, _cfg, _logManager, specProvider); + protected virtual IShutterEon InitEon() + => new ShutterEon(_readOnlyBlockTree, _txProcessingEnvFactory, _abiEncoder, _cfg, _logManager); protected virtual ShutterTime InitTime(ISpecProvider specProvider, ITimestamper timestamper) => new(specProvider.BeaconChainGenesisTimestamp!.Value * 1000, timestamper, _slotLength, _blockUpToDateCutoff); diff --git a/src/Nethermind/Nethermind.Shutter/ShutterBlockHandler.cs b/src/Nethermind/Nethermind.Shutter/ShutterBlockHandler.cs index dbb7feeaf99..873db545473 100644 --- a/src/Nethermind/Nethermind.Shutter/ShutterBlockHandler.cs +++ b/src/Nethermind/Nethermind.Shutter/ShutterBlockHandler.cs @@ -16,7 +16,6 @@ using Nethermind.Core.Crypto; using Nethermind.Blockchain; using Nethermind.Core.Collections; -using Nethermind.Core.Specs; using Nethermind.Shutter.Config; namespace Nethermind.Shutter; @@ -43,7 +42,6 @@ public class ShutterBlockHandler : IShutterBlockHandler private readonly Dictionary> _blockWaitTasks = []; private readonly LruCache _slotToBlockHash = new(5, "Slot to block hash mapping"); private readonly Lock _syncObject = new(); - private readonly ISpecProvider _specProvider; public ShutterBlockHandler( ulong chainId, @@ -58,8 +56,7 @@ public ShutterBlockHandler( ShutterTime time, ILogManager logManager, TimeSpan slotLength, - TimeSpan blockWaitCutoff, - ISpecProvider specProvider) + TimeSpan blockWaitCutoff) { _chainId = chainId; _cfg = cfg; @@ -76,7 +73,6 @@ public ShutterBlockHandler( _envFactory = envFactory; _slotLength = slotLength; _blockWaitCutoff = blockWaitCutoff; - _specProvider = specProvider; _blockTree.NewHeadBlock += OnNewHeadBlock; } @@ -204,7 +200,7 @@ private void CheckAllValidatorsRegistered(in BlockHeader parent, in ShutterValid IReadOnlyTxProcessingScope scope = _envFactory.Create().Build(parent.StateRoot!); ITransactionProcessor processor = scope.TransactionProcessor; - ValidatorRegistryContract validatorRegistryContract = new(processor, _abiEncoder, new(_cfg.ValidatorRegistryContractAddress!), _logManager, _chainId, _cfg.ValidatorRegistryMessageVersion!, _specProvider); + ValidatorRegistryContract validatorRegistryContract = new(processor, _abiEncoder, new(_cfg.ValidatorRegistryContractAddress!), _logManager, _chainId, _cfg.ValidatorRegistryMessageVersion!); if (validatorRegistryContract.IsRegistered(parent, validatorsInfo, out HashSet unregistered)) { if (_logger.IsInfo) _logger.Info($"All Shutter validator keys are registered."); diff --git a/src/Nethermind/Nethermind.Shutter/ShutterEon.cs b/src/Nethermind/Nethermind.Shutter/ShutterEon.cs index 60a6d681656..b330d36be26 100644 --- a/src/Nethermind/Nethermind.Shutter/ShutterEon.cs +++ b/src/Nethermind/Nethermind.Shutter/ShutterEon.cs @@ -11,7 +11,6 @@ using Nethermind.Shutter.Config; using Nethermind.Consensus.Processing; using Nethermind.Core.Crypto; -using Nethermind.Core.Specs; namespace Nethermind.Shutter; @@ -20,8 +19,7 @@ public class ShutterEon( ReadOnlyTxProcessingEnvFactory envFactory, IAbiEncoder abiEncoder, IShutterConfig shutterConfig, - ILogManager logManager, - ISpecProvider specProvider) : IShutterEon + ILogManager logManager) : IShutterEon { private IShutterEon.Info? _currentInfo; private readonly Address _keyBroadcastContractAddress = new(shutterConfig.KeyBroadcastContractAddress!); @@ -38,20 +36,20 @@ public void Update(BlockHeader header) try { - KeyperSetManagerContract keyperSetManagerContract = new(processor, abiEncoder, _keyperSetManagerContractAddress, specProvider); + KeyperSetManagerContract keyperSetManagerContract = new(processor, abiEncoder, _keyperSetManagerContractAddress); ulong eon = keyperSetManagerContract.GetKeyperSetIndexByBlock(header, (ulong)header.Number + 1); if (_currentInfo is null || _currentInfo.Value.Eon != eon) { Address keyperSetContractAddress = keyperSetManagerContract.GetKeyperSetAddress(header, eon); - KeyperSetContract keyperSetContract = new(processor, abiEncoder, keyperSetContractAddress, specProvider); + KeyperSetContract keyperSetContract = new(processor, abiEncoder, keyperSetContractAddress); if (keyperSetContract.IsFinalized(header)) { ulong threshold = keyperSetContract.GetThreshold(header); Address[] addresses = keyperSetContract.GetMembers(header); - KeyBroadcastContract keyBroadcastContract = new(processor, abiEncoder, _keyBroadcastContractAddress, specProvider); + KeyBroadcastContract keyBroadcastContract = new(processor, abiEncoder, _keyBroadcastContractAddress); byte[] eonKey = keyBroadcastContract.GetEonKey(blockTree.Head!.Header, eon); // update atomically diff --git a/src/Nethermind/Nethermind.Shutter/ShutterTxLoader.cs b/src/Nethermind/Nethermind.Shutter/ShutterTxLoader.cs index f38ab883b9a..0e8d2f814b3 100644 --- a/src/Nethermind/Nethermind.Shutter/ShutterTxLoader.cs +++ b/src/Nethermind/Nethermind.Shutter/ShutterTxLoader.cs @@ -33,7 +33,7 @@ public class ShutterTxLoader( ILogManager logManager) { private readonly ShutterLogScanner _logScanner = new( - new(new Address(cfg.SequencerContractAddress!), specProvider), + new(new Address(cfg.SequencerContractAddress!)), logFinder, logManager, abiEncoder); From 1d0dcc113406d121e12e79ef7afcea7050515272 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Sun, 8 Dec 2024 15:54:43 +0500 Subject: [PATCH 41/68] fix compilation erros --- src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs | 2 +- src/Nethermind/Nethermind.Evm.Benchmark/EvmBenchmarks.cs | 2 +- .../Nethermind.Evm.Benchmark/MultipleUnsignedOperations.cs | 2 +- src/Nethermind/Nethermind.Evm.Benchmark/StaticCallBenchmarks.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs b/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs index 9d8fb992fcb..44e14ace9dd 100644 --- a/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs +++ b/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs @@ -137,7 +137,7 @@ protected EthereumTestResult RunTest(GeneralStateTest test, ITxTracer txTracer) if (txIsValid) { - transactionProcessor.Execute(test.Transaction, new BlockExecutionContext(header, spec), txTracer); + transactionProcessor.Execute(test.Transaction, header, txTracer); } else { diff --git a/src/Nethermind/Nethermind.Evm.Benchmark/EvmBenchmarks.cs b/src/Nethermind/Nethermind.Evm.Benchmark/EvmBenchmarks.cs index 368fc710537..b29fcf00088 100644 --- a/src/Nethermind/Nethermind.Evm.Benchmark/EvmBenchmarks.cs +++ b/src/Nethermind/Nethermind.Evm.Benchmark/EvmBenchmarks.cs @@ -54,7 +54,7 @@ public void GlobalSetup() codeInfo: new CodeInfo(ByteCode), value: 0, transferValue: 0, - txExecutionContext: new TxExecutionContext(new BlockExecutionContext(_header, _spec), Address.Zero, 0, null, codeInfoRepository), + txExecutionContext: new TxExecutionContext(_header, Address.Zero, 0, null, codeInfoRepository), inputData: default ); diff --git a/src/Nethermind/Nethermind.Evm.Benchmark/MultipleUnsignedOperations.cs b/src/Nethermind/Nethermind.Evm.Benchmark/MultipleUnsignedOperations.cs index 04a0964cc57..97d0d9e6cf8 100644 --- a/src/Nethermind/Nethermind.Evm.Benchmark/MultipleUnsignedOperations.cs +++ b/src/Nethermind/Nethermind.Evm.Benchmark/MultipleUnsignedOperations.cs @@ -87,7 +87,7 @@ public void GlobalSetup() codeInfo: new CodeInfo(_bytecode.Concat(_bytecode).Concat(_bytecode).Concat(_bytecode).ToArray()), value: 0, transferValue: 0, - txExecutionContext: new TxExecutionContext(new BlockExecutionContext(_header, _spec), Address.Zero, 0, null, codeInfoRepository), + txExecutionContext: new TxExecutionContext(_header, Address.Zero, 0, null, codeInfoRepository), inputData: default ); diff --git a/src/Nethermind/Nethermind.Evm.Benchmark/StaticCallBenchmarks.cs b/src/Nethermind/Nethermind.Evm.Benchmark/StaticCallBenchmarks.cs index ec3e37c276f..b7b8d39945b 100644 --- a/src/Nethermind/Nethermind.Evm.Benchmark/StaticCallBenchmarks.cs +++ b/src/Nethermind/Nethermind.Evm.Benchmark/StaticCallBenchmarks.cs @@ -98,7 +98,7 @@ public void GlobalSetup() codeInfo: new CodeInfo(Bytecode), value: 0, transferValue: 0, - txExecutionContext: new TxExecutionContext(new BlockExecutionContext(_header, _spec), Address.Zero, 0, null, codeInfoRepository), + txExecutionContext: new TxExecutionContext(_header, Address.Zero, 0, null, codeInfoRepository), inputData: default ); From aba9f7c1a8a0faa28857c1c817a6918516e7d80f Mon Sep 17 00:00:00 2001 From: yerke26 Date: Sun, 8 Dec 2024 16:14:06 +0500 Subject: [PATCH 42/68] fix tests --- .../Contract/ValidatorContractTests.cs | 2 +- .../Reward/AuRaRewardCalculatorTests.cs | 2 +- .../Validators/ContractBasedValidatorTests.cs | 8 ++++---- .../Nethermind.Facade.Test/BlockchainBridgeTests.cs | 11 +++++------ tools/Evm/T8n/T8nExecutor.cs | 2 +- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/Nethermind/Nethermind.AuRa.Test/Contract/ValidatorContractTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Contract/ValidatorContractTests.cs index 282e2827875..ae1a5040a4f 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Contract/ValidatorContractTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Contract/ValidatorContractTests.cs @@ -83,7 +83,7 @@ public void finalize_change_should_call_correct_transaction() contract.FinalizeChange(_block.Header); _transactionProcessor.Received().Execute( - Arg.Is(t => IsEquivalentTo(expectation, t)), Arg.Is(blockHeader => blockHeader.Equals(_block.Header)), Arg.Any()); + Arg.Is(t => IsEquivalentTo(expectation, t)), Arg.Is(blkCtx => blkCtx.Header.Equals(_block.Header)), Arg.Any()); } private static bool IsEquivalentTo(Transaction expected, Transaction item) diff --git a/src/Nethermind/Nethermind.AuRa.Test/Reward/AuRaRewardCalculatorTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Reward/AuRaRewardCalculatorTests.cs index 9ed0eb7caaf..ff5569c876a 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Reward/AuRaRewardCalculatorTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Reward/AuRaRewardCalculatorTests.cs @@ -198,7 +198,7 @@ private void SetupBlockRewards(IDictionary rewards) { _transactionProcessor.When(x => x.Execute( Arg.Is(t => CheckTransaction(t, rewards.Keys, _rewardData)), - Arg.Is(header => header.Equals(_block.Header)), + Arg.Is(blkCtx => blkCtx.Header.Equals(_block.Header)), Arg.Is(t => t is CallOutputTracer))) .Do(args => { diff --git a/src/Nethermind/Nethermind.AuRa.Test/Validators/ContractBasedValidatorTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Validators/ContractBasedValidatorTests.cs index d1f780f9072..edba996a099 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Validators/ContractBasedValidatorTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Validators/ContractBasedValidatorTests.cs @@ -184,13 +184,13 @@ public void loads_initial_validators_from_contract(long blockNumber) _transactionProcessor.Received() .CallAndRestore( Arg.Is(t => CheckTransaction(t, _getValidatorsData)), - Arg.Is(blockHeader => blockHeader.Equals(_parentHeader)), + Arg.Is(blkCtx => blkCtx.Header.Equals(_parentHeader)), Arg.Is(t => t is CallOutputTracer)); // finalizeChange should be called _transactionProcessor.Received(finalizeChangeCalled ? 1 : 0) .Execute(Arg.Is(t => CheckTransaction(t, _finalizeChangeData)), - Arg.Is(blockHeader => blockHeader.Equals(block.Header)), + Arg.Is(blkCtx => blkCtx.Header.Equals(block.Header)), Arg.Is(t => t is CallOutputTracer)); // initial validator should be true @@ -603,7 +603,7 @@ private void ValidateFinalizationForChain(ConsecutiveInitiateChangeTestParameter // finalizeChange should be called or not based on test spec _transactionProcessor.Received(chain.ExpectedFinalizationCount) .Execute(Arg.Is(t => CheckTransaction(t, _finalizeChangeData)), - Arg.Is(header => header.Equals(_block.Header)), + Arg.Is(blkCtx => blkCtx.Header.Equals(_block.Header)), Arg.Is(t => t is CallOutputTracer)); _transactionProcessor.ClearReceivedCalls(); @@ -634,7 +634,7 @@ private void SetupInitialValidators(BlockHeader header, BlockHeader parentHeader _transactionProcessor.When(x => x.CallAndRestore( Arg.Is(t => CheckTransaction(t, _getValidatorsData)), - Arg.Any(), + Arg.Any(), Arg.Is(t => t is CallOutputTracer))) .Do(args => args.Arg().MarkAsSuccess( diff --git a/src/Nethermind/Nethermind.Facade.Test/BlockchainBridgeTests.cs b/src/Nethermind/Nethermind.Facade.Test/BlockchainBridgeTests.cs index 4cad78d270a..120f294677b 100644 --- a/src/Nethermind/Nethermind.Facade.Test/BlockchainBridgeTests.cs +++ b/src/Nethermind/Nethermind.Facade.Test/BlockchainBridgeTests.cs @@ -153,8 +153,8 @@ public void Call_uses_valid_post_merge_and_random_value() _blockchainBridge.Call(header, tx); _transactionProcessor.Received().CallAndRestore( tx, - Arg.Is(blockHeader => - blockHeader.IsPostMerge && blockHeader.Random == TestItem.KeccakA), + Arg.Is(blkCtx => + blkCtx.Header.IsPostMerge && blkCtx.Header.Random == TestItem.KeccakA), Arg.Any()); } @@ -169,7 +169,7 @@ public void Call_uses_valid_block_number() _blockchainBridge.Call(header, tx); _transactionProcessor.Received().CallAndRestore( tx, - Arg.Is(blockHeader => blockHeader.Number == 10), + Arg.Is(blkCtx => blkCtx.Header.Number == 10), Arg.Any()); } @@ -184,8 +184,7 @@ public void Call_uses_valid_mix_hash() _blockchainBridge.Call(header, tx); _transactionProcessor.Received().CallAndRestore( tx, - Arg.Is(blockHeader => blockHeader.MixHash == TestItem.KeccakA), - Arg.Any()); + Arg.Is(blkCtx => blkCtx.Header.MixHash == TestItem.KeccakA), Arg.Any()); } [Test] @@ -199,7 +198,7 @@ public void Call_uses_valid_beneficiary() _blockchainBridge.Call(header, tx); _transactionProcessor.Received().CallAndRestore( tx, - Arg.Is(blockHeader => blockHeader.Beneficiary == TestItem.AddressB), + Arg.Is(blkCtx => blkCtx.Header.Beneficiary == TestItem.AddressB), Arg.Any()); } diff --git a/tools/Evm/T8n/T8nExecutor.cs b/tools/Evm/T8n/T8nExecutor.cs index 1173e7c39c5..1869cc13a22 100644 --- a/tools/Evm/T8n/T8nExecutor.cs +++ b/tools/Evm/T8n/T8nExecutor.cs @@ -102,7 +102,7 @@ public static T8nExecutionResult Execute(T8nCommandArguments arguments) blockReceiptsTracer.StartNewTxTrace(transaction); TransactionResult transactionResult = transactionProcessor - .Execute(transaction, new BlockExecutionContext(block.Header, test.Spec), blockReceiptsTracer); + .Execute(transaction, block.Header, blockReceiptsTracer); blockReceiptsTracer.EndTxTrace(); transactionExecutionReport.ValidTransactions.Add(transaction); From 36f635d2e44154f7993edb84dce7d425127264da Mon Sep 17 00:00:00 2001 From: yerke26 Date: Sun, 8 Dec 2024 17:46:30 +0500 Subject: [PATCH 43/68] fix tests, refactoring --- .../ReportingValidatorContractTests.cs | 1 - .../Contracts/Contract.cs | 1 - .../TransactionPermissionContractV1.cs | 4 +--- .../BlockchainBridgeTests.cs | 3 ++- .../Modules/Proof/ProofRpcModule.cs | 5 +++-- .../Modules/ReceiptFinderExtensions.cs | 5 +++-- .../EngineRpcModule.cs | 2 +- .../ShutterEventSimulator.cs | 1 + .../ShutterTxLoaderTests.cs | 20 +++++++++++++++++++ .../ShutterValidatorRegistryTests.cs | 1 + .../Contracts/ValidatorRegistryContract.cs | 1 + 11 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/Nethermind/Nethermind.AuRa.Test/Contract/ReportingValidatorContractTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Contract/ReportingValidatorContractTests.cs index 3d5d52e2dcf..fbb75a79e2a 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Contract/ReportingValidatorContractTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Contract/ReportingValidatorContractTests.cs @@ -7,7 +7,6 @@ using Nethermind.Consensus.AuRa.Contracts; using Nethermind.Core; using Nethermind.Core.Extensions; -using Nethermind.Specs; using NSubstitute; using NUnit.Framework; diff --git a/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs b/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs index f06ed66e541..40b6f3d7f86 100644 --- a/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs +++ b/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs @@ -7,7 +7,6 @@ using Nethermind.Blockchain.Contracts.Json; using Nethermind.Core; using Nethermind.Core.Crypto; -using Nethermind.Core.Specs; using Nethermind.Crypto; using Nethermind.Int256; using Nethermind.Evm; diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV1.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV1.cs index 6d47bd5314b..7509c8a2f6b 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV1.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Contracts/TransactionPermissionContractV1.cs @@ -4,7 +4,6 @@ using System; using Nethermind.Abi; using Nethermind.Core; -using Nethermind.Core.Specs; using Nethermind.Int256; using Nethermind.Evm.TransactionProcessing; @@ -22,8 +21,7 @@ public TransactionPermissionContractV1( protected override object[] GetAllowedTxTypesParameters(Transaction tx, BlockHeader parentHeader) => new object[] { tx.SenderAddress }; - protected override (ITransactionPermissionContract.TxPermissions, bool) CallAllowedTxTypes( - PermissionConstantContract.PermissionCallInfo callInfo) => + protected override (ITransactionPermissionContract.TxPermissions, bool) CallAllowedTxTypes(PermissionConstantContract.PermissionCallInfo callInfo) => (Constant.Call(callInfo), true); public override UInt256 Version => UInt256.One; diff --git a/src/Nethermind/Nethermind.Facade.Test/BlockchainBridgeTests.cs b/src/Nethermind/Nethermind.Facade.Test/BlockchainBridgeTests.cs index 120f294677b..9986a989509 100644 --- a/src/Nethermind/Nethermind.Facade.Test/BlockchainBridgeTests.cs +++ b/src/Nethermind/Nethermind.Facade.Test/BlockchainBridgeTests.cs @@ -184,7 +184,8 @@ public void Call_uses_valid_mix_hash() _blockchainBridge.Call(header, tx); _transactionProcessor.Received().CallAndRestore( tx, - Arg.Is(blkCtx => blkCtx.Header.MixHash == TestItem.KeccakA), Arg.Any()); + Arg.Is(blkCtx => blkCtx.Header.MixHash == TestItem.KeccakA), + Arg.Any()); } [Test] diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Proof/ProofRpcModule.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Proof/ProofRpcModule.cs index d57e9a23d4c..fb0cc68ca0a 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Proof/ProofRpcModule.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Proof/ProofRpcModule.cs @@ -155,12 +155,13 @@ public ResultWrapper proof_getTransactionReceipt(Hash256 txHas TxReceipt[] receipts = receiptsTracer.TxReceipts.ToArray(); Transaction[] txs = block.Transactions; ReceiptWithProof receiptWithProof = new(); - bool isEip1559Enabled = _specProvider.GetSpec(block.Header).IsEip1559Enabled; + var spec = _specProvider.GetSpec(block.Header); + bool isEip1559Enabled = spec.IsEip1559Enabled; Transaction? tx = txs.FirstOrDefault(x => x.Hash == txHash); int logIndexStart = _receiptFinder.Get(block).GetBlockLogFirstIndex(receipt.Index); - receiptWithProof.Receipt = new ReceiptForRpc(txHash, receipt, tx?.GetGasInfo(isEip1559Enabled, block.Header, _specProvider.GetSpec(block.Header)) ?? new(), logIndexStart); + receiptWithProof.Receipt = new ReceiptForRpc(txHash, receipt, tx?.GetGasInfo(isEip1559Enabled, block.Header, spec) ?? new(), logIndexStart); receiptWithProof.ReceiptProof = BuildReceiptProofs(block.Header, receipts, receipt.Index); receiptWithProof.TxProof = BuildTxProofs(txs, _specProvider.GetSpec(block.Header), receipt.Index); diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/ReceiptFinderExtensions.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/ReceiptFinderExtensions.cs index 51829e0102f..749ed49c626 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/ReceiptFinderExtensions.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/ReceiptFinderExtensions.cs @@ -33,11 +33,12 @@ public static ResultWrapper GetBlockReceipts(this IReceiptFinde Block block = searchResult.Object; TxReceipt[] receipts = receiptFinder.Get(block) ?? new TxReceipt[block.Transactions.Length]; - bool isEip1559Enabled = specProvider.GetSpec(block.Header).IsEip1559Enabled; + var spec = specProvider.GetSpec(block.Header); + bool isEip1559Enabled = spec.IsEip1559Enabled; IEnumerable result = receipts .Zip(block.Transactions, (r, t) => { - return new ReceiptForRpc(t.Hash, r, t.GetGasInfo(isEip1559Enabled, block.Header, specProvider.GetSpec(block.Header)), receipts.GetBlockLogFirstIndex(r.Index)); + return new ReceiptForRpc(t.Hash, r, t.GetGasInfo(isEip1559Enabled, block.Header, spec), receipts.GetBlockLogFirstIndex(r.Index)); }); ReceiptForRpc[] resultAsArray = result.ToArray(); return ResultWrapper.Success(resultAsArray); diff --git a/src/Nethermind/Nethermind.Merge.Plugin/EngineRpcModule.cs b/src/Nethermind/Nethermind.Merge.Plugin/EngineRpcModule.cs index eb38596f2e8..9a711d9aa3b 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/EngineRpcModule.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/EngineRpcModule.cs @@ -17,7 +17,7 @@ public partial class EngineRpcModule : IEngineRpcModule { private readonly IHandler, IEnumerable> _capabilitiesHandler; - protected readonly ISpecProvider _specProvider; + private readonly ISpecProvider _specProvider; protected readonly ILogger _logger; public EngineRpcModule( diff --git a/src/Nethermind/Nethermind.Shutter.Test/ShutterEventSimulator.cs b/src/Nethermind/Nethermind.Shutter.Test/ShutterEventSimulator.cs index c6009bb761c..06460d48b08 100644 --- a/src/Nethermind/Nethermind.Shutter.Test/ShutterEventSimulator.cs +++ b/src/Nethermind/Nethermind.Shutter.Test/ShutterEventSimulator.cs @@ -14,6 +14,7 @@ using Nethermind.Serialization.Rlp; using Nethermind.Core.Test.Builders; using Nethermind.Abi; + using G1 = Nethermind.Crypto.Bls.P1; using G2 = Nethermind.Crypto.Bls.P2; using EncryptedMessage = Nethermind.Shutter.ShutterCrypto.EncryptedMessage; diff --git a/src/Nethermind/Nethermind.Shutter.Test/ShutterTxLoaderTests.cs b/src/Nethermind/Nethermind.Shutter.Test/ShutterTxLoaderTests.cs index decd53ded26..fa428ea8694 100644 --- a/src/Nethermind/Nethermind.Shutter.Test/ShutterTxLoaderTests.cs +++ b/src/Nethermind/Nethermind.Shutter.Test/ShutterTxLoaderTests.cs @@ -17,6 +17,26 @@ namespace Nethermind.Shutter.Test; [TestFixture] class ShutterTxLoaderTests : EngineModuleTests { + private class ShutterEventSimulatorHalfInvalid(Random rnd, ulong chainId, ulong threshold, ulong slot, IAbiEncoder abiEncoder, Address sequencerContractAddress) : ShutterEventSimulator(rnd, chainId, threshold, slot, abiEncoder, sequencerContractAddress) + { + private readonly Transaction _validTx = Build.A.Transaction.WithChainId(chainId).Signed().TestObject; + private readonly Transaction _invalidTx = Build.A.Transaction.TestObject; + protected override IEnumerable EmitEvents() + { + IEnumerable EmitHalfInvalid() + { + bool valid = false; + while (true) + { + valid = !valid; + yield return valid ? _validTx : _invalidTx; + } + } + + return EmitEvents(EmitDefaultEons(), EmitHalfInvalid()); + } + } + private class ShutterEventSimulatorHalfNextEon(Random rnd, ulong chainId, ulong threshold, ulong slot, IAbiEncoder abiEncoder, Address sequencerContractAddress) : ShutterEventSimulator(rnd, chainId, threshold, slot, abiEncoder, sequencerContractAddress) { protected override IEnumerable EmitEvents() diff --git a/src/Nethermind/Nethermind.Shutter.Test/ShutterValidatorRegistryTests.cs b/src/Nethermind/Nethermind.Shutter.Test/ShutterValidatorRegistryTests.cs index 87bfdf69fcd..a8c134b5d90 100644 --- a/src/Nethermind/Nethermind.Shutter.Test/ShutterValidatorRegistryTests.cs +++ b/src/Nethermind/Nethermind.Shutter.Test/ShutterValidatorRegistryTests.cs @@ -12,6 +12,7 @@ using Nethermind.Shutter.Config; using Nethermind.Crypto; using Nethermind.Core.Crypto; + using Update = (byte[] Message, byte[] Signature); using G1 = Nethermind.Crypto.Bls.P1; diff --git a/src/Nethermind/Nethermind.Shutter/Contracts/ValidatorRegistryContract.cs b/src/Nethermind/Nethermind.Shutter/Contracts/ValidatorRegistryContract.cs index 9b1e887590b..ce8f6297556 100644 --- a/src/Nethermind/Nethermind.Shutter/Contracts/ValidatorRegistryContract.cs +++ b/src/Nethermind/Nethermind.Shutter/Contracts/ValidatorRegistryContract.cs @@ -14,6 +14,7 @@ using Nethermind.Crypto; using Nethermind.Shutter.Config; using System.Linq; + using Update = (byte[] Message, byte[] Signature); namespace Nethermind.Shutter.Contracts; From 34ec30c0cd54062ccba4de5a9f4ce700f8463bea Mon Sep 17 00:00:00 2001 From: yerke26 Date: Sun, 8 Dec 2024 20:31:29 +0500 Subject: [PATCH 44/68] change to const --- src/Nethermind/Nethermind.Core/Eip7742Constants.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Core/Eip7742Constants.cs b/src/Nethermind/Nethermind.Core/Eip7742Constants.cs index e808fcb239d..c13a63355fd 100644 --- a/src/Nethermind/Nethermind.Core/Eip7742Constants.cs +++ b/src/Nethermind/Nethermind.Core/Eip7742Constants.cs @@ -11,5 +11,5 @@ public class Eip7742Constants /// Gets the BLOB_GASPRICE_UPDATE_FRACTION parameter. ///
/// Defaults to 3338477. - public static UInt256 BlobGasPriceUpdateFraction { get; private set; } = 1112825; + public const ulong BlobGasPriceUpdateFraction = 1112825; } From 8657a8c48f462497ad29b5a33f10c89cebee4943 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Sun, 8 Dec 2024 21:39:45 +0500 Subject: [PATCH 45/68] fix TxPoolTxSource --- .../Producers/TxPoolTxSource.cs | 17 ++++++++++++----- .../Nethermind.Core/Eip7742Constants.cs | 2 -- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs index 233b44315c2..bf7201af967 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs @@ -62,7 +62,12 @@ public IEnumerable GetTransactions(BlockHeader parent, long gasLimi int checkedTransactions = 0; int selectedTransactions = 0; - using ArrayPoolList selectedBlobTxs = new((int)(payloadAttributes?.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock())); + if (spec.IsEip7742Enabled && payloadAttributes == null) + { + if (_logger.IsDebug) _logger.Debug("Eip-7742 is enabled, but no payload attributes were provided."); + yield break; + } + using ArrayPoolList selectedBlobTxs = new((int)(payloadAttributes.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock())); SelectBlobTransactions(blobTransactions, parent, spec, selectedBlobTxs); @@ -119,7 +124,7 @@ private static IEnumerable PickBlobTxsBetterThanCurrentTx(ArrayPool } } - private void SelectBlobTransactions(IEnumerable blobTransactions, BlockHeader parent, IReleaseSpec spec, ArrayPoolList selectedBlobTxs) + private void SelectBlobTransactions(IEnumerable blobTransactions, BlockHeader parent, IReleaseSpec spec, ArrayPoolList selectedBlobTxs, PayloadAttributes? payloadAttributes = null) { int checkedBlobTransactions = 0; int selectedBlobTransactions = 0; @@ -128,7 +133,8 @@ private void SelectBlobTransactions(IEnumerable blobTransactions, B foreach (Transaction blobTx in blobTransactions) { - if (!spec.IsEip7742Enabled && blobGasCounter >= _eip4844Config.MaxBlobGasPerBlock) + if ((spec.IsEip7742Enabled && blobGasCounter >= payloadAttributes?.MaxBlobCount * Eip4844Constants.GasPerBlob) + || (!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; @@ -137,8 +143,9 @@ private void SelectBlobTransactions(IEnumerable blobTransactions, B checkedBlobTransactions++; ulong txBlobGas = (ulong)(blobTx.BlobVersionedHashes?.Length ?? 0) * _eip4844Config.GasPerBlob; - // no validation is needed when eip7742 is activated - if (!spec.IsEip7742Enabled && txBlobGas > _eip4844Config.MaxBlobGasPerBlock - blobGasCounter) + + if ((spec.IsEip7742Enabled && txBlobGas >= payloadAttributes?.MaxBlobCount * Eip4844Constants.GasPerBlob - blobGasCounter) + || (!spec.IsEip7742Enabled && txBlobGas > _eip4844Config.MaxBlobGasPerBlock - blobGasCounter)) { if (_logger.IsTrace) _logger.Trace($"Declining {blobTx.ToShortString()}, not enough blob space."); continue; diff --git a/src/Nethermind/Nethermind.Core/Eip7742Constants.cs b/src/Nethermind/Nethermind.Core/Eip7742Constants.cs index c13a63355fd..4ea67b5f159 100644 --- a/src/Nethermind/Nethermind.Core/Eip7742Constants.cs +++ b/src/Nethermind/Nethermind.Core/Eip7742Constants.cs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited // SPDX-License-Identifier: LGPL-3.0-only -using Nethermind.Int256; - namespace Nethermind.Core; public class Eip7742Constants From bb630852b23ea9324d02eac0f1f02cb0d0f86395 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Sun, 8 Dec 2024 22:00:26 +0500 Subject: [PATCH 46/68] fix --- src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs index bf7201af967..9070c49d89d 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs @@ -67,7 +67,7 @@ public IEnumerable GetTransactions(BlockHeader parent, long gasLimi if (_logger.IsDebug) _logger.Debug("Eip-7742 is enabled, but no payload attributes were provided."); yield break; } - using ArrayPoolList selectedBlobTxs = new((int)(payloadAttributes.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock())); + using ArrayPoolList selectedBlobTxs = new((int)(payloadAttributes?.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock())); SelectBlobTransactions(blobTransactions, parent, spec, selectedBlobTxs); From 4a833757c3ce6f93b72a8098bd27259692567cbd Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 9 Dec 2024 13:46:01 +0500 Subject: [PATCH 47/68] revert blobGasCalculator changes --- .../Ethereum.Test.Base/GeneralTestBase.cs | 2 +- .../ChainHeadInfoProvider.cs | 3 +- ...cessor.BlockProductionTransactionPicker.cs | 2 +- .../Producers/TxPoolTxSource.cs | 4 +-- .../Validators/BlockValidator.cs | 2 +- .../Validators/HeaderValidator.cs | 2 +- .../BlobGasCalculatorTests.cs | 2 +- .../Nethermind.Evm/BlobGasCalculator.cs | 32 +++++++------------ .../Nethermind.Evm/TransactionExtensions.cs | 2 +- .../TransactionProcessor.cs | 2 +- .../Nethermind.Evm/VirtualMachine.cs | 16 ++-------- .../Nethermind.Facade/BlockchainBridge.cs | 2 +- .../Simulate/SimulateBridgeHelper.cs | 2 +- .../Modules/Eth/EthRpcModule.cs | 3 +- .../Eth/FeeHistory/FeeHistoryOracle.cs | 2 +- .../BlockProduction/PostMergeBlockProducer.cs | 2 +- 16 files changed, 28 insertions(+), 52 deletions(-) diff --git a/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs b/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs index 44e14ace9dd..dee4a5e5d5a 100644 --- a/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs +++ b/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs @@ -130,7 +130,7 @@ protected EthereumTestResult RunTest(GeneralStateTest test, ITxTracer txTracer) BlobGasUsed = (ulong)test.ParentBlobGasUsed, ExcessBlobGas = (ulong)test.ParentExcessBlobGas, }; - header.ExcessBlobGas = BlobGasCalculator.CalculateExcessBlobGas(parent, spec, header); + header.ExcessBlobGas = BlobGasCalculator.CalculateExcessBlobGas(parent, spec); } ValidationResult txIsValid = _txValidator.IsWellFormed(test.Transaction, spec); diff --git a/src/Nethermind/Nethermind.Blockchain/ChainHeadInfoProvider.cs b/src/Nethermind/Nethermind.Blockchain/ChainHeadInfoProvider.cs index a212c7068dc..77cccd0e7d5 100644 --- a/src/Nethermind/Nethermind.Blockchain/ChainHeadInfoProvider.cs +++ b/src/Nethermind/Nethermind.Blockchain/ChainHeadInfoProvider.cs @@ -78,8 +78,7 @@ private void OnHeadChanged(object? sender, BlockReplacementEventArgs e) BlockGasLimit = e.Block!.GasLimit; CurrentBaseFee = e.Block.Header.BaseFeePerGas; CurrentFeePerBlobGas = - BlobGasCalculator.TryCalculateFeePerBlobGas(e.Block.Header, out UInt256 currentFeePerBlobGas, - SpecProvider.GetSpec(e.Block.Header)) + BlobGasCalculator.TryCalculateFeePerBlobGas(e.Block.Header, out UInt256 currentFeePerBlobGas) ? currentFeePerBlobGas : UInt256.Zero; HeadChanged?.Invoke(sender, e); diff --git a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionPicker.cs b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionPicker.cs index 8bdce8fce04..9b9d1f49cba 100644 --- a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionPicker.cs +++ b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionPicker.cs @@ -109,7 +109,7 @@ private static bool HasEnoughFounds(Transaction transaction, in UInt256 senderBa } if (transaction.SupportsBlobs && ( - !BlobGasCalculator.TryCalculateBlobBaseFee(block.Header, transaction, out UInt256 blobBaseFee, releaseSpec) || + !BlobGasCalculator.TryCalculateBlobBaseFee(block.Header, transaction, out UInt256 blobBaseFee) || senderBalance < (maxFee += blobBaseFee))) { e.Set(TxAction.Skip, $"{maxFee} is higher than sender balance ({senderBalance}), MaxFeePerGas: ({transaction.MaxFeePerGas}), GasLimit {transaction.GasLimit}, BlobBaseFee: {blobBaseFee}"); diff --git a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs index 9070c49d89d..d88a7065687 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs @@ -196,7 +196,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, parent); + ulong? excessDataGas = BlobGasCalculator.CalculateExcessBlobGas(parent, spec); if (excessDataGas is null) { if (_logger.IsTrace) _logger.Trace($"Declining {lightBlobTx.ToShortString()}, the specification is not configured to handle shard blob transactions."); @@ -204,7 +204,7 @@ private bool TryUpdateFeePerBlobGas(Transaction lightBlobTx, BlockHeader parent, return false; } - if (!BlobGasCalculator.TryCalculateFeePerBlobGas(excessDataGas.Value, out feePerBlobGas, parent.TargetBlobCount, spec)) + if (!BlobGasCalculator.TryCalculateFeePerBlobGas(excessDataGas.Value, out feePerBlobGas)) { if (_logger.IsTrace) _logger.Trace($"Declining {lightBlobTx.ToShortString()}, failed to calculate data gas price."); feePerBlobGas = UInt256.Zero; diff --git a/src/Nethermind/Nethermind.Consensus/Validators/BlockValidator.cs b/src/Nethermind/Nethermind.Consensus/Validators/BlockValidator.cs index 276a6520771..9becb478ad9 100644 --- a/src/Nethermind/Nethermind.Consensus/Validators/BlockValidator.cs +++ b/src/Nethermind/Nethermind.Consensus/Validators/BlockValidator.cs @@ -317,7 +317,7 @@ protected virtual bool ValidateEip4844Fields(Block block, IReleaseSpec spec, out if (feePerBlobGas.IsZero) { - if (!BlobGasCalculator.TryCalculateFeePerBlobGas(block.Header, out feePerBlobGas, spec)) + if (!BlobGasCalculator.TryCalculateFeePerBlobGas(block.Header, out feePerBlobGas)) { error = BlockErrorMessages.BlobGasPriceOverflow; if (_logger.IsDebug) _logger.Debug($"{Invalid(block)} {error}."); diff --git a/src/Nethermind/Nethermind.Consensus/Validators/HeaderValidator.cs b/src/Nethermind/Nethermind.Consensus/Validators/HeaderValidator.cs index 1a75677cf2c..4664674f6bd 100644 --- a/src/Nethermind/Nethermind.Consensus/Validators/HeaderValidator.cs +++ b/src/Nethermind/Nethermind.Consensus/Validators/HeaderValidator.cs @@ -353,7 +353,7 @@ protected virtual bool ValidateBlobGasFields(BlockHeader header, BlockHeader par return false; } - ulong? expectedExcessBlobGas = BlobGasCalculator.CalculateExcessBlobGas(parentHeader, spec, header); + ulong? expectedExcessBlobGas = BlobGasCalculator.CalculateExcessBlobGas(parentHeader, spec); if (header.ExcessBlobGas != expectedExcessBlobGas) { if (_logger.IsWarn) _logger.Warn($"ExcessBlobGas field is incorrect: {header.ExcessBlobGas}, should be {expectedExcessBlobGas}."); diff --git a/src/Nethermind/Nethermind.Evm.Test/BlobGasCalculatorTests.cs b/src/Nethermind/Nethermind.Evm.Test/BlobGasCalculatorTests.cs index 3f011525fef..62d89004c3f 100644 --- a/src/Nethermind/Nethermind.Evm.Test/BlobGasCalculatorTests.cs +++ b/src/Nethermind/Nethermind.Evm.Test/BlobGasCalculatorTests.cs @@ -23,7 +23,7 @@ private void TestExcessBlobGas(IReleaseSpec spec, bool areBlobsEnabled, (ulong p .WithBlobGasUsed(BlobGasCalculator.CalculateBlobGas(testCase.parentBlobsCount)) .WithExcessBlobGas(testCase.parentExcessBlobGas).TestObject; - Assert.That(BlobGasCalculator.CalculateExcessBlobGas(parentHeader, spec, header), Is.EqualTo(areBlobsEnabled ? testCase.expectedExcessBlobGas : null)); + Assert.That(BlobGasCalculator.CalculateExcessBlobGas(parentHeader, spec), Is.EqualTo(areBlobsEnabled ? testCase.expectedExcessBlobGas : null)); } [TestCaseSource(nameof(ExcessBlobGasTestCaseSource))] diff --git a/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs b/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs index 6502db59b7d..5b240a865f4 100644 --- a/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs +++ b/src/Nethermind/Nethermind.Evm/BlobGasCalculator.cs @@ -1,7 +1,6 @@ // SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited // SPDX-License-Identifier: LGPL-3.0-only -using System.IO; using Nethermind.Core; using Nethermind.Core.Specs; using Nethermind.Int256; @@ -30,9 +29,9 @@ public static ulong CalculateBlobGas(Transaction[] transactions) return CalculateBlobGas(blobCount); } - public static bool TryCalculateBlobBaseFee(BlockHeader header, Transaction transaction, out UInt256 blobBaseFee, IReleaseSpec? spec = null) + public static bool TryCalculateBlobBaseFee(BlockHeader header, Transaction transaction, out UInt256 blobBaseFee) { - if (!TryCalculateFeePerBlobGas(header.ExcessBlobGas, out UInt256 feePerBlobGas, header.TargetBlobCount, spec)) + if (!TryCalculateFeePerBlobGas(header.ExcessBlobGas.Value, out UInt256 feePerBlobGas)) { blobBaseFee = UInt256.MaxValue; return false; @@ -40,12 +39,14 @@ public static bool TryCalculateBlobBaseFee(BlockHeader header, Transaction trans return !UInt256.MultiplyOverflow(CalculateBlobGas(transaction), feePerBlobGas, out blobBaseFee); } - public static bool TryCalculateFeePerBlobGas(BlockHeader header, out UInt256 feePerBlobGas, IReleaseSpec? spec = null) + public static bool TryCalculateFeePerBlobGas(BlockHeader header, out UInt256 feePerBlobGas) { - return TryCalculateFeePerBlobGas(header.ExcessBlobGas, out feePerBlobGas, header.TargetBlobCount, spec); + feePerBlobGas = UInt256.MaxValue; + return header.ExcessBlobGas is not null + && TryCalculateFeePerBlobGas(header.ExcessBlobGas.Value, out feePerBlobGas); } - public static bool TryCalculateFeePerBlobGas(ulong? excessBlobGas, out UInt256 feePerBlobGas, UInt256? targetBlobCount = null, IReleaseSpec? spec = null) + public static bool TryCalculateFeePerBlobGas(ulong excessBlobGas, out UInt256 feePerBlobGas) { static bool FakeExponentialOverflow(UInt256 factor, UInt256 num, UInt256 denominator, out UInt256 feePerBlobGas) { @@ -84,16 +85,10 @@ static bool FakeExponentialOverflow(UInt256 factor, UInt256 num, UInt256 denomin return false; } - var denominator = spec?.IsEip7742Enabled ?? false - ? Eip7742Constants.BlobGasPriceUpdateFraction * targetBlobCount - ?? throw new InvalidDataException("header is missing target blob count") - : Eip4844Constants.BlobGasPriceUpdateFraction; - - feePerBlobGas = UInt256.MaxValue; - return excessBlobGas is not null && !FakeExponentialOverflow(Eip4844Constants.MinBlobGasPrice, excessBlobGas.Value, denominator, out feePerBlobGas); + return !FakeExponentialOverflow(Eip4844Constants.MinBlobGasPrice, excessBlobGas, Eip4844Constants.BlobGasPriceUpdateFraction, out feePerBlobGas); } - public static ulong? CalculateExcessBlobGas(BlockHeader? parentBlockHeader, IReleaseSpec releaseSpec, BlockHeader header) + public static ulong? CalculateExcessBlobGas(BlockHeader? parentBlockHeader, IReleaseSpec releaseSpec) { if (!releaseSpec.IsEip4844Enabled) { @@ -107,13 +102,8 @@ static bool FakeExponentialOverflow(UInt256 factor, UInt256 num, UInt256 denomin ulong excessBlobGas = parentBlockHeader.ExcessBlobGas ?? 0; excessBlobGas += parentBlockHeader.BlobGasUsed ?? 0; - var targetBlobCount = releaseSpec.IsEip7742Enabled - ? header.TargetBlobCount * Eip4844Constants.GasPerBlob - ?? throw new InvalidDataException("header is missing target blob count") - : Eip4844Constants.TargetBlobGasPerBlock; - - return excessBlobGas < targetBlobCount + return excessBlobGas < Eip4844Constants.TargetBlobGasPerBlock ? 0 - : excessBlobGas - targetBlobCount; + : (excessBlobGas - Eip4844Constants.TargetBlobGasPerBlock); } } diff --git a/src/Nethermind/Nethermind.Evm/TransactionExtensions.cs b/src/Nethermind/Nethermind.Evm/TransactionExtensions.cs index f22d02b40c8..5e7d8e34f24 100644 --- a/src/Nethermind/Nethermind.Evm/TransactionExtensions.cs +++ b/src/Nethermind/Nethermind.Evm/TransactionExtensions.cs @@ -26,7 +26,7 @@ public static TxGasInfo GetGasInfo(this Transaction tx, bool is1559Enabled, Bloc throw new ArgumentException($"Block that contains Shard Blob Transactions should have {nameof(header.ExcessBlobGas)} set.", nameof(header.ExcessBlobGas)); } - if (!BlobGasCalculator.TryCalculateFeePerBlobGas(header, out UInt256 feePerBlobGas, spec)) + if (!BlobGasCalculator.TryCalculateFeePerBlobGas(header, out UInt256 feePerBlobGas)) { throw new OverflowException("Blob gas price calculation led to overflow."); } diff --git a/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs b/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs index ec4ee8d9708..2857279d410 100644 --- a/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs +++ b/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs @@ -501,7 +501,7 @@ protected virtual TransactionResult BuyGas(Transaction tx, BlockHeader header, I overflows = UInt256.MultiplyOverflow((UInt256)tx.GasLimit, effectiveGasPrice, out senderReservedGasPayment); if (!overflows && tx.SupportsBlobs) { - overflows = !BlobGasCalculator.TryCalculateBlobBaseFee(header, tx, out blobBaseFee, spec); + overflows = !BlobGasCalculator.TryCalculateBlobBaseFee(header, tx, out blobBaseFee); if (!overflows) { overflows = UInt256.AddOverflow(senderReservedGasPayment, blobBaseFee, out senderReservedGasPayment); diff --git a/src/Nethermind/Nethermind.Evm/VirtualMachine.cs b/src/Nethermind/Nethermind.Evm/VirtualMachine.cs index e909bf46ae2..2d12fccfef9 100644 --- a/src/Nethermind/Nethermind.Evm/VirtualMachine.cs +++ b/src/Nethermind/Nethermind.Evm/VirtualMachine.cs @@ -1515,23 +1515,11 @@ private CallResult ExecuteCode b ? 0 : BaseFeeCalculator.Calculate(parent, spec); - result.ExcessBlobGas = spec.IsEip4844Enabled ? BlobGasCalculator.CalculateExcessBlobGas(parent, spec, result) : (ulong?)0; + result.ExcessBlobGas = spec.IsEip4844Enabled ? BlobGasCalculator.CalculateExcessBlobGas(parent, spec) : (ulong?)0; return result; } diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs index 2bd081e5c60..973d739aeab 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs @@ -111,9 +111,8 @@ public ResultWrapper
eth_coinbase() { return ResultWrapper.Success(UInt256.Zero); } - IReleaseSpec? spec = _blockFinder.Head?.Header is null ? null : specProvider.GetSpec(_blockFinder.Head.Header); if (!BlobGasCalculator.TryCalculateFeePerBlobGas(_blockFinder.Head?.Header?.ExcessBlobGas ?? 0, - out UInt256 feePerBlobGas, _blockFinder.Head?.Header.TargetBlobCount, spec)) + out UInt256 feePerBlobGas)) { return ResultWrapper.Fail("Unable to calculate the current blob base fee"); } diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs index 3fd87b88db0..c9a52245e5d 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs @@ -108,7 +108,7 @@ private readonly record struct BlockFeeHistorySearchInfo( { BlockFeeHistorySearchInfo BlockFeeHistorySearchInfoFromBlock(Block b) { - BlobGasCalculator.TryCalculateFeePerBlobGas(b.Header, out UInt256 feePerBlobGas, _specProvider.GetSpec(block.Header)); + BlobGasCalculator.TryCalculateFeePerBlobGas(b.Header, out UInt256 feePerBlobGas); var maxBlobGasPerBlock = (double)(block.TargetBlobCount * 2 ?? Eip4844Constants.GetMaxBlobsPerBlock()) * Eip4844Constants.GasPerBlob; diff --git a/src/Nethermind/Nethermind.Merge.Plugin/BlockProduction/PostMergeBlockProducer.cs b/src/Nethermind/Nethermind.Merge.Plugin/BlockProduction/PostMergeBlockProducer.cs index a7427b31af6..3004e0c26b9 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/BlockProduction/PostMergeBlockProducer.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/BlockProduction/PostMergeBlockProducer.cs @@ -101,7 +101,7 @@ protected virtual void AmendHeader(BlockHeader blockHeader, BlockHeader parent, if (spec.IsEip4844Enabled) { blockHeader.BlobGasUsed = 0; - blockHeader.ExcessBlobGas = BlobGasCalculator.CalculateExcessBlobGas(parent, spec, blockHeader); + blockHeader.ExcessBlobGas = BlobGasCalculator.CalculateExcessBlobGas(parent, spec); } } } From aa8cc8bae77d93dbc74c2eb8a04223b634fd354f Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 9 Dec 2024 13:50:29 +0500 Subject: [PATCH 48/68] fix evm build --- tools/Evm/T8n/T8nTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Evm/T8n/T8nTest.cs b/tools/Evm/T8n/T8nTest.cs index 90d6e287da0..6d88aae73b4 100644 --- a/tools/Evm/T8n/T8nTest.cs +++ b/tools/Evm/T8n/T8nTest.cs @@ -65,7 +65,7 @@ private BlockHeader ConstructBlockHeader() .WithExcessBlobGas((ulong)ParentExcessBlobGas) .WithBlobGasUsed((ulong)ParentBlobGasUsed) .TestObject; - header.ExcessBlobGas = BlobGasCalculator.CalculateExcessBlobGas(parentHeader, Spec, header); + header.ExcessBlobGas = BlobGasCalculator.CalculateExcessBlobGas(parentHeader, Spec); } header.BlobGasUsed = BlobGasCalculator.CalculateBlobGas(Transactions); header.IsPostMerge = Spec is Paris; From e87620168c8980e2965240a3ed545d78f84efb0c Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 9 Dec 2024 15:13:52 +0500 Subject: [PATCH 49/68] revert BlobGasCalculatorTests --- .../BlobGasCalculatorTests.cs | 92 +++++++------------ 1 file changed, 35 insertions(+), 57 deletions(-) diff --git a/src/Nethermind/Nethermind.Evm.Test/BlobGasCalculatorTests.cs b/src/Nethermind/Nethermind.Evm.Test/BlobGasCalculatorTests.cs index 62d89004c3f..39302bb37dd 100644 --- a/src/Nethermind/Nethermind.Evm.Test/BlobGasCalculatorTests.cs +++ b/src/Nethermind/Nethermind.Evm.Test/BlobGasCalculatorTests.cs @@ -14,40 +14,31 @@ 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), Is.EqualTo(areBlobsEnabled ? testCase.expectedExcessBlobGas : null)); - } - [TestCaseSource(nameof(ExcessBlobGasTestCaseSource))] - 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) + public void Excess_blob_gas_is_calculated_properly((ulong parentExcessBlobGas, int parentBlobsCount, ulong expectedExcessBlobGas) testCase) { - TestExcessBlobGas(Prague.Instance, true, 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); } [TestCaseSource(nameof(BlobGasCostTestCaseSource))] @@ -74,41 +65,28 @@ public void Blob_base_fee_may_overflow() Assert.That(blobBaseFee, Is.EqualTo(UInt256.MaxValue)); } - public static IEnumerable<(ulong parentExcessBlobGas, int parentBlobsCount, ulong expectedExcessBlobGas, ulong? targetBlobCount)> ExcessBlobGasTestCaseSource() + public static IEnumerable<(ulong parentExcessBlobGas, int parentBlobsCount, ulong expectedExcessBlobGas)> ExcessBlobGasTestCaseSource() { - 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 (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 ( Eip4844Constants.MaxBlobGasPerBlock, (int)(Eip4844Constants.TargetBlobGasPerBlock / Eip4844Constants.GasPerBlob), - Eip4844Constants.MaxBlobGasPerBlock, null); + Eip4844Constants.MaxBlobGasPerBlock); yield return ( Eip4844Constants.MaxBlobGasPerBlock, (int)(Eip4844Constants.MaxBlobGasPerBlock / Eip4844Constants.GasPerBlob), - Eip4844Constants.MaxBlobGasPerBlock * 2 - Eip4844Constants.TargetBlobGasPerBlock, null + Eip4844Constants.MaxBlobGasPerBlock * 2 - Eip4844Constants.TargetBlobGasPerBlock ); } - 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); From 1d05358571cc7d4802b138cb0573073ab096d3c2 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 9 Dec 2024 15:15:45 +0500 Subject: [PATCH 50/68] revert BlockExecutionContext --- src/Nethermind/Nethermind.Evm/BlockExecutionContext.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Nethermind/Nethermind.Evm/BlockExecutionContext.cs b/src/Nethermind/Nethermind.Evm/BlockExecutionContext.cs index 9826d4d94b7..2bd0b7456b9 100644 --- a/src/Nethermind/Nethermind.Evm/BlockExecutionContext.cs +++ b/src/Nethermind/Nethermind.Evm/BlockExecutionContext.cs @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited // SPDX-License-Identifier: LGPL-3.0-only +using System; using Nethermind.Core; using Nethermind.Int256; @@ -14,6 +15,14 @@ public readonly struct BlockExecutionContext public BlockExecutionContext(BlockHeader blockHeader) { Header = blockHeader; + if (blockHeader?.ExcessBlobGas is not null) + { + if (!BlobGasCalculator.TryCalculateFeePerBlobGas(blockHeader.ExcessBlobGas.Value, out UInt256 feePerBlobGas)) + { + throw new OverflowException("Blob gas price calculation led to overflow."); + } + BlobBaseFee = feePerBlobGas; + } } public BlockExecutionContext(BlockHeader blockHeader, UInt256 forceBlobBaseFee) From c60067cc2009628605f11658b69909a660062e83 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 9 Dec 2024 18:37:18 +0500 Subject: [PATCH 51/68] revert BlockHeader implicit conversion --- src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs | 2 +- .../Nethermind.Blockchain/Contracts/CallableContract.cs | 2 +- src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs | 4 ++-- src/Nethermind/Nethermind.Blockchain/GenesisLoader.cs | 2 +- .../ExecutionRequests/ExecutionRequestProcessor.cs | 2 +- .../BlockProcessor.BlockProductionTransactionsExecutor.cs | 3 ++- src/Nethermind/Nethermind.Evm.Test/EvmPooledMemoryTests.cs | 2 +- .../TransactionProcessing/TransactionProcessor.cs | 2 +- src/Nethermind/Nethermind.Taiko/BlockInvalidTxExecutor.cs | 3 ++- src/Nethermind/Nethermind.Taiko/Rpc/TaikoEngineRpcModule.cs | 3 ++- tools/Evm/T8n/T8nExecutor.cs | 2 +- 11 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs b/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs index dee4a5e5d5a..f657f103d28 100644 --- a/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs +++ b/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs @@ -137,7 +137,7 @@ protected EthereumTestResult RunTest(GeneralStateTest test, ITxTracer txTracer) if (txIsValid) { - transactionProcessor.Execute(test.Transaction, header, txTracer); + transactionProcessor.Execute(test.Transaction, new BlockExecutionContext(header), txTracer); } else { diff --git a/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs b/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs index 02088df3fd8..54ddaf92945 100644 --- a/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs +++ b/src/Nethermind/Nethermind.Blockchain/Contracts/CallableContract.cs @@ -66,7 +66,7 @@ private bool TryCall(BlockHeader header, Transaction transaction, out byte[] res try { - _transactionProcessor.Execute(transaction, header, tracer); + _transactionProcessor.Execute(transaction, new BlockExecutionContext(header), tracer); result = tracer.ReturnValue; return tracer.StatusCode == StatusCode.Success; } diff --git a/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs b/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs index 40b6f3d7f86..c6d06215188 100644 --- a/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs +++ b/src/Nethermind/Nethermind.Blockchain/Contracts/Contract.cs @@ -178,11 +178,11 @@ protected byte[] CallCore(ITransactionProcessor transactionProcessor, BlockHeade { if (callAndRestore) { - transactionProcessor.CallAndRestore(transaction, header, tracer); + transactionProcessor.CallAndRestore(transaction, new BlockExecutionContext(header), tracer); } else { - transactionProcessor.Execute(transaction, header, tracer); + transactionProcessor.Execute(transaction, new BlockExecutionContext(header), tracer); } failure = tracer.StatusCode != StatusCode.Success; diff --git a/src/Nethermind/Nethermind.Blockchain/GenesisLoader.cs b/src/Nethermind/Nethermind.Blockchain/GenesisLoader.cs index 3663d52e31a..2c94e4d7c6d 100644 --- a/src/Nethermind/Nethermind.Blockchain/GenesisLoader.cs +++ b/src/Nethermind/Nethermind.Blockchain/GenesisLoader.cs @@ -80,7 +80,7 @@ private void Preallocate(Block genesis) }; CallOutputTracer outputTracer = new(); - _transactionProcessor.Execute(constructorTransaction, genesis.Header, outputTracer); + _transactionProcessor.Execute(constructorTransaction, new BlockExecutionContext(genesis.Header), outputTracer); if (outputTracer.StatusCode != StatusCode.Success) { diff --git a/src/Nethermind/Nethermind.Consensus/ExecutionRequests/ExecutionRequestProcessor.cs b/src/Nethermind/Nethermind.Consensus/ExecutionRequests/ExecutionRequestProcessor.cs index 6b6d78ad22f..7d79e8950df 100644 --- a/src/Nethermind/Nethermind.Consensus/ExecutionRequests/ExecutionRequestProcessor.cs +++ b/src/Nethermind/Nethermind.Consensus/ExecutionRequests/ExecutionRequestProcessor.cs @@ -119,7 +119,7 @@ private byte[] ReadRequests(Block block, IWorldState state, IReleaseSpec spec, A CallOutputTracer tracer = new(); - _transactionProcessor.Execute(isWithdrawalRequests ? _withdrawalTransaction : _consolidationTransaction, block.Header, tracer); + _transactionProcessor.Execute(isWithdrawalRequests ? _withdrawalTransaction : _consolidationTransaction, new BlockExecutionContext(block.Header), tracer); if (tracer.ReturnValue is null || tracer.ReturnValue.Length == 0) { diff --git a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionsExecutor.cs b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionsExecutor.cs index fb13a8f7912..b6f659fbade 100644 --- a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionsExecutor.cs +++ b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionsExecutor.cs @@ -70,9 +70,10 @@ public virtual TxReceipt[] ProcessTransactions(Block block, ProcessingOptions pr int i = 0; LinkedHashSet transactionsInBlock = new(ByHashTxComparer.Instance); + BlockExecutionContext blkCtx = new(block.Header); foreach (Transaction currentTx in transactions) { - TxAction action = ProcessTransaction(block, block.Header, currentTx, i++, receiptsTracer, processingOptions, transactionsInBlock); + TxAction action = ProcessTransaction(block, blkCtx, currentTx, i++, receiptsTracer, processingOptions, transactionsInBlock); if (action == TxAction.Stop) break; } diff --git a/src/Nethermind/Nethermind.Evm.Test/EvmPooledMemoryTests.cs b/src/Nethermind/Nethermind.Evm.Test/EvmPooledMemoryTests.cs index 69fce9e4e46..33c7eb093cc 100644 --- a/src/Nethermind/Nethermind.Evm.Test/EvmPooledMemoryTests.cs +++ b/src/Nethermind/Nethermind.Evm.Test/EvmPooledMemoryTests.cs @@ -196,7 +196,7 @@ private static string Run(byte[] input) MyTracer tracer = new(); transactionProcessor.Execute( tx, - block.Header, + new BlockExecutionContext(block.Header), tracer); return tracer.lastmemline; } diff --git a/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs b/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs index 2857279d410..de88ea69482 100644 --- a/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs +++ b/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs @@ -125,7 +125,7 @@ private TransactionResult ExecuteCore(Transaction tx, in BlockExecutionContext b if (tx.IsSystem()) { _systemTransactionProcessor ??= new SystemTransactionProcessor(SpecProvider, WorldState, VirtualMachine, _codeInfoRepository, _logManager); - return _systemTransactionProcessor.Execute(tx, blCtx, tracer, opts); + return _systemTransactionProcessor.Execute(tx, blCtx.Header, tracer, opts); } return Execute(tx, in blCtx, tracer, opts); diff --git a/src/Nethermind/Nethermind.Taiko/BlockInvalidTxExecutor.cs b/src/Nethermind/Nethermind.Taiko/BlockInvalidTxExecutor.cs index 24785ebaaa1..3577d9a4479 100644 --- a/src/Nethermind/Nethermind.Taiko/BlockInvalidTxExecutor.cs +++ b/src/Nethermind/Nethermind.Taiko/BlockInvalidTxExecutor.cs @@ -32,6 +32,7 @@ public TxReceipt[] ProcessTransactions(Block block, ProcessingOptions processing block.Transactions[0].IsAnchorTx = true; + BlockExecutionContext blkCtx = new(block.Header); using ArrayPoolList correctTransactions = new(block.Transactions.Length); for (int i = 0; i < block.Transactions.Length; i++) @@ -49,7 +50,7 @@ public TxReceipt[] ProcessTransactions(Block block, ProcessingOptions processing try { - if (!_txProcessor.Execute(tx, block.Header, receiptsTracer)) + if (!_txProcessor.Execute(tx, in blkCtx, receiptsTracer)) { // if the transaction was invalid, we ignore it and continue _worldState.Restore(snap); diff --git a/src/Nethermind/Nethermind.Taiko/Rpc/TaikoEngineRpcModule.cs b/src/Nethermind/Nethermind.Taiko/Rpc/TaikoEngineRpcModule.cs index b85976738fd..cfd45fa0501 100644 --- a/src/Nethermind/Nethermind.Taiko/Rpc/TaikoEngineRpcModule.cs +++ b/src/Nethermind/Nethermind.Taiko/Rpc/TaikoEngineRpcModule.cs @@ -158,6 +158,7 @@ void CommitAndDisposeBatch(Batch batch) batch.Dispose(); } + BlockExecutionContext blkCtx = new(blockHeader); worldState.StateRoot = blockHeader.StateRoot; Batch batch = new(maxBytesPerTxList, txSource.Length, txDecoder); @@ -171,7 +172,7 @@ void CommitAndDisposeBatch(Batch batch) try { - TransactionResult executionResult = txProcessor.Execute(tx, blockHeader, NullTxTracer.Instance); + TransactionResult executionResult = txProcessor.Execute(tx, in blkCtx, NullTxTracer.Instance); if (!executionResult) { diff --git a/tools/Evm/T8n/T8nExecutor.cs b/tools/Evm/T8n/T8nExecutor.cs index 1869cc13a22..c0bcb03c30d 100644 --- a/tools/Evm/T8n/T8nExecutor.cs +++ b/tools/Evm/T8n/T8nExecutor.cs @@ -102,7 +102,7 @@ public static T8nExecutionResult Execute(T8nCommandArguments arguments) blockReceiptsTracer.StartNewTxTrace(transaction); TransactionResult transactionResult = transactionProcessor - .Execute(transaction, block.Header, blockReceiptsTracer); + .Execute(transaction, new BlockExecutionContext(block.Header), blockReceiptsTracer); blockReceiptsTracer.EndTxTrace(); transactionExecutionReport.ValidTransactions.Add(transaction); From ce81cbe280f9aa99b796b59006f1eae0a91fba07 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 9 Dec 2024 18:48:06 +0500 Subject: [PATCH 52/68] revert remaining implicit conversion of header --- .../BlockProcessor.BlockProductionTransactionsExecutor.cs | 2 +- src/Nethermind/Nethermind.Evm/Tracing/GasEstimator.cs | 3 ++- src/Nethermind/Nethermind.Evm/TransactionExtensions.cs | 2 +- src/Nethermind/Nethermind.Facade/BlockchainBridge.cs | 4 ++-- .../Nethermind.JsonRpc/Modules/Proof/ProofRpcModule.cs | 5 ++--- .../Nethermind.JsonRpc/Modules/ReceiptFinderExtensions.cs | 5 ++--- .../Nethermind.Optimism/Rpc/OptimismEthRpcModule.cs | 5 ++--- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionsExecutor.cs b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionsExecutor.cs index b6f659fbade..9725e29b7fd 100644 --- a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionsExecutor.cs +++ b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.BlockProductionTransactionsExecutor.cs @@ -73,7 +73,7 @@ public virtual TxReceipt[] ProcessTransactions(Block block, ProcessingOptions pr BlockExecutionContext blkCtx = new(block.Header); foreach (Transaction currentTx in transactions) { - TxAction action = ProcessTransaction(block, blkCtx, currentTx, i++, receiptsTracer, processingOptions, transactionsInBlock); + TxAction action = ProcessTransaction(block, in blkCtx, currentTx, i++, receiptsTracer, processingOptions, transactionsInBlock); if (action == TxAction.Stop) break; } diff --git a/src/Nethermind/Nethermind.Evm/Tracing/GasEstimator.cs b/src/Nethermind/Nethermind.Evm/Tracing/GasEstimator.cs index c3eb80143c6..a673ef8b657 100644 --- a/src/Nethermind/Nethermind.Evm/Tracing/GasEstimator.cs +++ b/src/Nethermind/Nethermind.Evm/Tracing/GasEstimator.cs @@ -114,7 +114,8 @@ private bool TryExecutableTransaction(Transaction transaction, BlockHeader block transaction.GasLimit = gasLimit; - _transactionProcessor.CallAndRestore(transaction, block, tracer.WithCancellation(token)); + BlockExecutionContext blCtx = new(block); + _transactionProcessor.CallAndRestore(transaction, in blCtx, tracer.WithCancellation(token)); transaction.GasLimit = originalGasLimit; return !tracer.OutOfGas; diff --git a/src/Nethermind/Nethermind.Evm/TransactionExtensions.cs b/src/Nethermind/Nethermind.Evm/TransactionExtensions.cs index 5e7d8e34f24..037edf8dfd6 100644 --- a/src/Nethermind/Nethermind.Evm/TransactionExtensions.cs +++ b/src/Nethermind/Nethermind.Evm/TransactionExtensions.cs @@ -15,7 +15,7 @@ public static class TransactionExtensions ? tx.SenderAddress : ContractAddress.From(tx.SenderAddress, nonce > 0 ? nonce - 1 : nonce)); - public static TxGasInfo GetGasInfo(this Transaction tx, bool is1559Enabled, BlockHeader header, IReleaseSpec spec) + public static TxGasInfo GetGasInfo(this Transaction tx, bool is1559Enabled, BlockHeader header) { UInt256 effectiveGasPrice = tx.CalculateEffectiveGasPrice(is1559Enabled, header.BaseFeePerGas); diff --git a/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs b/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs index ee35373665f..c1943d01460 100644 --- a/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs +++ b/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs @@ -129,7 +129,7 @@ private bool TryGetCanonicalTransaction( { int logIndexStart = txReceipts.GetBlockLogFirstIndex(txReceipt.Index); bool is1559Enabled = _specProvider.GetSpecFor1559(block.Number).IsEip1559Enabled; - return (txReceipt, tx.GetGasInfo(is1559Enabled, block.Header, _specProvider.GetSpec(block.Header)), logIndexStart); + return (txReceipt, tx.GetGasInfo(is1559Enabled, block.Header), logIndexStart); } return (null, null, 0); @@ -299,7 +299,7 @@ private TransactionResult CallAndRestore( callHeader.IsPostMerge = blockHeader.Difficulty == 0; callHeader.TargetBlobCount = blockHeader.TargetBlobCount; transaction.Hash = transaction.CalculateHash(); - return scope.TransactionProcessor.CallAndRestore(transaction, callHeader, tracer); + return scope.TransactionProcessor.CallAndRestore(transaction, new(callHeader), tracer); } public ulong GetChainId() diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Proof/ProofRpcModule.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Proof/ProofRpcModule.cs index fb0cc68ca0a..99ca25d3666 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Proof/ProofRpcModule.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Proof/ProofRpcModule.cs @@ -155,13 +155,12 @@ public ResultWrapper proof_getTransactionReceipt(Hash256 txHas TxReceipt[] receipts = receiptsTracer.TxReceipts.ToArray(); Transaction[] txs = block.Transactions; ReceiptWithProof receiptWithProof = new(); - var spec = _specProvider.GetSpec(block.Header); - bool isEip1559Enabled = spec.IsEip1559Enabled; + bool isEip1559Enabled = _specProvider.GetSpec(block.Header).IsEip1559Enabled; Transaction? tx = txs.FirstOrDefault(x => x.Hash == txHash); int logIndexStart = _receiptFinder.Get(block).GetBlockLogFirstIndex(receipt.Index); - receiptWithProof.Receipt = new ReceiptForRpc(txHash, receipt, tx?.GetGasInfo(isEip1559Enabled, block.Header, spec) ?? new(), logIndexStart); + receiptWithProof.Receipt = new ReceiptForRpc(txHash, receipt, tx?.GetGasInfo(isEip1559Enabled, block.Header) ?? new(), logIndexStart); receiptWithProof.ReceiptProof = BuildReceiptProofs(block.Header, receipts, receipt.Index); receiptWithProof.TxProof = BuildTxProofs(txs, _specProvider.GetSpec(block.Header), receipt.Index); diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/ReceiptFinderExtensions.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/ReceiptFinderExtensions.cs index 749ed49c626..7ebf603cfcc 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/ReceiptFinderExtensions.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/ReceiptFinderExtensions.cs @@ -33,12 +33,11 @@ public static ResultWrapper GetBlockReceipts(this IReceiptFinde Block block = searchResult.Object; TxReceipt[] receipts = receiptFinder.Get(block) ?? new TxReceipt[block.Transactions.Length]; - var spec = specProvider.GetSpec(block.Header); - bool isEip1559Enabled = spec.IsEip1559Enabled; + bool isEip1559Enabled = specProvider.GetSpec(block.Header).IsEip1559Enabled; IEnumerable result = receipts .Zip(block.Transactions, (r, t) => { - return new ReceiptForRpc(t.Hash, r, t.GetGasInfo(isEip1559Enabled, block.Header, spec), receipts.GetBlockLogFirstIndex(r.Index)); + return new ReceiptForRpc(t.Hash, r, t.GetGasInfo(isEip1559Enabled, block.Header), receipts.GetBlockLogFirstIndex(r.Index)); }); ReceiptForRpc[] resultAsArray = result.ToArray(); return ResultWrapper.Success(resultAsArray); diff --git a/src/Nethermind/Nethermind.Optimism/Rpc/OptimismEthRpcModule.cs b/src/Nethermind/Nethermind.Optimism/Rpc/OptimismEthRpcModule.cs index 866083b87dd..e5933bb58f6 100644 --- a/src/Nethermind/Nethermind.Optimism/Rpc/OptimismEthRpcModule.cs +++ b/src/Nethermind/Nethermind.Optimism/Rpc/OptimismEthRpcModule.cs @@ -92,15 +92,14 @@ public OptimismEthRpcModule( Block? block = searchResult.Object!; OptimismTxReceipt[] receipts = receiptFinder.Get(block).Cast().ToArray() ?? new OptimismTxReceipt[block.Transactions.Length]; - IReleaseSpec spec = specProvider.GetSpec(block.Header); - bool isEip1559Enabled = spec.IsEip1559Enabled; + bool isEip1559Enabled = specProvider.GetSpec(block.Header).IsEip1559Enabled; L1BlockGasInfo l1BlockGasInfo = new(block, opSpecHelper); OptimismReceiptForRpc[]? result = [.. receipts .Zip(block.Transactions, (r, t) => { - return new OptimismReceiptForRpc(t.Hash!, r, t.GetGasInfo(isEip1559Enabled, block.Header, spec), l1BlockGasInfo.GetTxGasInfo(t), receipts.GetBlockLogFirstIndex(r.Index)); + return new OptimismReceiptForRpc(t.Hash!, r, t.GetGasInfo(isEip1559Enabled, block.Header), l1BlockGasInfo.GetTxGasInfo(t), receipts.GetBlockLogFirstIndex(r.Index)); })]; return ResultWrapper.Success(result); } From 77c82a649a576a1efc6f8ec87d18eea33320b95e Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 9 Dec 2024 18:51:30 +0500 Subject: [PATCH 53/68] remove unnecessary import --- src/Nethermind/Nethermind.Evm/TransactionExtensions.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Evm/TransactionExtensions.cs b/src/Nethermind/Nethermind.Evm/TransactionExtensions.cs index 037edf8dfd6..0bb04c021fd 100644 --- a/src/Nethermind/Nethermind.Evm/TransactionExtensions.cs +++ b/src/Nethermind/Nethermind.Evm/TransactionExtensions.cs @@ -3,7 +3,6 @@ using System; using Nethermind.Core; -using Nethermind.Core.Specs; using Nethermind.Int256; namespace Nethermind.Evm From b46573918ac08f923da14e400a4562fc87f4f331 Mon Sep 17 00:00:00 2001 From: yerke26 <160018032+yerke26@users.noreply.github.com> Date: Mon, 9 Dec 2024 18:53:31 +0500 Subject: [PATCH 54/68] Update src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs Co-authored-by: Lukasz Rozmej --- src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs index d88a7065687..3fdf9616e35 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs @@ -62,7 +62,7 @@ public IEnumerable GetTransactions(BlockHeader parent, long gasLimi int checkedTransactions = 0; int selectedTransactions = 0; - if (spec.IsEip7742Enabled && payloadAttributes == null) + if (spec.IsEip7742Enabled && payloadAttributes is null) { if (_logger.IsDebug) _logger.Debug("Eip-7742 is enabled, but no payload attributes were provided."); yield break; From 41703ec3638cac682b8d70fc80d4bc6f9ac2f99b Mon Sep 17 00:00:00 2001 From: yerke26 <160018032+yerke26@users.noreply.github.com> Date: Mon, 9 Dec 2024 18:53:54 +0500 Subject: [PATCH 55/68] Update src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs Co-authored-by: Lukasz Rozmej --- .../Nethermind.Consensus/Producers/TxPoolTxSource.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs index 3fdf9616e35..e4c34ac972e 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs @@ -133,8 +133,10 @@ private void SelectBlobTransactions(IEnumerable blobTransactions, B foreach (Transaction blobTx in blobTransactions) { - if ((spec.IsEip7742Enabled && blobGasCounter >= payloadAttributes?.MaxBlobCount * Eip4844Constants.GasPerBlob) - || (!spec.IsEip7742Enabled && 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; From fc1832bc2a237e1a6f33a93a40bbc5079f6cb3e4 Mon Sep 17 00:00:00 2001 From: yerke26 <160018032+yerke26@users.noreply.github.com> Date: Mon, 9 Dec 2024 18:54:10 +0500 Subject: [PATCH 56/68] Update src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs Co-authored-by: Lukasz Rozmej --- .../Nethermind.Consensus/Producers/TxPoolTxSource.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs index e4c34ac972e..9956049f1e0 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs @@ -146,8 +146,10 @@ private void SelectBlobTransactions(IEnumerable blobTransactions, B ulong txBlobGas = (ulong)(blobTx.BlobVersionedHashes?.Length ?? 0) * _eip4844Config.GasPerBlob; - if ((spec.IsEip7742Enabled && txBlobGas >= payloadAttributes?.MaxBlobCount * Eip4844Constants.GasPerBlob - blobGasCounter) - || (!spec.IsEip7742Enabled && txBlobGas > _eip4844Config.MaxBlobGasPerBlock - blobGasCounter)) + UInt256? blobGasLeft = spec.IsEip7742Enabled + ? payloadAttributes?.MaxBlobCount * Eip4844Constants.GasPerBlob - blobGasCounter + : _eip4844Config.MaxBlobGasPerBlock - blobGasCounter; + if (txBlobGas > blobGasLeft) { if (_logger.IsTrace) _logger.Trace($"Declining {blobTx.ToShortString()}, not enough blob space."); continue; From a6c75cce88a1e5fbb062b162dcd9295c45c3bb35 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Tue, 10 Dec 2024 11:56:49 +0500 Subject: [PATCH 57/68] resolve comments --- .../Producers/TxPoolTxSource.cs | 11 +++++------ src/Nethermind/Nethermind.Core/Eip7742Constants.cs | 13 ------------- src/Nethermind/Nethermind.TxPool/TxPool.cs | 3 ++- 3 files changed, 7 insertions(+), 20 deletions(-) delete mode 100644 src/Nethermind/Nethermind.Core/Eip7742Constants.cs diff --git a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs index 9956049f1e0..84c77950474 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs @@ -62,14 +62,13 @@ public IEnumerable GetTransactions(BlockHeader parent, long gasLimi int checkedTransactions = 0; int selectedTransactions = 0; - if (spec.IsEip7742Enabled && payloadAttributes is null) - { - if (_logger.IsDebug) _logger.Debug("Eip-7742 is enabled, but no payload attributes were provided."); - yield break; - } + using ArrayPoolList selectedBlobTxs = new((int)(payloadAttributes?.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock())); - SelectBlobTransactions(blobTransactions, parent, spec, selectedBlobTxs); + if (spec.IsEip7742Enabled && payloadAttributes?.MaxBlobCount is not null) + { + SelectBlobTransactions(blobTransactions, parent, spec, selectedBlobTxs); + } foreach (Transaction tx in transactions) { diff --git a/src/Nethermind/Nethermind.Core/Eip7742Constants.cs b/src/Nethermind/Nethermind.Core/Eip7742Constants.cs deleted file mode 100644 index 4ea67b5f159..00000000000 --- a/src/Nethermind/Nethermind.Core/Eip7742Constants.cs +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -namespace Nethermind.Core; - -public class Eip7742Constants -{ - /// - /// Gets the BLOB_GASPRICE_UPDATE_FRACTION parameter. - /// - /// Defaults to 3338477. - public const ulong BlobGasPriceUpdateFraction = 1112825; -} diff --git a/src/Nethermind/Nethermind.TxPool/TxPool.cs b/src/Nethermind/Nethermind.TxPool/TxPool.cs index a30ae3ebaa8..ebc5c1e836e 100644 --- a/src/Nethermind/Nethermind.TxPool/TxPool.cs +++ b/src/Nethermind/Nethermind.TxPool/TxPool.cs @@ -304,7 +304,8 @@ private void ReAddReorganisedTransactions(Block? previousBlock) private void RemoveProcessedTransactions(Block block) { Transaction[] blockTransactions = block.Transactions; - using ArrayPoolList blobTxsToSave = new(blockTransactions.Length); + var blockTransactionsCount = blockTransactions.Count(transaction => transaction.Type == TxType.Blob); + using ArrayPoolList blobTxsToSave = new(blockTransactionsCount); long discoveredForPendingTxs = 0; long discoveredForHashCache = 0; long eip1559Txs = 0; From 981f9eed76d3483f247ee37ee9b49d67eec5614b Mon Sep 17 00:00:00 2001 From: yerke26 Date: Tue, 10 Dec 2024 12:32:15 +0500 Subject: [PATCH 58/68] fix --- src/Nethermind/Nethermind.TxPool/TxPool.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Nethermind/Nethermind.TxPool/TxPool.cs b/src/Nethermind/Nethermind.TxPool/TxPool.cs index ebc5c1e836e..a30ae3ebaa8 100644 --- a/src/Nethermind/Nethermind.TxPool/TxPool.cs +++ b/src/Nethermind/Nethermind.TxPool/TxPool.cs @@ -304,8 +304,7 @@ private void ReAddReorganisedTransactions(Block? previousBlock) private void RemoveProcessedTransactions(Block block) { Transaction[] blockTransactions = block.Transactions; - var blockTransactionsCount = blockTransactions.Count(transaction => transaction.Type == TxType.Blob); - using ArrayPoolList blobTxsToSave = new(blockTransactionsCount); + using ArrayPoolList blobTxsToSave = new(blockTransactions.Length); long discoveredForPendingTxs = 0; long discoveredForHashCache = 0; long eip1559Txs = 0; From 4339472d6c1ac596abc3585dc5e05c911e95b742 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Tue, 10 Dec 2024 12:35:58 +0500 Subject: [PATCH 59/68] fix --- .../Nethermind.Consensus/Producers/TxPoolTxSource.cs | 2 +- src/Nethermind/Nethermind.TxPool/TxPool.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs index 84c77950474..f1e0708ef10 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs @@ -65,7 +65,7 @@ public IEnumerable GetTransactions(BlockHeader parent, long gasLimi using ArrayPoolList selectedBlobTxs = new((int)(payloadAttributes?.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock())); - if (spec.IsEip7742Enabled && payloadAttributes?.MaxBlobCount is not null) + if (!spec.IsEip7742Enabled || payloadAttributes?.MaxBlobCount is not null) { SelectBlobTransactions(blobTransactions, parent, spec, selectedBlobTxs); } diff --git a/src/Nethermind/Nethermind.TxPool/TxPool.cs b/src/Nethermind/Nethermind.TxPool/TxPool.cs index a30ae3ebaa8..ebc5c1e836e 100644 --- a/src/Nethermind/Nethermind.TxPool/TxPool.cs +++ b/src/Nethermind/Nethermind.TxPool/TxPool.cs @@ -304,7 +304,8 @@ private void ReAddReorganisedTransactions(Block? previousBlock) private void RemoveProcessedTransactions(Block block) { Transaction[] blockTransactions = block.Transactions; - using ArrayPoolList blobTxsToSave = new(blockTransactions.Length); + var blockTransactionsCount = blockTransactions.Count(transaction => transaction.Type == TxType.Blob); + using ArrayPoolList blobTxsToSave = new(blockTransactionsCount); long discoveredForPendingTxs = 0; long discoveredForHashCache = 0; long eip1559Txs = 0; From c2abd4ca3ba272fc7b0bb0f036e82e007486f10d Mon Sep 17 00:00:00 2001 From: yerke26 Date: Tue, 10 Dec 2024 13:01:10 +0500 Subject: [PATCH 60/68] Fix TransactionProcessorFeeTests: add eip enabled/disabled tests --- .../TransactionProcessorFeeTests.cs | 13 +++++++++---- .../Nethermind.Specs.Test/OverridableReleaseSpec.cs | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Nethermind/Nethermind.Evm.Test/TransactionProcessorFeeTests.cs b/src/Nethermind/Nethermind.Evm.Test/TransactionProcessorFeeTests.cs index 0426687faaf..0f1ac56b238 100644 --- a/src/Nethermind/Nethermind.Evm.Test/TransactionProcessorFeeTests.cs +++ b/src/Nethermind/Nethermind.Evm.Test/TransactionProcessorFeeTests.cs @@ -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) @@ -119,7 +121,10 @@ public void Check_paid_fees_with_blob(bool withFeeCollector) initialBalance = _stateProvider.GetBalance(TestItem.AddressC); } - BlockHeader header = Build.A.BlockHeader.WithExcessBlobGas(0).WithTargetBlobCount(3).TestObject; + 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) diff --git a/src/Nethermind/Nethermind.Specs.Test/OverridableReleaseSpec.cs b/src/Nethermind/Nethermind.Specs.Test/OverridableReleaseSpec.cs index 762bf1356e5..7aeafa27611 100644 --- a/src/Nethermind/Nethermind.Specs.Test/OverridableReleaseSpec.cs +++ b/src/Nethermind/Nethermind.Specs.Test/OverridableReleaseSpec.cs @@ -19,6 +19,7 @@ public OverridableReleaseSpec(IReleaseSpec spec) { _spec = spec; IsEip3607Enabled = _spec.IsEip3607Enabled; + IsEip7742Enabled = _spec.IsEip7742Enabled; BlockReward = _spec.BlockReward; } @@ -113,7 +114,7 @@ public OverridableReleaseSpec(IReleaseSpec spec) public bool IsEip3541Enabled => _spec.IsEip3541Enabled; public bool IsEip4844Enabled => _spec.IsEip4844Enabled; public bool IsRip7212Enabled => _spec.IsRip7212Enabled; - public bool IsEip7742Enabled => _spec.IsEip7742Enabled; + public bool IsEip7742Enabled { get; set; } public bool IsOpGraniteEnabled => _spec.IsOpGraniteEnabled; public bool IsOpHoloceneEnabled => _spec.IsOpHoloceneEnabled; From d1b14e9a7253813b4bb0900d7ae922c0c27950de Mon Sep 17 00:00:00 2001 From: yerke26 Date: Tue, 10 Dec 2024 18:03:45 +0500 Subject: [PATCH 61/68] add MaxBlobCount to BlockHeader --- .../Processing/BlockProcessor.cs | 1 + .../Producers/BlockProducerBase.cs | 1 + .../Blockchain/TestBlockchain.cs | 2 +- .../Builders/BlockBuilder.cs | 6 ++++++ src/Nethermind/Nethermind.Core/Block.cs | 2 ++ src/Nethermind/Nethermind.Core/BlockHeader.cs | 1 + .../Nethermind.Facade/BlockchainBridge.cs | 1 + .../Simulate/SimulateBridgeHelper.cs | 1 + .../Eth/EthRpcModuleTests.FeeHistory.cs | 6 +++--- .../Modules/Eth/FeeHistory/FeeHistoryOracle.cs | 14 +++++++++++++- .../EngineModuleTests.V4.cs | 2 ++ .../Data/ExecutionPayload.cs | 7 +++++++ .../HeaderDecoder.cs | 18 +++++++++++++++++- 13 files changed, 56 insertions(+), 6 deletions(-) diff --git a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs index 0cff8238651..b572479171a 100644 --- a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs +++ b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs @@ -398,6 +398,7 @@ private Block PrepareBlockForProcessing(Block suggestedBlock) IsPostMerge = bh.IsPostMerge, ParentBeaconBlockRoot = bh.ParentBeaconBlockRoot, TargetBlobCount = bh.TargetBlobCount, + MaxBlobCount = bh.MaxBlobCount, }; if (!ShouldComputeStateRoot(bh)) diff --git a/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerBase.cs b/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerBase.cs index 60a270f962f..1e0d062793b 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerBase.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerBase.cs @@ -234,6 +234,7 @@ protected virtual BlockHeader PrepareBlockHeader(BlockHeader parent, MixHash = payloadAttributes?.PrevRandao, ParentBeaconBlockRoot = payloadAttributes?.ParentBeaconBlockRoot, TargetBlobCount = payloadAttributes?.TargetBlobCount, + MaxBlobCount = payloadAttributes?.MaxBlobCount, }; UInt256 difficulty = _difficultyCalculator.Calculate(header, parent); diff --git a/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs b/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs index d68abb59e33..61c1d080037 100644 --- a/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs +++ b/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs @@ -445,7 +445,7 @@ private async Task AddBlockInternal(params Transaction[] trans Timestamper.Add(TimeSpan.FromSeconds(1)); var headProcessed = new SemaphoreSlim(0); TxPool.TxPoolHeadChanged += (s, a) => headProcessed.Release(); - await BlockProductionTrigger.BuildBlock(payloadAttributes: new PayloadAttributes { TargetBlobCount = 0 }).ConfigureAwait(false); + await BlockProductionTrigger.BuildBlock(payloadAttributes: new PayloadAttributes { TargetBlobCount = 0, MaxBlobCount = 1 }).ConfigureAwait(false); await headProcessed.WaitAsync().ConfigureAwait(false); return txResults; } diff --git a/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs b/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs index cbc7e79ffb9..5cdc412057f 100644 --- a/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs +++ b/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs @@ -294,5 +294,11 @@ public BlockBuilder WithTargetBlobCount(ulong? targetBlobCount) TestObjectInternal.Header.TargetBlobCount = targetBlobCount; return this; } + + public BlockBuilder WithMaxBlobCount(ulong? maxBlobCount) + { + TestObjectInternal.Header.MaxBlobCount = maxBlobCount; + return this; + } } } diff --git a/src/Nethermind/Nethermind.Core/Block.cs b/src/Nethermind/Nethermind.Core/Block.cs index 2346592a4ef..d7c7a48287f 100644 --- a/src/Nethermind/Nethermind.Core/Block.cs +++ b/src/Nethermind/Nethermind.Core/Block.cs @@ -122,6 +122,8 @@ public Transaction[] Transactions public ulong? TargetBlobCount => Header.TargetBlobCount; // do not add setter here + public ulong? MaxBlobCount => Header.MaxBlobCount; + [JsonIgnore] public ArrayPoolList? AccountChanges { get; set; } [JsonIgnore] diff --git a/src/Nethermind/Nethermind.Core/BlockHeader.cs b/src/Nethermind/Nethermind.Core/BlockHeader.cs index 75f54a4ba68..1eac1e3791f 100644 --- a/src/Nethermind/Nethermind.Core/BlockHeader.cs +++ b/src/Nethermind/Nethermind.Core/BlockHeader.cs @@ -84,6 +84,7 @@ 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) { diff --git a/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs b/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs index c1943d01460..3095210578e 100644 --- a/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs +++ b/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs @@ -298,6 +298,7 @@ private TransactionResult CallAndRestore( callHeader.MixHash = blockHeader.MixHash; callHeader.IsPostMerge = blockHeader.Difficulty == 0; callHeader.TargetBlobCount = blockHeader.TargetBlobCount; + callHeader.MaxBlobCount = blockHeader.MaxBlobCount; transaction.Hash = transaction.CalculateHash(); return scope.TransactionProcessor.CallAndRestore(transaction, new(callHeader), tracer); } diff --git a/src/Nethermind/Nethermind.Facade/Simulate/SimulateBridgeHelper.cs b/src/Nethermind/Nethermind.Facade/Simulate/SimulateBridgeHelper.cs index 9299ba96830..e5bc96e4510 100644 --- a/src/Nethermind/Nethermind.Facade/Simulate/SimulateBridgeHelper.cs +++ b/src/Nethermind/Nethermind.Facade/Simulate/SimulateBridgeHelper.cs @@ -289,6 +289,7 @@ private BlockHeader GetCallHeader(BlockStateCall b IsPostMerge = parent.Difficulty == 0, }; result.TargetBlobCount = parent.TargetBlobCount; + result.MaxBlobCount = parent.MaxBlobCount; result.Timestamp = parent.Timestamp + 1; result.BaseFeePerGas = block.BlockOverrides is { BaseFeePerGas: not null } ? block.BlockOverrides.BaseFeePerGas.Value diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.FeeHistory.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.FeeHistory.cs index bbf2a86480e..6f03257123c 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.FeeHistory.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.FeeHistory.cs @@ -25,9 +25,9 @@ namespace Nethermind.JsonRpc.Test.Modules.Eth; public partial class EthRpcModuleTests { - [TestCase(1, "latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x2da282a8\",\"0x27ee3253\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[NaN],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] - [TestCase(1, "pending", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x2da282a8\",\"0x27ee3253\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[NaN],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] - [TestCase(2, "0x01", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x0\",\"0x3b9aca00\",\"0x342770c0\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0,0.0],\"blobGasUsedRatio\":[0.0,NaN],\"oldestBlock\":\"0x0\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"],[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] + [TestCase(1, "latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x2da282a8\",\"0x27ee3253\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[0.0],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] + [TestCase(1, "pending", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x2da282a8\",\"0x27ee3253\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[0.0],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] + [TestCase(2, "0x01", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x0\",\"0x3b9aca00\",\"0x342770c0\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0,0.0],\"blobGasUsedRatio\":[0.0,0.0],\"oldestBlock\":\"0x0\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"],[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] [TestCase(2, "earliest", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x0\",\"0x3b9aca00\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[0.0],\"oldestBlock\":\"0x0\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] public async Task Eth_feeHistory(long blockCount, string blockParameter, string expected) { diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs index c9a52245e5d..d0c15ea238e 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs @@ -110,7 +110,19 @@ BlockFeeHistorySearchInfo BlockFeeHistorySearchInfoFromBlock(Block b) { BlobGasCalculator.TryCalculateFeePerBlobGas(b.Header, out UInt256 feePerBlobGas); - var maxBlobGasPerBlock = (double)(block.TargetBlobCount * 2 ?? Eip4844Constants.GetMaxBlobsPerBlock()) * Eip4844Constants.GasPerBlob; + double maxBlobGasPerBlock; + if (!_specProvider.GetSpec(block.Header).IsEip7742Enabled) + { + maxBlobGasPerBlock = Eip4844Constants.MaxBlobGasPerBlock; + } + else if (block.MaxBlobCount.HasValue) + { + maxBlobGasPerBlock = block.MaxBlobCount.Value * Eip4844Constants.GasPerBlob; + } + else + { + throw new InvalidBlockException(block, "header is missing MaxBlobCount"); + } return new( b.Number, diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs index 8416f435a3e..37db8663751 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs @@ -107,6 +107,7 @@ public virtual async Task Should_process_block_as_expected_V4(string latestValid ReceiptsRoot = chain.BlockTree.Head!.ReceiptsRoot!, StateRoot = new(stateRoot), TargetBlobCount = 0, + MaxBlobCount = 0, }, Array.Empty(), Array.Empty(), @@ -349,6 +350,7 @@ private async Task BuildAndGetPayloadResultV4( ParentBeaconBlockRoot = Keccak.Zero, Withdrawals = withdrawals, TargetBlobCount = 0, + MaxBlobCount = 0, }; ResultWrapper result = rpc.engine_forkchoiceUpdatedV4(forkchoiceState, payloadAttributes).Result; diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs index 0912948082d..c1d8b7f5c1a 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs @@ -111,6 +111,12 @@ public byte[][] Transactions /// public virtual ulong? TargetBlobCount { get; set; } + /// + /// Gets or sets as defined in + /// EIP-7742. + /// + public virtual ulong? MaxBlobCount { get; set; } + public static ExecutionPayload Create(Block block) => Create(block); protected static TExecutionPayload Create(Block block) where TExecutionPayload : ExecutionPayload, new() @@ -172,6 +178,7 @@ public virtual bool TryGetBlock([NotNullWhen(true)] out Block? block, UInt256? t TxRoot = TxTrie.CalculateRoot(transactions), WithdrawalsRoot = Withdrawals is null ? null : new WithdrawalTrie(Withdrawals).RootHash, TargetBlobCount = TargetBlobCount, + MaxBlobCount = MaxBlobCount, }; block = new(header, transactions, Array.Empty(), Withdrawals); diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs index b1e9c50d707..afb4d37ac0b 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs @@ -99,6 +99,11 @@ public class HeaderDecoder : IRlpValueDecoder, IRlpStreamDecoder= 7 && decoderContext.Position != headerCheck) + { + blockHeader.MaxBlobCount = decoderContext.DecodeULong(); + } } @@ -196,6 +201,11 @@ public class HeaderDecoder : IRlpValueDecoder, IRlpStreamDecoder= 7 && rlpStream.Position != headerCheck) + { + blockHeader.MaxBlobCount = rlpStream.DecodeULong(); + } } if ((rlpBehaviors & RlpBehaviors.AllowExtraBytes) != RlpBehaviors.AllowExtraBytes) @@ -275,6 +285,11 @@ public void Encode(RlpStream rlpStream, BlockHeader? header, RlpBehaviors rlpBeh { rlpStream.Encode(header.TargetBlobCount.GetValueOrDefault()); } + + if (header.MaxBlobCount is not null) + { + rlpStream.Encode(header.MaxBlobCount.GetValueOrDefault()); + } } public Rlp Encode(BlockHeader? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) @@ -318,7 +333,8 @@ private static int GetContentLength(BlockHeader? item, RlpBehaviors rlpBehaviors + (item.BlobGasUsed is null ? 0 : Rlp.LengthOf(item.BlobGasUsed.Value)) + (item.ExcessBlobGas is null ? 0 : Rlp.LengthOf(item.ExcessBlobGas.Value)) + (item.RequestsHash is null ? 0 : Rlp.LengthOf(item.RequestsHash)) - + (item.TargetBlobCount is null ? 0 : Rlp.LengthOf(item.TargetBlobCount)); + + (item.TargetBlobCount is null ? 0 : Rlp.LengthOf(item.TargetBlobCount)) + + (item.MaxBlobCount is null ? 0 : Rlp.LengthOf(item.MaxBlobCount)); if (notForSealing) { From 2eb9fee5a584bad54ad514cd5c0fdbe8afdee88f Mon Sep 17 00:00:00 2001 From: yerke26 <160018032+yerke26@users.noreply.github.com> Date: Wed, 11 Dec 2024 00:23:53 +0500 Subject: [PATCH 62/68] Update src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs Co-authored-by: Lukasz Rozmej --- .../Nethermind.Consensus/Producers/TxPoolTxSource.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs index f1e0708ef10..e3710683aa1 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs @@ -145,9 +145,7 @@ private void SelectBlobTransactions(IEnumerable blobTransactions, B ulong txBlobGas = (ulong)(blobTx.BlobVersionedHashes?.Length ?? 0) * _eip4844Config.GasPerBlob; - UInt256? blobGasLeft = spec.IsEip7742Enabled - ? payloadAttributes?.MaxBlobCount * Eip4844Constants.GasPerBlob - blobGasCounter - : _eip4844Config.MaxBlobGasPerBlock - blobGasCounter; + UInt256 blobGasLeft = maxBlobGas - blobGasCounter; if (txBlobGas > blobGasLeft) { if (_logger.IsTrace) _logger.Trace($"Declining {blobTx.ToShortString()}, not enough blob space."); From 82f6f4b34276f531f2d36f2fabd46cc041d196cb Mon Sep 17 00:00:00 2001 From: yerke26 Date: Wed, 11 Dec 2024 09:53:32 +0500 Subject: [PATCH 63/68] Revert "add MaxBlobCount to BlockHeader" This reverts commit d1b14e9a7253813b4bb0900d7ae922c0c27950de. --- .../Processing/BlockProcessor.cs | 1 - .../Producers/BlockProducerBase.cs | 1 - .../Blockchain/TestBlockchain.cs | 2 +- .../Builders/BlockBuilder.cs | 6 ------ src/Nethermind/Nethermind.Core/Block.cs | 2 -- src/Nethermind/Nethermind.Core/BlockHeader.cs | 1 - .../Nethermind.Facade/BlockchainBridge.cs | 1 - .../Simulate/SimulateBridgeHelper.cs | 1 - .../Eth/EthRpcModuleTests.FeeHistory.cs | 6 +++--- .../Modules/Eth/FeeHistory/FeeHistoryOracle.cs | 14 +------------- .../EngineModuleTests.V4.cs | 2 -- .../Data/ExecutionPayload.cs | 7 ------- .../HeaderDecoder.cs | 18 +----------------- 13 files changed, 6 insertions(+), 56 deletions(-) diff --git a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs index b572479171a..0cff8238651 100644 --- a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs +++ b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs @@ -398,7 +398,6 @@ private Block PrepareBlockForProcessing(Block suggestedBlock) IsPostMerge = bh.IsPostMerge, ParentBeaconBlockRoot = bh.ParentBeaconBlockRoot, TargetBlobCount = bh.TargetBlobCount, - MaxBlobCount = bh.MaxBlobCount, }; if (!ShouldComputeStateRoot(bh)) diff --git a/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerBase.cs b/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerBase.cs index 1e0d062793b..60a270f962f 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerBase.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerBase.cs @@ -234,7 +234,6 @@ protected virtual BlockHeader PrepareBlockHeader(BlockHeader parent, MixHash = payloadAttributes?.PrevRandao, ParentBeaconBlockRoot = payloadAttributes?.ParentBeaconBlockRoot, TargetBlobCount = payloadAttributes?.TargetBlobCount, - MaxBlobCount = payloadAttributes?.MaxBlobCount, }; UInt256 difficulty = _difficultyCalculator.Calculate(header, parent); diff --git a/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs b/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs index 61c1d080037..d68abb59e33 100644 --- a/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs +++ b/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs @@ -445,7 +445,7 @@ private async Task AddBlockInternal(params Transaction[] trans Timestamper.Add(TimeSpan.FromSeconds(1)); var headProcessed = new SemaphoreSlim(0); TxPool.TxPoolHeadChanged += (s, a) => headProcessed.Release(); - await BlockProductionTrigger.BuildBlock(payloadAttributes: new PayloadAttributes { TargetBlobCount = 0, MaxBlobCount = 1 }).ConfigureAwait(false); + await BlockProductionTrigger.BuildBlock(payloadAttributes: new PayloadAttributes { TargetBlobCount = 0 }).ConfigureAwait(false); await headProcessed.WaitAsync().ConfigureAwait(false); return txResults; } diff --git a/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs b/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs index 5cdc412057f..cbc7e79ffb9 100644 --- a/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs +++ b/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs @@ -294,11 +294,5 @@ public BlockBuilder WithTargetBlobCount(ulong? targetBlobCount) TestObjectInternal.Header.TargetBlobCount = targetBlobCount; return this; } - - public BlockBuilder WithMaxBlobCount(ulong? maxBlobCount) - { - TestObjectInternal.Header.MaxBlobCount = maxBlobCount; - return this; - } } } diff --git a/src/Nethermind/Nethermind.Core/Block.cs b/src/Nethermind/Nethermind.Core/Block.cs index d7c7a48287f..2346592a4ef 100644 --- a/src/Nethermind/Nethermind.Core/Block.cs +++ b/src/Nethermind/Nethermind.Core/Block.cs @@ -122,8 +122,6 @@ public Transaction[] Transactions public ulong? TargetBlobCount => Header.TargetBlobCount; // do not add setter here - public ulong? MaxBlobCount => Header.MaxBlobCount; - [JsonIgnore] public ArrayPoolList? AccountChanges { get; set; } [JsonIgnore] diff --git a/src/Nethermind/Nethermind.Core/BlockHeader.cs b/src/Nethermind/Nethermind.Core/BlockHeader.cs index 1eac1e3791f..75f54a4ba68 100644 --- a/src/Nethermind/Nethermind.Core/BlockHeader.cs +++ b/src/Nethermind/Nethermind.Core/BlockHeader.cs @@ -84,7 +84,6 @@ 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) { diff --git a/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs b/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs index 3095210578e..c1943d01460 100644 --- a/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs +++ b/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs @@ -298,7 +298,6 @@ private TransactionResult CallAndRestore( callHeader.MixHash = blockHeader.MixHash; callHeader.IsPostMerge = blockHeader.Difficulty == 0; callHeader.TargetBlobCount = blockHeader.TargetBlobCount; - callHeader.MaxBlobCount = blockHeader.MaxBlobCount; transaction.Hash = transaction.CalculateHash(); return scope.TransactionProcessor.CallAndRestore(transaction, new(callHeader), tracer); } diff --git a/src/Nethermind/Nethermind.Facade/Simulate/SimulateBridgeHelper.cs b/src/Nethermind/Nethermind.Facade/Simulate/SimulateBridgeHelper.cs index e5bc96e4510..9299ba96830 100644 --- a/src/Nethermind/Nethermind.Facade/Simulate/SimulateBridgeHelper.cs +++ b/src/Nethermind/Nethermind.Facade/Simulate/SimulateBridgeHelper.cs @@ -289,7 +289,6 @@ private BlockHeader GetCallHeader(BlockStateCall b IsPostMerge = parent.Difficulty == 0, }; result.TargetBlobCount = parent.TargetBlobCount; - result.MaxBlobCount = parent.MaxBlobCount; result.Timestamp = parent.Timestamp + 1; result.BaseFeePerGas = block.BlockOverrides is { BaseFeePerGas: not null } ? block.BlockOverrides.BaseFeePerGas.Value diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.FeeHistory.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.FeeHistory.cs index 6f03257123c..bbf2a86480e 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.FeeHistory.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.FeeHistory.cs @@ -25,9 +25,9 @@ namespace Nethermind.JsonRpc.Test.Modules.Eth; public partial class EthRpcModuleTests { - [TestCase(1, "latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x2da282a8\",\"0x27ee3253\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[0.0],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] - [TestCase(1, "pending", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x2da282a8\",\"0x27ee3253\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[0.0],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] - [TestCase(2, "0x01", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x0\",\"0x3b9aca00\",\"0x342770c0\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0,0.0],\"blobGasUsedRatio\":[0.0,0.0],\"oldestBlock\":\"0x0\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"],[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] + [TestCase(1, "latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x2da282a8\",\"0x27ee3253\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[NaN],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] + [TestCase(1, "pending", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x2da282a8\",\"0x27ee3253\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[NaN],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] + [TestCase(2, "0x01", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x0\",\"0x3b9aca00\",\"0x342770c0\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0,0.0],\"blobGasUsedRatio\":[0.0,NaN],\"oldestBlock\":\"0x0\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"],[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] [TestCase(2, "earliest", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x0\",\"0x3b9aca00\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[0.0],\"oldestBlock\":\"0x0\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] public async Task Eth_feeHistory(long blockCount, string blockParameter, string expected) { diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs index d0c15ea238e..c9a52245e5d 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs @@ -110,19 +110,7 @@ BlockFeeHistorySearchInfo BlockFeeHistorySearchInfoFromBlock(Block b) { BlobGasCalculator.TryCalculateFeePerBlobGas(b.Header, out UInt256 feePerBlobGas); - double maxBlobGasPerBlock; - if (!_specProvider.GetSpec(block.Header).IsEip7742Enabled) - { - maxBlobGasPerBlock = Eip4844Constants.MaxBlobGasPerBlock; - } - else if (block.MaxBlobCount.HasValue) - { - maxBlobGasPerBlock = block.MaxBlobCount.Value * Eip4844Constants.GasPerBlob; - } - else - { - throw new InvalidBlockException(block, "header is missing MaxBlobCount"); - } + var maxBlobGasPerBlock = (double)(block.TargetBlobCount * 2 ?? Eip4844Constants.GetMaxBlobsPerBlock()) * Eip4844Constants.GasPerBlob; return new( b.Number, diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs index 37db8663751..8416f435a3e 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs @@ -107,7 +107,6 @@ public virtual async Task Should_process_block_as_expected_V4(string latestValid ReceiptsRoot = chain.BlockTree.Head!.ReceiptsRoot!, StateRoot = new(stateRoot), TargetBlobCount = 0, - MaxBlobCount = 0, }, Array.Empty(), Array.Empty(), @@ -350,7 +349,6 @@ private async Task BuildAndGetPayloadResultV4( ParentBeaconBlockRoot = Keccak.Zero, Withdrawals = withdrawals, TargetBlobCount = 0, - MaxBlobCount = 0, }; ResultWrapper result = rpc.engine_forkchoiceUpdatedV4(forkchoiceState, payloadAttributes).Result; diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs index c1d8b7f5c1a..0912948082d 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs @@ -111,12 +111,6 @@ public byte[][] Transactions /// public virtual ulong? TargetBlobCount { get; set; } - /// - /// Gets or sets as defined in - /// EIP-7742. - /// - public virtual ulong? MaxBlobCount { get; set; } - public static ExecutionPayload Create(Block block) => Create(block); protected static TExecutionPayload Create(Block block) where TExecutionPayload : ExecutionPayload, new() @@ -178,7 +172,6 @@ public virtual bool TryGetBlock([NotNullWhen(true)] out Block? block, UInt256? t TxRoot = TxTrie.CalculateRoot(transactions), WithdrawalsRoot = Withdrawals is null ? null : new WithdrawalTrie(Withdrawals).RootHash, TargetBlobCount = TargetBlobCount, - MaxBlobCount = MaxBlobCount, }; block = new(header, transactions, Array.Empty(), Withdrawals); diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs index afb4d37ac0b..b1e9c50d707 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs @@ -99,11 +99,6 @@ public class HeaderDecoder : IRlpValueDecoder, IRlpStreamDecoder= 7 && decoderContext.Position != headerCheck) - { - blockHeader.MaxBlobCount = decoderContext.DecodeULong(); - } } @@ -201,11 +196,6 @@ public class HeaderDecoder : IRlpValueDecoder, IRlpStreamDecoder= 7 && rlpStream.Position != headerCheck) - { - blockHeader.MaxBlobCount = rlpStream.DecodeULong(); - } } if ((rlpBehaviors & RlpBehaviors.AllowExtraBytes) != RlpBehaviors.AllowExtraBytes) @@ -285,11 +275,6 @@ public void Encode(RlpStream rlpStream, BlockHeader? header, RlpBehaviors rlpBeh { rlpStream.Encode(header.TargetBlobCount.GetValueOrDefault()); } - - if (header.MaxBlobCount is not null) - { - rlpStream.Encode(header.MaxBlobCount.GetValueOrDefault()); - } } public Rlp Encode(BlockHeader? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) @@ -333,8 +318,7 @@ private static int GetContentLength(BlockHeader? item, RlpBehaviors rlpBehaviors + (item.BlobGasUsed is null ? 0 : Rlp.LengthOf(item.BlobGasUsed.Value)) + (item.ExcessBlobGas is null ? 0 : Rlp.LengthOf(item.ExcessBlobGas.Value)) + (item.RequestsHash is null ? 0 : Rlp.LengthOf(item.RequestsHash)) - + (item.TargetBlobCount is null ? 0 : Rlp.LengthOf(item.TargetBlobCount)) - + (item.MaxBlobCount is null ? 0 : Rlp.LengthOf(item.MaxBlobCount)); + + (item.TargetBlobCount is null ? 0 : Rlp.LengthOf(item.TargetBlobCount)); if (notForSealing) { From f63e7ef72989453e74220598993d245369005dc8 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Wed, 11 Dec 2024 10:10:05 +0500 Subject: [PATCH 64/68] fix tests with TargetBlobCount = 1 --- .../Blockchain/TestBlockchain.cs | 2 +- .../Modules/Eth/EthRpcModuleTests.FeeHistory.cs | 6 +++--- .../Modules/Eth/FeeHistory/FeeHistoryOracle.cs | 16 ++++++++++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs b/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs index d68abb59e33..645eb8c56b9 100644 --- a/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs +++ b/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs @@ -445,7 +445,7 @@ private async Task AddBlockInternal(params Transaction[] trans Timestamper.Add(TimeSpan.FromSeconds(1)); var headProcessed = new SemaphoreSlim(0); TxPool.TxPoolHeadChanged += (s, a) => headProcessed.Release(); - await BlockProductionTrigger.BuildBlock(payloadAttributes: new PayloadAttributes { TargetBlobCount = 0 }).ConfigureAwait(false); + await BlockProductionTrigger.BuildBlock(payloadAttributes: new PayloadAttributes { TargetBlobCount = 1 }).ConfigureAwait(false); await headProcessed.WaitAsync().ConfigureAwait(false); return txResults; } diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.FeeHistory.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.FeeHistory.cs index bbf2a86480e..6f03257123c 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.FeeHistory.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.FeeHistory.cs @@ -25,9 +25,9 @@ namespace Nethermind.JsonRpc.Test.Modules.Eth; public partial class EthRpcModuleTests { - [TestCase(1, "latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x2da282a8\",\"0x27ee3253\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[NaN],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] - [TestCase(1, "pending", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x2da282a8\",\"0x27ee3253\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[NaN],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] - [TestCase(2, "0x01", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x0\",\"0x3b9aca00\",\"0x342770c0\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0,0.0],\"blobGasUsedRatio\":[0.0,NaN],\"oldestBlock\":\"0x0\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"],[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] + [TestCase(1, "latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x2da282a8\",\"0x27ee3253\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[0.0],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] + [TestCase(1, "pending", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x2da282a8\",\"0x27ee3253\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[0.0],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] + [TestCase(2, "0x01", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x0\",\"0x3b9aca00\",\"0x342770c0\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0,0.0],\"blobGasUsedRatio\":[0.0,0.0],\"oldestBlock\":\"0x0\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"],[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] [TestCase(2, "earliest", "{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x0\",\"0x3b9aca00\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0],\"blobGasUsedRatio\":[0.0],\"oldestBlock\":\"0x0\",\"reward\":[[\"0x0\",\"0x0\",\"0x0\",\"0x0\",\"0x0\"]]},\"id\":67}")] public async Task Eth_feeHistory(long blockCount, string blockParameter, string expected) { diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs index c9a52245e5d..10e7c4bab44 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs @@ -110,7 +110,19 @@ BlockFeeHistorySearchInfo BlockFeeHistorySearchInfoFromBlock(Block b) { BlobGasCalculator.TryCalculateFeePerBlobGas(b.Header, out UInt256 feePerBlobGas); - var maxBlobGasPerBlock = (double)(block.TargetBlobCount * 2 ?? Eip4844Constants.GetMaxBlobsPerBlock()) * Eip4844Constants.GasPerBlob; + double maxBlobGasPerBlock; + if (!_specProvider.GetSpec(b.Header).IsEip7742Enabled) + { + maxBlobGasPerBlock = Eip4844Constants.GetMaxBlobsPerBlock(); + } + else if (b.Header.TargetBlobCount.HasValue) + { + maxBlobGasPerBlock = b.Header.TargetBlobCount.Value * 2; + } + else + { + throw new InvalidBlockException(b, "header is missing TargetBlobCount"); + } return new( b.Number, @@ -118,7 +130,7 @@ BlockFeeHistorySearchInfo BlockFeeHistorySearchInfoFromBlock(Block b) BaseFeeCalculator.Calculate(b.Header, _specProvider.GetSpecFor1559(b.Number + 1)), feePerBlobGas == UInt256.MaxValue ? UInt256.Zero : feePerBlobGas, b.GasUsed / (double)b.GasLimit, - (b.BlobGasUsed ?? 0) / maxBlobGasPerBlock, + (b.BlobGasUsed ?? 0) / (maxBlobGasPerBlock * Eip4844Constants.GasPerBlob), b.ParentHash, b.GasUsed, b.Transactions.Length, From 13b65bd21a5ab316d6b789ffd2af74c165645ca6 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Wed, 11 Dec 2024 10:51:04 +0500 Subject: [PATCH 65/68] fix tests --- .../Modules/Eth/EthRpcModuleTests.cs | 28 +++++++++---------- .../Modules/TraceRpcModuleTests.cs | 6 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs index 6ee19f00a39..b9432aa10bd 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs @@ -69,7 +69,7 @@ public async Task Eth_get_eth_feeHistory() { using Context ctx = await Context.Create(); string serialized = await ctx.Test.TestEthRpc("eth_feeHistory", "0x1", "latest", "[20,50,90]"); - Assert.That(serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x0\",\"0x0\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0105],\"blobGasUsedRatio\":[NaN],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x1\",\"0x1\",\"0x1\"]]},\"id\":67}")); + Assert.That(serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":{\"baseFeePerGas\":[\"0x0\",\"0x0\"],\"baseFeePerBlobGas\":[\"0x0\",\"0x0\"],\"gasUsedRatio\":[0.0105],\"blobGasUsedRatio\":[0.0],\"oldestBlock\":\"0x3\",\"reward\":[[\"0x1\",\"0x1\",\"0x1\"]]},\"id\":67}")); } [Test] @@ -77,7 +77,7 @@ public async Task Eth_get_transaction_by_block_hash_and_index() { using Context ctx = await Context.Create(); string serialized = await ctx.Test.TestEthRpc("eth_getTransactionByBlockHashAndIndex", ctx.Test.BlockTree.FindHeadBlock()!.Hash!.ToString(), "1"); - JToken.Parse(serialized).Should().BeEquivalentTo("""{"jsonrpc":"2.0","result":{"hash":"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b","nonce":"0x2","blockHash":"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47","blockNumber":"0x3","transactionIndex":"0x1","from":"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099","to":"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358","value":"0x1","gasPrice":"0x1","gas":"0x5208","input":"0x","type":"0x0","v":"0x25","s":"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb","r":"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd"},"id":67}"""); + JToken.Parse(serialized).Should().BeEquivalentTo("""{"jsonrpc":"2.0","result":{"type":"0x0","nonce":"0x2","to":"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358","from":"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099","gas":"0x5208","value":"0x1","input":"0x","gasPrice":"0x1","v":"0x25","r":"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd","s":"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb","hash":"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b","transactionIndex":"0x1","blockHash":"0x920131365494a9700b85720630ebbb653a5f0c9ef5c33da358135a8d8ebbdfa7","blockNumber":"0x3"},"id":67}"""); } [Test] @@ -85,7 +85,7 @@ public async Task Eth_get_transaction_by_hash() { using Context ctx = await Context.Create(); string serialized = await ctx.Test.TestEthRpc("eth_getTransactionByHash", ctx.Test.BlockTree.FindHeadBlock()!.Transactions.Last().Hash!.ToString()); - JToken.Parse(serialized).Should().BeEquivalentTo("""{"jsonrpc":"2.0","result":{"hash":"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b","nonce":"0x2","blockHash":"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47","blockNumber":"0x3","transactionIndex":"0x1","from":"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099","to":"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358","value":"0x1","gasPrice":"0x1","gas":"0x5208","input":"0x","type":"0x0","v":"0x25","s":"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb","r":"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd"},"id":67}"""); + JToken.Parse(serialized).Should().BeEquivalentTo("""{"jsonrpc":"2.0","result":{"type":"0x0","nonce":"0x2","to":"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358","from":"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099","gas":"0x5208","value":"0x1","input":"0x","gasPrice":"0x1","v":"0x25","r":"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd","s":"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb","hash":"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b","transactionIndex":"0x1","blockHash":"0x920131365494a9700b85720630ebbb653a5f0c9ef5c33da358135a8d8ebbdfa7","blockNumber":"0x3"},"id":67}"""); } [Test] @@ -137,7 +137,7 @@ public async Task Eth_getBlockReceipts() { using Context ctx = await Context.Create(); string serialized = await ctx.Test.TestEthRpc("eth_getBlockReceipts", "latest"); - string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":[{\"transactionHash\":\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"transactionIndex\":\"0x0\",\"blockHash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"blockNumber\":\"0x3\",\"cumulativeGasUsed\":\"0x5208\",\"gasUsed\":\"0x5208\",\"effectiveGasPrice\":\"0x1\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"contractAddress\":null,\"logs\":[],\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"status\":\"0x1\",\"type\":\"0x0\"},{\"transactionHash\":\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\",\"transactionIndex\":\"0x1\",\"blockHash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"blockNumber\":\"0x3\",\"cumulativeGasUsed\":\"0xa410\",\"gasUsed\":\"0x5208\",\"effectiveGasPrice\":\"0x1\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"contractAddress\":null,\"logs\":[],\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"status\":\"0x1\",\"type\":\"0x0\"}],\"id\":67}"; + string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":[{\"transactionHash\":\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"transactionIndex\":\"0x0\",\"blockHash\":\"0x920131365494a9700b85720630ebbb653a5f0c9ef5c33da358135a8d8ebbdfa7\",\"blockNumber\":\"0x3\",\"cumulativeGasUsed\":\"0x5208\",\"gasUsed\":\"0x5208\",\"effectiveGasPrice\":\"0x1\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"contractAddress\":null,\"logs\":[],\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"status\":\"0x1\",\"type\":\"0x0\"},{\"transactionHash\":\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\",\"transactionIndex\":\"0x1\",\"blockHash\":\"0x920131365494a9700b85720630ebbb653a5f0c9ef5c33da358135a8d8ebbdfa7\",\"blockNumber\":\"0x3\",\"cumulativeGasUsed\":\"0xa410\",\"gasUsed\":\"0x5208\",\"effectiveGasPrice\":\"0x1\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"contractAddress\":null,\"logs\":[],\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"status\":\"0x1\",\"type\":\"0x0\"}],\"id\":67}"; Assert.That(serialized, Is.EqualTo(expectedResult)); } @@ -146,7 +146,7 @@ public async Task Eth_get_transaction_by_block_number_and_index() { using Context ctx = await Context.Create(); string serialized = await ctx.Test.TestEthRpc("eth_getTransactionByBlockNumberAndIndex", ctx.Test.BlockTree.FindHeadBlock()!.Number.ToString(), "1"); - JToken.Parse(serialized).Should().BeEquivalentTo("""{"jsonrpc":"2.0","result":{"hash":"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b","nonce":"0x2","blockHash":"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47","blockNumber":"0x3","transactionIndex":"0x1","from":"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099","to":"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358","value":"0x1","gasPrice":"0x1","gas":"0x5208","input":"0x","type":"0x0","v":"0x25","s":"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb","r":"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd"},"id":67}"""); + JToken.Parse(serialized).Should().BeEquivalentTo("""{"jsonrpc":"2.0","result":{"type":"0x0","nonce":"0x2","to":"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358","from":"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099","gas":"0x5208","value":"0x1","input":"0x","gasPrice":"0x1","v":"0x25","r":"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd","s":"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb","hash":"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b","transactionIndex":"0x1","blockHash":"0x920131365494a9700b85720630ebbb653a5f0c9ef5c33da358135a8d8ebbdfa7","blockNumber":"0x3"},"id":67}"""); } [TestCase(false, "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x0000000000000000000000000000000000000000\",\"difficulty\":\"0xf4240\",\"extraData\":\"0x010203\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0x0\",\"hash\":\"0xa2a9f03b9493046696099d27b2612b99497aa1f392ec966716ab393c715a5bb6\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x0000000000000000000000000000000000000000\",\"mixHash\":\"0x2ba5557a4c62a513c7e56d1bf13373e0da6bec016755483e91589fe1c6d212e2\",\"nonce\":\"0x00000000000003e8\",\"number\":\"0x0\",\"parentHash\":\"0xff483e972a04a9a62bb4b7d04ae403c615604e4090521ecc5bb7af67f71be09c\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x201\",\"stateRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"totalDifficulty\":\"0x0\",\"timestamp\":\"0xf4240\",\"transactions\":[],\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"uncles\":[]},\"id\":67}")] @@ -289,7 +289,7 @@ public async Task Eth_get_filter_changes_with_block() await ctx.Test.AddBlock(); string serialized2 = await ctx.Test.TestEthRpc("eth_getFilterChanges", "0"); - Assert.That(serialized2, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":[\"0xa174bdcf7b2b3e2a855b98d3d585d399c8a122004ae5da3c88d9beaa803fc42b\"],\"id\":67}"), serialized2.Replace("\"", "\\\"")); + Assert.That(serialized2, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":[\"0x11f96fb5e596f08800fc0825b680e3f0309427b999b490aaf57246d5b07b7ba2\"],\"id\":67}"), serialized2.Replace("\"", "\\\"")); } [Test] @@ -326,7 +326,7 @@ void handleNewBlock(object? sender, BlockEventArgs e) //expect new transaction logs string getFilterLogsSerialized2 = await test.TestEthRpc("eth_getFilterChanges", (newFilterResp as JsonRpcSuccessResponse)!.Result?.ToString() ?? "0x0"); - getFilterLogsSerialized2.Should().Be("{\"jsonrpc\":\"2.0\",\"result\":[{\"address\":\"0x0ffd3e46594919c04bcfd4e146203c8255670828\",\"blockHash\":\"0xe1efdb179e29ec3d8bb8ebf3f17a3655805b3be3cf02e936ef588bc93ba9bc21\",\"blockNumber\":\"0x4\",\"data\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"logIndex\":\"0x0\",\"removed\":false,\"topics\":[],\"transactionHash\":\"0x8c9c109bff7969c8aed8e51ab4ea35c6f835a0c3266bc5c5721821a38cbf5445\",\"transactionIndex\":\"0x0\",\"transactionLogIndex\":\"0x0\"}],\"id\":67}"); + getFilterLogsSerialized2.Should().Be("{\"jsonrpc\":\"2.0\",\"result\":[{\"address\":\"0x0ffd3e46594919c04bcfd4e146203c8255670828\",\"blockHash\":\"0x06d7c3de9c8d15a6dda8f13d984efee1a07c6ae72ebb5cb9305a83e131f8b8e8\",\"blockNumber\":\"0x4\",\"data\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"logIndex\":\"0x0\",\"removed\":false,\"topics\":[],\"transactionHash\":\"0x8c9c109bff7969c8aed8e51ab4ea35c6f835a0c3266bc5c5721821a38cbf5445\",\"transactionIndex\":\"0x0\",\"transactionLogIndex\":\"0x0\"}],\"id\":67}"); //expect empty - previous call cleans logs string getFilterLogsSerialized3 = await test.TestEthRpc("eth_getFilterChanges", (newFilterResp as JsonRpcSuccessResponse)!.Result?.ToString() ?? "0x0"); @@ -643,8 +643,8 @@ public async Task Eth_get_block_by_hash_null() Assert.That(serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":null,\"id\":67}")); } - [TestCase("0x71eac5e72c3b64431c246173352a8c625c8434d944eb5f3f58204fec3ec36b54", false, "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0xdb2fc4f70fc54c923b94ee0767901815685a5ff608e112c19e754316a9b8c97a\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2c8\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"transactions\":[\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\"],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] - [TestCase("0x71eac5e72c3b64431c246173352a8c625c8434d944eb5f3f58204fec3ec36b54", true, "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0xdb2fc4f70fc54c923b94ee0767901815685a5ff608e112c19e754316a9b8c97a\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2c8\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"transactions\":[{\"hash\":\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"nonce\":\"0x1\",\"blockHash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"blockNumber\":\"0x3\",\"transactionIndex\":\"0x0\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"value\":\"0x1\",\"gasPrice\":\"0x1\",\"gas\":\"0x5208\",\"input\":\"0x\",\"type\":\"0x0\",\"v\":\"0x25\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\"},{\"hash\":\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\",\"nonce\":\"0x2\",\"blockHash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"blockNumber\":\"0x3\",\"transactionIndex\":\"0x1\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"value\":\"0x1\",\"gasPrice\":\"0x1\",\"gas\":\"0x5208\",\"input\":\"0x\",\"type\":\"0x0\",\"v\":\"0x25\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\"}],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] + [TestCase("0x71eac5e72c3b64431c246173352a8c625c8434d944eb5f3f58204fec3ec36b54", false, "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x920131365494a9700b85720630ebbb653a5f0c9ef5c33da358135a8d8ebbdfa7\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0x656d36043de0c20ac0499ed845a653c3b9ba6ea8c311ed17db365a83c01b8752\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2c8\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"transactions\":[\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\"],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] + [TestCase("0x71eac5e72c3b64431c246173352a8c625c8434d944eb5f3f58204fec3ec36b54", true, "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x920131365494a9700b85720630ebbb653a5f0c9ef5c33da358135a8d8ebbdfa7\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0x656d36043de0c20ac0499ed845a653c3b9ba6ea8c311ed17db365a83c01b8752\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2c8\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"transactions\":[{\"type\":\"0x0\",\"nonce\":\"0x1\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"gas\":\"0x5208\",\"value\":\"0x1\",\"input\":\"0x\",\"gasPrice\":\"0x1\",\"v\":\"0x25\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"hash\":\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"transactionIndex\":\"0x0\",\"blockHash\":\"0x920131365494a9700b85720630ebbb653a5f0c9ef5c33da358135a8d8ebbdfa7\",\"blockNumber\":\"0x3\"},{\"type\":\"0x0\",\"nonce\":\"0x2\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"gas\":\"0x5208\",\"value\":\"0x1\",\"input\":\"0x\",\"gasPrice\":\"0x1\",\"v\":\"0x25\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"hash\":\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\",\"transactionIndex\":\"0x1\",\"blockHash\":\"0x920131365494a9700b85720630ebbb653a5f0c9ef5c33da358135a8d8ebbdfa7\",\"blockNumber\":\"0x3\"}],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] public async Task Eth_get_block_by_hash_with_tx(string blockParameter, bool withTxData, string expectedResult) { using Context ctx = await Context.Create(); @@ -653,11 +653,11 @@ public async Task Eth_get_block_by_hash_with_tx(string blockParameter, bool with } [TestCase(false, "earliest", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x0000000000000000000000000000000000000000\",\"difficulty\":\"0xf4240\",\"extraData\":\"0x010203\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0x0\",\"hash\":\"0x2167088a0f0de66028d2b728235af6d467108c1750c3e11a8f6e6cd60fddb0e4\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x0000000000000000000000000000000000000000\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x00000000000003e8\",\"number\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x201\",\"stateRoot\":\"0x1ef7300d8961797263939a3d29bbba4ccf1702fabf02d8ad7a20b454edb6fd2f\",\"totalDifficulty\":\"0xf4240\",\"timestamp\":\"0xf4240\",\"transactions\":[],\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"uncles\":[]},\"id\":67}")] - [TestCase(false, "latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0xdb2fc4f70fc54c923b94ee0767901815685a5ff608e112c19e754316a9b8c97a\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2c8\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"transactions\":[{\"hash\":\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"nonce\":\"0x1\",\"blockHash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"blockNumber\":\"0x3\",\"transactionIndex\":\"0x0\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"value\":\"0x1\",\"gasPrice\":\"0x1\",\"gas\":\"0x5208\",\"input\":\"0x\",\"type\":\"0x0\",\"v\":\"0x25\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\"},{\"hash\":\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\",\"nonce\":\"0x2\",\"blockHash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"blockNumber\":\"0x3\",\"transactionIndex\":\"0x1\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"value\":\"0x1\",\"gasPrice\":\"0x1\",\"gas\":\"0x5208\",\"input\":\"0x\",\"type\":\"0x0\",\"v\":\"0x25\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\"}],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] - [TestCase(false, "pending", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0xdb2fc4f70fc54c923b94ee0767901815685a5ff608e112c19e754316a9b8c97a\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2c8\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"transactions\":[{\"hash\":\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"nonce\":\"0x1\",\"blockHash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"blockNumber\":\"0x3\",\"transactionIndex\":\"0x0\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"value\":\"0x1\",\"gasPrice\":\"0x1\",\"gas\":\"0x5208\",\"input\":\"0x\",\"type\":\"0x0\",\"v\":\"0x25\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\"},{\"hash\":\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\",\"nonce\":\"0x2\",\"blockHash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"blockNumber\":\"0x3\",\"transactionIndex\":\"0x1\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"value\":\"0x1\",\"gasPrice\":\"0x1\",\"gas\":\"0x5208\",\"input\":\"0x\",\"type\":\"0x0\",\"v\":\"0x25\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\"}],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] + [TestCase(false, "latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x920131365494a9700b85720630ebbb653a5f0c9ef5c33da358135a8d8ebbdfa7\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0x656d36043de0c20ac0499ed845a653c3b9ba6ea8c311ed17db365a83c01b8752\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2c8\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"transactions\":[{\"type\":\"0x0\",\"nonce\":\"0x1\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"gas\":\"0x5208\",\"value\":\"0x1\",\"input\":\"0x\",\"gasPrice\":\"0x1\",\"v\":\"0x25\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"hash\":\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"transactionIndex\":\"0x0\",\"blockHash\":\"0x920131365494a9700b85720630ebbb653a5f0c9ef5c33da358135a8d8ebbdfa7\",\"blockNumber\":\"0x3\"},{\"type\":\"0x0\",\"nonce\":\"0x2\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"gas\":\"0x5208\",\"value\":\"0x1\",\"input\":\"0x\",\"gasPrice\":\"0x1\",\"v\":\"0x25\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"hash\":\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\",\"transactionIndex\":\"0x1\",\"blockHash\":\"0x920131365494a9700b85720630ebbb653a5f0c9ef5c33da358135a8d8ebbdfa7\",\"blockNumber\":\"0x3\"}],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] + [TestCase(false, "pending", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x920131365494a9700b85720630ebbb653a5f0c9ef5c33da358135a8d8ebbdfa7\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0x656d36043de0c20ac0499ed845a653c3b9ba6ea8c311ed17db365a83c01b8752\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2c8\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"transactions\":[{\"type\":\"0x0\",\"nonce\":\"0x1\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"gas\":\"0x5208\",\"value\":\"0x1\",\"input\":\"0x\",\"gasPrice\":\"0x1\",\"v\":\"0x25\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"hash\":\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"transactionIndex\":\"0x0\",\"blockHash\":\"0x920131365494a9700b85720630ebbb653a5f0c9ef5c33da358135a8d8ebbdfa7\",\"blockNumber\":\"0x3\"},{\"type\":\"0x0\",\"nonce\":\"0x2\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"gas\":\"0x5208\",\"value\":\"0x1\",\"input\":\"0x\",\"gasPrice\":\"0x1\",\"v\":\"0x25\",\"r\":\"0xe7c5ff3cba254c4fe8f9f12c3f202150bb9a0aebeee349ff2f4acb23585f56bd\",\"s\":\"0x575361bb330bf38b9a89dd8279d42a20d34edeaeede9739a7c2bdcbe3242d7bb\",\"hash\":\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\",\"transactionIndex\":\"0x1\",\"blockHash\":\"0x920131365494a9700b85720630ebbb653a5f0c9ef5c33da358135a8d8ebbdfa7\",\"blockNumber\":\"0x3\"}],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] [TestCase(false, "0x0", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x0000000000000000000000000000000000000000\",\"difficulty\":\"0xf4240\",\"extraData\":\"0x010203\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0x0\",\"hash\":\"0x2167088a0f0de66028d2b728235af6d467108c1750c3e11a8f6e6cd60fddb0e4\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x0000000000000000000000000000000000000000\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x00000000000003e8\",\"number\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x201\",\"stateRoot\":\"0x1ef7300d8961797263939a3d29bbba4ccf1702fabf02d8ad7a20b454edb6fd2f\",\"totalDifficulty\":\"0xf4240\",\"timestamp\":\"0xf4240\",\"transactions\":[],\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"uncles\":[]},\"id\":67}")] [TestCase(true, "earliest", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x0000000000000000000000000000000000000000\",\"difficulty\":\"0xf4240\",\"extraData\":\"0x010203\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0x0\",\"hash\":\"0x2167088a0f0de66028d2b728235af6d467108c1750c3e11a8f6e6cd60fddb0e4\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x0000000000000000000000000000000000000000\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x00000000000003e8\",\"number\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x201\",\"stateRoot\":\"0x1ef7300d8961797263939a3d29bbba4ccf1702fabf02d8ad7a20b454edb6fd2f\",\"totalDifficulty\":\"0xf4240\",\"timestamp\":\"0xf4240\",\"baseFeePerGas\":\"0x0\",\"transactions\":[],\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"uncles\":[]},\"id\":67}")] - [TestCase(true, "latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x7a1200\",\"gasUsed\":\"0x0\",\"hash\":\"0x042fb755f4e325060234433ab0339847ea70615911336b641530bbcf69d86e03\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0x5dbe3f5334cdbbe1b356007965b4ac8b6b1c59efc340e651c18b8539adbec5b7\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x208\",\"stateRoot\":\"0x1ef7300d8961797263939a3d29bbba4ccf1702fabf02d8ad7a20b454edb6fd2f\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"baseFeePerGas\":\"0x2da282a8\",\"transactions\":[],\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"uncles\":[]},\"id\":67}")] + [TestCase(true, "latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x7a1200\",\"gasUsed\":\"0x0\",\"hash\":\"0xbbd6784dfbd0d60b47ccb37d2d5919e551a4d2b7286f00c14ef7e21b0caf02ad\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0xb0ba03efc4c72fcd2d1d86ce0a7a9bca8224f6681d64923b6eb97ab1ef31c12b\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x208\",\"stateRoot\":\"0x1ef7300d8961797263939a3d29bbba4ccf1702fabf02d8ad7a20b454edb6fd2f\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"baseFeePerGas\":\"0x2da282a8\",\"transactions\":[],\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"uncles\":[]},\"id\":67}")] [TestCase(true, "0x0", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x0000000000000000000000000000000000000000\",\"difficulty\":\"0xf4240\",\"extraData\":\"0x010203\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0x0\",\"hash\":\"0x2167088a0f0de66028d2b728235af6d467108c1750c3e11a8f6e6cd60fddb0e4\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x0000000000000000000000000000000000000000\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x00000000000003e8\",\"number\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x201\",\"stateRoot\":\"0x1ef7300d8961797263939a3d29bbba4ccf1702fabf02d8ad7a20b454edb6fd2f\",\"totalDifficulty\":\"0xf4240\",\"timestamp\":\"0xf4240\",\"baseFeePerGas\":\"0x0\",\"transactions\":[],\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"uncles\":[]},\"id\":67}")] [TestCase(false, "0x20", "{\"jsonrpc\":\"2.0\",\"result\":null,\"id\":67}")] public async Task Eth_get_block_by_number(bool eip1559, string blockParameter, string expectedResult) @@ -668,8 +668,8 @@ public async Task Eth_get_block_by_number(bool eip1559, string blockParameter, s } [TestCase("earliest", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x0000000000000000000000000000000000000000\",\"difficulty\":\"0xf4240\",\"extraData\":\"0x010203\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0x0\",\"hash\":\"0x2167088a0f0de66028d2b728235af6d467108c1750c3e11a8f6e6cd60fddb0e4\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x0000000000000000000000000000000000000000\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x00000000000003e8\",\"number\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x201\",\"stateRoot\":\"0x1ef7300d8961797263939a3d29bbba4ccf1702fabf02d8ad7a20b454edb6fd2f\",\"totalDifficulty\":\"0xf4240\",\"timestamp\":\"0xf4240\",\"transactions\":[],\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"uncles\":[]},\"id\":67}")] - [TestCase("latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0xdb2fc4f70fc54c923b94ee0767901815685a5ff608e112c19e754316a9b8c97a\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2c8\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"transactions\":[\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\"],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] - [TestCase("pending", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x5942e88dfea91035be2163de8c9d529cff231225f34c8a81d16d8544444cdf47\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0xdb2fc4f70fc54c923b94ee0767901815685a5ff608e112c19e754316a9b8c97a\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2c8\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"transactions\":[\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\"],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] + [TestCase("latest", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x920131365494a9700b85720630ebbb653a5f0c9ef5c33da358135a8d8ebbdfa7\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0x656d36043de0c20ac0499ed845a653c3b9ba6ea8c311ed17db365a83c01b8752\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2c8\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"transactions\":[\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\"],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] + [TestCase("pending", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"difficulty\":\"0x1\",\"extraData\":\"0x4e65746865726d696e64\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0xa410\",\"hash\":\"0x920131365494a9700b85720630ebbb653a5f0c9ef5c33da358135a8d8ebbdfa7\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"number\":\"0x3\",\"parentHash\":\"0x656d36043de0c20ac0499ed845a653c3b9ba6ea8c311ed17db365a83c01b8752\",\"receiptsRoot\":\"0xd95b673818fa493deec414e01e610d97ee287c9421c8eff4102b1647c1a184e4\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x2c8\",\"stateRoot\":\"0x4e786afc8bed76b7299973ca70022b367cbb94c14ec30e9e7273b31b6b968de9\",\"totalDifficulty\":\"0xf4243\",\"timestamp\":\"0x0\",\"transactions\":[\"0x681c2b6f99e37fd6fe6046db8b51ec3460d699cacd6a376143fd5842ac50621f\",\"0x7126cf20a0ad8bd51634837d9049615c34c1bff5e1a54e5663f7e23109bff48b\"],\"transactionsRoot\":\"0x2e6e6deb19d24bd48eda6071ab38b1bae64c15ef1998c96f0d153711d3a3efc7\",\"uncles\":[]},\"id\":67}")] [TestCase("0x0", "{\"jsonrpc\":\"2.0\",\"result\":{\"author\":\"0x0000000000000000000000000000000000000000\",\"difficulty\":\"0xf4240\",\"extraData\":\"0x010203\",\"gasLimit\":\"0x3d0900\",\"gasUsed\":\"0x0\",\"hash\":\"0x2167088a0f0de66028d2b728235af6d467108c1750c3e11a8f6e6cd60fddb0e4\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x0000000000000000000000000000000000000000\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x00000000000003e8\",\"number\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x201\",\"stateRoot\":\"0x1ef7300d8961797263939a3d29bbba4ccf1702fabf02d8ad7a20b454edb6fd2f\",\"totalDifficulty\":\"0xf4240\",\"timestamp\":\"0xf4240\",\"transactions\":[],\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"uncles\":[]},\"id\":67}")] [TestCase("0x20", "{\"jsonrpc\":\"2.0\",\"result\":null,\"id\":67}")] public async Task Eth_get_block_by_number_no_details(string blockParameter, string expectedResult) diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/TraceRpcModuleTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/TraceRpcModuleTests.cs index 97e475d74a9..7cec5901007 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/TraceRpcModuleTests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/TraceRpcModuleTests.cs @@ -93,7 +93,7 @@ public async Task Tx_positions_are_fine() string serialized = await RpcTest.TestSerializedRequest( context.TraceRpcModule, "trace_block", "latest"); - Assert.That(serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":[{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xa1e0e640b433d5a8931881b8eee7b1a125474b04e430c0bf8afff52584c53273\",\"transactionPosition\":0,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x5cf5d4a0a93000beb1cfb373508ce4c0153ab491be99b3c927f482346c86a0e1\",\"transactionPosition\":1,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x02d2cde9120e37722f607771ebaa0d4e98c5d99a8a9e7df6872e8c8c9f5c0bc5\",\"transactionPosition\":2,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xe50a2a2d170011b1f9ee080c3810bed0c63dbb1b2b2c541c78ada5b222cc3fd2\",\"transactionPosition\":3,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xff0d4524d379fc15c41a9b0444b943e1a530779b7d09c8863858267c5ef92b24\",\"transactionPosition\":4,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xf9b69366c82084e3799dc4a7ad87dc173ef4923d853bc250de86b81786f2972a\",\"transactionPosition\":5,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x28171c29b23cd96f032fe43f444402af4555ee5f074d5d0d0a1089d940f136e7\",\"transactionPosition\":6,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x09b01caf4b7ecfe9d02251b2e478f2da0fdf08412e3fa1ff963fa80635dab031\",\"transactionPosition\":7,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xd82382905afbe4ca4c2b8e54cea43818c91e0014c3827e3020fbd82b732b8239\",\"transactionPosition\":8,\"type\":\"call\"},{\"action\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"rewardType\":\"block\",\"value\":\"0x1bc16d674ec80000\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"subtraces\":0,\"traceAddress\":[],\"type\":\"reward\"}],\"id\":67}")); + Assert.That(serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":[{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xa1e0e640b433d5a8931881b8eee7b1a125474b04e430c0bf8afff52584c53273\",\"transactionPosition\":0,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x5cf5d4a0a93000beb1cfb373508ce4c0153ab491be99b3c927f482346c86a0e1\",\"transactionPosition\":1,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x02d2cde9120e37722f607771ebaa0d4e98c5d99a8a9e7df6872e8c8c9f5c0bc5\",\"transactionPosition\":2,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xe50a2a2d170011b1f9ee080c3810bed0c63dbb1b2b2c541c78ada5b222cc3fd2\",\"transactionPosition\":3,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xff0d4524d379fc15c41a9b0444b943e1a530779b7d09c8863858267c5ef92b24\",\"transactionPosition\":4,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xf9b69366c82084e3799dc4a7ad87dc173ef4923d853bc250de86b81786f2972a\",\"transactionPosition\":5,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x28171c29b23cd96f032fe43f444402af4555ee5f074d5d0d0a1089d940f136e7\",\"transactionPosition\":6,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x09b01caf4b7ecfe9d02251b2e478f2da0fdf08412e3fa1ff963fa80635dab031\",\"transactionPosition\":7,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xd82382905afbe4ca4c2b8e54cea43818c91e0014c3827e3020fbd82b732b8239\",\"transactionPosition\":8,\"type\":\"call\"},{\"action\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"rewardType\":\"block\",\"value\":\"0x1bc16d674ec80000\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"subtraces\":0,\"traceAddress\":[],\"type\":\"reward\"}],\"id\":67}")); } [Test] @@ -145,7 +145,7 @@ public async Task Trace_filter_return_expected_json() context.TraceRpcModule, "trace_filter", new EthereumJsonSerializer().Serialize(traceFilterRequest)); - Assert.That(serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":[{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xa1e0e640b433d5a8931881b8eee7b1a125474b04e430c0bf8afff52584c53273\",\"transactionPosition\":0,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x5cf5d4a0a93000beb1cfb373508ce4c0153ab491be99b3c927f482346c86a0e1\",\"transactionPosition\":1,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x02d2cde9120e37722f607771ebaa0d4e98c5d99a8a9e7df6872e8c8c9f5c0bc5\",\"transactionPosition\":2,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xe50a2a2d170011b1f9ee080c3810bed0c63dbb1b2b2c541c78ada5b222cc3fd2\",\"transactionPosition\":3,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xff0d4524d379fc15c41a9b0444b943e1a530779b7d09c8863858267c5ef92b24\",\"transactionPosition\":4,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xf9b69366c82084e3799dc4a7ad87dc173ef4923d853bc250de86b81786f2972a\",\"transactionPosition\":5,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x28171c29b23cd96f032fe43f444402af4555ee5f074d5d0d0a1089d940f136e7\",\"transactionPosition\":6,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x09b01caf4b7ecfe9d02251b2e478f2da0fdf08412e3fa1ff963fa80635dab031\",\"transactionPosition\":7,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xd82382905afbe4ca4c2b8e54cea43818c91e0014c3827e3020fbd82b732b8239\",\"transactionPosition\":8,\"type\":\"call\"},{\"action\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"rewardType\":\"block\",\"value\":\"0x1bc16d674ec80000\"},\"blockHash\":\"0x215c968290c6370b77da28acf430f8f475121ff9fe9938a64cec408e05619918\",\"blockNumber\":15,\"subtraces\":0,\"traceAddress\":[],\"type\":\"reward\"}],\"id\":67}"), serialized.Replace("\"", "\\\"")); + Assert.That(serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":[{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xa1e0e640b433d5a8931881b8eee7b1a125474b04e430c0bf8afff52584c53273\",\"transactionPosition\":0,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x5cf5d4a0a93000beb1cfb373508ce4c0153ab491be99b3c927f482346c86a0e1\",\"transactionPosition\":1,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x02d2cde9120e37722f607771ebaa0d4e98c5d99a8a9e7df6872e8c8c9f5c0bc5\",\"transactionPosition\":2,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xe50a2a2d170011b1f9ee080c3810bed0c63dbb1b2b2c541c78ada5b222cc3fd2\",\"transactionPosition\":3,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xff0d4524d379fc15c41a9b0444b943e1a530779b7d09c8863858267c5ef92b24\",\"transactionPosition\":4,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xf9b69366c82084e3799dc4a7ad87dc173ef4923d853bc250de86b81786f2972a\",\"transactionPosition\":5,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x28171c29b23cd96f032fe43f444402af4555ee5f074d5d0d0a1089d940f136e7\",\"transactionPosition\":6,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0x09b01caf4b7ecfe9d02251b2e478f2da0fdf08412e3fa1ff963fa80635dab031\",\"transactionPosition\":7,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x0\",\"input\":\"0x\",\"to\":\"0x0000000000000000000000000000000000000000\",\"value\":\"0x1\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[],\"transactionHash\":\"0xd82382905afbe4ca4c2b8e54cea43818c91e0014c3827e3020fbd82b732b8239\",\"transactionPosition\":8,\"type\":\"call\"},{\"action\":{\"author\":\"0x475674cb523a0a2736b7f7534390288fce16982c\",\"rewardType\":\"block\",\"value\":\"0x1bc16d674ec80000\"},\"blockHash\":\"0xc2bb4e9114f6ce15bc48100b595ce149eca0123a922cadb03421d35056f5a095\",\"blockNumber\":15,\"subtraces\":0,\"traceAddress\":[],\"type\":\"reward\"}],\"id\":67}")); } [Test] @@ -527,7 +527,7 @@ public async Task Trace_transaction_with_error_reverted() traces.Data.ElementAt(0).TransactionHash.Should().Be(transaction2.Hash!); string serialized = new EthereumJsonSerializer().Serialize(traces.Data); - Assert.That(serialized, Is.EqualTo("[{\"action\":{\"creationMethod\":\"create\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x9a6c\",\"init\":\"0x60006000600060006000736b5887043de753ecfa6269f947129068263ffbe261c350f160006000600060006000736b5887043de753ecfa6269f947129068263ffbe261c350f1fd\",\"value\":\"0x1\"},\"blockHash\":\"0x69f380ee1f366db2573819bf624f34c1c669f907f348ff4d405c749c56570882\",\"blockNumber\":18,\"subtraces\":2,\"traceAddress\":[],\"transactionHash\":\"0x787616b8756424622f162fc3817331517ef941366f28db452defc0214bc36b22\",\"transactionPosition\":0,\"type\":\"create\",\"error\":\"Reverted\"},{\"action\":{\"callType\":\"call\",\"from\":\"0xd6a48bcd4c5ad5adacfab677519c25ce7b2805a5\",\"gas\":\"0x8def\",\"input\":\"0x\",\"to\":\"0x6b5887043de753ecfa6269f947129068263ffbe2\",\"value\":\"0x0\"},\"blockHash\":\"0x69f380ee1f366db2573819bf624f34c1c669f907f348ff4d405c749c56570882\",\"blockNumber\":18,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[0],\"transactionHash\":\"0x787616b8756424622f162fc3817331517ef941366f28db452defc0214bc36b22\",\"transactionPosition\":0,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0xd6a48bcd4c5ad5adacfab677519c25ce7b2805a5\",\"gas\":\"0x8d78\",\"input\":\"0x\",\"to\":\"0x6b5887043de753ecfa6269f947129068263ffbe2\",\"value\":\"0x0\"},\"blockHash\":\"0x69f380ee1f366db2573819bf624f34c1c669f907f348ff4d405c749c56570882\",\"blockNumber\":18,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[1],\"transactionHash\":\"0x787616b8756424622f162fc3817331517ef941366f28db452defc0214bc36b22\",\"transactionPosition\":0,\"type\":\"call\"}]"), serialized.Replace("\"", "\\\"")); + Assert.That(serialized, Is.EqualTo("[{\"action\":{\"creationMethod\":\"create\",\"from\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"gas\":\"0x9a6c\",\"init\":\"0x60006000600060006000736b5887043de753ecfa6269f947129068263ffbe261c350f160006000600060006000736b5887043de753ecfa6269f947129068263ffbe261c350f1fd\",\"value\":\"0x1\"},\"blockHash\":\"0xccf549813563b9acfa0a258aa7d4cb8d05b07df26fe0fb81753696ecc0a4219c\",\"blockNumber\":18,\"subtraces\":2,\"traceAddress\":[],\"transactionHash\":\"0x787616b8756424622f162fc3817331517ef941366f28db452defc0214bc36b22\",\"transactionPosition\":0,\"type\":\"create\",\"error\":\"Reverted\"},{\"action\":{\"callType\":\"call\",\"from\":\"0xd6a48bcd4c5ad5adacfab677519c25ce7b2805a5\",\"gas\":\"0x8def\",\"input\":\"0x\",\"to\":\"0x6b5887043de753ecfa6269f947129068263ffbe2\",\"value\":\"0x0\"},\"blockHash\":\"0xccf549813563b9acfa0a258aa7d4cb8d05b07df26fe0fb81753696ecc0a4219c\",\"blockNumber\":18,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[0],\"transactionHash\":\"0x787616b8756424622f162fc3817331517ef941366f28db452defc0214bc36b22\",\"transactionPosition\":0,\"type\":\"call\"},{\"action\":{\"callType\":\"call\",\"from\":\"0xd6a48bcd4c5ad5adacfab677519c25ce7b2805a5\",\"gas\":\"0x8d78\",\"input\":\"0x\",\"to\":\"0x6b5887043de753ecfa6269f947129068263ffbe2\",\"value\":\"0x0\"},\"blockHash\":\"0xccf549813563b9acfa0a258aa7d4cb8d05b07df26fe0fb81753696ecc0a4219c\",\"blockNumber\":18,\"result\":{\"gasUsed\":\"0x0\",\"output\":\"0x\"},\"subtraces\":0,\"traceAddress\":[1],\"transactionHash\":\"0x787616b8756424622f162fc3817331517ef941366f28db452defc0214bc36b22\",\"transactionPosition\":0,\"type\":\"call\"}]")); } [Test] public async Task trace_timeout_is_separate_for_rpc_calls() From 64752657401eef682c4e9f56bfad09f4ab54e1e9 Mon Sep 17 00:00:00 2001 From: yerke26 <160018032+yerke26@users.noreply.github.com> Date: Wed, 11 Dec 2024 15:23:37 +0500 Subject: [PATCH 66/68] Update src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs Co-authored-by: Lukasz Rozmej --- .../Modules/Eth/FeeHistory/FeeHistoryOracle.cs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs index 10e7c4bab44..6712f0cf84a 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs @@ -110,19 +110,10 @@ BlockFeeHistorySearchInfo BlockFeeHistorySearchInfoFromBlock(Block b) { BlobGasCalculator.TryCalculateFeePerBlobGas(b.Header, out UInt256 feePerBlobGas); - double maxBlobGasPerBlock; - if (!_specProvider.GetSpec(b.Header).IsEip7742Enabled) - { - maxBlobGasPerBlock = Eip4844Constants.GetMaxBlobsPerBlock(); - } - else if (b.Header.TargetBlobCount.HasValue) - { - maxBlobGasPerBlock = b.Header.TargetBlobCount.Value * 2; - } - else - { - throw new InvalidBlockException(b, "header is missing TargetBlobCount"); - } + IReleaseSpec spec = _specProvider.GetSpec(b.Header); + double maxBlobGasPerBlock = !spec.IsEip7742Enabled + ? Eip4844Constants.GetMaxBlobsPerBlock() + : b.Header.TargetBlobCount * 2 ?? throw new InvalidBlockException(b, "header is missing TargetBlobCount"); return new( b.Number, From dfe634e0ca5e596d19034d5a798de1c0f175c4af Mon Sep 17 00:00:00 2001 From: yerke26 Date: Wed, 11 Dec 2024 15:26:35 +0500 Subject: [PATCH 67/68] fix whitespaces --- .../Modules/Eth/FeeHistory/FeeHistoryOracle.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs index 6712f0cf84a..a4627432833 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/FeeHistory/FeeHistoryOracle.cs @@ -111,7 +111,7 @@ BlockFeeHistorySearchInfo BlockFeeHistorySearchInfoFromBlock(Block b) BlobGasCalculator.TryCalculateFeePerBlobGas(b.Header, out UInt256 feePerBlobGas); IReleaseSpec spec = _specProvider.GetSpec(b.Header); - double maxBlobGasPerBlock = !spec.IsEip7742Enabled + double maxBlobGasPerBlock = !spec.IsEip7742Enabled ? Eip4844Constants.GetMaxBlobsPerBlock() : b.Header.TargetBlobCount * 2 ?? throw new InvalidBlockException(b, "header is missing TargetBlobCount"); From 5c6dc2c75baa3d0f2029840f335c1942af17bdd1 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Thu, 19 Dec 2024 15:54:23 +0800 Subject: [PATCH 68/68] resolve merge conflicts --- .../AuRaMergeEngineModuleTests.cs | 6 +++--- .../Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs b/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs index 7aed634bac3..e32899a8db0 100644 --- a/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs +++ b/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs @@ -64,10 +64,10 @@ int ErrorCode => base.forkchoiceUpdatedV2_should_validate_withdrawals(input); [TestCase( - "0x8c991b526ff658e90a4a4d4c1e83dd55aee17c5467e71599690967c83c0b9c2f", - "0x445476686cccd0ee909b5e514b15389b7b6ddb01ab8048c30f4f9f130286f3fb", + "0x64fc59f08c4ecc90455e13ca16a78517cd4cc73d06405b03c2c6e50e2cc84c48", + "0xc928b3a56463263ee0f30ff57210bf3101cbf3c1d48a50145d8d3857c8e2df5e", "0xd75d320c3a98a02ec7fe2abdcb1769bd063fec04d73f1735810f365ac12bc4ba", - "0x99ac9270a267569a")] + "0x9fe739bad82688be")] public override Task Should_process_block_as_expected_V4(string latestValidHash, string blockHash, string stateRoot, string payloadId) => base.Should_process_block_as_expected_V4(latestValidHash, blockHash, stateRoot, payloadId); diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs index 4674d9dc426..5d086e47784 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs @@ -24,10 +24,10 @@ namespace Nethermind.Merge.Plugin.Test; public partial class EngineModuleTests { [TestCase( - "0xffcfa58bd573f32084c9e33f52be0c07f26f2b416aeb3a564f75a5b3b2702d6c", - "0xc07d3d9dc7ba2d475938961a90e4317b8109942241edc1201c2a44085c274b38", + "0xb79ac644bd8fdacc11c408e2a143cd802baab81f13086fce79c471b38a8e0cd3", + "0xa92cb7c874e510507d218c888a84b95a889fda2ef904803dcf42629ad3a27326", "0xa272b2f949e4a0e411c9b45542bd5d0ef3c311b5f26c4ed6b7a8d4f605a91154", - "0x039cc417630de68a")] + "0xe7e7f64c04b395a6")] public virtual async Task Should_process_block_as_expected_V4(string latestValidHash, string blockHash, string stateRoot, string payloadId) {