Fixed state reset case
This commit is contained in:
parent
42bb3d8aae
commit
b01cb2406f
@ -67,11 +67,19 @@ func (self *State) Empty() {
|
|||||||
func (self *State) Update() {
|
func (self *State) Update() {
|
||||||
for _, stateObject := range self.stateObjects {
|
for _, stateObject := range self.stateObjects {
|
||||||
if stateObject.remove {
|
if stateObject.remove {
|
||||||
self.trie.Delete(string(stateObject.Address()))
|
self.DeleteStateObject(stateObject)
|
||||||
} else {
|
} else {
|
||||||
|
println(ethutil.Bytes2Hex(stateObject.Address()))
|
||||||
self.UpdateStateObject(stateObject)
|
self.UpdateStateObject(stateObject)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME trie delete is broken
|
||||||
|
valid, t2 := ethtrie.ParanoiaCheck(self.trie)
|
||||||
|
if !valid {
|
||||||
|
self.trie = t2
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Purges the current trie.
|
// Purges the current trie.
|
||||||
@ -100,6 +108,12 @@ func (self *State) UpdateStateObject(stateObject *StateObject) {
|
|||||||
self.manifest.AddObjectChange(stateObject)
|
self.manifest.AddObjectChange(stateObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *State) DeleteStateObject(stateObject *StateObject) {
|
||||||
|
self.trie.Delete(string(stateObject.Address()))
|
||||||
|
|
||||||
|
delete(self.stateObjects, string(stateObject.Address()))
|
||||||
|
}
|
||||||
|
|
||||||
func (self *State) GetStateObject(addr []byte) *StateObject {
|
func (self *State) GetStateObject(addr []byte) *StateObject {
|
||||||
stateObject := self.stateObjects[string(addr)]
|
stateObject := self.stateObjects[string(addr)]
|
||||||
if stateObject != nil {
|
if stateObject != nil {
|
||||||
|
@ -84,6 +84,7 @@ func NewStateObjectFromBytes(address, data []byte) *StateObject {
|
|||||||
|
|
||||||
func (self *StateObject) MarkForDeletion() {
|
func (self *StateObject) MarkForDeletion() {
|
||||||
self.remove = true
|
self.remove = true
|
||||||
|
statelogger.Infof("%x: #%d %v (deletion)\n", self.Address(), self.Nonce, self.Amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *StateObject) GetAddr(addr []byte) *ethutil.Value {
|
func (c *StateObject) GetAddr(addr []byte) *ethutil.Value {
|
||||||
|
@ -176,15 +176,23 @@ func (self *StateTransition) TransitionState() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
receiver = self.Receiver()
|
/* 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 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
|
// Create a new state object for the contract
|
||||||
receiver = self.MakeStateObject(self.state, tx)
|
receiver = self.MakeStateObject(self.state, tx)
|
||||||
|
self.rec = receiver
|
||||||
if receiver == nil {
|
if receiver == nil {
|
||||||
return fmt.Errorf("Unable to create contract")
|
return fmt.Errorf("Unable to create contract")
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
receiver = self.Receiver()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transfer value from sender to receiver
|
// Transfer value from sender to receiver
|
||||||
@ -192,7 +200,9 @@ func (self *StateTransition) TransitionState() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
snapshot := self.state.Copy()
|
if snapshot == nil {
|
||||||
|
snapshot = self.state.Copy()
|
||||||
|
}
|
||||||
|
|
||||||
// Process the init code and create 'valid' contract
|
// Process the init code and create 'valid' contract
|
||||||
if IsContractAddr(self.receiver) {
|
if IsContractAddr(self.receiver) {
|
||||||
|
Loading…
Reference in New Issue
Block a user