From f768eb9c64ca2183aa6e7754be3a353d0643692d Mon Sep 17 00:00:00 2001 From: George Date: Tue, 12 Nov 2024 09:39:17 -0800 Subject: [PATCH] Fix max cursor overflow by using correct type (#325) --- cmd/soroban-rpc/internal/db/cursor.go | 6 +++--- cmd/soroban-rpc/internal/methods/get_events.go | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd/soroban-rpc/internal/db/cursor.go b/cmd/soroban-rpc/internal/db/cursor.go index 8393f104..4102038d 100644 --- a/cmd/soroban-rpc/internal/db/cursor.go +++ b/cmd/soroban-rpc/internal/db/cursor.go @@ -129,9 +129,9 @@ var ( // MaxCursor is the largest possible cursor //nolint:gochecknoglobals MaxCursor = Cursor{ - Ledger: math.MaxUint32, - Tx: math.MaxUint32, - Op: math.MaxUint32, + Ledger: math.MaxInt32, + Tx: math.MaxInt32, + Op: math.MaxInt32, Event: math.MaxUint32, } ) diff --git a/cmd/soroban-rpc/internal/methods/get_events.go b/cmd/soroban-rpc/internal/methods/get_events.go index 933e6d81..0bc7ab11 100644 --- a/cmd/soroban-rpc/internal/methods/get_events.go +++ b/cmd/soroban-rpc/internal/methods/get_events.go @@ -446,10 +446,8 @@ func (h eventsRPCHandler) getEvents(ctx context.Context, request GetEventsReques } } endLedger := start.Ledger + LedgerScanLimit - // endLedger should not exceed ledger retention window endLedger = min(ledgerRange.LastLedger.Sequence+1, endLedger) - if request.EndLedger != 0 { endLedger = min(request.EndLedger, endLedger) }