diff --git a/cmd/rpcdaemon/commands/eth_receipts.go b/cmd/rpcdaemon/commands/eth_receipts.go index 80d80b3b9..d418dce43 100644 --- a/cmd/rpcdaemon/commands/eth_receipts.go +++ b/cmd/rpcdaemon/commands/eth_receipts.go @@ -155,11 +155,11 @@ func (api *APIImpl) GetLogs(ctx context.Context, crit filters.FilterCriteria) ([ return nil, err } - block := uint64(iter.Next()) + blockNumber := uint64(iter.Next()) var logIndex uint var txIndex uint var blockLogs []*types.Log - err := tx.ForPrefix(kv.Log, dbutils.EncodeBlockNumber(block), func(k, v []byte) error { + err := tx.ForPrefix(kv.Log, dbutils.EncodeBlockNumber(blockNumber), func(k, v []byte) error { var logs types.Logs if err := cbor.Unmarshal(&logs, bytes.NewReader(v)); err != nil { return fmt.Errorf("receipt unmarshal failed: %w", err) @@ -187,18 +187,19 @@ func (api *APIImpl) GetLogs(ctx context.Context, crit filters.FilterCriteria) ([ continue } - b, err := api.blockByNumberWithSenders(tx, block) + blockHash, err := rawdb.ReadCanonicalHash(tx, blockNumber) if err != nil { return nil, err } - if b == nil { - return nil, fmt.Errorf("block not found %d", block) + + body, err := api._blockReader.BodyWithTransactions(ctx, tx, blockHash, blockNumber) + if err != nil || body == nil { + return nil, fmt.Errorf("block not found %d", blockNumber) } - blockHash := b.Hash() for _, log := range blockLogs { - log.BlockNumber = block + log.BlockNumber = blockNumber log.BlockHash = blockHash - log.TxHash = b.Transactions()[log.TxIndex].Hash() + log.TxHash = body.Transactions[log.TxIndex].Hash() } logs = append(logs, blockLogs...)