aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/state_transition.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-07-01 02:03:31 +0800
committerobscuren <geffobscura@gmail.com>2014-07-01 02:03:31 +0800
commited276cd7c241749a9cf8add4e2fae3d3608a7ea4 (patch)
tree40416177aeac9874e0eecdb7194db9bc13e39174 /ethchain/state_transition.go
parent82272ee08a7d72be1cc0947b6a0e8096a0353362 (diff)
downloadgo-tangerine-ed276cd7c241749a9cf8add4e2fae3d3608a7ea4.tar
go-tangerine-ed276cd7c241749a9cf8add4e2fae3d3608a7ea4.tar.gz
go-tangerine-ed276cd7c241749a9cf8add4e2fae3d3608a7ea4.tar.bz2
go-tangerine-ed276cd7c241749a9cf8add4e2fae3d3608a7ea4.tar.lz
go-tangerine-ed276cd7c241749a9cf8add4e2fae3d3608a7ea4.tar.xz
go-tangerine-ed276cd7c241749a9cf8add4e2fae3d3608a7ea4.tar.zst
go-tangerine-ed276cd7c241749a9cf8add4e2fae3d3608a7ea4.zip
Added Paranoia check for VM execution
Diffstat (limited to 'ethchain/state_transition.go')
-rw-r--r--ethchain/state_transition.go33
1 files changed, 15 insertions, 18 deletions
diff --git a/ethchain/state_transition.go b/ethchain/state_transition.go
index 4b4cbeb51..b18091691 100644
--- a/ethchain/state_transition.go
+++ b/ethchain/state_transition.go
@@ -226,20 +226,14 @@ func (self *StateTransition) transferValue(sender, receiver *StateObject) error
return fmt.Errorf("Insufficient funds to transfer value. Req %v, has %v", self.value, sender.Amount)
}
- //if self.value.Cmp(ethutil.Big0) > 0 {
// Subtract the amount from the senders account
sender.SubAmount(self.value)
// Add the amount to receivers account which should conclude this transaction
receiver.AddAmount(self.value)
- //statelogger.Debugf("%x => %x (%v)\n", sender.Address()[:4], receiver.Address()[:4], self.value)
- //}
-
return nil
}
-var testAddr = ethutil.FromHex("ec4f34c97e43fbb2816cfd95e388353c7181dab1")
-
func (self *StateTransition) Eval(script []byte, context *StateObject) (ret []byte, err error, deepErr bool) {
var (
block = self.block
@@ -263,6 +257,7 @@ func (self *StateTransition) Eval(script []byte, context *StateObject) (ret []by
deepErr = vm.err != nil
/*
+ var testAddr = ethutil.FromHex("ec4f34c97e43fbb2816cfd95e388353c7181dab1")
if bytes.Compare(testAddr, context.Address()) == 0 {
trie := context.state.trie
trie.NewIterator().Each(func(key string, v *ethutil.Value) {
@@ -273,7 +268,7 @@ func (self *StateTransition) Eval(script []byte, context *StateObject) (ret []by
}
*/
- Paranoia := true
+ Paranoia := true // TODO Create a flag for this
if Paranoia {
var (
trie = context.state.trie
@@ -287,17 +282,19 @@ func (self *StateTransition) Eval(script []byte, context *StateObject) (ret []by
a := ethutil.NewValue(trie2.Root).Bytes()
b := ethutil.NewValue(context.state.trie.Root).Bytes()
if bytes.Compare(a, b) != 0 {
- fmt.Printf("original: %x\n", trie.Root)
- trie.NewIterator().Each(func(key string, v *ethutil.Value) {
- v.Decode()
- fmt.Printf("%x : %x\n", key, v.Str())
- })
-
- fmt.Printf("new: %x\n", trie2.Root)
- trie2.NewIterator().Each(func(key string, v *ethutil.Value) {
- v.Decode()
- fmt.Printf("%x : %x\n", key, v.Str())
- })
+ /*
+ statelogger.Debugf("(o): %x\n", trie.Root)
+ trie.NewIterator().Each(func(key string, v *ethutil.Value) {
+ v.Decode()
+ statelogger.Debugf("%x : %x\n", key, v.Str())
+ })
+
+ statelogger.Debugf("(c): %x\n", trie2.Root)
+ trie2.NewIterator().Each(func(key string, v *ethutil.Value) {
+ v.Decode()
+ statelogger.Debugf("%x : %x\n", key, v.Str())
+ })
+ */
return nil, fmt.Errorf("PARANOIA: Different state object roots during copy"), false
}