From f021096a7d859af02fb61cdd99e3e6b877e2ffb5 Mon Sep 17 00:00:00 2001 From: Tomasz Kajetan Stanczak Date: Fri, 21 Jun 2019 14:43:31 +0100 Subject: [PATCH 1/2] tx hash fix --- src/Nethermind/Nethermind.Blockchain/BlockProcessor.cs | 2 +- .../Nethermind.Blockchain/Filters/FilterManager.cs | 2 +- .../Nethermind.Blockchain/Receipts/InMemoryReceiptStorage.cs | 4 ++-- .../Receipts/PersistentReceiptStorage.cs | 4 ++-- .../Synchronization/FastBlocks/FastBlocksFeed.cs | 2 +- .../Nethermind.Core.Test/Builders/BlockTreeBuilder.cs | 2 +- .../Nethermind.Core.Test/Builders/ReceiptBuilder.cs | 2 +- src/Nethermind/Nethermind.Core/TransactionReceipt.cs | 2 +- .../ContractInteractionTest.cs | 2 +- src/Nethermind/Nethermind.Evm/Tracing/BlockReceiptsTracer.cs | 2 +- src/Nethermind/Nethermind.Facade/BlockchainBridge.cs | 5 +++-- .../Nethermind.JsonRpc.Test/Modules/EthModuleTests.cs | 2 +- src/Nethermind/Nethermind.JsonRpc/Data/LogEntryForRpc.cs | 2 +- src/Nethermind/Nethermind.PubSub.Kafka/Avro/AvroMapper.cs | 4 ++-- src/Nethermind/Nethermind.PubSub/PubSubModelMapper.cs | 2 +- src/tests | 2 +- 16 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/Nethermind/Nethermind.Blockchain/BlockProcessor.cs b/src/Nethermind/Nethermind.Blockchain/BlockProcessor.cs index 3e86fcc4f83..3a8573d5ca5 100644 --- a/src/Nethermind/Nethermind.Blockchain/BlockProcessor.cs +++ b/src/Nethermind/Nethermind.Blockchain/BlockProcessor.cs @@ -232,7 +232,7 @@ private void StoreTxReceipts(Block block, TxReceipt[] txReceipts) { txReceipts[i].BlockHash = block.Hash; _receiptStorage.Add(txReceipts[i], true); - _txPool.RemoveTransaction(txReceipts[i].TransactionHash); + _txPool.RemoveTransaction(txReceipts[i].TxHash); } } diff --git a/src/Nethermind/Nethermind.Blockchain/Filters/FilterManager.cs b/src/Nethermind/Nethermind.Blockchain/Filters/FilterManager.cs index f392ae6cf81..636c90614af 100644 --- a/src/Nethermind/Nethermind.Blockchain/Filters/FilterManager.cs +++ b/src/Nethermind/Nethermind.Blockchain/Filters/FilterManager.cs @@ -303,7 +303,7 @@ private FilterLog CreateLog(LogFilter logFilter, TxReceipt txReceipt, LogEntry l private FilterLog CreateLog(UInt256 logIndex, TxReceipt txReceipt, LogEntry logEntry) { return new FilterLog(logIndex, txReceipt.BlockNumber, txReceipt.BlockHash, - (UInt256)txReceipt.Index, txReceipt.TransactionHash, logEntry.LoggersAddress, + (UInt256)txReceipt.Index, txReceipt.TxHash, logEntry.LoggersAddress, logEntry.Data, logEntry.Topics); } } diff --git a/src/Nethermind/Nethermind.Blockchain/Receipts/InMemoryReceiptStorage.cs b/src/Nethermind/Nethermind.Blockchain/Receipts/InMemoryReceiptStorage.cs index f71bff9de9f..a82b8c858fb 100644 --- a/src/Nethermind/Nethermind.Blockchain/Receipts/InMemoryReceiptStorage.cs +++ b/src/Nethermind/Nethermind.Blockchain/Receipts/InMemoryReceiptStorage.cs @@ -34,13 +34,13 @@ public TxReceipt Find(Keccak hash) } public void Add(TxReceipt txReceipt, bool isProcessed) - => _receipts.TryAdd(txReceipt.TransactionHash, txReceipt); + => _receipts.TryAdd(txReceipt.TxHash, txReceipt); public void Insert(long blockNumber, TxReceipt txReceipt) { if (txReceipt != null) { - _receipts.TryAdd(txReceipt.TransactionHash, txReceipt); + _receipts.TryAdd(txReceipt.TxHash, txReceipt); } LowestInsertedReceiptBlock = blockNumber; diff --git a/src/Nethermind/Nethermind.Blockchain/Receipts/PersistentReceiptStorage.cs b/src/Nethermind/Nethermind.Blockchain/Receipts/PersistentReceiptStorage.cs index 0d9c4b99278..caabbbcf29c 100644 --- a/src/Nethermind/Nethermind.Blockchain/Receipts/PersistentReceiptStorage.cs +++ b/src/Nethermind/Nethermind.Blockchain/Receipts/PersistentReceiptStorage.cs @@ -65,7 +65,7 @@ public void Add(TxReceipt txReceipt, bool isProcessed) behaviors = behaviors | RlpBehaviors.Storage; } - _database.Set(txReceipt.TransactionHash, + _database.Set(txReceipt.TxHash, Rlp.Encode(txReceipt, behaviors).Bytes); } @@ -80,7 +80,7 @@ public void Insert(long blockNumber, TxReceipt txReceipt) { var spec = _specProvider.GetSpec(blockNumber); RlpBehaviors behaviors = spec.IsEip658Enabled ? RlpBehaviors.Eip658Receipts : RlpBehaviors.None; - _database.Set(txReceipt.TransactionHash, Rlp.Encode(txReceipt, behaviors).Bytes); + _database.Set(txReceipt.TxHash, Rlp.Encode(txReceipt, behaviors).Bytes); } LowestInsertedReceiptBlock = blockNumber; diff --git a/src/Nethermind/Nethermind.Blockchain/Synchronization/FastBlocks/FastBlocksFeed.cs b/src/Nethermind/Nethermind.Blockchain/Synchronization/FastBlocks/FastBlocksFeed.cs index 4c114890574..57a693a230b 100644 --- a/src/Nethermind/Nethermind.Blockchain/Synchronization/FastBlocks/FastBlocksFeed.cs +++ b/src/Nethermind/Nethermind.Blockchain/Synchronization/FastBlocks/FastBlocksFeed.cs @@ -499,7 +499,7 @@ private int InsertReceipts(FastBlocksBatch batch) break; } - receipt.TransactionHash = block + receipt.TxHash = block .Transactions[receiptIndex] .Hash; } diff --git a/src/Nethermind/Nethermind.Core.Test/Builders/BlockTreeBuilder.cs b/src/Nethermind/Nethermind.Core.Test/Builders/BlockTreeBuilder.cs index 3409badbd05..43dcf64bd22 100644 --- a/src/Nethermind/Nethermind.Core.Test/Builders/BlockTreeBuilder.cs +++ b/src/Nethermind/Nethermind.Core.Test/Builders/BlockTreeBuilder.cs @@ -126,7 +126,7 @@ private Block CreateBlock(int splitVariant, int splitFrom, int i, Block parent) foreach (Transaction transaction in current.Transactions) { TxReceipt receipt = new TxReceipt(); - receipt.TransactionHash = transaction.Hash; + receipt.TxHash = transaction.Hash; _receiptStorage.Add(receipt, false); receipts.Add(receipt); } diff --git a/src/Nethermind/Nethermind.Core.Test/Builders/ReceiptBuilder.cs b/src/Nethermind/Nethermind.Core.Test/Builders/ReceiptBuilder.cs index ade9bfc8d8b..4c770d4cef9 100644 --- a/src/Nethermind/Nethermind.Core.Test/Builders/ReceiptBuilder.cs +++ b/src/Nethermind/Nethermind.Core.Test/Builders/ReceiptBuilder.cs @@ -57,7 +57,7 @@ public ReceiptBuilder WithLogs(LogEntry[] logs) public ReceiptBuilder WithTransactionHash(Keccak hash) { - TestObject.TransactionHash = hash; + TestObject.TxHash = hash; return this; } diff --git a/src/Nethermind/Nethermind.Core/TransactionReceipt.cs b/src/Nethermind/Nethermind.Core/TransactionReceipt.cs index 7c4ab837233..425ac99dccc 100644 --- a/src/Nethermind/Nethermind.Core/TransactionReceipt.cs +++ b/src/Nethermind/Nethermind.Core/TransactionReceipt.cs @@ -30,7 +30,7 @@ public class TxReceipt public long BlockNumber { get; set; } public Keccak BlockHash { get; set; } - public Keccak TransactionHash { get; set; } + public Keccak TxHash { get; set; } public int Index { get; set; } public long GasUsed { get; set; } public long GasUsedTotal { get; set; } diff --git a/src/Nethermind/Nethermind.DataMarketplace.Test/ContractInteractionTest.cs b/src/Nethermind/Nethermind.DataMarketplace.Test/ContractInteractionTest.cs index 0efc1e3d19d..34877c16f02 100644 --- a/src/Nethermind/Nethermind.DataMarketplace.Test/ContractInteractionTest.cs +++ b/src/Nethermind/Nethermind.DataMarketplace.Test/ContractInteractionTest.cs @@ -245,7 +245,7 @@ public Keccak SendTransaction(Transaction transaction, bool doNotEvict = false) public TxReceipt GetReceipt(Keccak txHash) { - return _receiptsTracer.TxReceipts.Single(r => r?.TransactionHash == txHash); + return _receiptsTracer.TxReceipts.Single(r => r?.TxHash == txHash); } public Facade.BlockchainBridge.CallOutput Call(BlockHeader blockHeader, Transaction transaction) diff --git a/src/Nethermind/Nethermind.Evm/Tracing/BlockReceiptsTracer.cs b/src/Nethermind/Nethermind.Evm/Tracing/BlockReceiptsTracer.cs index 5040ac9688d..0faa7d68fa4 100644 --- a/src/Nethermind/Nethermind.Evm/Tracing/BlockReceiptsTracer.cs +++ b/src/Nethermind/Nethermind.Evm/Tracing/BlockReceiptsTracer.cs @@ -87,7 +87,7 @@ private TxReceipt BuildReceipt(Address recipient, long spentGas, byte statusCode txReceipt.GasUsed = spentGas; txReceipt.Sender = transaction.SenderAddress; txReceipt.ContractAddress = transaction.IsContractCreation ? recipient : null; - txReceipt.TransactionHash = transaction.Hash; + txReceipt.TxHash = transaction.Hash; return txReceipt; } diff --git a/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs b/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs index 58b992e08fa..c650ce62c17 100644 --- a/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs +++ b/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs @@ -131,8 +131,9 @@ public Keccak SendTransaction(Transaction transaction, bool doNotEvict = false) public TxReceipt GetReceipt(Keccak txHash) { - var rec = _receiptStorage.Find(txHash); - return rec; + var txReceipt = _receiptStorage.Find(txHash); + txReceipt.TxHash = txHash; + return txReceipt; } public class CallOutput diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/EthModuleTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/EthModuleTests.cs index def005546f0..03f64496617 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/EthModuleTests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/EthModuleTests.cs @@ -258,7 +258,7 @@ public void Eth_get_transaction_receipt() string serialized = RpcTest.TestSerializedRequest(module, "eth_getTransactionReceipt", TestItem.KeccakA.ToString()); - Assert.AreEqual("{\"id\":67,\"jsonrpc\":\"2.0\",\"result\":{\"transactionHash\":\"0x03783fac2efed8fbc9ad443e592ee30e61d65f471140c10ca155e937b435b760\",\"transactionIndex\":\"0x2\",\"blockHash\":\"0x017e667f4b8c174291d1543c466717566e206df1bfd6f30271055ddafdb18f72\",\"blockNumber\":\"0x2\",\"cumulativeGasUsed\":\"0x3e8\",\"gasUsed\":\"0x64\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"contractAddress\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"logs\":[{\"removed\":false,\"logIndex\":\"0x0\",\"transactionIndex\":\"0x2\",\"transactionHash\":\"0x017e667f4b8c174291d1543c466717566e206df1bfd6f30271055ddafdb18f72\",\"blockHash\":\"0x017e667f4b8c174291d1543c466717566e206df1bfd6f30271055ddafdb18f72\",\"blockNumber\":\"0x2\",\"address\":\"0x0000000000000000000000000000000000000000\",\"data\":\"0x\",\"topics\":[\"0x0000000000000000000000000000000000000000000000000000000000000000\"]},{\"removed\":false,\"logIndex\":\"0x1\",\"transactionIndex\":\"0x2\",\"transactionHash\":\"0x017e667f4b8c174291d1543c466717566e206df1bfd6f30271055ddafdb18f72\",\"blockHash\":\"0x017e667f4b8c174291d1543c466717566e206df1bfd6f30271055ddafdb18f72\",\"blockNumber\":\"0x2\",\"address\":\"0x0000000000000000000000000000000000000000\",\"data\":\"0x\",\"topics\":[\"0x0000000000000000000000000000000000000000000000000000000000000000\"]}],\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"root\":\"0x1f675bff07515f5df96737194ea945c36c41e7b4fcef307b7cd4d0e602a69111\",\"status\":\"0x0\",\"error\":\"error\"}}", serialized); + Assert.AreEqual("{\"id\":67,\"jsonrpc\":\"2.0\",\"result\":{\"transactionHash\":\"0x03783fac2efed8fbc9ad443e592ee30e61d65f471140c10ca155e937b435b760\",\"transactionIndex\":\"0x2\",\"blockHash\":\"0x017e667f4b8c174291d1543c466717566e206df1bfd6f30271055ddafdb18f72\",\"blockNumber\":\"0x2\",\"cumulativeGasUsed\":\"0x3e8\",\"gasUsed\":\"0x64\",\"from\":\"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099\",\"to\":\"0x942921b14f1b1c385cd7e0cc2ef7abe5598c8358\",\"contractAddress\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"logs\":[{\"removed\":false,\"logIndex\":\"0x0\",\"transactionIndex\":\"0x2\",\"transactionHash\":\"0x03783fac2efed8fbc9ad443e592ee30e61d65f471140c10ca155e937b435b760\",\"blockHash\":\"0x017e667f4b8c174291d1543c466717566e206df1bfd6f30271055ddafdb18f72\",\"blockNumber\":\"0x2\",\"address\":\"0x0000000000000000000000000000000000000000\",\"data\":\"0x\",\"topics\":[\"0x0000000000000000000000000000000000000000000000000000000000000000\"]},{\"removed\":false,\"logIndex\":\"0x1\",\"transactionIndex\":\"0x2\",\"transactionHash\":\"0x03783fac2efed8fbc9ad443e592ee30e61d65f471140c10ca155e937b435b760\",\"blockHash\":\"0x017e667f4b8c174291d1543c466717566e206df1bfd6f30271055ddafdb18f72\",\"blockNumber\":\"0x2\",\"address\":\"0x0000000000000000000000000000000000000000\",\"data\":\"0x\",\"topics\":[\"0x0000000000000000000000000000000000000000000000000000000000000000\"]}],\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"root\":\"0x1f675bff07515f5df96737194ea945c36c41e7b4fcef307b7cd4d0e602a69111\",\"status\":\"0x0\",\"error\":\"error\"}}", serialized); } [Test] diff --git a/src/Nethermind/Nethermind.JsonRpc/Data/LogEntryForRpc.cs b/src/Nethermind/Nethermind.JsonRpc/Data/LogEntryForRpc.cs index 36bcd1e6e62..5157568bc02 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Data/LogEntryForRpc.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Data/LogEntryForRpc.cs @@ -41,7 +41,7 @@ public LogEntryForRpc(TxReceipt receipt, LogEntry logEntry, int index) Removed = false; LogIndex = index; TransactionIndex = receipt.Index; - TransactionHash = receipt.TransactionHash; + TransactionHash = receipt.TxHash; BlockHash = receipt.BlockHash; BlockNumber = receipt.BlockNumber; Address = logEntry.LoggersAddress; diff --git a/src/Nethermind/Nethermind.PubSub.Kafka/Avro/AvroMapper.cs b/src/Nethermind/Nethermind.PubSub.Kafka/Avro/AvroMapper.cs index 56113e8b977..3538e21a78e 100644 --- a/src/Nethermind/Nethermind.PubSub.Kafka/Avro/AvroMapper.cs +++ b/src/Nethermind/Nethermind.PubSub.Kafka/Avro/AvroMapper.cs @@ -101,7 +101,7 @@ public FullTransaction MapFullTransaction(Core.FullTransaction fullTransaction) logsBloom = receipt.Bloom.ToString(), gasUsed = receipt.GasUsed, contractAddress = receipt.ContractAddress?.ToString() ?? string.Empty, - transactionHash = receipt.TransactionHash.ToString(), + transactionHash = receipt.TxHash.ToString(), cumulativeGasUsed = receipt.GasUsedTotal, status = receipt.StatusCode, logs = receipt.Logs?.Select((l, i) => new Log @@ -111,7 +111,7 @@ public FullTransaction MapFullTransaction(Core.FullTransaction fullTransaction) transactionIndex = receipt.Index, blockHash = receipt.BlockHash.ToString(), data = l.Data.ToString(), - transactionHash = receipt.TransactionHash.ToString(), + transactionHash = receipt.TxHash.ToString(), address = l.LoggersAddress.ToString(), logTopics = l.Topics?.Select(t => t.ToString()).ToList() ?? new List(), removed = removed diff --git a/src/Nethermind/Nethermind.PubSub/PubSubModelMapper.cs b/src/Nethermind/Nethermind.PubSub/PubSubModelMapper.cs index bc22f1059f5..76b114be77a 100644 --- a/src/Nethermind/Nethermind.PubSub/PubSubModelMapper.cs +++ b/src/Nethermind/Nethermind.PubSub/PubSubModelMapper.cs @@ -53,7 +53,7 @@ public TransactionReceipt MapTransactionReceipt(Core.TxReceipt receipt) StatusCode = receipt.StatusCode, BlockNumber = receipt.BlockNumber.ToString(), BlockHash = receipt.BlockHash?.Bytes, - TransactionHash = receipt.TransactionHash?.Bytes, + TransactionHash = receipt.TxHash?.Bytes, Index = receipt.Index, GasUsed = receipt.GasUsed, Sender = receipt.Sender?.Bytes, diff --git a/src/tests b/src/tests index ebb2dc8c6a4..784ff964111 160000 --- a/src/tests +++ b/src/tests @@ -1 +1 @@ -Subproject commit ebb2dc8c6a4c5bebce6479cebc9a9c9f77200e92 +Subproject commit 784ff964111cf1e1d2d52db0cfd06796bd03321c From 50268b2cb5613a12c1432932fb874ed818f414e7 Mon Sep 17 00:00:00 2001 From: Tomasz Kajetan Stanczak Date: Fri, 21 Jun 2019 14:57:07 +0100 Subject: [PATCH 2/2] CLI and config fix --- src/Nethermind/Nethermind.Cli/Modules/EthCliModule.cs | 8 ++++---- src/Nethermind/Nethermind.Runner/RunnerApp.cs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Nethermind/Nethermind.Cli/Modules/EthCliModule.cs b/src/Nethermind/Nethermind.Cli/Modules/EthCliModule.cs index d7bdaf3c6a7..24c1c6beb35 100644 --- a/src/Nethermind/Nethermind.Cli/Modules/EthCliModule.cs +++ b/src/Nethermind/Nethermind.Cli/Modules/EthCliModule.cs @@ -100,15 +100,15 @@ public string GetUncleCountByBlockNumber(string blockParameter) } [CliFunction("eth", "getTransactionByBlockNumberAndIndex")] - public string GetTransactionByBlockNumberAndIndex(string blockParameter, string index) + public object GetTransactionByBlockNumberAndIndex(string blockParameter, string index) { - return NodeManager.Post("eth_getTransactionByBlockNumberAndIndex", blockParameter, index).Result; + return NodeManager.Post("eth_getTransactionByBlockNumberAndIndex", blockParameter, index).Result; } [CliFunction("eth", "getTransactionReceipt")] - public string GetTransactionReceipt(string txHash) + public object GetTransactionReceipt(string txHash) { - return NodeManager.Post("eth_getTransactionReceipt", txHash).Result; + return NodeManager.Post("eth_getTransactionReceipt", txHash).Result; } [CliFunction("eth", "getBalance")] diff --git a/src/Nethermind/Nethermind.Runner/RunnerApp.cs b/src/Nethermind/Nethermind.Runner/RunnerApp.cs index 883a87f989d..18fded04743 100644 --- a/src/Nethermind/Nethermind.Runner/RunnerApp.cs +++ b/src/Nethermind/Nethermind.Runner/RunnerApp.cs @@ -81,7 +81,7 @@ protected override (CommandLineApplication, Func, Func) var configurationType = typeof(IConfig); var configs = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(a => a.GetTypes()) - .Where(t => configurationType.IsAssignableFrom(t) && t.IsInterface && t != configurationType) + .Where(t => configurationType.IsAssignableFrom(t) && !t.IsInterface) .ToList(); var app = new CommandLineApplication {Name = "Nethermind.Runner"};