From c637c84fc430807cd5818ff8f80002a31230dba0 Mon Sep 17 00:00:00 2001 From: Delweng Date: Mon, 23 Oct 2023 23:25:26 +0800 Subject: [PATCH] graphql: return error if block from>to (#28393) As per discussion in ethereum/execution-apis#475 --- graphql/graphql.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/graphql/graphql.go b/graphql/graphql.go index 8304a64cf49f..ec7382f80adc 100644 --- a/graphql/graphql.go +++ b/graphql/graphql.go @@ -41,7 +41,8 @@ import ( ) var ( - errBlockInvariant = errors.New("block objects must be instantiated with at least one of num or hash") + errBlockInvariant = errors.New("block objects must be instantiated with at least one of num or hash") + errInvalidBlockRange = errors.New("invalid from and to block combination: from > to") ) type Long int64 @@ -1333,7 +1334,7 @@ func (r *Resolver) Blocks(ctx context.Context, args struct { to = rpc.BlockNumber(r.backend.CurrentBlock().Number.Int64()) } if to < from { - return []*Block{}, nil + return nil, errInvalidBlockRange } var ret []*Block for i := from; i <= to; i++ {