From 384dbceedc4a32c6e443f6c9745b4d2b886e3e44 Mon Sep 17 00:00:00 2001 From: Jayden Lee <41176085+tkxkd0159@users.noreply.github.com> Date: Fri, 3 May 2024 20:10:42 +0900 Subject: [PATCH] add query bound for SeqToBlocknums --- x/fbridge/keeper/grpc_query.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/x/fbridge/keeper/grpc_query.go b/x/fbridge/keeper/grpc_query.go index 3f6feb5d06..e2460064c2 100644 --- a/x/fbridge/keeper/grpc_query.go +++ b/x/fbridge/keeper/grpc_query.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "fmt" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -32,6 +33,12 @@ func (k Keeper) SeqToBlocknums(goCtx context.Context, req *types.QuerySeqToBlock return nil, status.Error(codes.InvalidArgument, "empty request") } + const lowerBound int = 1 + const upperBound int = 1000 + if len(req.Seqs) < lowerBound || len(req.Seqs) > upperBound { + return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("The number of seqs requested must be between %d and %d", lowerBound, upperBound)) + } + ctx := sdk.UnwrapSDKContext(goCtx) bhList := make([]uint64, len(req.Seqs)) for i, seq := range req.Seqs {