aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-10-11 06:41:37 +0800
committerobscuren <geffobscura@gmail.com>2014-10-11 06:41:37 +0800
commit2e894b668a2bde3eb83418cfd9128f3a571e0026 (patch)
tree2c9cae400a364929dce7e3c9a8112ebf053ddab6
parentcb845b9bc84dada9d03eb9d9cb9ccfa96c7ce06c (diff)
downloadgo-tangerine-2e894b668a2bde3eb83418cfd9128f3a571e0026.tar
go-tangerine-2e894b668a2bde3eb83418cfd9128f3a571e0026.tar.gz
go-tangerine-2e894b668a2bde3eb83418cfd9128f3a571e0026.tar.bz2
go-tangerine-2e894b668a2bde3eb83418cfd9128f3a571e0026.tar.lz
go-tangerine-2e894b668a2bde3eb83418cfd9128f3a571e0026.tar.xz
go-tangerine-2e894b668a2bde3eb83418cfd9128f3a571e0026.tar.zst
go-tangerine-2e894b668a2bde3eb83418cfd9128f3a571e0026.zip
Max callstack
-rw-r--r--ethchain/block.go2
-rw-r--r--ethvm/vm.go13
2 files changed, 11 insertions, 4 deletions
diff --git a/ethchain/block.go b/ethchain/block.go
index 72dc5b55a..0fb01ea5b 100644
--- a/ethchain/block.go
+++ b/ethchain/block.go
@@ -348,7 +348,7 @@ func NewUncleBlockFromValue(header *ethutil.Value) *Block {
return block
}
-func (block *Block) Trie() *ethrie.Trie {
+func (block *Block) Trie() *ethtrie.Trie {
return block.state.Trie
}
diff --git a/ethvm/vm.go b/ethvm/vm.go
index 97adedbed..0c9fa6f14 100644
--- a/ethvm/vm.go
+++ b/ethvm/vm.go
@@ -12,6 +12,8 @@ import (
// Shortcut :-)
var To256 = ethutil.To256
+const MaxCallDepth = 1024
+
type Debugger interface {
BreakHook(step int, op OpCode, mem *Memory, stack *Stack, object *ethstate.StateObject) bool
StepHook(step int, op OpCode, mem *Memory, stack *Stack, object *ethstate.StateObject) bool
@@ -37,6 +39,8 @@ type Vm struct {
Fn string
Recoverable bool
+
+ depth int
}
type Environment interface {
@@ -80,6 +84,8 @@ func u256(n int64) *big.Int {
}
func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
+ self.depth++
+
if self.Recoverable {
// Recover from any require exception
defer func() {
@@ -766,9 +772,6 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
// Generate a new address
addr := ethcrypto.CreateAddress(closure.Address(), closure.object.Nonce)
- //for i := uint64(0); self.env.State().GetStateObject(addr) != nil; i++ {
- // ethcrypto.CreateAddress(closure.Address(), closure.object.Nonce+i)
- //}
closure.object.Nonce++
self.Printf(" (*) %x", addr).Endl()
@@ -953,6 +956,10 @@ func (self *Execution) Exec(codeAddr []byte, caller ClosureRef) (ret []byte, err
ret = p.Call(self.input)
}
} else {
+ if self.vm.depth == MaxCallDepth {
+ return nil, fmt.Errorf("Max call depth exceeded (%d)", MaxCallDepth)
+ }
+
// Retrieve the executing code
code := self.vm.env.State().GetCode(codeAddr)