From ebceb251766cc8ef165f44855b8d0c0f245f7b72 Mon Sep 17 00:00:00 2001 From: qinglin89 <316032931@qq.com> Date: Mon, 20 Jun 2022 18:47:25 +0800 Subject: [PATCH 1/2] fix:correct logic for eip check of NewEVMInterpreter --- core/vm/interpreter.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 1155037a1e..23c3cc7284 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -122,13 +122,15 @@ func NewEVMInterpreter(evm *EVM, cfg Config) *EVMInterpreter { default: jt = frontierInstructionSet } - for i, eip := range cfg.ExtraEips { - if err := EnableEIP(eip, &jt); err != nil { + for i := 0; i < len(cfg.ExtraEips); i++ { + if err := EnableEIP(cfg.ExtraEips[i], &jt); err != nil { // Disable it, so caller can check if it's activated or not cfg.ExtraEips = append(cfg.ExtraEips[:i], cfg.ExtraEips[i+1:]...) - log.Error("EIP activation failed", "eip", eip, "error", err) + i-- + log.Error("EIP activation failed", "eip", cfg.ExtraEips[i], "error", err) } } + cfg.JumpTable = jt } evmInterpreter := EVMInterpreterPool.Get().(*EVMInterpreter) From 0137f20a312ed4dc952e9ac642878ff44405e676 Mon Sep 17 00:00:00 2001 From: qinglin89 <316032931@qq.com> Date: Tue, 21 Jun 2022 12:36:59 +0800 Subject: [PATCH 2/2] refactor: cuncurrency safe for state_prefetcher --- core/vm/interpreter.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 23c3cc7284..1ecd7b3ce8 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -122,15 +122,16 @@ func NewEVMInterpreter(evm *EVM, cfg Config) *EVMInterpreter { default: jt = frontierInstructionSet } - for i := 0; i < len(cfg.ExtraEips); i++ { - if err := EnableEIP(cfg.ExtraEips[i], &jt); err != nil { + var extraEips []int + for _, eip := range cfg.ExtraEips { + if err := EnableEIP(eip, &jt); err != nil { // Disable it, so caller can check if it's activated or not - cfg.ExtraEips = append(cfg.ExtraEips[:i], cfg.ExtraEips[i+1:]...) - i-- - log.Error("EIP activation failed", "eip", cfg.ExtraEips[i], "error", err) + log.Error("EIP activation failed", "eip", eip, "error", err) + } else { + extraEips = append(extraEips, eip) } } - + cfg.ExtraEips = extraEips cfg.JumpTable = jt } evmInterpreter := EVMInterpreterPool.Get().(*EVMInterpreter)