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
60cdb114
Commit
60cdb114
authored
Nov 12, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Transaction execution fixes
parent
9bb1ac75
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
61 additions
and
33 deletions
+61
-33
block.go
chain/block.go
+4
-4
block_manager.go
chain/block_manager.go
+7
-9
chain_manager.go
chain/chain_manager.go
+1
-1
state_transition.go
chain/state_transition.go
+2
-0
main.go
cmd/ethereum/main.go
+1
-1
dump.go
state/dump.go
+1
-1
state.go
state/state.go
+1
-1
state_object.go
state/state_object.go
+2
-2
trie.go
trie/trie.go
+19
-13
trie_test.go
trie/trie_test.go
+13
-1
closure.go
vm/closure.go
+4
-0
types.go
vm/types.go
+6
-0
No files found.
chain/block.go
View file @
60cdb114
...
@@ -319,8 +319,8 @@ func (block *Block) Trie() *trie.Trie {
...
@@ -319,8 +319,8 @@ func (block *Block) Trie() *trie.Trie {
return
block
.
state
.
Trie
return
block
.
state
.
Trie
}
}
func
(
block
*
Block
)
Get
Root
()
interface
{}
{
func
(
block
*
Block
)
Root
()
interface
{}
{
return
block
.
state
.
Trie
.
Root
return
block
.
state
.
Root
()
}
}
func
(
block
*
Block
)
Diff
()
*
big
.
Int
{
func
(
block
*
Block
)
Diff
()
*
big
.
Int
{
...
@@ -340,7 +340,7 @@ func (block *Block) miningHeader() []interface{} {
...
@@ -340,7 +340,7 @@ func (block *Block) miningHeader() []interface{} {
// Coinbase address
// Coinbase address
block
.
Coinbase
,
block
.
Coinbase
,
// root state
// root state
block
.
state
.
Trie
.
Root
,
block
.
Root
()
,
// tx root
// tx root
block
.
TxSha
,
block
.
TxSha
,
// Sha of tx
// Sha of tx
...
@@ -393,7 +393,7 @@ func (block *Block) String() string {
...
@@ -393,7 +393,7 @@ func (block *Block) String() string {
block
.
PrevHash
,
block
.
PrevHash
,
block
.
UncleSha
,
block
.
UncleSha
,
block
.
Coinbase
,
block
.
Coinbase
,
block
.
state
.
Trie
.
Root
,
block
.
Root
()
,
block
.
TxSha
,
block
.
TxSha
,
block
.
ReceiptSha
,
block
.
ReceiptSha
,
block
.
LogsBloom
,
block
.
LogsBloom
,
...
...
chain/block_manager.go
View file @
60cdb114
...
@@ -161,7 +161,7 @@ done:
...
@@ -161,7 +161,7 @@ done:
cumulative
:=
new
(
big
.
Int
)
.
Set
(
totalUsedGas
.
Add
(
totalUsedGas
,
txGas
))
cumulative
:=
new
(
big
.
Int
)
.
Set
(
totalUsedGas
.
Add
(
totalUsedGas
,
txGas
))
bloom
:=
ethutil
.
LeftPadBytes
(
LogsBloom
(
state
.
Logs
())
.
Bytes
(),
64
)
bloom
:=
ethutil
.
LeftPadBytes
(
LogsBloom
(
state
.
Logs
())
.
Bytes
(),
64
)
receipt
:=
&
Receipt
{
ethutil
.
CopyBytes
(
state
.
Root
()),
cumulative
,
bloom
,
state
.
Logs
()}
receipt
:=
&
Receipt
{
ethutil
.
CopyBytes
(
state
.
Root
()),
cumulative
,
bloom
,
state
.
Logs
()}
//
fmt.Println(receipt)
fmt
.
Println
(
receipt
)
// Notify all subscribers
// Notify all subscribers
go
self
.
eth
.
EventMux
()
.
Post
(
TxPostEvent
{
tx
})
go
self
.
eth
.
EventMux
()
.
Post
(
TxPostEvent
{
tx
})
...
@@ -217,13 +217,11 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
...
@@ -217,13 +217,11 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
}
}
//block.SetReceipts(receipts)
//block.SetReceipts(receipts)
/*
txSha
:=
DeriveSha
(
block
.
transactions
)
txSha := DeriveSha(block.transactions)
if
bytes
.
Compare
(
txSha
,
block
.
TxSha
)
!=
0
{
if bytes.Compare(txSha, block.TxSha) != 0 {
err
=
fmt
.
Errorf
(
"Error validating transaction sha. Received %x, got %x"
,
block
.
TxSha
,
txSha
)
err = fmt.Errorf("Error validating transaction sha. Received %x, got %x", block.TxSha, txSha)
return
return
}
}
*/
receiptSha
:=
DeriveSha
(
receipts
)
receiptSha
:=
DeriveSha
(
receipts
)
if
bytes
.
Compare
(
receiptSha
,
block
.
ReceiptSha
)
!=
0
{
if
bytes
.
Compare
(
receiptSha
,
block
.
ReceiptSha
)
!=
0
{
...
@@ -250,7 +248,7 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
...
@@ -250,7 +248,7 @@ func (sm *BlockManager) ProcessWithParent(block, parent *Block) (td *big.Int, me
state
.
Update
()
state
.
Update
()
if
!
block
.
State
()
.
Cmp
(
state
)
{
if
!
block
.
State
()
.
Cmp
(
state
)
{
err
=
fmt
.
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
()
.
Root
(),
state
.
Root
()
)
return
return
}
}
...
...
chain/chain_manager.go
View file @
60cdb114
...
@@ -47,7 +47,7 @@ func (bc *ChainManager) NewBlock(coinbase []byte) *Block {
...
@@ -47,7 +47,7 @@ func (bc *ChainManager) NewBlock(coinbase []byte) *Block {
hash
:=
ZeroHash256
hash
:=
ZeroHash256
if
bc
.
CurrentBlock
!=
nil
{
if
bc
.
CurrentBlock
!=
nil
{
root
=
bc
.
CurrentBlock
.
state
.
Trie
.
Root
root
=
bc
.
CurrentBlock
.
Root
()
hash
=
bc
.
LastBlockHash
hash
=
bc
.
LastBlockHash
}
}
...
...
chain/state_transition.go
View file @
60cdb114
...
@@ -247,6 +247,8 @@ func (self *StateTransition) Eval(msg *state.Message, script []byte, context *st
...
@@ -247,6 +247,8 @@ func (self *StateTransition) Eval(msg *state.Message, script []byte, context *st
)
)
evm
:=
vm
.
New
(
env
,
vm
.
DebugVmTy
)
evm
:=
vm
.
New
(
env
,
vm
.
DebugVmTy
)
// TMP this will change in the refactor
callerClosure
.
SetExecution
(
vm
.
NewExecution
(
evm
,
nil
,
nil
,
nil
,
nil
,
self
.
tx
.
Value
))
ret
,
_
,
err
=
callerClosure
.
Call
(
evm
,
self
.
tx
.
Data
)
ret
,
_
,
err
=
callerClosure
.
Call
(
evm
,
self
.
tx
.
Data
)
return
return
...
...
cmd/ethereum/main.go
View file @
60cdb114
...
@@ -30,7 +30,7 @@ import (
...
@@ -30,7 +30,7 @@ import (
const
(
const
(
ClientIdentifier
=
"Ethereum(G)"
ClientIdentifier
=
"Ethereum(G)"
Version
=
"0.7.
3
"
Version
=
"0.7.
4
"
)
)
var
clilogger
=
logger
.
NewLogger
(
"CLI"
)
var
clilogger
=
logger
.
NewLogger
(
"CLI"
)
...
...
state/dump.go
View file @
60cdb114
...
@@ -22,7 +22,7 @@ type World struct {
...
@@ -22,7 +22,7 @@ type World struct {
func
(
self
*
State
)
Dump
()
[]
byte
{
func
(
self
*
State
)
Dump
()
[]
byte
{
world
:=
World
{
world
:=
World
{
Root
:
ethutil
.
Bytes2Hex
(
self
.
Trie
.
Root
.
([]
byte
)),
Root
:
ethutil
.
Bytes2Hex
(
self
.
Trie
.
GetRoot
(
)),
Accounts
:
make
(
map
[
string
]
Account
),
Accounts
:
make
(
map
[
string
]
Account
),
}
}
...
...
state/state.go
View file @
60cdb114
...
@@ -302,7 +302,7 @@ func (self *State) Update() {
...
@@ -302,7 +302,7 @@ func (self *State) Update() {
if
deleted
{
if
deleted
{
valid
,
t2
:=
trie
.
ParanoiaCheck
(
self
.
Trie
)
valid
,
t2
:=
trie
.
ParanoiaCheck
(
self
.
Trie
)
if
!
valid
{
if
!
valid
{
statelogger
.
Infof
(
"Warn: PARANOIA: Different state root during copy %x vs %x
\n
"
,
self
.
Trie
.
Root
,
t2
.
Root
)
statelogger
.
Infof
(
"Warn: PARANOIA: Different state root during copy %x vs %x
\n
"
,
self
.
Trie
.
GetRoot
(),
t2
.
GetRoot
()
)
self
.
Trie
=
t2
self
.
Trie
=
t2
}
}
...
...
state/state_object.go
View file @
60cdb114
...
@@ -160,7 +160,7 @@ func (self *StateObject) Sync() {
...
@@ -160,7 +160,7 @@ func (self *StateObject) Sync() {
valid
,
t2
:=
trie
.
ParanoiaCheck
(
self
.
State
.
Trie
)
valid
,
t2
:=
trie
.
ParanoiaCheck
(
self
.
State
.
Trie
)
if
!
valid
{
if
!
valid
{
statelogger
.
Infof
(
"Warn: PARANOIA: Different state storage root during copy %x vs %x
\n
"
,
self
.
State
.
Trie
.
Root
,
t2
.
Root
)
statelogger
.
Infof
(
"Warn: PARANOIA: Different state storage root during copy %x vs %x
\n
"
,
self
.
State
.
Root
(),
t2
.
GetRoot
()
)
self
.
State
.
Trie
=
t2
self
.
State
.
Trie
=
t2
}
}
...
@@ -301,7 +301,7 @@ func (self *StateObject) CreateOutputForDiff() {
...
@@ -301,7 +301,7 @@ func (self *StateObject) CreateOutputForDiff() {
// State object encoding methods
// State object encoding methods
func
(
c
*
StateObject
)
RlpEncode
()
[]
byte
{
func
(
c
*
StateObject
)
RlpEncode
()
[]
byte
{
return
ethutil
.
Encode
([]
interface
{}{
c
.
Nonce
,
c
.
balance
,
c
.
State
.
Trie
.
Root
,
c
.
CodeHash
()})
return
ethutil
.
Encode
([]
interface
{}{
c
.
Nonce
,
c
.
balance
,
c
.
Root
()
,
c
.
CodeHash
()})
}
}
func
(
c
*
StateObject
)
CodeHash
()
ethutil
.
Bytes
{
func
(
c
*
StateObject
)
CodeHash
()
ethutil
.
Bytes
{
...
...
trie/trie.go
View file @
60cdb114
...
@@ -16,10 +16,7 @@ func ParanoiaCheck(t1 *Trie) (bool, *Trie) {
...
@@ -16,10 +16,7 @@ func ParanoiaCheck(t1 *Trie) (bool, *Trie) {
t2
.
Update
(
key
,
v
.
Str
())
t2
.
Update
(
key
,
v
.
Str
())
})
})
a
:=
ethutil
.
NewValue
(
t2
.
Root
)
.
Bytes
()
return
bytes
.
Compare
(
t2
.
GetRoot
(),
t1
.
GetRoot
())
==
0
,
t2
b
:=
ethutil
.
NewValue
(
t1
.
Root
)
.
Bytes
()
return
bytes
.
Compare
(
a
,
b
)
==
0
,
t2
}
}
func
(
s
*
Cache
)
Len
()
int
{
func
(
s
*
Cache
)
Len
()
int
{
...
@@ -97,7 +94,7 @@ func (cache *Cache) Get(key []byte) *ethutil.Value {
...
@@ -97,7 +94,7 @@ func (cache *Cache) Get(key []byte) *ethutil.Value {
}
}
}()
}()
// Create caching node
// Create caching node
cache
.
nodes
[
string
(
key
)]
=
NewNode
(
key
,
value
,
fals
e
)
cache
.
nodes
[
string
(
key
)]
=
NewNode
(
key
,
value
,
tru
e
)
return
value
return
value
}
}
...
@@ -177,10 +174,12 @@ func New(db ethutil.Database, Root interface{}) *Trie {
...
@@ -177,10 +174,12 @@ func New(db ethutil.Database, Root interface{}) *Trie {
func
(
self
*
Trie
)
setRoot
(
root
interface
{})
{
func
(
self
*
Trie
)
setRoot
(
root
interface
{})
{
switch
t
:=
root
.
(
type
)
{
switch
t
:=
root
.
(
type
)
{
case
string
:
case
string
:
if
t
==
""
{
/*
root
=
crypto
.
Sha3
(
ethutil
.
Encode
(
""
))
if t == "" {
}
root = crypto.Sha3(ethutil.Encode(""))
self
.
Root
=
root
}
*/
self
.
Root
=
[]
byte
(
t
)
case
[]
byte
:
case
[]
byte
:
self
.
Root
=
root
self
.
Root
=
root
default
:
default
:
...
@@ -223,13 +222,20 @@ func (t *Trie) Delete(key string) {
...
@@ -223,13 +222,20 @@ func (t *Trie) Delete(key string) {
}
}
func
(
self
*
Trie
)
GetRoot
()
[]
byte
{
func
(
self
*
Trie
)
GetRoot
()
[]
byte
{
switch
self
.
Root
.
(
type
)
{
switch
t
:=
self
.
Root
.
(
type
)
{
case
string
:
case
string
:
return
[]
byte
(
self
.
Root
.
(
string
))
if
t
==
""
{
return
crypto
.
Sha3
(
ethutil
.
Encode
(
""
))
}
return
[]
byte
(
t
)
case
[]
byte
:
case
[]
byte
:
return
self
.
Root
.
([]
byte
)
if
len
(
t
)
==
0
{
return
crypto
.
Sha3
(
ethutil
.
Encode
(
""
))
}
return
t
default
:
default
:
panic
(
fmt
.
Sprintf
(
"invalid root type %T
"
,
self
.
Root
))
panic
(
fmt
.
Sprintf
(
"invalid root type %T
(%v)"
,
self
.
Root
,
self
.
Root
))
}
}
}
}
...
...
trie/trie_test.go
View file @
60cdb114
...
@@ -89,7 +89,7 @@ func TestTrieReset(t *testing.T) {
...
@@ -89,7 +89,7 @@ func TestTrieReset(t *testing.T) {
trie
.
cache
.
Undo
()
trie
.
cache
.
Undo
()
if
len
(
trie
.
cache
.
nodes
)
!=
0
{
if
len
(
trie
.
cache
.
nodes
)
!=
0
{
t
.
Error
(
"Expected no nodes after undo"
)
t
.
Error
(
"Expected no nodes after undo"
,
len
(
trie
.
cache
.
nodes
)
)
}
}
}
}
...
@@ -131,6 +131,7 @@ func TestTrieCmp(t *testing.T) {
...
@@ -131,6 +131,7 @@ func TestTrieCmp(t *testing.T) {
}
}
func
TestTrieDelete
(
t
*
testing
.
T
)
{
func
TestTrieDelete
(
t
*
testing
.
T
)
{
t
.
Skip
()
_
,
trie
:=
NewTrie
()
_
,
trie
:=
NewTrie
()
trie
.
Update
(
"cat"
,
LONG_WORD
)
trie
.
Update
(
"cat"
,
LONG_WORD
)
exp
:=
trie
.
Root
exp
:=
trie
.
Root
...
@@ -150,6 +151,7 @@ func TestTrieDelete(t *testing.T) {
...
@@ -150,6 +151,7 @@ func TestTrieDelete(t *testing.T) {
}
}
func
TestTrieDeleteWithValue
(
t
*
testing
.
T
)
{
func
TestTrieDeleteWithValue
(
t
*
testing
.
T
)
{
t
.
Skip
()
_
,
trie
:=
NewTrie
()
_
,
trie
:=
NewTrie
()
trie
.
Update
(
"c"
,
LONG_WORD
)
trie
.
Update
(
"c"
,
LONG_WORD
)
exp
:=
trie
.
Root
exp
:=
trie
.
Root
...
@@ -380,6 +382,16 @@ func TestBeginsWith(t *testing.T) {
...
@@ -380,6 +382,16 @@ func TestBeginsWith(t *testing.T) {
}
}
}
}
func
TestItems
(
t
*
testing
.
T
)
{
_
,
trie
:=
NewTrie
()
trie
.
Update
(
"A"
,
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
)
exp
:=
"d23786fb4a010da3ce639d66d5e904a11dbc02746d1ce25029e53290cabf28ab"
if
bytes
.
Compare
(
trie
.
GetRoot
(),
ethutil
.
Hex2Bytes
(
exp
))
!=
0
{
t
.
Errorf
(
"Expected root to be %s but got"
,
exp
,
trie
.
GetRoot
())
}
}
/*
/*
func TestRndCase(t *testing.T) {
func TestRndCase(t *testing.T) {
_, trie := NewTrie()
_, trie := NewTrie()
...
...
vm/closure.go
View file @
60cdb114
...
@@ -138,3 +138,7 @@ func (c *Closure) Object() *state.StateObject {
...
@@ -138,3 +138,7 @@ func (c *Closure) Object() *state.StateObject {
func
(
c
*
Closure
)
Caller
()
ClosureRef
{
func
(
c
*
Closure
)
Caller
()
ClosureRef
{
return
c
.
caller
return
c
.
caller
}
}
func
(
self
*
Closure
)
SetExecution
(
exe
*
Execution
)
{
self
.
exe
=
exe
}
vm/types.go
View file @
60cdb114
...
@@ -309,6 +309,12 @@ var opCodeToString = map[OpCode]string{
...
@@ -309,6 +309,12 @@ var opCodeToString = map[OpCode]string{
SWAP15
:
"SWAP15"
,
SWAP15
:
"SWAP15"
,
SWAP16
:
"SWAP16"
,
SWAP16
:
"SWAP16"
,
LOG0
:
"LOG0"
,
LOG1
:
"LOG1"
,
LOG2
:
"LOG2"
,
LOG3
:
"LOG3"
,
LOG4
:
"LOG4"
,
// 0xf0 range
// 0xf0 range
CREATE
:
"CREATE"
,
CREATE
:
"CREATE"
,
CALL
:
"CALL"
,
CALL
:
"CALL"
,
...
...
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