Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
8ddd4c4c
Commit
8ddd4c4c
authored
Jun 30, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
5a86892e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
2 deletions
+59
-2
state_manager.go
ethchain/state_manager.go
+2
-1
state_object.go
ethchain/state_object.go
+4
-1
state_transition.go
ethchain/state_transition.go
+45
-0
value.go
ethutil/value.go
+8
-0
No files found.
ethchain/state_manager.go
View file @
8ddd4c4c
...
...
@@ -3,6 +3,7 @@ package ethchain
import
(
"bytes"
"container/list"
"fmt"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire"
...
...
@@ -200,7 +201,7 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) {
}
if
!
block
.
State
()
.
Cmp
(
state
)
{
statelogger
.
Errorf
(
"Invalid merkle root.
\n
rec: %x
\n
is: %x"
,
block
.
State
()
.
trie
.
Root
,
state
.
trie
.
Root
)
err
=
fmt
.
Errorf
(
"Invalid merkle root.
\n
rec: %x
\n
is: %x"
,
block
.
State
()
.
trie
.
Root
,
state
.
trie
.
Root
)
return
}
...
...
ethchain/state_object.go
View file @
8ddd4c4c
...
...
@@ -48,7 +48,10 @@ func MakeContract(tx *Transaction, state *State) *StateObject {
}
func
NewStateObject
(
addr
[]
byte
)
*
StateObject
{
return
&
StateObject
{
address
:
addr
,
Amount
:
new
(
big
.
Int
),
gasPool
:
new
(
big
.
Int
)}
object
:=
&
StateObject
{
address
:
addr
,
Amount
:
new
(
big
.
Int
),
gasPool
:
new
(
big
.
Int
)}
object
.
state
=
NewState
(
ethutil
.
NewTrie
(
ethutil
.
Config
.
Db
,
""
))
return
object
}
func
NewContract
(
address
[]
byte
,
Amount
*
big
.
Int
,
root
[]
byte
)
*
StateObject
{
...
...
ethchain/state_transition.go
View file @
8ddd4c4c
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
}
ethutil/value.go
View file @
8ddd4c4c
...
...
@@ -116,6 +116,8 @@ func (val *Value) Bytes() []byte {
return
a
}
else
if
s
,
ok
:=
val
.
Val
.
(
byte
);
ok
{
return
[]
byte
{
s
}
}
else
if
s
,
ok
:=
val
.
Val
.
(
string
);
ok
{
return
[]
byte
(
s
)
}
return
[]
byte
{}
...
...
@@ -196,6 +198,12 @@ func (val *Value) Encode() []byte {
return
Encode
(
val
.
Val
)
}
// Assume that the data we have is encoded
func
(
self
*
Value
)
Decode
()
{
v
,
_
:=
Decode
(
self
.
Bytes
(),
0
)
self
.
Val
=
v
}
func
NewValueFromBytes
(
data
[]
byte
)
*
Value
{
if
len
(
data
)
!=
0
{
data
,
_
:=
Decode
(
data
,
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment