From 2608f69d0d550d2afb2817e0e86c54cfea76046f Mon Sep 17 00:00:00 2001 From: benaadams Date: Tue, 12 Dec 2023 22:06:12 +0000 Subject: [PATCH 01/10] Hive fixes --- .../EngineModuleTests.V3.cs | 16 ++++++++++++++++ .../Data/NewPayloadV1Result.cs | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs index e636cca9525..d4f2afa781d 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs @@ -199,6 +199,22 @@ 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 serializer, ExecutionPayloadV3 executionPayload) + = await PreparePayloadRequestEnv(); + + string requestStr = """ + {"jsonrpc":"2.0","id":4,"method":"engine_newPayloadV3","params":[{"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"},[],"0x169630f535b4a41330164c6e5c92b1224c0c407f582d407d0ac3d206cd32fd52"]} + """; + JsonRpcRequest request = JsonSerializer.Deserialize(requestStr, EthereumJsonSerializer.JsonOptions)!; + 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/NewPayloadV1Result.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/NewPayloadV1Result.cs index 4d78659888f..ed3315c9abb 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/NewPayloadV1Result.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/NewPayloadV1Result.cs @@ -17,7 +17,7 @@ public static class NewPayloadV1Result public static ResultWrapper Invalid(Hash256? latestValidHash, string? validationError = null) { - return ResultWrapper.Success(new PayloadStatusV1() { Status = PayloadStatus.Invalid, LatestValidHash = latestValidHash, ValidationError = validationError }); + return ResultWrapper.Fail("Invalid Params", ErrorCodes.InvalidParams, new PayloadStatusV1() { Status = PayloadStatus.Invalid, LatestValidHash = latestValidHash, ValidationError = validationError }); } public static ResultWrapper Valid(Hash256? latestValidHash) From f90c5a1cfdf58fe2e1ec51ae50e774f4a6979ec8 Mon Sep 17 00:00:00 2001 From: benaadams Date: Tue, 12 Dec 2023 22:13:56 +0000 Subject: [PATCH 02/10] invalid params --- .../Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs index d4f2afa781d..5a55654e422 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs @@ -155,7 +155,7 @@ public virtual async Task NewPayloadV3_should_decline_mempool_encoding(bool inMe ResultWrapper result = await rpcModule.engine_newPayloadV3(payload, blobVersionedHashes, payload.ParentBeaconBlockRoot); - Assert.That(result.ErrorCode, Is.EqualTo(ErrorCodes.None)); + Assert.That(result.ErrorCode, Is.EqualTo(expectedPayloadStatus == PayloadStatus.Invalid ? ErrorCodes.InvalidParams : ErrorCodes.None)); result.Data.Status.Should().Be(expectedPayloadStatus); } From 1fe1873d34cb290cbb67fa2dbac5fe3c73871429 Mon Sep 17 00:00:00 2001 From: benaadams Date: Tue, 12 Dec 2023 23:04:05 +0000 Subject: [PATCH 03/10] Wrong place --- .../Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs index 5a55654e422..3633d7f8539 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs @@ -155,7 +155,7 @@ public virtual async Task NewPayloadV3_should_decline_mempool_encoding(bool inMe ResultWrapper result = await rpcModule.engine_newPayloadV3(payload, blobVersionedHashes, payload.ParentBeaconBlockRoot); - Assert.That(result.ErrorCode, Is.EqualTo(expectedPayloadStatus == PayloadStatus.Invalid ? ErrorCodes.InvalidParams : ErrorCodes.None)); + Assert.That(result.ErrorCode, Is.EqualTo(ErrorCodes.None)); result.Data.Status.Should().Be(expectedPayloadStatus); } @@ -179,7 +179,7 @@ public virtual async Task NewPayloadV3_should_decline_incorrect_blobgasused(bool byte[]?[] blobVersionedHashes = transactions.SelectMany(tx => tx.BlobVersionedHashes ?? Array.Empty()).ToArray(); ResultWrapper result = await prevRpcModule.engine_newPayloadV3(payload, blobVersionedHashes, payload.ParentBeaconBlockRoot); - Assert.That(result.ErrorCode, Is.EqualTo(ErrorCodes.None)); + Assert.That(result.ErrorCode, Is.EqualTo(expectedPayloadStatus == PayloadStatus.Invalid ? ErrorCodes.InvalidParams : ErrorCodes.None)); result.Data.Status.Should().Be(expectedPayloadStatus); } From 530961159db9d5d16fb67e10db7d4b9452d1a2b9 Mon Sep 17 00:00:00 2001 From: benaadams Date: Wed, 13 Dec 2023 03:34:49 +0000 Subject: [PATCH 04/10] Only return for engine_newPayloadV3 --- src/Nethermind/Nethermind.JsonRpc/JsonRpcService.cs | 5 +++++ .../Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs | 2 +- .../Nethermind.Merge.Plugin/Data/NewPayloadV1Result.cs | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Nethermind/Nethermind.JsonRpc/JsonRpcService.cs b/src/Nethermind/Nethermind.JsonRpc/JsonRpcService.cs index bea90a5b9a4..d5bcf16e8ba 100644 --- a/src/Nethermind/Nethermind.JsonRpc/JsonRpcService.cs +++ b/src/Nethermind/Nethermind.JsonRpc/JsonRpcService.cs @@ -183,6 +183,11 @@ private async Task ExecuteAsync(JsonRpcRequest request, string resultWrapper = task.GetType().GetProperty("Result")?.GetValue(task) as IResultWrapper; break; } + + if (methodName == "engine_newPayloadV3" && resultWrapper.Data.GetType().GetProperty("Status")?.GetValue(resultWrapper.Data) as string == "INVALID") + { + return GetErrorResponse(methodName, ErrorCodes.InvalidParams, "Invalid params", null, request.Id, returnAction); + } } catch (Exception e) when (e is TargetParameterCountException || e is ArgumentException) { diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs index 3633d7f8539..d4f2afa781d 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs @@ -179,7 +179,7 @@ public virtual async Task NewPayloadV3_should_decline_incorrect_blobgasused(bool byte[]?[] blobVersionedHashes = transactions.SelectMany(tx => tx.BlobVersionedHashes ?? Array.Empty()).ToArray(); ResultWrapper result = await prevRpcModule.engine_newPayloadV3(payload, blobVersionedHashes, payload.ParentBeaconBlockRoot); - Assert.That(result.ErrorCode, Is.EqualTo(expectedPayloadStatus == PayloadStatus.Invalid ? ErrorCodes.InvalidParams : ErrorCodes.None)); + Assert.That(result.ErrorCode, Is.EqualTo(ErrorCodes.None)); result.Data.Status.Should().Be(expectedPayloadStatus); } diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/NewPayloadV1Result.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/NewPayloadV1Result.cs index ed3315c9abb..4d78659888f 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/NewPayloadV1Result.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/NewPayloadV1Result.cs @@ -17,7 +17,7 @@ public static class NewPayloadV1Result public static ResultWrapper Invalid(Hash256? latestValidHash, string? validationError = null) { - return ResultWrapper.Fail("Invalid Params", ErrorCodes.InvalidParams, new PayloadStatusV1() { Status = PayloadStatus.Invalid, LatestValidHash = latestValidHash, ValidationError = validationError }); + return ResultWrapper.Success(new PayloadStatusV1() { Status = PayloadStatus.Invalid, LatestValidHash = latestValidHash, ValidationError = validationError }); } public static ResultWrapper Valid(Hash256? latestValidHash) From b0254b9c06c79d7c0c4c264119a394d3334027bf Mon Sep 17 00:00:00 2001 From: "lukasz.rozmej" Date: Wed, 13 Dec 2023 12:54:24 +0100 Subject: [PATCH 05/10] Make ExecutionPayloadV3.BlobGasUsed and ExcessBlobGas required --- .../Nethermind.JsonRpc/JsonRpcService.cs | 5 ----- .../EngineModuleTests.V3.cs | 8 +++++--- .../Data/ExecutionPayload.cs | 7 ++----- .../Data/ExecutionPayloadV3.cs | 15 +++++++++++++++ 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/Nethermind/Nethermind.JsonRpc/JsonRpcService.cs b/src/Nethermind/Nethermind.JsonRpc/JsonRpcService.cs index d5bcf16e8ba..bea90a5b9a4 100644 --- a/src/Nethermind/Nethermind.JsonRpc/JsonRpcService.cs +++ b/src/Nethermind/Nethermind.JsonRpc/JsonRpcService.cs @@ -183,11 +183,6 @@ private async Task ExecuteAsync(JsonRpcRequest request, string resultWrapper = task.GetType().GetProperty("Result")?.GetValue(task) as IResultWrapper; break; } - - if (methodName == "engine_newPayloadV3" && resultWrapper.Data.GetType().GetProperty("Status")?.GetValue(resultWrapper.Data) as string == "INVALID") - { - return GetErrorResponse(methodName, ErrorCodes.InvalidParams, "Invalid params", null, request.Id, returnAction); - } } catch (Exception e) when (e is TargetParameterCountException || e is ArgumentException) { diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs index d4f2afa781d..5000517898b 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs @@ -206,9 +206,11 @@ public async Task NewPayloadV3_invalidblockhash() = await PreparePayloadRequestEnv(); string requestStr = """ - {"jsonrpc":"2.0","id":4,"method":"engine_newPayloadV3","params":[{"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"},[],"0x169630f535b4a41330164c6e5c92b1224c0c407f582d407d0ac3d206cd32fd52"]} - """; - JsonRpcRequest request = JsonSerializer.Deserialize(requestStr, EthereumJsonSerializer.JsonOptions)!; + {"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); 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; } } From 45fd6a63a1651c273c69adbb295443fd6e6a0e34 Mon Sep 17 00:00:00 2001 From: "lukasz.rozmej" Date: Wed, 13 Dec 2023 12:58:16 +0100 Subject: [PATCH 06/10] small cleanup --- .../Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V3.cs index 5000517898b..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!); @@ -202,7 +198,7 @@ public async Task NewPayloadV3_should_decline_null_blobversionedhashes() [Test] public async Task NewPayloadV3_invalidblockhash() { - (JsonRpcService jsonRpcService, JsonRpcContext context, EthereumJsonSerializer serializer, ExecutionPayloadV3 executionPayload) + (JsonRpcService jsonRpcService, JsonRpcContext context, EthereumJsonSerializer _, ExecutionPayloadV3 _) = await PreparePayloadRequestEnv(); string requestStr = """ From 27c36863e82cd75b6c327da2d101e730f69724cd Mon Sep 17 00:00:00 2001 From: "lukasz.rozmej" Date: Wed, 13 Dec 2023 14:00:01 +0100 Subject: [PATCH 07/10] overload instead of override --- .../Data/ExecutionPayload.cs | 4 ++-- .../Data/ExecutionPayloadV3.cs | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs index cedac0264f8..81a3553220a 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs @@ -97,14 +97,14 @@ public byte[][] Transactions /// EIP-4844. /// [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public virtual ulong? BlobGasUsed { get; set; } + public ulong? BlobGasUsed { get; set; } /// /// Gets or sets as defined in /// EIP-4844. /// [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public virtual ulong? ExcessBlobGas { get; set; } + public 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 ff236bab63d..e4f8f477e91 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV3.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV3.cs @@ -18,8 +18,8 @@ public class ExecutionPayloadV3 : ExecutionPayload public ExecutionPayloadV3(Block block) : base(block) { ParentBeaconBlockRoot = block.ParentBeaconBlockRoot; - BlobGasUsed = block.BlobGasUsed; - ExcessBlobGas = block.ExcessBlobGas; + base.BlobGasUsed = block.BlobGasUsed; + base.ExcessBlobGas = block.ExcessBlobGas; } public override bool TryGetBlock(out Block? block, UInt256? totalDifficulty = null) @@ -43,12 +43,20 @@ public override bool ValidateFork(ISpecProvider specProvider) => /// EIP-4844. /// [JsonRequired] - public override ulong? BlobGasUsed { get; set; } + public new ulong BlobGasUsed + { + get => base.BlobGasUsed ?? 0; + set => base.BlobGasUsed = value; + } /// /// Gets or sets as defined in /// EIP-4844. /// [JsonRequired] - public override ulong? ExcessBlobGas { get; set; } + public new ulong ExcessBlobGas + { + get => base.ExcessBlobGas ?? 0; + set => base.ExcessBlobGas = value; + } } From ab921f950d1c62de245a43522b9065aa411cebd4 Mon Sep 17 00:00:00 2001 From: "lukasz.rozmej" Date: Wed, 13 Dec 2023 22:08:28 +0100 Subject: [PATCH 08/10] Revert "overload instead of override" This reverts commit 27c36863e82cd75b6c327da2d101e730f69724cd. --- .../Data/ExecutionPayload.cs | 4 ++-- .../Data/ExecutionPayloadV3.cs | 16 ++++------------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs index 81a3553220a..cedac0264f8 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs @@ -97,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 e4f8f477e91..ff236bab63d 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV3.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV3.cs @@ -18,8 +18,8 @@ public class ExecutionPayloadV3 : ExecutionPayload public ExecutionPayloadV3(Block block) : base(block) { ParentBeaconBlockRoot = block.ParentBeaconBlockRoot; - base.BlobGasUsed = block.BlobGasUsed; - base.ExcessBlobGas = block.ExcessBlobGas; + BlobGasUsed = block.BlobGasUsed; + ExcessBlobGas = block.ExcessBlobGas; } public override bool TryGetBlock(out Block? block, UInt256? totalDifficulty = null) @@ -43,20 +43,12 @@ public override bool ValidateFork(ISpecProvider specProvider) => /// EIP-4844. /// [JsonRequired] - public new ulong BlobGasUsed - { - get => base.BlobGasUsed ?? 0; - set => base.BlobGasUsed = value; - } + public override ulong? BlobGasUsed { get; set; } /// /// Gets or sets as defined in /// EIP-4844. /// [JsonRequired] - public new ulong ExcessBlobGas - { - get => base.ExcessBlobGas ?? 0; - set => base.ExcessBlobGas = value; - } + public override ulong? ExcessBlobGas { get; set; } } From 782200e45de662d5eb33748c29f3e6206f59fc94 Mon Sep 17 00:00:00 2001 From: "lukasz.rozmej" Date: Wed, 13 Dec 2023 22:53:39 +0100 Subject: [PATCH 09/10] Revert "Revert "overload instead of override"" This reverts commit ab921f950d1c62de245a43522b9065aa411cebd4. --- .../Data/ExecutionPayload.cs | 4 ++-- .../Data/ExecutionPayloadV3.cs | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs index cedac0264f8..81a3553220a 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs @@ -97,14 +97,14 @@ public byte[][] Transactions /// EIP-4844. /// [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public virtual ulong? BlobGasUsed { get; set; } + public ulong? BlobGasUsed { get; set; } /// /// Gets or sets as defined in /// EIP-4844. /// [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public virtual ulong? ExcessBlobGas { get; set; } + public 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 ff236bab63d..e4f8f477e91 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV3.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV3.cs @@ -18,8 +18,8 @@ public class ExecutionPayloadV3 : ExecutionPayload public ExecutionPayloadV3(Block block) : base(block) { ParentBeaconBlockRoot = block.ParentBeaconBlockRoot; - BlobGasUsed = block.BlobGasUsed; - ExcessBlobGas = block.ExcessBlobGas; + base.BlobGasUsed = block.BlobGasUsed; + base.ExcessBlobGas = block.ExcessBlobGas; } public override bool TryGetBlock(out Block? block, UInt256? totalDifficulty = null) @@ -43,12 +43,20 @@ public override bool ValidateFork(ISpecProvider specProvider) => /// EIP-4844. /// [JsonRequired] - public override ulong? BlobGasUsed { get; set; } + public new ulong BlobGasUsed + { + get => base.BlobGasUsed ?? 0; + set => base.BlobGasUsed = value; + } /// /// Gets or sets as defined in /// EIP-4844. /// [JsonRequired] - public override ulong? ExcessBlobGas { get; set; } + public new ulong ExcessBlobGas + { + get => base.ExcessBlobGas ?? 0; + set => base.ExcessBlobGas = value; + } } From 12060c3616e2f2e9f23a79563de8a08d46c0e555 Mon Sep 17 00:00:00 2001 From: "lukasz.rozmej" Date: Thu, 14 Dec 2023 02:45:11 +0100 Subject: [PATCH 10/10] Revert "Revert "Revert "overload instead of override""" This reverts commit 782200e45de662d5eb33748c29f3e6206f59fc94. --- .../Data/ExecutionPayload.cs | 4 ++-- .../Data/ExecutionPayloadV3.cs | 16 ++++------------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs index 81a3553220a..cedac0264f8 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayload.cs @@ -97,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 e4f8f477e91..ff236bab63d 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV3.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Data/ExecutionPayloadV3.cs @@ -18,8 +18,8 @@ public class ExecutionPayloadV3 : ExecutionPayload public ExecutionPayloadV3(Block block) : base(block) { ParentBeaconBlockRoot = block.ParentBeaconBlockRoot; - base.BlobGasUsed = block.BlobGasUsed; - base.ExcessBlobGas = block.ExcessBlobGas; + BlobGasUsed = block.BlobGasUsed; + ExcessBlobGas = block.ExcessBlobGas; } public override bool TryGetBlock(out Block? block, UInt256? totalDifficulty = null) @@ -43,20 +43,12 @@ public override bool ValidateFork(ISpecProvider specProvider) => /// EIP-4844. /// [JsonRequired] - public new ulong BlobGasUsed - { - get => base.BlobGasUsed ?? 0; - set => base.BlobGasUsed = value; - } + public override ulong? BlobGasUsed { get; set; } /// /// Gets or sets as defined in /// EIP-4844. /// [JsonRequired] - public new ulong ExcessBlobGas - { - get => base.ExcessBlobGas ?? 0; - set => base.ExcessBlobGas = value; - } + public override ulong? ExcessBlobGas { get; set; } }