Skip to content

Commit

Permalink
fix: hashing of statesync txn
Browse files Browse the repository at this point in the history
  • Loading branch information
anshalshukla committed Apr 3, 2024
1 parent 3e113ed commit 3e7023a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ func (s *BlockChainAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rpc.

result := make([]map[string]interface{}, len(receipts))
for i, receipt := range receipts {
result[i] = marshalReceipt(receipt, block.Hash(), block.NumberU64(), signer, txs[i], i)
result[i] = marshalReceipt(receipt, block.Hash(), block.NumberU64(), signer, txs[i], i, false)
}

return result, nil
Expand Down Expand Up @@ -2225,17 +2225,24 @@ func (s *TransactionAPI) GetTransactionReceipt(ctx context.Context, hash common.

// Derive the sender.
signer := types.MakeSigner(s.b.ChainConfig(), header.Number, header.Time)
return marshalReceipt(receipt, blockHash, blockNumber, signer, tx, int(index)), nil
return marshalReceipt(receipt, blockHash, blockNumber, signer, tx, int(index), borTx), nil
}

// marshalReceipt marshals a transaction receipt into a JSON object.
func marshalReceipt(receipt *types.Receipt, blockHash common.Hash, blockNumber uint64, signer types.Signer, tx *types.Transaction, txIndex int) map[string]interface{} {
func marshalReceipt(receipt *types.Receipt, blockHash common.Hash, blockNumber uint64, signer types.Signer, tx *types.Transaction, txIndex int, borTx bool) map[string]interface{} {
from, _ := types.Sender(signer, tx)

txHash := common.Hash{}
if borTx {
txHash = types.GetDerivedBorTxHash(types.BorReceiptKey(blockNumber, blockHash))
} else {
txHash = tx.Hash()
}

fields := map[string]interface{}{
"blockHash": blockHash,
"blockNumber": hexutil.Uint64(blockNumber),
"transactionHash": tx.Hash(),
"transactionHash": txHash,
"transactionIndex": hexutil.Uint64(txIndex),
"from": from,
"to": tx.To(),
Expand Down

0 comments on commit 3e7023a

Please sign in to comment.