diff --git a/src/Nethermind/Nethermind.Consensus.Test/ExecutionRequestProcessorTests.cs b/src/Nethermind/Nethermind.Consensus.Test/ExecutionRequestProcessorTests.cs index 4b29c44121d..e7731326ea9 100644 --- a/src/Nethermind/Nethermind.Consensus.Test/ExecutionRequestProcessorTests.cs +++ b/src/Nethermind/Nethermind.Consensus.Test/ExecutionRequestProcessorTests.cs @@ -123,6 +123,6 @@ .. executionConsolidationRequests Assert.That(processedRequest.RequestData, Is.EqualTo(expectedRequest.RequestData)); } - Assert.That(block.Header.RequestsHash, Is.EqualTo(block.ExecutionRequests.CalculateHash())); + Assert.That(block.Header.RequestsHash, Is.EqualTo(block.ExecutionRequests.ToArray().CalculateHash())); } } diff --git a/src/Nethermind/Nethermind.Consensus/ExecutionRequests/ExecutionRequestProcessor.cs b/src/Nethermind/Nethermind.Consensus/ExecutionRequests/ExecutionRequestProcessor.cs index c933ba71b83..9827bc6b4c0 100644 --- a/src/Nethermind/Nethermind.Consensus/ExecutionRequests/ExecutionRequestProcessor.cs +++ b/src/Nethermind/Nethermind.Consensus/ExecutionRequests/ExecutionRequestProcessor.cs @@ -129,9 +129,9 @@ private IEnumerable ReadRequests(Block block, IWorldState stat } - public Hash256 CalculateRequestsHash(Block block, IWorldState state, TxReceipt[] receipts, IReleaseSpec spec, out ExecutionRequest[] requests) + public Hash256 CalculateRequestsHash(Block block, IWorldState state, TxReceipt[] receipts, IReleaseSpec spec, out ArrayPoolList requests) { - List requestsList = new(); + ArrayPoolList requestsList = new ArrayPoolList(0); using (SHA256 sha256 = SHA256.Create()) { using (SHA256 sha256Inner = SHA256.Create()) @@ -162,7 +162,7 @@ public Hash256 CalculateRequestsHash(Block block, IWorldState state, TxReceipt[] // Complete the final hash computation sha256.TransformFinalBlock(new byte[0], 0, 0); - requests = requestsList.ToArray(); + requests = requestsList; return new Hash256(sha256.Hash!); } } @@ -172,7 +172,7 @@ public void ProcessExecutionRequests(Block block, IWorldState state, TxReceipt[] { if (!spec.RequestsEnabled) return; - block.Header.RequestsHash = CalculateRequestsHash(block, state, receipts, spec, out ExecutionRequest[] requests); + block.Header.RequestsHash = CalculateRequestsHash(block, state, receipts, spec, out ArrayPoolList requests); block.ExecutionRequests = requests; } } diff --git a/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs b/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs index e8b68230935..ee80f1bb81a 100644 --- a/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs +++ b/src/Nethermind/Nethermind.Core.Test/Builders/BlockBuilder.cs @@ -3,6 +3,7 @@ using System; using System.Linq; +using Nethermind.Core.Collections; using Nethermind.Core.Crypto; using Nethermind.Core.ExecutionRequest; using Nethermind.Core.Specs; @@ -251,7 +252,7 @@ public BlockBuilder WithReceiptsRoot(Hash256 keccak) public BlockBuilder WithEmptyRequestsHash() { TestObjectInternal.Header.RequestsHash = Array.Empty().CalculateHash(); - TestObjectInternal.ExecutionRequests = Array.Empty(); + TestObjectInternal.ExecutionRequests = new ArrayPoolList(0); return this; } diff --git a/src/Nethermind/Nethermind.Core/Block.cs b/src/Nethermind/Nethermind.Core/Block.cs index 57ebf3b5726..935a1b0b900 100644 --- a/src/Nethermind/Nethermind.Core/Block.cs +++ b/src/Nethermind/Nethermind.Core/Block.cs @@ -118,7 +118,7 @@ public Transaction[] Transactions public Hash256? RequestsHash => Header.RequestsHash; // do not add setter here [JsonIgnore] - public ExecutionRequest.ExecutionRequest[]? ExecutionRequests { get; set; } + public ArrayPoolList? ExecutionRequests { get; set; } [JsonIgnore] public ArrayPoolList? AccountChanges { get; set; } diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs index dfaf9444a88..9d37c53446c 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V4.cs @@ -228,7 +228,7 @@ public async Task can_progress_chain_one_by_one_v4_with_requests(int count) last!.IsGenesis.Should().BeTrue(); Block? head = chain.BlockTree.Head; - head!.ExecutionRequests!.Length.Should().Be(ExecutionRequestsProcessorMock.Requests.Length); + head!.ExecutionRequests!.ToArray().Length.Should().Be(ExecutionRequestsProcessorMock.Requests.Length); } private async Task> ProduceBranchV4(IEngineRpcModule rpc, diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/ExecutionRequestsProcessorMock.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/ExecutionRequestsProcessorMock.cs index efb14cac6cf..4217bec0535 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/ExecutionRequestsProcessorMock.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/ExecutionRequestsProcessorMock.cs @@ -3,6 +3,7 @@ using Nethermind.Consensus.ExecutionRequests; using Nethermind.Core; +using Nethermind.Core.Collections; using Nethermind.Core.ExecutionRequest; using Nethermind.Core.Specs; using Nethermind.Core.Test.Builders; @@ -30,7 +31,11 @@ public void ProcessExecutionRequests(Block block, IWorldState state, TxReceipt[] if (block.IsGenesis) return; - block.ExecutionRequests = Requests; + block.ExecutionRequests = new ArrayPoolList(Requests.Length); + foreach (var request in Requests) + { + block.ExecutionRequests.Add(request); + } block.Header.RequestsHash = Requests.CalculateHash(); } } diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Handlers/GetPayloadV4Handler.cs b/src/Nethermind/Nethermind.Merge.Plugin/Handlers/GetPayloadV4Handler.cs index 45f51c5df35..5969ce68965 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Handlers/GetPayloadV4Handler.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Handlers/GetPayloadV4Handler.cs @@ -23,7 +23,7 @@ public class GetPayloadV4Handler( { protected override GetPayloadV4Result GetPayloadResultFromBlock(IBlockProductionContext context) { - return new(context.CurrentBestBlock!, context.BlockFees, new BlobsBundleV1(context.CurrentBestBlock!), context.CurrentBestBlock!.ExecutionRequests!) + return new(context.CurrentBestBlock!, context.BlockFees, new BlobsBundleV1(context.CurrentBestBlock!), context.CurrentBestBlock!.ExecutionRequests!.ToArray()) { ShouldOverrideBuilder = censorshipDetector?.GetCensoredBlocks().Contains(new BlockNumberHash(context.CurrentBestBlock!)) ?? false };