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
37e6870f
Commit
37e6870f
authored
Feb 26, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
a1c830cd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
16 deletions
+29
-16
block_processor.go
core/block_processor.go
+6
-4
state_transition.go
core/state_transition.go
+2
-2
worker.go
miner/worker.go
+2
-2
dump.go
state/dump.go
+1
-1
state_object.go
state/state_object.go
+15
-6
vm.go
vm/vm.go
+3
-1
No files found.
core/block_processor.go
View file @
37e6870f
...
@@ -48,9 +48,8 @@ type BlockProcessor struct {
...
@@ -48,9 +48,8 @@ type BlockProcessor struct {
func
NewBlockProcessor
(
db
ethutil
.
Database
,
txpool
*
TxPool
,
chainManager
*
ChainManager
,
eventMux
*
event
.
TypeMux
)
*
BlockProcessor
{
func
NewBlockProcessor
(
db
ethutil
.
Database
,
txpool
*
TxPool
,
chainManager
*
ChainManager
,
eventMux
*
event
.
TypeMux
)
*
BlockProcessor
{
sm
:=
&
BlockProcessor
{
sm
:=
&
BlockProcessor
{
db
:
db
,
db
:
db
,
mem
:
make
(
map
[
string
]
*
big
.
Int
),
mem
:
make
(
map
[
string
]
*
big
.
Int
),
//Pow: ðash.Ethash{},
Pow
:
ezp
.
New
(),
Pow
:
ezp
.
New
(),
bc
:
chainManager
,
bc
:
chainManager
,
eventMux
:
eventMux
,
eventMux
:
eventMux
,
...
@@ -100,7 +99,8 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated
...
@@ -100,7 +99,8 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated
// Notify all subscribers
// Notify all subscribers
if
!
transientProcess
{
if
!
transientProcess
{
go
self
.
eventMux
.
Post
(
TxPostEvent
{
tx
})
go
self
.
eventMux
.
Post
(
TxPostEvent
{
tx
})
go
self
.
eventMux
.
Post
(
statedb
.
Logs
())
logs
:=
statedb
.
Logs
()
go
self
.
eventMux
.
Post
(
logs
)
}
}
return
receipt
,
txGas
,
err
return
receipt
,
txGas
,
err
...
@@ -205,6 +205,8 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big
...
@@ -205,6 +205,8 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big
receiptSha
:=
types
.
DeriveSha
(
receipts
)
receiptSha
:=
types
.
DeriveSha
(
receipts
)
if
bytes
.
Compare
(
receiptSha
,
header
.
ReceiptHash
)
!=
0
{
if
bytes
.
Compare
(
receiptSha
,
header
.
ReceiptHash
)
!=
0
{
fmt
.
Println
(
"receipts"
,
receipts
)
fmt
.
Println
(
"receipts"
,
receipts
)
state
.
Sync
()
chainlogger
.
Infof
(
"%s
\n
"
,
state
.
Dump
())
err
=
fmt
.
Errorf
(
"validating receipt root. received=%x got=%x"
,
header
.
ReceiptHash
,
receiptSha
)
err
=
fmt
.
Errorf
(
"validating receipt root. received=%x got=%x"
,
header
.
ReceiptHash
,
receiptSha
)
return
return
}
}
...
...
core/state_transition.go
View file @
37e6870f
...
@@ -126,7 +126,7 @@ func (self *StateTransition) BuyGas() error {
...
@@ -126,7 +126,7 @@ func (self *StateTransition) BuyGas() error {
self
.
AddGas
(
self
.
msg
.
Gas
())
self
.
AddGas
(
self
.
msg
.
Gas
())
self
.
initialGas
.
Set
(
self
.
msg
.
Gas
())
self
.
initialGas
.
Set
(
self
.
msg
.
Gas
())
sender
.
Sub
Amount
(
MessageGasValue
(
self
.
msg
))
sender
.
Sub
Balance
(
MessageGasValue
(
self
.
msg
))
return
nil
return
nil
}
}
...
@@ -251,7 +251,7 @@ func (self *StateTransition) RefundGas() {
...
@@ -251,7 +251,7 @@ func (self *StateTransition) RefundGas() {
coinbase
,
sender
:=
self
.
Coinbase
(),
self
.
From
()
coinbase
,
sender
:=
self
.
Coinbase
(),
self
.
From
()
// Return remaining gas
// Return remaining gas
remaining
:=
new
(
big
.
Int
)
.
Mul
(
self
.
gas
,
self
.
msg
.
GasPrice
())
remaining
:=
new
(
big
.
Int
)
.
Mul
(
self
.
gas
,
self
.
msg
.
GasPrice
())
sender
.
Add
Amount
(
remaining
)
sender
.
Add
Balance
(
remaining
)
uhalf
:=
new
(
big
.
Int
)
.
Div
(
self
.
GasUsed
(),
ethutil
.
Big2
)
uhalf
:=
new
(
big
.
Int
)
.
Div
(
self
.
GasUsed
(),
ethutil
.
Big2
)
for
addr
,
ref
:=
range
self
.
state
.
Refunds
()
{
for
addr
,
ref
:=
range
self
.
state
.
Refunds
()
{
...
...
miner/worker.go
View file @
37e6870f
...
@@ -197,7 +197,7 @@ gasLimit:
...
@@ -197,7 +197,7 @@ gasLimit:
}
}
self
.
eth
.
TxPool
()
.
RemoveSet
(
remove
)
self
.
eth
.
TxPool
()
.
RemoveSet
(
remove
)
self
.
current
.
coinbase
.
Add
Amount
(
core
.
BlockReward
)
self
.
current
.
coinbase
.
Add
Balance
(
core
.
BlockReward
)
self
.
current
.
state
.
Update
(
ethutil
.
Big0
)
self
.
current
.
state
.
Update
(
ethutil
.
Big0
)
self
.
push
()
self
.
push
()
...
@@ -225,7 +225,7 @@ func (self *worker) commitUncle(uncle *types.Header) error {
...
@@ -225,7 +225,7 @@ func (self *worker) commitUncle(uncle *types.Header) error {
}
}
uncleAccount
:=
self
.
current
.
state
.
GetAccount
(
uncle
.
Coinbase
)
uncleAccount
:=
self
.
current
.
state
.
GetAccount
(
uncle
.
Coinbase
)
uncleAccount
.
Add
Amount
(
uncleReward
)
uncleAccount
.
Add
Balance
(
uncleReward
)
self
.
current
.
coinbase
.
AddBalance
(
uncleReward
)
self
.
current
.
coinbase
.
AddBalance
(
uncleReward
)
...
...
state/dump.go
View file @
37e6870f
...
@@ -35,7 +35,7 @@ func (self *StateDB) Dump() []byte {
...
@@ -35,7 +35,7 @@ func (self *StateDB) Dump() []byte {
storageIt
:=
stateObject
.
State
.
trie
.
Iterator
()
storageIt
:=
stateObject
.
State
.
trie
.
Iterator
()
for
storageIt
.
Next
()
{
for
storageIt
.
Next
()
{
account
.
Storage
[
ethutil
.
Bytes2Hex
(
it
.
Key
)]
=
ethutil
.
Bytes2Hex
(
i
t
.
Value
)
account
.
Storage
[
ethutil
.
Bytes2Hex
(
storageIt
.
Key
)]
=
ethutil
.
Bytes2Hex
(
storageI
t
.
Value
)
}
}
world
.
Accounts
[
ethutil
.
Bytes2Hex
(
it
.
Key
)]
=
account
world
.
Accounts
[
ethutil
.
Bytes2Hex
(
it
.
Key
)]
=
account
}
}
...
...
state/state_object.go
View file @
37e6870f
...
@@ -19,6 +19,14 @@ func (self Code) String() string {
...
@@ -19,6 +19,14 @@ func (self Code) String() string {
type
Storage
map
[
string
]
*
ethutil
.
Value
type
Storage
map
[
string
]
*
ethutil
.
Value
func
(
self
Storage
)
String
()
(
str
string
)
{
for
key
,
value
:=
range
self
{
str
+=
fmt
.
Sprintf
(
"%X : %X
\n
"
,
key
,
value
.
Bytes
())
}
return
}
func
(
self
Storage
)
Copy
()
Storage
{
func
(
self
Storage
)
Copy
()
Storage
{
cpy
:=
make
(
Storage
)
cpy
:=
make
(
Storage
)
for
key
,
value
:=
range
self
{
for
key
,
value
:=
range
self
{
...
@@ -119,10 +127,9 @@ func (self *StateObject) GetStorage(key *big.Int) *ethutil.Value {
...
@@ -119,10 +127,9 @@ func (self *StateObject) GetStorage(key *big.Int) *ethutil.Value {
}
}
func
(
self
*
StateObject
)
SetStorage
(
key
*
big
.
Int
,
value
*
ethutil
.
Value
)
{
func
(
self
*
StateObject
)
SetStorage
(
key
*
big
.
Int
,
value
*
ethutil
.
Value
)
{
self
.
SetState
(
key
.
Bytes
(),
value
)
self
.
SetState
(
key
.
Bytes
(),
value
)
self
.
dirty
=
true
}
}
func
(
self
*
StateObject
)
Storage
()
map
[
string
]
*
ethutil
.
Valu
e
{
func
(
self
*
StateObject
)
Storage
()
Storag
e
{
return
self
.
storage
return
self
.
storage
}
}
...
@@ -172,20 +179,22 @@ func (c *StateObject) AddBalance(amount *big.Int) {
...
@@ -172,20 +179,22 @@ func (c *StateObject) AddBalance(amount *big.Int) {
statelogger
.
Debugf
(
"%x: #%d %v (+ %v)
\n
"
,
c
.
Address
(),
c
.
nonce
,
c
.
balance
,
amount
)
statelogger
.
Debugf
(
"%x: #%d %v (+ %v)
\n
"
,
c
.
Address
(),
c
.
nonce
,
c
.
balance
,
amount
)
}
}
func
(
c
*
StateObject
)
AddAmount
(
amount
*
big
.
Int
)
{
c
.
AddBalance
(
amount
)
}
func
(
c
*
StateObject
)
SubBalance
(
amount
*
big
.
Int
)
{
func
(
c
*
StateObject
)
SubBalance
(
amount
*
big
.
Int
)
{
c
.
SetBalance
(
new
(
big
.
Int
)
.
Sub
(
c
.
balance
,
amount
))
c
.
SetBalance
(
new
(
big
.
Int
)
.
Sub
(
c
.
balance
,
amount
))
statelogger
.
Debugf
(
"%x: #%d %v (- %v)
\n
"
,
c
.
Address
(),
c
.
nonce
,
c
.
balance
,
amount
)
statelogger
.
Debugf
(
"%x: #%d %v (- %v)
\n
"
,
c
.
Address
(),
c
.
nonce
,
c
.
balance
,
amount
)
}
}
func
(
c
*
StateObject
)
SubAmount
(
amount
*
big
.
Int
)
{
c
.
SubBalance
(
amount
)
}
func
(
c
*
StateObject
)
SetBalance
(
amount
*
big
.
Int
)
{
func
(
c
*
StateObject
)
SetBalance
(
amount
*
big
.
Int
)
{
c
.
balance
=
amount
c
.
balance
=
amount
c
.
dirty
=
true
c
.
dirty
=
true
}
}
func
(
c
*
StateObject
)
St
()
Storage
{
return
c
.
storage
}
//
//
// Gas setters and getters
// Gas setters and getters
//
//
...
@@ -198,7 +207,7 @@ func (c *StateObject) ConvertGas(gas, price *big.Int) error {
...
@@ -198,7 +207,7 @@ func (c *StateObject) ConvertGas(gas, price *big.Int) error {
return
fmt
.
Errorf
(
"insufficient amount: %v, %v"
,
c
.
balance
,
total
)
return
fmt
.
Errorf
(
"insufficient amount: %v, %v"
,
c
.
balance
,
total
)
}
}
c
.
Sub
Amount
(
total
)
c
.
Sub
Balance
(
total
)
c
.
dirty
=
true
c
.
dirty
=
true
...
@@ -221,7 +230,7 @@ func (self *StateObject) BuyGas(gas, price *big.Int) error {
...
@@ -221,7 +230,7 @@ func (self *StateObject) BuyGas(gas, price *big.Int) error {
rGas
:=
new
(
big
.
Int
)
.
Set
(
gas
)
rGas
:=
new
(
big
.
Int
)
.
Set
(
gas
)
rGas
.
Mul
(
rGas
,
price
)
rGas
.
Mul
(
rGas
,
price
)
self
.
Add
Amount
(
rGas
)
self
.
Add
Balance
(
rGas
)
self
.
dirty
=
true
self
.
dirty
=
true
...
...
vm/vm.go
View file @
37e6870f
...
@@ -54,6 +54,8 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
...
@@ -54,6 +54,8 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
err
=
fmt
.
Errorf
(
"%v"
,
r
)
err
=
fmt
.
Errorf
(
"%v"
,
r
)
}
else
{
fmt
.
Println
(
me
.
(
*
state
.
StateObject
)
.
Storage
())
}
}
}()
}()
}
}
...
@@ -727,7 +729,7 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
...
@@ -727,7 +729,7 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
self
.
Printf
(
" => (%x) %v"
,
receiver
.
Address
()[
:
4
],
balance
)
self
.
Printf
(
" => (%x) %v"
,
receiver
.
Address
()[
:
4
],
balance
)
receiver
.
Add
Amount
(
balance
)
receiver
.
Add
Balance
(
balance
)
statedb
.
Delete
(
context
.
Address
())
statedb
.
Delete
(
context
.
Address
())
fallthrough
fallthrough
...
...
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