diff options
author | obscuren <geffobscura@gmail.com> | 2014-12-18 06:58:52 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-12-18 06:58:52 +0800 |
commit | 4dbdcaecb117d7e1fcaf0869f5d4602312552991 (patch) | |
tree | 2da5cc7174f2f0a26f6c5aa20d079f94858e24cb /core/execution.go | |
parent | b1c58b76a9588a90db5a773a997bb70265c378d3 (diff) | |
download | dexon-4dbdcaecb117d7e1fcaf0869f5d4602312552991.tar dexon-4dbdcaecb117d7e1fcaf0869f5d4602312552991.tar.gz dexon-4dbdcaecb117d7e1fcaf0869f5d4602312552991.tar.bz2 dexon-4dbdcaecb117d7e1fcaf0869f5d4602312552991.tar.lz dexon-4dbdcaecb117d7e1fcaf0869f5d4602312552991.tar.xz dexon-4dbdcaecb117d7e1fcaf0869f5d4602312552991.tar.zst dexon-4dbdcaecb117d7e1fcaf0869f5d4602312552991.zip |
Moved pre-compiled, moved depth check
* Depth check has been moved to the execution
* Pre compiled execution has been moved to the VM
* PrecompiledAddress has been renamed to PrecompiledAccount
Diffstat (limited to 'core/execution.go')
-rw-r--r-- | core/execution.go | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/core/execution.go b/core/execution.go index 58d46c509..827e1ee0e 100644 --- a/core/execution.go +++ b/core/execution.go @@ -4,7 +4,6 @@ import ( "fmt" "math/big" - "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/vm" ) @@ -36,6 +35,11 @@ func (self *Execution) exec(code, contextAddr []byte, caller vm.ClosureRef) (ret env := self.vm.Env() chainlogger.Debugf("pre state %x\n", env.State().Root()) + if self.vm.Env().Depth() == vm.MaxCallDepth { + // Consume all gas (by not returning it) and return a depth error + return nil, vm.DepthError{} + } + from, to := env.State().GetStateObject(caller.Address()), env.State().GetOrNewStateObject(self.address) // Skipping transfer is used on testing for the initial call if !self.SkipTransfer { @@ -50,24 +54,14 @@ func (self *Execution) exec(code, contextAddr []byte, caller vm.ClosureRef) (ret snapshot := env.State().Copy() defer func() { - if vm.IsDepthErr(err) || vm.IsOOGErr(err) { + if /*vm.IsDepthErr(err) ||*/ vm.IsOOGErr(err) { env.State().Set(snapshot) } chainlogger.Debugf("post state %x\n", env.State().Root()) }() self.object = to - // Pre-compiled contracts (address.go) 1, 2 & 3. - naddr := ethutil.BigD(contextAddr).Uint64() - if p := vm.Precompiled[naddr]; p != nil { - if self.Gas.Cmp(p.Gas(len(self.input))) >= 0 { - ret = p.Call(self.input) - self.vm.Printf("NATIVE_FUNC(%x) => %x", naddr, ret) - self.vm.Endl() - } - } else { - ret, err = self.vm.Run(to, caller, code, self.value, self.Gas, self.price, self.input) - } + ret, err = self.vm.Run(to, caller, code, self.value, self.Gas, self.price, self.input) return } |