diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs index e636cca9525..75f1da2fdd8 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs @@ -5,12 +5,10 @@ using System.Collections.Generic; using System.IO.Abstractions; using System.Linq; -using System.Text.Json; using System.Text.Json.Nodes; using System.Threading; using System.Threading.Tasks; using FluentAssertions; -using k8s.Models; using Nethermind.Consensus.Producers; using Nethermind.Core; using Nethermind.Core.Crypto; @@ -28,7 +26,6 @@ using Nethermind.Merge.Plugin.Handlers; using Nethermind.Serialization.Json; using Nethermind.Serialization.Rlp; -using Nethermind.Specs; using Nethermind.Specs.Forks; using NSubstitute; using NUnit.Framework; @@ -190,7 +187,6 @@ public async Task NewPayloadV3_should_decline_null_blobversionedhashes() = await PreparePayloadRequestEnv(); string executionPayloadString = serializer.Serialize(executionPayload); - string blobsString = serializer.Serialize(Array.Empty()); JsonRpcRequest request = RpcTest.GetJsonRequest(nameof(IEngineRpcModule.engine_newPayloadV3), executionPayloadString, null!); @@ -199,6 +195,24 @@ public async Task NewPayloadV3_should_decline_null_blobversionedhashes() Assert.That(response!.Error!.Code, Is.EqualTo(ErrorCodes.InvalidParams)); } + [Test] + public async Task NewPayloadV3_invalidblockhash() + { + (JsonRpcService jsonRpcService, JsonRpcContext context, EthereumJsonSerializer _, ExecutionPayloadV3 _) + = await PreparePayloadRequestEnv(); + + string requestStr = """ + {"parentHash":"0xd6194b42ad579c195e9aaaf04692619f4de9c5fbdd6b58baaabe93384e834d25","feeRecipient":"0x0000000000000000000000000000000000000000","stateRoot":"0xfe1fa6bb862e4a5efd9ee8967b356d4f7b6205a437eeac8b0e625db3cb662018","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","prevRandao":"0xfaebfae9aef88ac8eba03decf329c8155991e07cb1a9dc6ac69e420550a45037","blockNumber":"0x1","gasLimit":"0x2fefd8","gasUsed":"0x0","timestamp":"0x1235","extraData":"0x4e65746865726d696e64","baseFeePerGas":"0x342770c0","blockHash":"0x0718890af079939b4aae6ac0ecaa94c633ad73e69e787f526f0d558043e8e2f1","transactions":[],"withdrawals":[{"index":"0x1","validatorIndex":"0x0","address":"0x0000000000000000000000000000000000000000","amount":"0x64"},{"index":"0x2","validatorIndex":"0x1","address":"0x0100000000000000000000000000000000000000","amount":"0x64"},{"index":"0x3","validatorIndex":"0x2","address":"0x0200000000000000000000000000000000000000","amount":"0x64"},{"index":"0x4","validatorIndex":"0x3","address":"0x0300000000000000000000000000000000000000","amount":"0x64"},{"index":"0x5","validatorIndex":"0x4","address":"0x0400000000000000000000000000000000000000","amount":"0x64"},{"index":"0x6","validatorIndex":"0x5","address":"0x0500000000000000000000000000000000000000","amount":"0x64"},{"index":"0x7","validatorIndex":"0x6","address":"0x0600000000000000000000000000000000000000","amount":"0x64"},{"index":"0x8","validatorIndex":"0x7","address":"0x0700000000000000000000000000000000000000","amount":"0x64"},{"index":"0x9","validatorIndex":"0x8","address":"0x0800000000000000000000000000000000000000","amount":"0x64"},{"index":"0xa","validatorIndex":"0x9","address":"0x0900000000000000000000000000000000000000","amount":"0x64"}],"excessBlobGas":"0x0"} + """; + JsonRpcRequest request = RpcTest.GetJsonRequest(nameof(IEngineRpcModule.engine_newPayloadV3), + requestStr, "[]", "0x169630f535b4a41330164c6e5c92b1224c0c407f582d407d0ac3d206cd32fd52"); + + var rpcResponse = await jsonRpcService.SendRequestAsync(request, context); + JsonRpcErrorResponse? response = (rpcResponse) as JsonRpcErrorResponse; + Assert.That(response?.Error, Is.Not.Null); + Assert.That(response!.Error!.Code, Is.EqualTo(ErrorCodes.InvalidParams)); + } + private async Task<(JsonRpcService jsonRpcService, JsonRpcContext context, EthereumJsonSerializer serializer, ExecutionPayloadV3 correctExecutionPayload)> PreparePayloadRequestEnv() { diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs index 20ee36d36f7..cedac0264f8 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs @@ -3,17 +3,14 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Linq; using Nethermind.Core; using Nethermind.Core.Crypto; using Nethermind.Core.Specs; using Nethermind.Int256; using Nethermind.Merge.Plugin.Handlers; -using Nethermind.Serialization.Json; using Nethermind.Serialization.Rlp; using Nethermind.State.Proofs; -using System.Text.Json; using System.Text.Json.Serialization; namespace Nethermind.Merge.Plugin.Data; @@ -100,14 +97,14 @@ public byte[][] Transactions /// EIP-4844. /// [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public ulong? BlobGasUsed { get; set; } + public virtual ulong? BlobGasUsed { get; set; } /// /// Gets or sets as defined in /// EIP-4844. /// [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public ulong? ExcessBlobGas { get; set; } + public virtual ulong? ExcessBlobGas { get; set; } /// /// Gets or sets as defined in diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV3.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV3.cs index dd78f8ea35a..ff236bab63d 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV3.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV3.cs @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited // SPDX-License-Identifier: LGPL-3.0-only +using System.Text.Json.Serialization; using Nethermind.Core; using Nethermind.Core.Specs; using Nethermind.Int256; @@ -36,4 +37,18 @@ public override bool TryGetBlock(out Block? block, UInt256? totalDifficulty = nu public override bool ValidateFork(ISpecProvider specProvider) => specProvider.GetSpec(BlockNumber, Timestamp).IsEip4844Enabled; + + /// + /// Gets or sets as defined in + /// EIP-4844. + /// + [JsonRequired] + public override ulong? BlobGasUsed { get; set; } + + /// + /// Gets or sets as defined in + /// EIP-4844. + /// + [JsonRequired] + public override ulong? ExcessBlobGas { get; set; } }