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
b417766b
Commit
b417766b
authored
Oct 08, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor tweaks for poc7
parent
0015ce1e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
40 deletions
+43
-40
block_pool.go
block_pool.go
+2
-2
block_chain.go
ethchain/block_chain.go
+22
-12
state_transition.go
ethchain/state_transition.go
+0
-9
types.go
ethchain/types.go
+8
-10
js_pipe.go
ethpipe/js_pipe.go
+2
-0
pipe.go
ethpipe/pipe.go
+1
-1
state.go
ethstate/state.go
+8
-6
No files found.
block_pool.go
View file @
b417766b
...
@@ -86,7 +86,7 @@ func (self *BlockPool) Blocks() (blocks ethchain.Blocks) {
...
@@ -86,7 +86,7 @@ func (self *BlockPool) Blocks() (blocks ethchain.Blocks) {
func
(
self
*
BlockPool
)
FetchHashes
(
peer
*
Peer
)
bool
{
func
(
self
*
BlockPool
)
FetchHashes
(
peer
*
Peer
)
bool
{
highestTd
:=
self
.
eth
.
HighestTDPeer
()
highestTd
:=
self
.
eth
.
HighestTDPeer
()
if
(
self
.
peer
==
nil
&&
peer
.
td
.
Cmp
(
highestTd
)
>=
0
)
||
(
self
.
peer
!=
nil
&&
peer
.
td
.
Cmp
(
self
.
peer
.
td
)
>
=
0
)
||
self
.
peer
==
peer
{
if
(
self
.
peer
==
nil
&&
peer
.
td
.
Cmp
(
highestTd
)
>=
0
)
||
(
self
.
peer
!=
nil
&&
peer
.
td
.
Cmp
(
self
.
peer
.
td
)
>
0
)
||
self
.
peer
==
peer
{
if
self
.
peer
!=
peer
{
if
self
.
peer
!=
peer
{
poollogger
.
Debugf
(
"Found better suitable peer (%v vs %v)
\n
"
,
self
.
td
,
peer
.
td
)
poollogger
.
Debugf
(
"Found better suitable peer (%v vs %v)
\n
"
,
self
.
td
,
peer
.
td
)
...
@@ -102,7 +102,7 @@ func (self *BlockPool) FetchHashes(peer *Peer) bool {
...
@@ -102,7 +102,7 @@ func (self *BlockPool) FetchHashes(peer *Peer) bool {
peer
.
doneFetchingHashes
=
false
peer
.
doneFetchingHashes
=
false
const
amount
=
256
const
amount
=
256
peerlogger
.
Debugf
(
"Fetching hashes (%d)
\n
"
,
amount
)
peerlogger
.
Debugf
(
"Fetching hashes (%d)
%x...
\n
"
,
amount
,
peer
.
lastReceivedHash
[
0
:
4
]
)
peer
.
QueueMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgGetBlockHashesTy
,
[]
interface
{}{
peer
.
lastReceivedHash
,
uint32
(
amount
)}))
peer
.
QueueMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgGetBlockHashesTy
,
[]
interface
{}{
peer
.
lastReceivedHash
,
uint32
(
amount
)}))
}
}
...
...
ethchain/block_chain.go
View file @
b417766b
...
@@ -78,6 +78,22 @@ func (bc *BlockChain) NewBlock(coinbase []byte) *Block {
...
@@ -78,6 +78,22 @@ func (bc *BlockChain) NewBlock(coinbase []byte) *Block {
return
block
return
block
}
}
func
(
bc
*
BlockChain
)
Reset
()
{
AddTestNetFunds
(
bc
.
genesisBlock
)
bc
.
genesisBlock
.
state
.
Trie
.
Sync
()
// Prepare the genesis block
bc
.
Add
(
bc
.
genesisBlock
)
fk
:=
append
([]
byte
(
"bloom"
),
bc
.
genesisBlock
.
Hash
()
...
)
bc
.
Ethereum
.
Db
()
.
Put
(
fk
,
make
([]
byte
,
255
))
bc
.
CurrentBlock
=
bc
.
genesisBlock
bc
.
SetTotalDifficulty
(
ethutil
.
Big
(
"0"
))
// Set the last know difficulty (might be 0x0 as initial value, Genesis)
bc
.
TD
=
ethutil
.
BigD
(
ethutil
.
Config
.
Db
.
LastKnownTD
())
}
func
(
bc
*
BlockChain
)
HasBlock
(
hash
[]
byte
)
bool
{
func
(
bc
*
BlockChain
)
HasBlock
(
hash
[]
byte
)
bool
{
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
(
hash
)
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
(
hash
)
return
len
(
data
)
!=
0
return
len
(
data
)
!=
0
...
@@ -149,28 +165,22 @@ func AddTestNetFunds(block *Block) {
...
@@ -149,28 +165,22 @@ func AddTestNetFunds(block *Block) {
}
}
func
(
bc
*
BlockChain
)
setLastBlock
()
{
func
(
bc
*
BlockChain
)
setLastBlock
()
{
// Prep genesis
AddTestNetFunds
(
bc
.
genesisBlock
)
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"LastBlock"
))
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"LastBlock"
))
if
len
(
data
)
!=
0
{
if
len
(
data
)
!=
0
{
// Prep genesis
AddTestNetFunds
(
bc
.
genesisBlock
)
block
:=
NewBlockFromBytes
(
data
)
block
:=
NewBlockFromBytes
(
data
)
bc
.
CurrentBlock
=
block
bc
.
CurrentBlock
=
block
bc
.
LastBlockHash
=
block
.
Hash
()
bc
.
LastBlockHash
=
block
.
Hash
()
bc
.
LastBlockNumber
=
block
.
Number
.
Uint64
()
bc
.
LastBlockNumber
=
block
.
Number
.
Uint64
()
// Set the last know difficulty (might be 0x0 as initial value, Genesis)
bc
.
TD
=
ethutil
.
BigD
(
ethutil
.
Config
.
Db
.
LastKnownTD
())
}
else
{
}
else
{
bc
.
genesisBlock
.
state
.
Trie
.
Sync
()
bc
.
Reset
()
// Prepare the genesis block
bc
.
Add
(
bc
.
genesisBlock
)
fk
:=
append
([]
byte
(
"bloom"
),
bc
.
genesisBlock
.
Hash
()
...
)
bc
.
Ethereum
.
Db
()
.
Put
(
fk
,
make
([]
byte
,
255
))
bc
.
CurrentBlock
=
bc
.
genesisBlock
}
}
// Set the last know difficulty (might be 0x0 as initial value, Genesis)
bc
.
TD
=
ethutil
.
BigD
(
ethutil
.
Config
.
Db
.
LastKnownTD
())
chainlogger
.
Infof
(
"Last block (#%d) %x
\n
"
,
bc
.
LastBlockNumber
,
bc
.
CurrentBlock
.
Hash
())
chainlogger
.
Infof
(
"Last block (#%d) %x
\n
"
,
bc
.
LastBlockNumber
,
bc
.
CurrentBlock
.
Hash
())
}
}
...
...
ethchain/state_transition.go
View file @
b417766b
...
@@ -276,15 +276,6 @@ func (self *StateTransition) Eval(msg *ethstate.Message, script []byte, context
...
@@ -276,15 +276,6 @@ func (self *StateTransition) Eval(msg *ethstate.Message, script []byte, context
ret
,
_
,
err
=
callerClosure
.
Call
(
vm
,
self
.
tx
.
Data
)
ret
,
_
,
err
=
callerClosure
.
Call
(
vm
,
self
.
tx
.
Data
)
if
err
==
nil
{
// Execute POSTs
for
e
:=
vm
.
Queue
()
.
Front
();
e
!=
nil
;
e
=
e
.
Next
()
{
msg
:=
e
.
Value
.
(
*
ethvm
.
Message
)
msg
.
Exec
(
msg
.
Addr
(),
transactor
)
}
}
return
return
}
}
...
...
ethchain/types.go
View file @
b417766b
...
@@ -144,11 +144,10 @@ const (
...
@@ -144,11 +144,10 @@ const (
SWAP16
=
0x9f
SWAP16
=
0x9f
// 0xf0 range - closures
// 0xf0 range - closures
CREATE
=
0xf0
CREATE
=
0xf0
CALL
=
0xf1
CALL
=
0xf1
RETURN
=
0xf2
RETURN
=
0xf2
POST
=
0xf3
CALLCODE
=
0xf3
CALLSTATELESS
=
0xf4
// 0x70 range - other
// 0x70 range - other
LOG
=
0xfe
// XXX Unofficial
LOG
=
0xfe
// XXX Unofficial
...
@@ -293,11 +292,10 @@ var opCodeToString = map[OpCode]string{
...
@@ -293,11 +292,10 @@ var opCodeToString = map[OpCode]string{
SWAP16
:
"SWAP16"
,
SWAP16
:
"SWAP16"
,
// 0xf0 range
// 0xf0 range
CREATE
:
"CREATE"
,
CREATE
:
"CREATE"
,
CALL
:
"CALL"
,
CALL
:
"CALL"
,
RETURN
:
"RETURN"
,
RETURN
:
"RETURN"
,
POST
:
"POST"
,
CALLCODE
:
"CALLCODE"
,
CALLSTATELESS
:
"CALLSTATELESS"
,
// 0x70 range - other
// 0x70 range - other
LOG
:
"LOG"
,
LOG
:
"LOG"
,
...
...
ethpipe/js_pipe.go
View file @
b417766b
...
@@ -3,6 +3,7 @@ package ethpipe
...
@@ -3,6 +3,7 @@ package ethpipe
import
(
import
(
"bytes"
"bytes"
"encoding/json"
"encoding/json"
"fmt"
"sync/atomic"
"sync/atomic"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethchain"
...
@@ -92,6 +93,7 @@ func (self *JSPipe) NumberToHuman(balance string) string {
...
@@ -92,6 +93,7 @@ func (self *JSPipe) NumberToHuman(balance string) string {
}
}
func
(
self
*
JSPipe
)
StorageAt
(
addr
,
storageAddr
string
)
string
{
func
(
self
*
JSPipe
)
StorageAt
(
addr
,
storageAddr
string
)
string
{
fmt
.
Println
(
"get"
,
addr
,
storageAddr
)
storage
:=
self
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
addr
))
.
Storage
(
ethutil
.
Hex2Bytes
(
storageAddr
))
storage
:=
self
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
addr
))
.
Storage
(
ethutil
.
Hex2Bytes
(
storageAddr
))
return
ethutil
.
Bytes2Hex
(
storage
.
Bytes
())
return
ethutil
.
Bytes2Hex
(
storage
.
Bytes
())
...
...
ethpipe/pipe.go
View file @
b417766b
...
@@ -61,7 +61,7 @@ func (self *Pipe) ExecuteObject(object *Object, data []byte, value, gas, price *
...
@@ -61,7 +61,7 @@ func (self *Pipe) ExecuteObject(object *Object, data []byte, value, gas, price *
vm
:=
ethvm
.
New
(
NewEnv
(
self
.
Vm
.
State
,
block
,
value
.
BigInt
(),
initiator
.
Address
()))
vm
:=
ethvm
.
New
(
NewEnv
(
self
.
Vm
.
State
,
block
,
value
.
BigInt
(),
initiator
.
Address
()))
vm
.
Verbose
=
true
vm
.
Verbose
=
true
msg
:=
ethvm
.
New
Message
(
vm
,
object
.
Address
(),
data
,
gas
.
BigInt
(),
price
.
BigInt
(),
value
.
BigInt
())
msg
:=
ethvm
.
New
Execution
(
vm
,
object
.
Address
(),
data
,
gas
.
BigInt
(),
price
.
BigInt
(),
value
.
BigInt
())
ret
,
err
:=
msg
.
Exec
(
object
.
Address
(),
initiator
)
ret
,
err
:=
msg
.
Exec
(
object
.
Address
(),
initiator
)
fmt
.
Println
(
"returned from call"
,
ret
,
err
)
fmt
.
Println
(
"returned from call"
,
ret
,
err
)
...
...
ethstate/state.go
View file @
b417766b
...
@@ -181,8 +181,6 @@ func (s *State) Reset() {
...
@@ -181,8 +181,6 @@ func (s *State) Reset() {
func
(
s
*
State
)
Sync
()
{
func
(
s
*
State
)
Sync
()
{
// Sync all nested states
// Sync all nested states
for
_
,
stateObject
:=
range
s
.
stateObjects
{
for
_
,
stateObject
:=
range
s
.
stateObjects
{
//s.UpdateStateObject(stateObject)
if
stateObject
.
State
==
nil
{
if
stateObject
.
State
==
nil
{
continue
continue
}
}
...
@@ -200,9 +198,11 @@ func (self *State) Empty() {
...
@@ -200,9 +198,11 @@ func (self *State) Empty() {
}
}
func
(
self
*
State
)
Update
()
{
func
(
self
*
State
)
Update
()
{
var
deleted
bool
for
_
,
stateObject
:=
range
self
.
stateObjects
{
for
_
,
stateObject
:=
range
self
.
stateObjects
{
if
stateObject
.
remove
{
if
stateObject
.
remove
{
self
.
DeleteStateObject
(
stateObject
)
self
.
DeleteStateObject
(
stateObject
)
deleted
=
true
}
else
{
}
else
{
stateObject
.
Sync
()
stateObject
.
Sync
()
...
@@ -211,11 +211,13 @@ func (self *State) Update() {
...
@@ -211,11 +211,13 @@ func (self *State) Update() {
}
}
// FIXME trie delete is broken
// FIXME trie delete is broken
valid
,
t2
:=
ethtrie
.
ParanoiaCheck
(
self
.
Trie
)
if
deleted
{
if
!
valid
{
valid
,
t2
:=
ethtrie
.
ParanoiaCheck
(
self
.
Trie
)
statelogger
.
Infof
(
"Warn: PARANOIA: Different state root during copy %x vs %x
\n
"
,
self
.
Trie
.
Root
,
t2
.
Root
)
if
!
valid
{
statelogger
.
Infof
(
"Warn: PARANOIA: Different state root during copy %x vs %x
\n
"
,
self
.
Trie
.
Root
,
t2
.
Root
)
self
.
Trie
=
t2
self
.
Trie
=
t2
}
}
}
}
}
...
...
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