aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/interpreter.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2017-08-15 16:23:23 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-08-15 18:03:49 +0800
commit3d123bcde67973b57c0a9e7edc219cc2ea589443 (patch)
treee806ab2faae07184fdcdfe23488b7111e75a9057 /core/vm/interpreter.go
parent9facf6423dbd38ebd7fbd9069cbcb98b0fd243c2 (diff)
downloadgo-tangerine-3d123bcde67973b57c0a9e7edc219cc2ea589443.tar
go-tangerine-3d123bcde67973b57c0a9e7edc219cc2ea589443.tar.gz
go-tangerine-3d123bcde67973b57c0a9e7edc219cc2ea589443.tar.bz2
go-tangerine-3d123bcde67973b57c0a9e7edc219cc2ea589443.tar.lz
go-tangerine-3d123bcde67973b57c0a9e7edc219cc2ea589443.tar.xz
go-tangerine-3d123bcde67973b57c0a9e7edc219cc2ea589443.tar.zst
go-tangerine-3d123bcde67973b57c0a9e7edc219cc2ea589443.zip
core/vm: implement metropolis static call opcode
Diffstat (limited to 'core/vm/interpreter.go')
-rw-r--r--core/vm/interpreter.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go
index 3faa98704..32d764b9f 100644
--- a/core/vm/interpreter.go
+++ b/core/vm/interpreter.go
@@ -69,6 +69,8 @@ func NewInterpreter(evm *EVM, cfg Config) *Interpreter {
// we'll set the default jump table.
if !cfg.JumpTable[STOP].valid {
switch {
+ case evm.ChainConfig().IsMetropolis(evm.BlockNumber):
+ cfg.JumpTable = metropolisInstructionSet
case evm.ChainConfig().IsHomestead(evm.BlockNumber):
cfg.JumpTable = homesteadInstructionSet
default:
@@ -85,6 +87,19 @@ func NewInterpreter(evm *EVM, cfg Config) *Interpreter {
}
func (in *Interpreter) enforceRestrictions(op OpCode, operation operation, stack *Stack) error {
+ if in.evm.chainRules.IsMetropolis {
+ if in.readonly {
+ // if the interpreter is operating in readonly mode, make sure no
+ // state-modifying operation is performed. The 4th stack item
+ // for a call operation is the value. Transfering value from one
+ // account to the others means the state is modified and should also
+ // return with an error.
+ if operation.writes ||
+ ((op == CALL || op == CALLCODE) && stack.Back(3).BitLen() > 0) {
+ return errWriteProtection
+ }
+ }
+ }
return nil
}
@@ -95,6 +110,7 @@ func (in *Interpreter) enforceRestrictions(op OpCode, operation operation, stack
// considered a revert-and-consume-all-gas operation. No error specific checks
// should be handled to reduce complexity and errors further down the in.
func (in *Interpreter) Run(snapshot int, contract *Contract, input []byte) (ret []byte, err error) {
+ // Increment the call depth which is restricted to 1024
in.evm.depth++
defer func() { in.evm.depth-- }()