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

Allow safe/finalized for eth_getLogs #9686

Merged
merged 1 commit into from
Mar 13, 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
16 changes: 0 additions & 16 deletions turbo/jsonrpc/eth_receipts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/binary"
"fmt"
"math/big"

"github.com/RoaringBitmap/roaring"
"github.com/ledgerwatch/log/v3"
Expand Down Expand Up @@ -35,8 +34,6 @@ import (
"github.com/ledgerwatch/erigon/turbo/transactions"
)

const PendingBlockNumber int64 = -2

func (api *BaseAPI) getReceipts(ctx context.Context, tx kv.Tx, chainConfig *chain.Config, block *types.Block, senders []common.Address) (types.Receipts, error) {
if cached := rawdb.ReadReceipts(tx, block, senders); cached != nil {
return cached, nil
Expand Down Expand Up @@ -110,10 +107,6 @@ func (api *APIImpl) GetLogs(ctx context.Context, crit filters.FilterCriteria) (t

begin = latest
if crit.FromBlock != nil {
if !getLogsIsValidBlockNumber(crit.FromBlock) {
return nil, fmt.Errorf("invalid value for FromBlock: %v", crit.FromBlock)
}

fromBlock := crit.FromBlock.Int64()
if fromBlock > 0 {
begin = uint64(fromBlock)
Expand All @@ -128,10 +121,6 @@ func (api *APIImpl) GetLogs(ctx context.Context, crit filters.FilterCriteria) (t
}
end = latest
if crit.ToBlock != nil {
if !getLogsIsValidBlockNumber(crit.ToBlock) {
return nil, fmt.Errorf("invalid value for ToBlock: %v", crit.ToBlock)
}

toBlock := crit.ToBlock.Int64()
if toBlock > 0 {
end = uint64(toBlock)
Expand Down Expand Up @@ -245,11 +234,6 @@ func (api *APIImpl) GetLogs(ctx context.Context, crit filters.FilterCriteria) (t
return logs, nil
}

// getLogsIsValidBlockNumber checks if block number is valid integer or "latest", "pending", "earliest" block number
func getLogsIsValidBlockNumber(blockNum *big.Int) bool {
return blockNum.IsInt64() && blockNum.Int64() >= PendingBlockNumber
}

// The Topic list restricts matches to particular event topics. Each event has a list
// of topics. Topics matches a prefix of that list. An empty element slice matches any
// topic. Non-empty elements represent an alternative that matches any of the
Expand Down
Loading