From 77288f176c05ded046a800461239ace9e4fc1557 Mon Sep 17 00:00:00 2001 From: Dmitry <46797839+dkeysil@users.noreply.github.com> Date: Fri, 10 Feb 2023 13:48:32 +0800 Subject: [PATCH 1/2] Check if block is nil to prevent panic (#736) --- internal/ethapi/api.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index dd3ea97f5b..f5953f59c3 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -631,6 +631,10 @@ func (s *PublicBlockChainAPI) GetTransactionReceiptsByBlock(ctx context.Context, return nil, err } + if block == nil { + return nil, errors.New("block not found") + } + receipts, err := s.b.GetReceipts(ctx, block.Hash()) if err != nil { return nil, err From 0bf6c616ef23da6a5bef20915c8c14484a579085 Mon Sep 17 00:00:00 2001 From: Manav Darji Date: Mon, 13 Feb 2023 23:41:49 +0530 Subject: [PATCH 2/2] miner: use env for tracing instead of block object (#728) --- miner/worker.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/miner/worker.go b/miner/worker.go index 797e7ea980..30809cd558 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1314,9 +1314,9 @@ func (w *worker) commit(ctx context.Context, env *environment, interval func(), tracing.SetAttributes( span, - attribute.Int("number", int(block.Number().Uint64())), - attribute.String("hash", block.Hash().String()), - attribute.String("sealhash", w.engine.SealHash(block.Header()).String()), + attribute.Int("number", int(env.header.Number.Uint64())), + attribute.String("hash", env.header.Hash().String()), + attribute.String("sealhash", w.engine.SealHash(env.header).String()), attribute.Int("len of env.txs", len(env.txs)), attribute.Bool("error", err != nil), )