refactor implementation of opcode restriction

This commit is contained in:
Hadrien Croubois 2024-03-07 18:41:40 +01:00
parent 0a6941be8e
commit 82ba7bfac6
No known key found for this signature in database
GPG key ID: B53810561A746A06
2 changed files with 6 additions and 6 deletions

View file

@ -423,7 +423,7 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error {
if dec.To == nil { if dec.To == nil {
return errors.New("missing required field 'to' in transaction") return errors.New("missing required field 'to' in transaction")
} }
itx.To = *dec.To itx.To = dec.To
if dec.Gas == nil { if dec.Gas == nil {
return errors.New("missing required field 'gas' for txdata") return errors.New("missing required field 'gas' for txdata")
} }

View file

@ -520,7 +520,7 @@ func opSload(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]by
} }
func opSstore(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) { func opSstore(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
if interpreter.evm.TxContext.Is5806 && (scope.Contract.CodeHash == (common.Hash{}) || scope.Contract.CodeHash == types.EmptyCodeHash) { if interpreter.evm.TxContext.Is5806 && interpreter.evm.Origin == scope.Contract.self.Address() {
return nil, ErrEip5806Write return nil, ErrEip5806Write
} }
if interpreter.readOnly { if interpreter.readOnly {
@ -578,7 +578,7 @@ func opGas(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte
} }
func opCreate(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) { func opCreate(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
if interpreter.evm.TxContext.Is5806 && (scope.Contract.CodeHash == (common.Hash{}) || scope.Contract.CodeHash == types.EmptyCodeHash) { if interpreter.evm.TxContext.Is5806 && interpreter.evm.Origin == scope.Contract.self.Address() {
return nil, ErrEip5806Write return nil, ErrEip5806Write
} }
if interpreter.readOnly { if interpreter.readOnly {
@ -622,7 +622,7 @@ func opCreate(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]b
} }
func opCreate2(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) { func opCreate2(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
if interpreter.evm.TxContext.Is5806 && (scope.Contract.CodeHash == (common.Hash{}) || scope.Contract.CodeHash == types.EmptyCodeHash) { if interpreter.evm.TxContext.Is5806 && interpreter.evm.Origin == scope.Contract.self.Address() {
return nil, ErrEip5806Write return nil, ErrEip5806Write
} }
if interpreter.readOnly { if interpreter.readOnly {
@ -806,7 +806,7 @@ func opStop(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byt
} }
func opSelfdestruct(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) { func opSelfdestruct(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
if interpreter.evm.TxContext.Is5806 && (scope.Contract.CodeHash == (common.Hash{}) || scope.Contract.CodeHash == types.EmptyCodeHash) { if interpreter.evm.TxContext.Is5806 && interpreter.evm.Origin == scope.Contract.self.Address() {
return nil, ErrEip5806Write return nil, ErrEip5806Write
} }
if interpreter.readOnly { if interpreter.readOnly {
@ -824,7 +824,7 @@ func opSelfdestruct(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext
} }
func opSelfdestruct6780(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) { func opSelfdestruct6780(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
if interpreter.evm.TxContext.Is5806 && (scope.Contract.CodeHash == (common.Hash{}) || scope.Contract.CodeHash == types.EmptyCodeHash) { if interpreter.evm.TxContext.Is5806 && interpreter.evm.Origin == scope.Contract.self.Address() {
return nil, ErrEip5806Write return nil, ErrEip5806Write
} }
if interpreter.readOnly { if interpreter.readOnly {