diff --git a/src/Nethermind/Nethermind.DataMarketplace.Infrastructure/NdmApi.cs b/src/Nethermind/Nethermind.DataMarketplace.Infrastructure/NdmApi.cs index a53ad77b9d8..beed1265a57 100644 --- a/src/Nethermind/Nethermind.DataMarketplace.Infrastructure/NdmApi.cs +++ b/src/Nethermind/Nethermind.DataMarketplace.Infrastructure/NdmApi.cs @@ -440,7 +440,7 @@ public ITrieStore? TrieStore set => _nethermindApi.TrieStore = value; } - public ITrieStore? ReadOnlyTrieStore + public ReadOnlyTrieStore? ReadOnlyTrieStore { get => _nethermindApi.ReadOnlyTrieStore; set => _nethermindApi.ReadOnlyTrieStore = value; diff --git a/src/Nethermind/Nethermind.Db/IRocksDbFactory.cs b/src/Nethermind/Nethermind.Db/IRocksDbFactory.cs index cd7d63ca7d8..48741c9e33c 100644 --- a/src/Nethermind/Nethermind.Db/IRocksDbFactory.cs +++ b/src/Nethermind/Nethermind.Db/IRocksDbFactory.cs @@ -20,6 +20,6 @@ public interface IRocksDbFactory { IDb CreateDb(RocksDbSettings rocksDbSettings); - IColumnsDb CreateColumnsDb(RocksDbSettings rocksDbSettings); + IColumnsDb CreateColumnsDb(RocksDbSettings rocksDbSettings) where T : notnull; } } diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/EthModuleTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/EthModuleTests.cs index 859625357dd..5288f03288a 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/EthModuleTests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/EthModuleTests.cs @@ -34,7 +34,6 @@ using Nethermind.Logging; using Nethermind.Serialization.Json; using Nethermind.Serialization.Rlp; -using Nethermind.Trie; using Nethermind.TxPool; using NSubstitute; using NUnit.Framework; diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/TransactionForRpcConverterTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/TransactionForRpcConverterTests.cs new file mode 100644 index 00000000000..33a65588eb8 --- /dev/null +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/TransactionForRpcConverterTests.cs @@ -0,0 +1,53 @@ +// Copyright (c) 2021 Demerzel Solutions Limited +// This file is part of the Nethermind library. +// +// The Nethermind library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The Nethermind library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the Nethermind. If not, see . + +using System; +using FluentAssertions; +using Nethermind.Core; +using Nethermind.Core.Crypto; +using Nethermind.JsonRpc.Data; +using Nethermind.JsonRpc.Test.Data; +using Nethermind.Serialization.Json; +using NUnit.Framework; + +namespace Nethermind.JsonRpc.Test.Modules +{ + [Parallelizable(ParallelScope.Self)] + [TestFixture] + public class TransactionForRpcConverterTests : SerializationTestBase + { + [Test] + public void R_and_s_are_quantity_and_not_data() + { + byte[] r = new byte[32]; + byte[] s = new byte[32]; + r[1] = 1; + s[2] = 2; + + Transaction tx = new Transaction(); + tx.Signature = new Signature(r, s, 27); + + TransactionForRpc txForRpc = new TransactionForRpc(tx); + + EthereumJsonSerializer serializer = new EthereumJsonSerializer(); + string serialized = serializer.Serialize(txForRpc); + + serialized.Should().Contain("0x20000000000000000000000000000000000000000000000000000000000"); + serialized.Should().Contain("0x1000000000000000000000000000000000000000000000000000000000000"); + Console.WriteLine(serialized); + } + } +} diff --git a/src/Nethermind/Nethermind.JsonRpc/Data/TransactionForRpc.cs b/src/Nethermind/Nethermind.JsonRpc/Data/TransactionForRpc.cs index 24a4ff58389..6acb10fe462 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Data/TransactionForRpc.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Data/TransactionForRpc.cs @@ -26,7 +26,7 @@ public class TransactionForRpc { public TransactionForRpc(Transaction transaction) : this(null, null, null, transaction) { } - public TransactionForRpc(Keccak blockHash, long? blockNumber, int? txIndex, Transaction transaction) + public TransactionForRpc(Keccak? blockHash, long? blockNumber, int? txIndex, Transaction transaction) { Hash = transaction.Hash; Nonce = transaction.Nonce; @@ -39,9 +39,14 @@ public TransactionForRpc(Keccak blockHash, long? blockNumber, int? txIndex, Tran GasPrice = transaction.GasPrice; Gas = transaction.GasLimit; Input = Data = transaction.Data ?? transaction.Init; - R = transaction.Signature?.R; - S = transaction.Signature?.S; - V = (UInt256?) transaction.Signature?.V; + + Signature? signature = transaction.Signature; + if (signature != null) + { + R = new UInt256(signature.R, true); + S = new UInt256(signature.S, true); + V = (UInt256?)signature.V; + } } // ReSharper disable once UnusedMember.Global @@ -49,33 +54,33 @@ public TransactionForRpc() { } - public Keccak Hash { get; set; } + public Keccak? Hash { get; set; } public UInt256? Nonce { get; set; } [JsonProperty(NullValueHandling = NullValueHandling.Include)] - public Keccak BlockHash { get; set; } + public Keccak? BlockHash { get; set; } [JsonProperty(NullValueHandling = NullValueHandling.Include)] public long? BlockNumber { get; set; } [JsonProperty(NullValueHandling = NullValueHandling.Include)] public long? TransactionIndex { get; set; } - public Address From { get; set; } + public Address? From { get; set; } [JsonProperty(NullValueHandling = NullValueHandling.Include)] - public Address To { get; set; } + public Address? To { get; set; } public UInt256? Value { get; set; } public UInt256? GasPrice { get; set; } public long? Gas { get; set; } - public byte[] Data { get; set; } + public byte[]? Data { get; set; } [JsonProperty(NullValueHandling = NullValueHandling.Include)] - public byte[] Input { get; set; } + public byte[]? Input { get; set; } public UInt256? V { get; set; } - public byte[] S { get; set; } + public UInt256? S { get; set; } - public byte[] R { get; set; } + public UInt256? R { get; set; } public Transaction ToTransactionWithDefaults() { diff --git a/src/Nethermind/Nethermind.JsonRpc/Nethermind.JsonRpc.csproj b/src/Nethermind/Nethermind.JsonRpc/Nethermind.JsonRpc.csproj index 03d6a67047c..20ad23863b4 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Nethermind.JsonRpc.csproj +++ b/src/Nethermind/Nethermind.JsonRpc/Nethermind.JsonRpc.csproj @@ -4,6 +4,7 @@ 9 true true + enable