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 fd4b9c2 commit 53db521
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)

Check warning on line 1095 in internal/ethapi/api.go

View check run for this annotation

Codecov / codecov/patch

internal/ethapi/api.go#L1095

Added line #L1095 was not covered by tests
}

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))

Check warning on line 2237 in internal/ethapi/api.go

View check run for this annotation

Codecov / codecov/patch

internal/ethapi/api.go#L2237

Added line #L2237 was not covered by tests
} 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 53db521

Please sign in to comment.