Skip to content

Commit 8905ea8

Browse files
authored
rpc: fix GetBlockTransactionCountByNumber with Pending (#19335)
When blockNr is set to rpc.PendingBlockNumber (-1), performing a direct conversion via .Uint64() results in an integer overflow. This transforms the special 'pending' tag into a literal, extremely large block number (2^{64}-1). Consequently, the blockByNumberWithSenders() function fails to recognize it as a special case and attempts to query a non-existent block height from the database
1 parent bf8f735 commit 8905ea8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rpc/jsonrpc/eth_block.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ func (api *APIImpl) GetBlockTransactionCountByNumber(ctx context.Context, blockN
345345
defer tx.Rollback()
346346

347347
if blockNr == rpc.PendingBlockNumber {
348-
b, err := api.blockByNumberWithSenders(ctx, tx, blockNr.Uint64())
348+
b, err := api.blockByNumber(ctx, blockNr, tx)
349349
if err != nil {
350350
return nil, err
351351
}

0 commit comments

Comments
 (0)