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
f298ffdb
Commit
f298ffdb
authored
Dec 04, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed State => StateDB
parent
3664cd58
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
73 additions
and
73 deletions
+73
-73
debugger.go
cmd/mist/debugger.go
+1
-1
vm_env.go
cmd/utils/vm_env.go
+3
-3
block_manager.go
core/block_manager.go
+9
-9
state_transition.go
core/state_transition.go
+3
-3
transaction_pool.go
core/transaction_pool.go
+1
-1
block.go
core/types/block.go
+2
-2
transaction.go
core/types/transaction.go
+1
-1
vm_env.go
core/vm_env.go
+3
-3
javascript_runtime.go
javascript/javascript_runtime.go
+1
-1
dump.go
state/dump.go
+1
-1
state.go
state/state.go
+34
-34
state_object.go
state/state_object.go
+1
-1
vm.go
tests/helper/vm.go
+6
-6
environment.go
vm/environment.go
+1
-1
js_types.go
xeth/js_types.go
+1
-1
pipe.go
xeth/pipe.go
+1
-1
vm_env.go
xeth/vm_env.go
+3
-3
world.go
xeth/world.go
+1
-1
No files found.
cmd/mist/debugger.go
View file @
f298ffdb
...
@@ -40,7 +40,7 @@ type DebuggerWindow struct {
...
@@ -40,7 +40,7 @@ type DebuggerWindow struct {
vm
*
vm
.
DebugVm
vm
*
vm
.
DebugVm
Db
*
Debugger
Db
*
Debugger
state
*
state
.
State
state
*
state
.
State
DB
}
}
func
NewDebuggerWindow
(
lib
*
UiLib
)
*
DebuggerWindow
{
func
NewDebuggerWindow
(
lib
*
UiLib
)
*
DebuggerWindow
{
...
...
cmd/utils/vm_env.go
View file @
f298ffdb
...
@@ -10,7 +10,7 @@ import (
...
@@ -10,7 +10,7 @@ import (
)
)
type
VMEnv
struct
{
type
VMEnv
struct
{
state
*
state
.
State
state
*
state
.
State
DB
block
*
types
.
Block
block
*
types
.
Block
transactor
[]
byte
transactor
[]
byte
...
@@ -20,7 +20,7 @@ type VMEnv struct {
...
@@ -20,7 +20,7 @@ type VMEnv struct {
Gas
*
big
.
Int
Gas
*
big
.
Int
}
}
func
NewEnv
(
state
*
state
.
State
,
block
*
types
.
Block
,
transactor
[]
byte
,
value
*
big
.
Int
)
*
VMEnv
{
func
NewEnv
(
state
*
state
.
State
DB
,
block
*
types
.
Block
,
transactor
[]
byte
,
value
*
big
.
Int
)
*
VMEnv
{
return
&
VMEnv
{
return
&
VMEnv
{
state
:
state
,
state
:
state
,
block
:
block
,
block
:
block
,
...
@@ -37,7 +37,7 @@ func (self *VMEnv) Time() int64 { return self.block.Time }
...
@@ -37,7 +37,7 @@ func (self *VMEnv) Time() int64 { return self.block.Time }
func
(
self
*
VMEnv
)
Difficulty
()
*
big
.
Int
{
return
self
.
block
.
Difficulty
}
func
(
self
*
VMEnv
)
Difficulty
()
*
big
.
Int
{
return
self
.
block
.
Difficulty
}
func
(
self
*
VMEnv
)
BlockHash
()
[]
byte
{
return
self
.
block
.
Hash
()
}
func
(
self
*
VMEnv
)
BlockHash
()
[]
byte
{
return
self
.
block
.
Hash
()
}
func
(
self
*
VMEnv
)
Value
()
*
big
.
Int
{
return
self
.
value
}
func
(
self
*
VMEnv
)
Value
()
*
big
.
Int
{
return
self
.
value
}
func
(
self
*
VMEnv
)
State
()
*
state
.
State
{
return
self
.
state
}
func
(
self
*
VMEnv
)
State
()
*
state
.
State
DB
{
return
self
.
state
}
func
(
self
*
VMEnv
)
GasLimit
()
*
big
.
Int
{
return
self
.
block
.
GasLimit
}
func
(
self
*
VMEnv
)
GasLimit
()
*
big
.
Int
{
return
self
.
block
.
GasLimit
}
func
(
self
*
VMEnv
)
Depth
()
int
{
return
self
.
depth
}
func
(
self
*
VMEnv
)
Depth
()
int
{
return
self
.
depth
}
func
(
self
*
VMEnv
)
SetDepth
(
i
int
)
{
self
.
depth
=
i
}
func
(
self
*
VMEnv
)
SetDepth
(
i
int
)
{
self
.
depth
=
i
}
...
...
core/block_manager.go
View file @
f298ffdb
...
@@ -62,10 +62,10 @@ type BlockManager struct {
...
@@ -62,10 +62,10 @@ type BlockManager struct {
// Transiently state. The trans state isn't ever saved, validated and
// Transiently state. The trans state isn't ever saved, validated and
// it could be used for setting account nonces without effecting
// it could be used for setting account nonces without effecting
// the main states.
// the main states.
transState
*
state
.
State
transState
*
state
.
State
DB
// Mining state. The mining state is used purely and solely by the mining
// Mining state. The mining state is used purely and solely by the mining
// operation.
// operation.
miningState
*
state
.
State
miningState
*
state
.
State
DB
// The last attempted block is mainly used for debugging purposes
// The last attempted block is mainly used for debugging purposes
// This does not have to be a valid block and will be set during
// This does not have to be a valid block and will be set during
...
@@ -96,19 +96,19 @@ func (self *BlockManager) Stop() {
...
@@ -96,19 +96,19 @@ func (self *BlockManager) Stop() {
statelogger
.
Debugln
(
"Stopping state manager"
)
statelogger
.
Debugln
(
"Stopping state manager"
)
}
}
func
(
sm
*
BlockManager
)
CurrentState
()
*
state
.
State
{
func
(
sm
*
BlockManager
)
CurrentState
()
*
state
.
State
DB
{
return
sm
.
eth
.
ChainManager
()
.
CurrentBlock
.
State
()
return
sm
.
eth
.
ChainManager
()
.
CurrentBlock
.
State
()
}
}
func
(
sm
*
BlockManager
)
TransState
()
*
state
.
State
{
func
(
sm
*
BlockManager
)
TransState
()
*
state
.
State
DB
{
return
sm
.
transState
return
sm
.
transState
}
}
func
(
sm
*
BlockManager
)
MiningState
()
*
state
.
State
{
func
(
sm
*
BlockManager
)
MiningState
()
*
state
.
State
DB
{
return
sm
.
miningState
return
sm
.
miningState
}
}
func
(
sm
*
BlockManager
)
NewMiningState
()
*
state
.
State
{
func
(
sm
*
BlockManager
)
NewMiningState
()
*
state
.
State
DB
{
sm
.
miningState
=
sm
.
eth
.
ChainManager
()
.
CurrentBlock
.
State
()
.
Copy
()
sm
.
miningState
=
sm
.
eth
.
ChainManager
()
.
CurrentBlock
.
State
()
.
Copy
()
return
sm
.
miningState
return
sm
.
miningState
...
@@ -118,7 +118,7 @@ func (sm *BlockManager) ChainManager() *ChainManager {
...
@@ -118,7 +118,7 @@ func (sm *BlockManager) ChainManager() *ChainManager {
return
sm
.
bc
return
sm
.
bc
}
}
func
(
sm
*
BlockManager
)
TransitionState
(
statedb
*
state
.
State
,
parent
,
block
*
types
.
Block
)
(
receipts
types
.
Receipts
,
err
error
)
{
func
(
sm
*
BlockManager
)
TransitionState
(
statedb
*
state
.
State
DB
,
parent
,
block
*
types
.
Block
)
(
receipts
types
.
Receipts
,
err
error
)
{
coinbase
:=
statedb
.
GetOrNewStateObject
(
block
.
Coinbase
)
coinbase
:=
statedb
.
GetOrNewStateObject
(
block
.
Coinbase
)
coinbase
.
SetGasPool
(
block
.
CalcGasLimit
(
parent
))
coinbase
.
SetGasPool
(
block
.
CalcGasLimit
(
parent
))
...
@@ -131,7 +131,7 @@ func (sm *BlockManager) TransitionState(statedb *state.State, parent, block *typ
...
@@ -131,7 +131,7 @@ func (sm *BlockManager) TransitionState(statedb *state.State, parent, block *typ
return
receipts
,
nil
return
receipts
,
nil
}
}
func
(
self
*
BlockManager
)
ProcessTransactions
(
coinbase
*
state
.
StateObject
,
state
*
state
.
State
,
block
,
parent
*
types
.
Block
,
txs
types
.
Transactions
)
(
types
.
Receipts
,
types
.
Transactions
,
types
.
Transactions
,
types
.
Transactions
,
error
)
{
func
(
self
*
BlockManager
)
ProcessTransactions
(
coinbase
*
state
.
StateObject
,
state
*
state
.
State
DB
,
block
,
parent
*
types
.
Block
,
txs
types
.
Transactions
)
(
types
.
Receipts
,
types
.
Transactions
,
types
.
Transactions
,
types
.
Transactions
,
error
)
{
var
(
var
(
receipts
types
.
Receipts
receipts
types
.
Receipts
handled
,
unhandled
types
.
Transactions
handled
,
unhandled
types
.
Transactions
...
@@ -342,7 +342,7 @@ func (sm *BlockManager) ValidateBlock(block, parent *types.Block) error {
...
@@ -342,7 +342,7 @@ func (sm *BlockManager) ValidateBlock(block, parent *types.Block) error {
return
nil
return
nil
}
}
func
(
sm
*
BlockManager
)
AccumelateRewards
(
statedb
*
state
.
State
,
block
,
parent
*
types
.
Block
)
error
{
func
(
sm
*
BlockManager
)
AccumelateRewards
(
statedb
*
state
.
State
DB
,
block
,
parent
*
types
.
Block
)
error
{
reward
:=
new
(
big
.
Int
)
.
Set
(
BlockReward
)
reward
:=
new
(
big
.
Int
)
.
Set
(
BlockReward
)
knownUncles
:=
ethutil
.
Set
(
parent
.
Uncles
)
knownUncles
:=
ethutil
.
Set
(
parent
.
Uncles
)
...
...
core/state_transition.go
View file @
f298ffdb
...
@@ -31,13 +31,13 @@ type StateTransition struct {
...
@@ -31,13 +31,13 @@ type StateTransition struct {
gas
,
gasPrice
*
big
.
Int
gas
,
gasPrice
*
big
.
Int
value
*
big
.
Int
value
*
big
.
Int
data
[]
byte
data
[]
byte
state
*
state
.
State
state
*
state
.
State
DB
block
*
types
.
Block
block
*
types
.
Block
cb
,
rec
,
sen
*
state
.
StateObject
cb
,
rec
,
sen
*
state
.
StateObject
}
}
func
NewStateTransition
(
coinbase
*
state
.
StateObject
,
tx
*
types
.
Transaction
,
state
*
state
.
State
,
block
*
types
.
Block
)
*
StateTransition
{
func
NewStateTransition
(
coinbase
*
state
.
StateObject
,
tx
*
types
.
Transaction
,
state
*
state
.
State
DB
,
block
*
types
.
Block
)
*
StateTransition
{
return
&
StateTransition
{
coinbase
.
Address
(),
tx
.
Recipient
,
tx
,
new
(
big
.
Int
),
new
(
big
.
Int
)
.
Set
(
tx
.
GasPrice
),
tx
.
Value
,
tx
.
Data
,
state
,
block
,
coinbase
,
nil
,
nil
}
return
&
StateTransition
{
coinbase
.
Address
(),
tx
.
Recipient
,
tx
,
new
(
big
.
Int
),
new
(
big
.
Int
)
.
Set
(
tx
.
GasPrice
),
tx
.
Value
,
tx
.
Data
,
state
,
block
,
coinbase
,
nil
,
nil
}
}
}
...
@@ -188,7 +188,7 @@ func (self *StateTransition) TransitionState() (err error) {
...
@@ -188,7 +188,7 @@ func (self *StateTransition) TransitionState() (err error) {
}
}
// Converts an transaction in to a state object
// Converts an transaction in to a state object
func
MakeContract
(
tx
*
types
.
Transaction
,
state
*
state
.
State
)
*
state
.
StateObject
{
func
MakeContract
(
tx
*
types
.
Transaction
,
state
*
state
.
State
DB
)
*
state
.
StateObject
{
addr
:=
tx
.
CreationAddress
(
state
)
addr
:=
tx
.
CreationAddress
(
state
)
contract
:=
state
.
GetOrNewStateObject
(
addr
)
contract
:=
state
.
GetOrNewStateObject
(
addr
)
...
...
core/transaction_pool.go
View file @
f298ffdb
...
@@ -186,7 +186,7 @@ func (pool *TxPool) CurrentTransactions() []*types.Transaction {
...
@@ -186,7 +186,7 @@ func (pool *TxPool) CurrentTransactions() []*types.Transaction {
return
txList
return
txList
}
}
func
(
pool
*
TxPool
)
RemoveInvalid
(
state
*
state
.
State
)
{
func
(
pool
*
TxPool
)
RemoveInvalid
(
state
*
state
.
State
DB
)
{
pool
.
mutex
.
Lock
()
pool
.
mutex
.
Lock
()
defer
pool
.
mutex
.
Unlock
()
defer
pool
.
mutex
.
Unlock
()
...
...
core/types/block.go
View file @
f298ffdb
...
@@ -77,7 +77,7 @@ type Block struct {
...
@@ -77,7 +77,7 @@ type Block struct {
Coinbase
[]
byte
Coinbase
[]
byte
// Block Trie state
// Block Trie state
//state *ethutil.Trie
//state *ethutil.Trie
state
*
state
.
State
state
*
state
.
State
DB
// Difficulty for the current block
// Difficulty for the current block
Difficulty
*
big
.
Int
Difficulty
*
big
.
Int
// Creation time
// Creation time
...
@@ -151,7 +151,7 @@ func (block *Block) HashNoNonce() []byte {
...
@@ -151,7 +151,7 @@ func (block *Block) HashNoNonce() []byte {
return
crypto
.
Sha3
(
ethutil
.
Encode
(
block
.
miningHeader
()))
return
crypto
.
Sha3
(
ethutil
.
Encode
(
block
.
miningHeader
()))
}
}
func
(
block
*
Block
)
State
()
*
state
.
State
{
func
(
block
*
Block
)
State
()
*
state
.
State
DB
{
return
block
.
state
return
block
.
state
}
}
...
...
core/types/transaction.go
View file @
f298ffdb
...
@@ -77,7 +77,7 @@ func (tx *Transaction) IsContract() bool {
...
@@ -77,7 +77,7 @@ func (tx *Transaction) IsContract() bool {
return
tx
.
CreatesContract
()
return
tx
.
CreatesContract
()
}
}
func
(
tx
*
Transaction
)
CreationAddress
(
state
*
state
.
State
)
[]
byte
{
func
(
tx
*
Transaction
)
CreationAddress
(
state
*
state
.
State
DB
)
[]
byte
{
// Generate a new address
// Generate a new address
return
crypto
.
Sha3
(
ethutil
.
NewValue
([]
interface
{}{
tx
.
Sender
(),
tx
.
Nonce
})
.
Encode
())[
12
:
]
return
crypto
.
Sha3
(
ethutil
.
NewValue
([]
interface
{}{
tx
.
Sender
(),
tx
.
Nonce
})
.
Encode
())[
12
:
]
}
}
...
...
core/vm_env.go
View file @
f298ffdb
...
@@ -9,13 +9,13 @@ import (
...
@@ -9,13 +9,13 @@ import (
)
)
type
VMEnv
struct
{
type
VMEnv
struct
{
state
*
state
.
State
state
*
state
.
State
DB
block
*
types
.
Block
block
*
types
.
Block
tx
*
types
.
Transaction
tx
*
types
.
Transaction
depth
int
depth
int
}
}
func
NewEnv
(
state
*
state
.
State
,
tx
*
types
.
Transaction
,
block
*
types
.
Block
)
*
VMEnv
{
func
NewEnv
(
state
*
state
.
State
DB
,
tx
*
types
.
Transaction
,
block
*
types
.
Block
)
*
VMEnv
{
return
&
VMEnv
{
return
&
VMEnv
{
state
:
state
,
state
:
state
,
block
:
block
,
block
:
block
,
...
@@ -31,7 +31,7 @@ func (self *VMEnv) Time() int64 { return self.block.Time }
...
@@ -31,7 +31,7 @@ func (self *VMEnv) Time() int64 { return self.block.Time }
func
(
self
*
VMEnv
)
Difficulty
()
*
big
.
Int
{
return
self
.
block
.
Difficulty
}
func
(
self
*
VMEnv
)
Difficulty
()
*
big
.
Int
{
return
self
.
block
.
Difficulty
}
func
(
self
*
VMEnv
)
BlockHash
()
[]
byte
{
return
self
.
block
.
Hash
()
}
func
(
self
*
VMEnv
)
BlockHash
()
[]
byte
{
return
self
.
block
.
Hash
()
}
func
(
self
*
VMEnv
)
Value
()
*
big
.
Int
{
return
self
.
tx
.
Value
}
func
(
self
*
VMEnv
)
Value
()
*
big
.
Int
{
return
self
.
tx
.
Value
}
func
(
self
*
VMEnv
)
State
()
*
state
.
State
{
return
self
.
state
}
func
(
self
*
VMEnv
)
State
()
*
state
.
State
DB
{
return
self
.
state
}
func
(
self
*
VMEnv
)
GasLimit
()
*
big
.
Int
{
return
self
.
block
.
GasLimit
}
func
(
self
*
VMEnv
)
GasLimit
()
*
big
.
Int
{
return
self
.
block
.
GasLimit
}
func
(
self
*
VMEnv
)
Depth
()
int
{
return
self
.
depth
}
func
(
self
*
VMEnv
)
Depth
()
int
{
return
self
.
depth
}
func
(
self
*
VMEnv
)
SetDepth
(
i
int
)
{
self
.
depth
=
i
}
func
(
self
*
VMEnv
)
SetDepth
(
i
int
)
{
self
.
depth
=
i
}
...
...
javascript/javascript_runtime.go
View file @
f298ffdb
...
@@ -128,7 +128,7 @@ func (self *JSRE) initStdFuncs() {
...
@@ -128,7 +128,7 @@ func (self *JSRE) initStdFuncs() {
*/
*/
func
(
self
*
JSRE
)
dump
(
call
otto
.
FunctionCall
)
otto
.
Value
{
func
(
self
*
JSRE
)
dump
(
call
otto
.
FunctionCall
)
otto
.
Value
{
var
state
*
state
.
State
var
state
*
state
.
State
DB
if
len
(
call
.
ArgumentList
)
>
0
{
if
len
(
call
.
ArgumentList
)
>
0
{
var
block
*
types
.
Block
var
block
*
types
.
Block
...
...
state/dump.go
View file @
f298ffdb
...
@@ -20,7 +20,7 @@ type World struct {
...
@@ -20,7 +20,7 @@ type World struct {
Accounts
map
[
string
]
Account
`json:"accounts"`
Accounts
map
[
string
]
Account
`json:"accounts"`
}
}
func
(
self
*
State
)
Dump
()
[]
byte
{
func
(
self
*
State
DB
)
Dump
()
[]
byte
{
world
:=
World
{
world
:=
World
{
Root
:
ethutil
.
Bytes2Hex
(
self
.
Trie
.
GetRoot
()),
Root
:
ethutil
.
Bytes2Hex
(
self
.
Trie
.
GetRoot
()),
Accounts
:
make
(
map
[
string
]
Account
),
Accounts
:
make
(
map
[
string
]
Account
),
...
...
state/state.go
View file @
f298ffdb
...
@@ -10,12 +10,12 @@ import (
...
@@ -10,12 +10,12 @@ import (
var
statelogger
=
logger
.
NewLogger
(
"STATE"
)
var
statelogger
=
logger
.
NewLogger
(
"STATE"
)
// States within the ethereum protocol are used to store anything
// State
DB
s within the ethereum protocol are used to store anything
// within the merkle trie. States take care of caching and storing
// within the merkle trie. State
DB
s take care of caching and storing
// nested states. It's the general query interface to retrieve:
// nested states. It's the general query interface to retrieve:
// * Contracts
// * Contracts
// * Accounts
// * Accounts
type
State
struct
{
type
State
DB
struct
{
// The trie for this structure
// The trie for this structure
Trie
*
trie
.
Trie
Trie
*
trie
.
Trie
...
@@ -29,24 +29,24 @@ type State struct {
...
@@ -29,24 +29,24 @@ type State struct {
}
}
// Create a new state from a given trie
// Create a new state from a given trie
func
New
(
trie
*
trie
.
Trie
)
*
State
{
func
New
(
trie
*
trie
.
Trie
)
*
State
DB
{
return
&
State
{
Trie
:
trie
,
stateObjects
:
make
(
map
[
string
]
*
StateObject
),
manifest
:
NewManifest
(),
refund
:
make
(
map
[
string
][]
refund
)}
return
&
State
DB
{
Trie
:
trie
,
stateObjects
:
make
(
map
[
string
]
*
StateObject
),
manifest
:
NewManifest
(),
refund
:
make
(
map
[
string
][]
refund
)}
}
}
func
(
self
*
State
)
EmptyLogs
()
{
func
(
self
*
State
DB
)
EmptyLogs
()
{
self
.
logs
=
nil
self
.
logs
=
nil
}
}
func
(
self
*
State
)
AddLog
(
log
*
Log
)
{
func
(
self
*
State
DB
)
AddLog
(
log
*
Log
)
{
self
.
logs
=
append
(
self
.
logs
,
log
)
self
.
logs
=
append
(
self
.
logs
,
log
)
}
}
func
(
self
*
State
)
Logs
()
Logs
{
func
(
self
*
State
DB
)
Logs
()
Logs
{
return
self
.
logs
return
self
.
logs
}
}
// Retrieve the balance from the given address or 0 if object not found
// Retrieve the balance from the given address or 0 if object not found
func
(
self
*
State
)
GetBalance
(
addr
[]
byte
)
*
big
.
Int
{
func
(
self
*
State
DB
)
GetBalance
(
addr
[]
byte
)
*
big
.
Int
{
stateObject
:=
self
.
GetStateObject
(
addr
)
stateObject
:=
self
.
GetStateObject
(
addr
)
if
stateObject
!=
nil
{
if
stateObject
!=
nil
{
return
stateObject
.
balance
return
stateObject
.
balance
...
@@ -59,18 +59,18 @@ type refund struct {
...
@@ -59,18 +59,18 @@ type refund struct {
gas
,
price
*
big
.
Int
gas
,
price
*
big
.
Int
}
}
func
(
self
*
State
)
Refund
(
addr
[]
byte
,
gas
,
price
*
big
.
Int
)
{
func
(
self
*
State
DB
)
Refund
(
addr
[]
byte
,
gas
,
price
*
big
.
Int
)
{
self
.
refund
[
string
(
addr
)]
=
append
(
self
.
refund
[
string
(
addr
)],
refund
{
gas
,
price
})
self
.
refund
[
string
(
addr
)]
=
append
(
self
.
refund
[
string
(
addr
)],
refund
{
gas
,
price
})
}
}
func
(
self
*
State
)
AddBalance
(
addr
[]
byte
,
amount
*
big
.
Int
)
{
func
(
self
*
State
DB
)
AddBalance
(
addr
[]
byte
,
amount
*
big
.
Int
)
{
stateObject
:=
self
.
GetStateObject
(
addr
)
stateObject
:=
self
.
GetStateObject
(
addr
)
if
stateObject
!=
nil
{
if
stateObject
!=
nil
{
stateObject
.
AddBalance
(
amount
)
stateObject
.
AddBalance
(
amount
)
}
}
}
}
func
(
self
*
State
)
GetNonce
(
addr
[]
byte
)
uint64
{
func
(
self
*
State
DB
)
GetNonce
(
addr
[]
byte
)
uint64
{
stateObject
:=
self
.
GetStateObject
(
addr
)
stateObject
:=
self
.
GetStateObject
(
addr
)
if
stateObject
!=
nil
{
if
stateObject
!=
nil
{
return
stateObject
.
Nonce
return
stateObject
.
Nonce
...
@@ -79,14 +79,14 @@ func (self *State) GetNonce(addr []byte) uint64 {
...
@@ -79,14 +79,14 @@ func (self *State) GetNonce(addr []byte) uint64 {
return
0
return
0
}
}
func
(
self
*
State
)
SetNonce
(
addr
[]
byte
,
nonce
uint64
)
{
func
(
self
*
State
DB
)
SetNonce
(
addr
[]
byte
,
nonce
uint64
)
{
stateObject
:=
self
.
GetStateObject
(
addr
)
stateObject
:=
self
.
GetStateObject
(
addr
)
if
stateObject
!=
nil
{
if
stateObject
!=
nil
{
stateObject
.
Nonce
=
nonce
stateObject
.
Nonce
=
nonce
}
}
}
}
func
(
self
*
State
)
GetCode
(
addr
[]
byte
)
[]
byte
{
func
(
self
*
State
DB
)
GetCode
(
addr
[]
byte
)
[]
byte
{
stateObject
:=
self
.
GetStateObject
(
addr
)
stateObject
:=
self
.
GetStateObject
(
addr
)
if
stateObject
!=
nil
{
if
stateObject
!=
nil
{
return
stateObject
.
Code
return
stateObject
.
Code
...
@@ -95,7 +95,7 @@ func (self *State) GetCode(addr []byte) []byte {
...
@@ -95,7 +95,7 @@ func (self *State) GetCode(addr []byte) []byte {
return
nil
return
nil
}
}
func
(
self
*
State
)
GetState
(
a
,
b
[]
byte
)
[]
byte
{
func
(
self
*
State
DB
)
GetState
(
a
,
b
[]
byte
)
[]
byte
{
stateObject
:=
self
.
GetStateObject
(
a
)
stateObject
:=
self
.
GetStateObject
(
a
)
if
stateObject
!=
nil
{
if
stateObject
!=
nil
{
return
stateObject
.
GetState
(
b
)
.
Bytes
()
return
stateObject
.
GetState
(
b
)
.
Bytes
()
...
@@ -104,14 +104,14 @@ func (self *State) GetState(a, b []byte) []byte {
...
@@ -104,14 +104,14 @@ func (self *State) GetState(a, b []byte) []byte {
return
nil
return
nil
}
}
func
(
self
*
State
)
SetState
(
addr
,
key
[]
byte
,
value
interface
{})
{
func
(
self
*
State
DB
)
SetState
(
addr
,
key
[]
byte
,
value
interface
{})
{
stateObject
:=
self
.
GetStateObject
(
addr
)
stateObject
:=
self
.
GetStateObject
(
addr
)
if
stateObject
!=
nil
{
if
stateObject
!=
nil
{
stateObject
.
SetState
(
key
,
ethutil
.
NewValue
(
value
))
stateObject
.
SetState
(
key
,
ethutil
.
NewValue
(
value
))
}
}
}
}
func
(
self
*
State
)
Delete
(
addr
[]
byte
)
bool
{
func
(
self
*
State
DB
)
Delete
(
addr
[]
byte
)
bool
{
stateObject
:=
self
.
GetStateObject
(
addr
)
stateObject
:=
self
.
GetStateObject
(
addr
)
if
stateObject
!=
nil
{
if
stateObject
!=
nil
{
stateObject
.
MarkForDeletion
()
stateObject
.
MarkForDeletion
()
...
@@ -127,7 +127,7 @@ func (self *State) Delete(addr []byte) bool {
...
@@ -127,7 +127,7 @@ func (self *State) Delete(addr []byte) bool {
//
//
// Update the given state object and apply it to state trie
// Update the given state object and apply it to state trie
func
(
self
*
State
)
UpdateStateObject
(
stateObject
*
StateObject
)
{
func
(
self
*
State
DB
)
UpdateStateObject
(
stateObject
*
StateObject
)
{
addr
:=
stateObject
.
Address
()
addr
:=
stateObject
.
Address
()
if
len
(
stateObject
.
CodeHash
())
>
0
{
if
len
(
stateObject
.
CodeHash
())
>
0
{
...
@@ -138,14 +138,14 @@ func (self *State) UpdateStateObject(stateObject *StateObject) {
...
@@ -138,14 +138,14 @@ func (self *State) UpdateStateObject(stateObject *StateObject) {
}
}
// Delete the given state object and delete it from the state trie
// Delete the given state object and delete it from the state trie
func
(
self
*
State
)
DeleteStateObject
(
stateObject
*
StateObject
)
{
func
(
self
*
State
DB
)
DeleteStateObject
(
stateObject
*
StateObject
)
{
self
.
Trie
.
Delete
(
string
(
stateObject
.
Address
()))
self
.
Trie
.
Delete
(
string
(
stateObject
.
Address
()))
delete
(
self
.
stateObjects
,
string
(
stateObject
.
Address
()))
delete
(
self
.
stateObjects
,
string
(
stateObject
.
Address
()))
}
}
// Retrieve a state object given my the address. Nil if not found
// Retrieve a state object given my the address. Nil if not found
func
(
self
*
State
)
GetStateObject
(
addr
[]
byte
)
*
StateObject
{
func
(
self
*
State
DB
)
GetStateObject
(
addr
[]
byte
)
*
StateObject
{
addr
=
ethutil
.
Address
(
addr
)
addr
=
ethutil
.
Address
(
addr
)
stateObject
:=
self
.
stateObjects
[
string
(
addr
)]
stateObject
:=
self
.
stateObjects
[
string
(
addr
)]
...
@@ -164,12 +164,12 @@ func (self *State) GetStateObject(addr []byte) *StateObject {
...
@@ -164,12 +164,12 @@ func (self *State) GetStateObject(addr []byte) *StateObject {
return
stateObject
return
stateObject
}
}
func
(
self
*
State
)
SetStateObject
(
object
*
StateObject
)
{
func
(
self
*
State
DB
)
SetStateObject
(
object
*
StateObject
)
{
self
.
stateObjects
[
string
(
object
.
address
)]
=
object
self
.
stateObjects
[
string
(
object
.
address
)]
=
object
}
}
// Retrieve a state object or create a new state object if nil
// Retrieve a state object or create a new state object if nil
func
(
self
*
State
)
GetOrNewStateObject
(
addr
[]
byte
)
*
StateObject
{
func
(
self
*
State
DB
)
GetOrNewStateObject
(
addr
[]
byte
)
*
StateObject
{
stateObject
:=
self
.
GetStateObject
(
addr
)
stateObject
:=
self
.
GetStateObject
(
addr
)
if
stateObject
==
nil
{
if
stateObject
==
nil
{
stateObject
=
self
.
NewStateObject
(
addr
)
stateObject
=
self
.
NewStateObject
(
addr
)
...
@@ -179,7 +179,7 @@ func (self *State) GetOrNewStateObject(addr []byte) *StateObject {
...
@@ -179,7 +179,7 @@ func (self *State) GetOrNewStateObject(addr []byte) *StateObject {
}
}
// Create a state object whether it exist in the trie or not
// Create a state object whether it exist in the trie or not
func
(
self
*
State
)
NewStateObject
(
addr
[]
byte
)
*
StateObject
{
func
(
self
*
State
DB
)
NewStateObject
(
addr
[]
byte
)
*
StateObject
{
addr
=
ethutil
.
Address
(
addr
)
addr
=
ethutil
.
Address
(
addr
)
statelogger
.
Debugf
(
"(+) %x
\n
"
,
addr
)
statelogger
.
Debugf
(
"(+) %x
\n
"
,
addr
)
...
@@ -191,7 +191,7 @@ func (self *State) NewStateObject(addr []byte) *StateObject {
...
@@ -191,7 +191,7 @@ func (self *State) NewStateObject(addr []byte) *StateObject {
}
}
// Deprecated
// Deprecated
func
(
self
*
State
)
GetAccount
(
addr
[]
byte
)
*
StateObject
{
func
(
self
*
State
DB
)
GetAccount
(
addr
[]
byte
)
*
StateObject
{
return
self
.
GetOrNewStateObject
(
addr
)
return
self
.
GetOrNewStateObject
(
addr
)
}
}
...
@@ -199,11 +199,11 @@ func (self *State) GetAccount(addr []byte) *StateObject {
...
@@ -199,11 +199,11 @@ func (self *State) GetAccount(addr []byte) *StateObject {
// Setting, copying of the state methods
// Setting, copying of the state methods
//
//
func
(
s
*
State
)
Cmp
(
other
*
State
)
bool
{
func
(
s
*
State
DB
)
Cmp
(
other
*
StateDB
)
bool
{
return
s
.
Trie
.
Cmp
(
other
.
Trie
)
return
s
.
Trie
.
Cmp
(
other
.
Trie
)
}
}
func
(
self
*
State
)
Copy
()
*
State
{
func
(
self
*
State
DB
)
Copy
()
*
StateDB
{
if
self
.
Trie
!=
nil
{
if
self
.
Trie
!=
nil
{
state
:=
New
(
self
.
Trie
.
Copy
())
state
:=
New
(
self
.
Trie
.
Copy
())
for
k
,
stateObject
:=
range
self
.
stateObjects
{
for
k
,
stateObject
:=
range
self
.
stateObjects
{
...
@@ -224,7 +224,7 @@ func (self *State) Copy() *State {
...
@@ -224,7 +224,7 @@ func (self *State) Copy() *State {
return
nil
return
nil
}
}
func
(
self
*
State
)
Set
(
state
*
State
)
{
func
(
self
*
State
DB
)
Set
(
state
*
StateDB
)
{
if
state
==
nil
{
if
state
==
nil
{
panic
(
"Tried setting 'state' to nil through 'Set'"
)
panic
(
"Tried setting 'state' to nil through 'Set'"
)
}
}
...
@@ -235,12 +235,12 @@ func (self *State) Set(state *State) {
...
@@ -235,12 +235,12 @@ func (self *State) Set(state *State) {
self
.
logs
=
state
.
logs
self
.
logs
=
state
.
logs
}
}
func
(
s
*
State
)
Root
()
[]
byte
{
func
(
s
*
State
DB
)
Root
()
[]
byte
{
return
s
.
Trie
.
GetRoot
()
return
s
.
Trie
.
GetRoot
()
}
}
// Resets the trie and all siblings
// Resets the trie and all siblings
func
(
s
*
State
)
Reset
()
{
func
(
s
*
State
DB
)
Reset
()
{
s
.
Trie
.
Undo
()
s
.
Trie
.
Undo
()
// Reset all nested states
// Reset all nested states
...
@@ -256,7 +256,7 @@ func (s *State) Reset() {
...
@@ -256,7 +256,7 @@ func (s *State) Reset() {
}
}
// Syncs the trie and all siblings
// Syncs the trie and all siblings
func
(
s
*
State
)
Sync
()
{
func
(
s
*
State
DB
)
Sync
()
{
// Sync all nested states
// Sync all nested states
for
_
,
stateObject
:=
range
s
.
stateObjects
{
for
_
,
stateObject
:=
range
s
.
stateObjects
{
if
stateObject
.
State
==
nil
{
if
stateObject
.
State
==
nil
{
...
@@ -271,12 +271,12 @@ func (s *State) Sync() {
...
@@ -271,12 +271,12 @@ func (s *State) Sync() {
s
.
Empty
()
s
.
Empty
()
}
}
func
(
self
*
State
)
Empty
()
{
func
(
self
*
State
DB
)
Empty
()
{
self
.
stateObjects
=
make
(
map
[
string
]
*
StateObject
)
self
.
stateObjects
=
make
(
map
[
string
]
*
StateObject
)
self
.
refund
=
make
(
map
[
string
][]
refund
)
self
.
refund
=
make
(
map
[
string
][]
refund
)
}
}
func
(
self
*
State
)
Update
(
gasUsed
*
big
.
Int
)
{
func
(
self
*
State
DB
)
Update
(
gasUsed
*
big
.
Int
)
{
var
deleted
bool
var
deleted
bool
// Refund any gas that's left
// Refund any gas that's left
...
@@ -313,12 +313,12 @@ func (self *State) Update(gasUsed *big.Int) {
...
@@ -313,12 +313,12 @@ func (self *State) Update(gasUsed *big.Int) {
}
}
}
}
func
(
self
*
State
)
Manifest
()
*
Manifest
{
func
(
self
*
State
DB
)
Manifest
()
*
Manifest
{
return
self
.
manifest
return
self
.
manifest
}
}
// Debug stuff
// Debug stuff
func
(
self
*
State
)
CreateOutputForDiff
()
{
func
(
self
*
State
DB
)
CreateOutputForDiff
()
{
for
_
,
stateObject
:=
range
self
.
stateObjects
{
for
_
,
stateObject
:=
range
self
.
stateObjects
{
stateObject
.
CreateOutputForDiff
()
stateObject
.
CreateOutputForDiff
()
}
}
...
...
state/state_object.go
View file @
f298ffdb
...
@@ -35,7 +35,7 @@ type StateObject struct {
...
@@ -35,7 +35,7 @@ type StateObject struct {
codeHash
[]
byte
codeHash
[]
byte
Nonce
uint64
Nonce
uint64
// Contract related attributes
// Contract related attributes
State
*
State
State
*
State
DB
Code
Code
Code
Code
InitCode
Code
InitCode
Code
...
...
tests/helper/vm.go
View file @
f298ffdb
...
@@ -12,7 +12,7 @@ import (
...
@@ -12,7 +12,7 @@ import (
type
Env
struct
{
type
Env
struct
{
depth
int
depth
int
state
*
state
.
State
state
*
state
.
State
DB
skipTransfer
bool
skipTransfer
bool
Gas
*
big
.
Int
Gas
*
big
.
Int
...
@@ -28,13 +28,13 @@ type Env struct {
...
@@ -28,13 +28,13 @@ type Env struct {
logs
state
.
Logs
logs
state
.
Logs
}
}
func
NewEnv
(
state
*
state
.
State
)
*
Env
{
func
NewEnv
(
state
*
state
.
State
DB
)
*
Env
{
return
&
Env
{
return
&
Env
{
state
:
state
,
state
:
state
,
}
}
}
}
func
NewEnvFromMap
(
state
*
state
.
State
,
envValues
map
[
string
]
string
,
exeValues
map
[
string
]
string
)
*
Env
{
func
NewEnvFromMap
(
state
*
state
.
State
DB
,
envValues
map
[
string
]
string
,
exeValues
map
[
string
]
string
)
*
Env
{
env
:=
NewEnv
(
state
)
env
:=
NewEnv
(
state
)
env
.
origin
=
ethutil
.
Hex2Bytes
(
exeValues
[
"caller"
])
env
.
origin
=
ethutil
.
Hex2Bytes
(
exeValues
[
"caller"
])
...
@@ -55,7 +55,7 @@ func (self *Env) Coinbase() []byte { return self.coinbase }
...
@@ -55,7 +55,7 @@ func (self *Env) Coinbase() []byte { return self.coinbase }
func
(
self
*
Env
)
Time
()
int64
{
return
self
.
time
}
func
(
self
*
Env
)
Time
()
int64
{
return
self
.
time
}
func
(
self
*
Env
)
Difficulty
()
*
big
.
Int
{
return
self
.
difficulty
}
func
(
self
*
Env
)
Difficulty
()
*
big
.
Int
{
return
self
.
difficulty
}
func
(
self
*
Env
)
BlockHash
()
[]
byte
{
return
nil
}
func
(
self
*
Env
)
BlockHash
()
[]
byte
{
return
nil
}
func
(
self
*
Env
)
State
()
*
state
.
State
{
return
self
.
state
}
func
(
self
*
Env
)
State
()
*
state
.
State
DB
{
return
self
.
state
}
func
(
self
*
Env
)
GasLimit
()
*
big
.
Int
{
return
self
.
gasLimit
}
func
(
self
*
Env
)
GasLimit
()
*
big
.
Int
{
return
self
.
gasLimit
}
func
(
self
*
Env
)
AddLog
(
log
*
state
.
Log
)
{
func
(
self
*
Env
)
AddLog
(
log
*
state
.
Log
)
{
self
.
logs
=
append
(
self
.
logs
,
log
)
self
.
logs
=
append
(
self
.
logs
,
log
)
...
@@ -91,7 +91,7 @@ func (self *Env) Create(caller vm.ClosureRef, addr, data []byte, gas, price, val
...
@@ -91,7 +91,7 @@ func (self *Env) Create(caller vm.ClosureRef, addr, data []byte, gas, price, val
return
exe
.
Create
(
caller
)
return
exe
.
Create
(
caller
)
}
}
func
RunVm
(
state
*
state
.
State
,
env
,
exec
map
[
string
]
string
)
([]
byte
,
state
.
Logs
,
*
big
.
Int
,
error
)
{
func
RunVm
(
state
*
state
.
State
DB
,
env
,
exec
map
[
string
]
string
)
([]
byte
,
state
.
Logs
,
*
big
.
Int
,
error
)
{
var
(
var
(
to
=
FromHex
(
exec
[
"address"
])
to
=
FromHex
(
exec
[
"address"
])
from
=
FromHex
(
exec
[
"caller"
])
from
=
FromHex
(
exec
[
"caller"
])
...
@@ -110,7 +110,7 @@ func RunVm(state *state.State, env, exec map[string]string) ([]byte, state.Logs,
...
@@ -110,7 +110,7 @@ func RunVm(state *state.State, env, exec map[string]string) ([]byte, state.Logs,
return
ret
,
vmenv
.
logs
,
vmenv
.
Gas
,
err
return
ret
,
vmenv
.
logs
,
vmenv
.
Gas
,
err
}
}
func
RunState
(
state
*
state
.
State
,
env
,
tx
map
[
string
]
string
)
([]
byte
,
state
.
Logs
,
*
big
.
Int
,
error
)
{
func
RunState
(
state
*
state
.
State
DB
,
env
,
tx
map
[
string
]
string
)
([]
byte
,
state
.
Logs
,
*
big
.
Int
,
error
)
{
var
(
var
(
keyPair
,
_
=
crypto
.
NewKeyPairFromSec
([]
byte
(
ethutil
.
Hex2Bytes
(
tx
[
"secretKey"
])))
keyPair
,
_
=
crypto
.
NewKeyPairFromSec
([]
byte
(
ethutil
.
Hex2Bytes
(
tx
[
"secretKey"
])))
to
=
FromHex
(
tx
[
"to"
])
to
=
FromHex
(
tx
[
"to"
])
...
...
vm/environment.go
View file @
f298ffdb
...
@@ -9,7 +9,7 @@ import (
...
@@ -9,7 +9,7 @@ import (
)
)
type
Environment
interface
{
type
Environment
interface
{
State
()
*
state
.
State
State
()
*
state
.
State
DB
Origin
()
[]
byte
Origin
()
[]
byte
BlockNumber
()
*
big
.
Int
BlockNumber
()
*
big
.
Int
...
...
xeth/js_types.go
View file @
f298ffdb
...
@@ -95,7 +95,7 @@ type JSTransaction struct {
...
@@ -95,7 +95,7 @@ type JSTransaction struct {
Confirmations
int
`json:"confirmations"`
Confirmations
int
`json:"confirmations"`
}
}
func
NewJSTx
(
tx
*
types
.
Transaction
,
state
*
state
.
State
)
*
JSTransaction
{
func
NewJSTx
(
tx
*
types
.
Transaction
,
state
*
state
.
State
DB
)
*
JSTransaction
{
hash
:=
ethutil
.
Bytes2Hex
(
tx
.
Hash
())
hash
:=
ethutil
.
Bytes2Hex
(
tx
.
Hash
())
receiver
:=
ethutil
.
Bytes2Hex
(
tx
.
Recipient
)
receiver
:=
ethutil
.
Bytes2Hex
(
tx
.
Recipient
)
if
receiver
==
"0000000000000000000000000000000000000000"
{
if
receiver
==
"0000000000000000000000000000000000000000"
{
...
...
xeth/pipe.go
View file @
f298ffdb
...
@@ -16,7 +16,7 @@ import (
...
@@ -16,7 +16,7 @@ import (
var
pipelogger
=
logger
.
NewLogger
(
"XETH"
)
var
pipelogger
=
logger
.
NewLogger
(
"XETH"
)
type
VmVars
struct
{
type
VmVars
struct
{
State
*
state
.
State
State
*
state
.
State
DB
}
}
type
XEth
struct
{
type
XEth
struct
{
...
...
xeth/vm_env.go
View file @
f298ffdb
...
@@ -10,7 +10,7 @@ import (
...
@@ -10,7 +10,7 @@ import (
)
)
type
VMEnv
struct
{
type
VMEnv
struct
{
state
*
state
.
State
state
*
state
.
State
DB
block
*
types
.
Block
block
*
types
.
Block
value
*
big
.
Int
value
*
big
.
Int
sender
[]
byte
sender
[]
byte
...
@@ -18,7 +18,7 @@ type VMEnv struct {
...
@@ -18,7 +18,7 @@ type VMEnv struct {
depth
int
depth
int
}
}
func
NewEnv
(
state
*
state
.
State
,
block
*
types
.
Block
,
value
*
big
.
Int
,
sender
[]
byte
)
*
VMEnv
{
func
NewEnv
(
state
*
state
.
State
DB
,
block
*
types
.
Block
,
value
*
big
.
Int
,
sender
[]
byte
)
*
VMEnv
{
return
&
VMEnv
{
return
&
VMEnv
{
state
:
state
,
state
:
state
,
block
:
block
,
block
:
block
,
...
@@ -35,7 +35,7 @@ func (self *VMEnv) Time() int64 { return self.block.Time }
...
@@ -35,7 +35,7 @@ func (self *VMEnv) Time() int64 { return self.block.Time }
func
(
self
*
VMEnv
)
Difficulty
()
*
big
.
Int
{
return
self
.
block
.
Difficulty
}
func
(
self
*
VMEnv
)
Difficulty
()
*
big
.
Int
{
return
self
.
block
.
Difficulty
}
func
(
self
*
VMEnv
)
BlockHash
()
[]
byte
{
return
self
.
block
.
Hash
()
}
func
(
self
*
VMEnv
)
BlockHash
()
[]
byte
{
return
self
.
block
.
Hash
()
}
func
(
self
*
VMEnv
)
Value
()
*
big
.
Int
{
return
self
.
value
}
func
(
self
*
VMEnv
)
Value
()
*
big
.
Int
{
return
self
.
value
}
func
(
self
*
VMEnv
)
State
()
*
state
.
State
{
return
self
.
state
}
func
(
self
*
VMEnv
)
State
()
*
state
.
State
DB
{
return
self
.
state
}
func
(
self
*
VMEnv
)
GasLimit
()
*
big
.
Int
{
return
self
.
block
.
GasLimit
}
func
(
self
*
VMEnv
)
GasLimit
()
*
big
.
Int
{
return
self
.
block
.
GasLimit
}
func
(
self
*
VMEnv
)
Depth
()
int
{
return
self
.
depth
}
func
(
self
*
VMEnv
)
Depth
()
int
{
return
self
.
depth
}
func
(
self
*
VMEnv
)
SetDepth
(
i
int
)
{
self
.
depth
=
i
}
func
(
self
*
VMEnv
)
SetDepth
(
i
int
)
{
self
.
depth
=
i
}
...
...
xeth/world.go
View file @
f298ffdb
...
@@ -22,7 +22,7 @@ func (self *XEth) World() *World {
...
@@ -22,7 +22,7 @@ func (self *XEth) World() *World {
return
self
.
world
return
self
.
world
}
}
func
(
self
*
World
)
State
()
*
state
.
State
{
func
(
self
*
World
)
State
()
*
state
.
State
DB
{
return
self
.
pipe
.
blockManager
.
CurrentState
()
return
self
.
pipe
.
blockManager
.
CurrentState
()
}
}
...
...
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