aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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)