aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/state_transition.go
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2014-07-15 01:50:06 +0800
committerzelig <viktor.tron@gmail.com>2014-07-15 01:50:06 +0800
commit3d5db7288f134fef7e51b25776007705f6663654 (patch)
treeedda6e8fd23584327473058411df9cd2c53241f4 /ethchain/state_transition.go
parentdc11b5c55e2888a7a3dac51fedc3864d112136ce (diff)
parent8845fb7eae3e51fd3e55c47c377bf1a9e0cfe2a9 (diff)
downloaddexon-3d5db7288f134fef7e51b25776007705f6663654.tar.gz
dexon-3d5db7288f134fef7e51b25776007705f6663654.tar.zst
dexon-3d5db7288f134fef7e51b25776007705f6663654.zip
merge upstream
Diffstat (limited to 'ethchain/state_transition.go')
-rw-r--r--ethchain/state_transition.go24
1 files changed, 16 insertions, 8 deletions
diff --git a/ethchain/state_transition.go b/ethchain/state_transition.go
index 6ea9a837d..314d858f2 100644
--- a/ethchain/state_transition.go
+++ b/ethchain/state_transition.go
@@ -164,8 +164,6 @@ func (self *StateTransition) TransitionState() (err error) {
// Increment the nonce for the next transaction
sender.Nonce += 1
- receiver = self.Receiver()
-
// Transaction gas
if err = self.UseGas(GasTx); err != nil {
return
@@ -178,13 +176,23 @@ func (self *StateTransition) TransitionState() (err error) {
return
}
+ /* FIXME
+ * If tx goes TO "0", goes OOG during init, reverse changes, but initial endowment should happen. The ether is lost forever
+ */
+ var snapshot *State
+
// If the receiver is nil it's a contract (\0*32).
- if receiver == nil {
+ if tx.CreatesContract() {
+ snapshot = self.state.Copy()
+
// Create a new state object for the contract
receiver = self.MakeStateObject(self.state, tx)
+ self.rec = receiver
if receiver == nil {
return fmt.Errorf("Unable to create contract")
}
+ } else {
+ receiver = self.Receiver()
}
// Transfer value from sender to receiver
@@ -192,7 +200,9 @@ func (self *StateTransition) TransitionState() (err error) {
return
}
- //snapshot := self.state.Copy()
+ if snapshot == nil {
+ snapshot = self.state.Copy()
+ }
// Process the init code and create 'valid' contract
if IsContractAddr(self.receiver) {
@@ -203,8 +213,7 @@ func (self *StateTransition) TransitionState() (err error) {
code, err := self.Eval(receiver.Init(), receiver, "init")
if err != nil {
- //self.state.Set(snapshot)
- self.state.ResetStateObject(receiver)
+ self.state.Set(snapshot)
return fmt.Errorf("Error during init execution %v", err)
}
@@ -214,8 +223,7 @@ func (self *StateTransition) TransitionState() (err error) {
if len(receiver.Script()) > 0 {
_, err = self.Eval(receiver.Script(), receiver, "code")
if err != nil {
- //self.state.Set(snapshot)
- self.state.ResetStateObject(receiver)
+ self.state.Set(snapshot)
return fmt.Errorf("Error during code execution %v", err)
}