From acf4b5753fd473f048176a12c42e1b8209035b57 Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 9 Dec 2014 20:27:57 +0100 Subject: Core changes * Code = '' if gas < len(D) * 5 * Sha3 gas 10 + 10 * len(D), rounding up 32 bytes * Sha256 gas 50 + 50 * len(D), rounding up 32 bytes * Ripmed gas 50 + 50 * len(D), rounding up 32 bytes * Accounts and value transfers no longer reverted --- core/execution.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'core') diff --git a/core/execution.go b/core/execution.go index 9f9d9a5d9..5176f7351 100644 --- a/core/execution.go +++ b/core/execution.go @@ -34,8 +34,14 @@ func (self *Execution) Call(codeAddr []byte, caller vm.ClosureRef) ([]byte, erro func (self *Execution) exec(code, caddr []byte, caller vm.ClosureRef) (ret []byte, err error) { env := self.vm.Env() - chainlogger.Debugf("pre state %x\n", env.State().Root()) + + 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 { + err = env.Transfer(from, to, self.value) + } + snapshot := env.State().Copy() defer func() { if vm.IsDepthErr(err) || vm.IsOOGErr(err) { @@ -44,12 +50,6 @@ func (self *Execution) exec(code, caddr []byte, caller vm.ClosureRef) (ret []byt chainlogger.Debugf("post state %x\n", env.State().Root()) }() - 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 { - err = env.Transfer(from, to, self.value) - } - if err != nil { caller.ReturnGas(self.Gas, self.price) @@ -59,7 +59,7 @@ func (self *Execution) exec(code, caddr []byte, caller vm.ClosureRef) (ret []byt // Pre-compiled contracts (address.go) 1, 2 & 3. naddr := ethutil.BigD(caddr).Uint64() if p := vm.Precompiled[naddr]; p != nil { - if self.Gas.Cmp(p.Gas) >= 0 { + 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() -- cgit v1.2.3