Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix eth_getBlockReceipts #2295

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading