Skip to content

Commit

Permalink
Merge pull request #547 from NethermindEth/receiptTxHash
Browse files Browse the repository at this point in the history
Receipt tx hash
  • Loading branch information
tkstanczak authored Jun 21, 2019
2 parents d43b0bd + 50268b2 commit 59b7cb6
Show file tree
Hide file tree
Showing 18 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Blockchain/BlockProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ private int InsertReceipts(FastBlocksBatch batch)
break;
}

receipt.TransactionHash = block
receipt.TxHash = block
.Transactions[receiptIndex]
.Hash;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Nethermind/Nethermind.Cli/Modules/EthCliModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>("eth_getTransactionByBlockNumberAndIndex", blockParameter, index).Result;
return NodeManager.Post<object>("eth_getTransactionByBlockNumberAndIndex", blockParameter, index).Result;
}

[CliFunction("eth", "getTransactionReceipt")]
public string GetTransactionReceipt(string txHash)
public object GetTransactionReceipt(string txHash)
{
return NodeManager.Post<string>("eth_getTransactionReceipt", txHash).Result;
return NodeManager.Post<object>("eth_getTransactionReceipt", txHash).Result;
}

[CliFunction("eth", "getBalance")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public ReceiptBuilder WithLogs(LogEntry[] logs)

public ReceiptBuilder WithTransactionHash(Keccak hash)
{
TestObject.TransactionHash = hash;
TestObject.TxHash = hash;
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Core/TransactionReceipt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 3 additions & 2 deletions src/Nethermind/Nethermind.Facade/BlockchainBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.JsonRpc/Data/LogEntryForRpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.PubSub.Kafka/Avro/AvroMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<string>(),
removed = removed
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.PubSub/PubSubModelMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Runner/RunnerApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected override (CommandLineApplication, Func<IConfigProvider>, Func<string>)
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"};
Expand Down
2 changes: 1 addition & 1 deletion src/tests
Submodule tests updated 11674 files

0 comments on commit 59b7cb6

Please sign in to comment.