From 3d134d137738c605c7f2b4ff85e1d165e0c3f8c3 Mon Sep 17 00:00:00 2001 From: Adrian Bacircea Date: Thu, 26 Oct 2023 14:20:22 +0300 Subject: [PATCH] Allow safe/finalized for eth_getLogs --- turbo/jsonrpc/eth_receipts.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/turbo/jsonrpc/eth_receipts.go b/turbo/jsonrpc/eth_receipts.go index 6d5f60c356f..f188bad21e5 100644 --- a/turbo/jsonrpc/eth_receipts.go +++ b/turbo/jsonrpc/eth_receipts.go @@ -5,7 +5,6 @@ import ( "context" "encoding/binary" "fmt" - "math/big" "github.com/RoaringBitmap/roaring" "github.com/ledgerwatch/log/v3" @@ -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 @@ -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) @@ -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) @@ -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