diff options
author | Jeffrey Wilcke <geffobscura@gmail.com> | 2016-01-20 06:50:00 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2016-02-18 17:11:48 +0800 |
commit | b6d88a0e9f9aaeb47d585d79c768d457b545af90 (patch) | |
tree | 49e667cd929ce6b561961ac741d9ff0f82e61261 /core/state_transition.go | |
parent | 4f4d2b647488eaa056613fa6f026229ac91f066a (diff) | |
download | dexon-b6d88a0e9f9aaeb47d585d79c768d457b545af90.tar dexon-b6d88a0e9f9aaeb47d585d79c768d457b545af90.tar.gz dexon-b6d88a0e9f9aaeb47d585d79c768d457b545af90.tar.bz2 dexon-b6d88a0e9f9aaeb47d585d79c768d457b545af90.tar.lz dexon-b6d88a0e9f9aaeb47d585d79c768d457b545af90.tar.xz dexon-b6d88a0e9f9aaeb47d585d79c768d457b545af90.tar.zst dexon-b6d88a0e9f9aaeb47d585d79c768d457b545af90.zip |
core, core/vm, crypto: fixes for homestead
* Removed some strange code that didn't apply state reverting properly
* Refactored code setting from vm & state transition to the executioner
* Updated tests
Diffstat (limited to 'core/state_transition.go')
-rw-r--r-- | core/state_transition.go | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/core/state_transition.go b/core/state_transition.go index 0cd226262..52a46c63d 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -21,7 +21,6 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" @@ -225,38 +224,24 @@ func (self *StateTransition) transitionDb() (ret []byte, usedGas *big.Int, err e } vmenv := self.env - snapshot := vmenv.MakeSnapshot() - var addr common.Address + //var addr common.Address if contractCreation { - ret, addr, err = vmenv.Create(sender, self.data, self.gas, self.gasPrice, self.value) - if err == nil { - dataGas := big.NewInt(int64(len(ret))) - dataGas.Mul(dataGas, params.CreateDataGas) - if err := self.useGas(dataGas); err == nil { - self.state.SetCode(addr, ret) - } else { - if homestead { - // rollback all contract creation changes except for - // sender's incremented account nonce and gas usage - // TODO: fucking gas hack... verify potential DoS vuln - accNonce := vmenv.Db().GetNonce(sender.Address()) - logs := vmenv.Db().(*state.StateDB).GetAllLogs() - vmenv.SetSnapshot(snapshot) - vmenv.Db().SetNonce(sender.Address(), accNonce) - vmenv.Db().(*state.StateDB).SetAllLogs(logs) - self.gas = Big0 - - } - ret = nil // does not affect consensus but useful for StateTests validations - glog.V(logger.Core).Infoln("Insufficient gas for creating code. Require", dataGas, "and have", self.gas) - } + ret, _, err = vmenv.Create(sender, self.data, self.gas, self.gasPrice, self.value) + if homestead && err == vm.CodeStoreOutOfGasError { + self.gas = Big0 + } + + if err != nil { + ret = nil + glog.V(logger.Core).Infoln("VM create err:", err) } - glog.V(logger.Core).Infoln("VM create err:", err) } else { // Increment the nonce for the next transaction self.state.SetNonce(sender.Address(), self.state.GetNonce(sender.Address())+1) ret, err = vmenv.Call(sender, self.to().Address(), self.data, self.gas, self.gasPrice, self.value) - glog.V(logger.Core).Infoln("VM call err:", err) + if err != nil { + glog.V(logger.Core).Infoln("VM call err:", err) + } } if err != nil && IsValueTransferErr(err) { |