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
This commit is contained in:
obscuren
2014-12-09 20:27:57 +01:00
parent 76842b0df8
commit acf4b5753f
4 changed files with 40 additions and 15 deletions

View File

@ -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()