From badb574b255ffc2463bf83686a0ff7acc53fa4dc Mon Sep 17 00:00:00 2001 From: Jerry Date: Wed, 3 May 2023 09:46:24 -0700 Subject: [PATCH] Skip looking up interruptedTxCache if it is not initialized --- core/vm/interpreter.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 398be75971..04184b95f7 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -278,6 +278,10 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool, i txHash, _ := GetCurrentTxFromContext(interruptCtx) interruptedTxCache, _ := GetCache(interruptCtx) + if interruptedTxCache == nil { + break + } + // if the tx is already in the cache, it means that it has been interrupted before and we will not interrupt it again found, _ := interruptedTxCache.Cache.ContainsOrAdd(txHash, true) if found { @@ -437,6 +441,11 @@ func (in *EVMInterpreter) RunWithDelay(contract *Contract, input []byte, readOnl case <-interruptCtx.Done(): txHash, _ := GetCurrentTxFromContext(interruptCtx) interruptedTxCache, _ := GetCache(interruptCtx) + + if interruptedTxCache == nil { + break + } + // if the tx is already in the cache, it means that it has been interrupted before and we will not interrupt it again found, _ := interruptedTxCache.Cache.ContainsOrAdd(txHash, true) log.Info("FOUND", "found", found, "txHash", txHash)