Skip to content

Commit

Permalink
Fix eth_getBlockReceipts (#2295)
Browse files Browse the repository at this point in the history
Updated the api method to take into account the celo block receipt.

There was previous confusion around whether eth_getBlockReceipts was
working or not, as it had worked for some people but not others.

This confusion was caused because block receipts are only added when logs
have been generated by system calls. Before gingerbread, we would update
the gas price minimum on every block and hence create a log for the update,
but post gingerbread the only updates that are happening are for epoch blocks.

Co-authored-by: Paul Lange <palango@users.noreply.github.com>
  • Loading branch information
piersy and palango authored Apr 11, 2024
1 parent 7859a78 commit d832d98
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -837,15 +837,21 @@ func (s *PublicBlockChainAPI) GetBlockReceipts(ctx context.Context, blockNrOrHas
return nil, err
}
txs := block.Transactions()
if len(txs) != len(receipts) {
// We need to account for the block receipt, which if present will mean
// that there is one more receipt than transactions.
if len(txs) != len(receipts) && len(txs)+1 != len(receipts) {
return nil, fmt.Errorf("receipts length mismatch: %d vs %d", len(txs), len(receipts))
}

// Derive the sender.
signer := types.MakeSigner(s.b.ChainConfig(), block.Number())
result := make([]map[string]interface{}, len(receipts))
for i, receipt := range receipts {
result[i], err = generateReceiptResponse(ctx, s.b, receipt, signer, txs[i], block.Hash(), block.NumberU64(), uint64(i))
var tx *types.Transaction
if i < len(txs) {
tx = txs[i]
}
result[i], err = generateReceiptResponse(ctx, s.b, receipt, signer, tx, block.Hash(), block.NumberU64(), uint64(i))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit d832d98

Please sign in to comment.