From 66d5f67616fa64b56234223711da5861d2c4cd5d Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Tue, 20 Feb 2024 22:18:00 +0100 Subject: [PATCH] combine conditions --- core/vm/instructions.go | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 73af956dbe..2289c8ea70 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -518,10 +518,8 @@ func opSload(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]by } func opSstore(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) { - if interpreter.evm.TxContext.Is5806 { - if scope.Contract.CodeHash == types.EmptyCodeHash || scope.Contract.CodeHash == (common.Hash{}) { - return nil, ErrEip5806Write - } + if interpreter.evm.TxContext.Is5806 && (scope.Contract.CodeHash == (common.Hash{}) || scope.Contract.CodeHash == types.EmptyCodeHash) { + return nil, ErrEip5806Write } if interpreter.readOnly { return nil, ErrWriteProtection @@ -578,10 +576,8 @@ func opGas(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte } func opCreate(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) { - if interpreter.evm.TxContext.Is5806 { - if scope.Contract.CodeHash == types.EmptyCodeHash || scope.Contract.CodeHash == (common.Hash{}) { - return nil, ErrEip5806Write - } + if interpreter.evm.TxContext.Is5806 && (scope.Contract.CodeHash == (common.Hash{}) || scope.Contract.CodeHash == types.EmptyCodeHash) { + return nil, ErrEip5806Write } if interpreter.readOnly { return nil, ErrWriteProtection @@ -805,10 +801,8 @@ func opStop(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byt } func opSelfdestruct(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) { - if interpreter.evm.TxContext.Is5806 { - if scope.Contract.CodeHash == types.EmptyCodeHash || scope.Contract.CodeHash == (common.Hash{}) { - return nil, ErrEip5806Write - } + if interpreter.evm.TxContext.Is5806 && (scope.Contract.CodeHash == (common.Hash{}) || scope.Contract.CodeHash == types.EmptyCodeHash) { + return nil, ErrEip5806Write } if interpreter.readOnly { return nil, ErrWriteProtection @@ -825,10 +819,8 @@ func opSelfdestruct(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext } func opSelfdestruct6780(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) { - if interpreter.evm.TxContext.Is5806 { - if scope.Contract.CodeHash == types.EmptyCodeHash || scope.Contract.CodeHash == (common.Hash{}) { - return nil, ErrEip5806Write - } + if interpreter.evm.TxContext.Is5806 && (scope.Contract.CodeHash == (common.Hash{}) || scope.Contract.CodeHash == types.EmptyCodeHash) { + return nil, ErrEip5806Write } if interpreter.readOnly { return nil, ErrWriteProtection