aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/state_transition.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-06-30 19:09:04 +0800
committerobscuren <geffobscura@gmail.com>2014-06-30 19:09:04 +0800
commit8ddd4c4c52eef9f382a321fa880adba4a1e35ee2 (patch)
tree0d9940dc0d58bad1a07e5bb41a69c3aedd6b199b /ethchain/state_transition.go
parent5a86892ecbd68c3d466cb1ef282c4cb81300abce (diff)
downloadgo-tangerine-8ddd4c4c52eef9f382a321fa880adba4a1e35ee2.tar
go-tangerine-8ddd4c4c52eef9f382a321fa880adba4a1e35ee2.tar.gz
go-tangerine-8ddd4c4c52eef9f382a321fa880adba4a1e35ee2.tar.bz2
go-tangerine-8ddd4c4c52eef9f382a321fa880adba4a1e35ee2.tar.lz
go-tangerine-8ddd4c4c52eef9f382a321fa880adba4a1e35ee2.tar.xz
go-tangerine-8ddd4c4c52eef9f382a321fa880adba4a1e35ee2.tar.zst
go-tangerine-8ddd4c4c52eef9f382a321fa880adba4a1e35ee2.zip
wip
Diffstat (limited to 'ethchain/state_transition.go')
-rw-r--r--ethchain/state_transition.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/ethchain/state_transition.go b/ethchain/state_transition.go
index f84c3486b..4b4cbeb51 100644
--- a/ethchain/state_transition.go
+++ b/ethchain/state_transition.go
@@ -1,7 +1,9 @@
package ethchain
import (
+ "bytes"
"fmt"
+ "github.com/ethereum/eth-go/ethutil"
"math/big"
)
@@ -236,6 +238,8 @@ func (self *StateTransition) transferValue(sender, receiver *StateObject) error
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
@@ -258,5 +262,46 @@ func (self *StateTransition) Eval(script []byte, context *StateObject) (ret []by
ret, _, err = closure.Call(vm, self.data, nil)
deepErr = vm.err != nil
+ /*
+ if bytes.Compare(testAddr, context.Address()) == 0 {
+ trie := context.state.trie
+ trie.NewIterator().Each(func(key string, v *ethutil.Value) {
+ v.Decode()
+ fmt.Printf("%x : %x\n", key, v.Str())
+ })
+ fmt.Println("\n\n")
+ }
+ */
+
+ Paranoia := true
+ if Paranoia {
+ var (
+ trie = context.state.trie
+ trie2 = ethutil.NewTrie(ethutil.Config.Db, "")
+ )
+
+ trie.NewIterator().Each(func(key string, v *ethutil.Value) {
+ trie2.Update(key, v.Str())
+ })
+
+ 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())
+ })
+
+ return nil, fmt.Errorf("PARANOIA: Different state object roots during copy"), false
+ }
+ }
+
return
}