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
a0e44e32
Commit
a0e44e32
authored
Apr 04, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
basic glog
parent
60e097a5
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
47 additions
and
49 deletions
+47
-49
section.go
blockpool/section.go
+1
-1
flags.go
cmd/utils/flags.go
+0
-4
block_processor.go
core/block_processor.go
+5
-19
chain_manager.go
core/chain_manager.go
+10
-0
state_object.go
core/state/state_object.go
+15
-4
statedb.go
core/state/statedb.go
+1
-3
common.go
core/vm/common.go
+2
-4
vm.go
core/vm/vm.go
+4
-7
glog.go
logger/glog/glog.go
+1
-0
gh_test.go
tests/vm/gh_test.go
+8
-7
No files found.
blockpool/section.go
View file @
a0e44e32
...
@@ -132,7 +132,7 @@ func (self *section) addSectionToBlockChain(p *peer) {
...
@@ -132,7 +132,7 @@ func (self *section) addSectionToBlockChain(p *peer) {
}
}
self
.
bp
.
lock
.
Unlock
()
self
.
bp
.
lock
.
Unlock
()
plog
.
Info
f
(
"[%s] insert %v blocks [%v/%v] into blockchain"
,
sectionhex
(
self
),
len
(
blocks
),
hex
(
blocks
[
0
]
.
Hash
()),
hex
(
blocks
[
len
(
blocks
)
-
1
]
.
Hash
()))
plog
.
Debug
f
(
"[%s] insert %v blocks [%v/%v] into blockchain"
,
sectionhex
(
self
),
len
(
blocks
),
hex
(
blocks
[
0
]
.
Hash
()),
hex
(
blocks
[
len
(
blocks
)
-
1
]
.
Hash
()))
err
:=
self
.
bp
.
insertChain
(
blocks
)
err
:=
self
.
bp
.
insertChain
(
blocks
)
if
err
!=
nil
{
if
err
!=
nil
{
self
.
invalid
=
true
self
.
invalid
=
true
...
...
cmd/utils/flags.go
View file @
a0e44e32
...
@@ -228,10 +228,6 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
...
@@ -228,10 +228,6 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
// Set the log type
// Set the log type
glog
.
SetToStderr
(
ctx
.
GlobalBool
(
LogToStdErrFlag
.
Name
))
glog
.
SetToStderr
(
ctx
.
GlobalBool
(
LogToStdErrFlag
.
Name
))
glog
.
V
(
2
)
.
Infoln
(
"test it"
)
glog
.
V
(
3
)
.
Infoln
(
"other stuff"
)
return
&
eth
.
Config
{
return
&
eth
.
Config
{
Name
:
common
.
MakeName
(
clientID
,
version
),
Name
:
common
.
MakeName
(
clientID
,
version
),
DataDir
:
ctx
.
GlobalString
(
DataDirFlag
.
Name
),
DataDir
:
ctx
.
GlobalString
(
DataDirFlag
.
Name
),
...
...
core/block_processor.go
View file @
a0e44e32
...
@@ -165,15 +165,9 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big
...
@@ -165,15 +165,9 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big
// Create a new state based on the parent's root (e.g., create copy)
// Create a new state based on the parent's root (e.g., create copy)
state
:=
state
.
New
(
parent
.
Root
(),
sm
.
db
)
state
:=
state
.
New
(
parent
.
Root
(),
sm
.
db
)
// track (possible) uncle block
var
uncle
bool
// Block validation
// Block validation
if
err
=
sm
.
ValidateHeader
(
block
.
Header
(),
parent
.
Header
());
err
!=
nil
{
if
err
=
sm
.
ValidateHeader
(
block
.
Header
(),
parent
.
Header
());
err
!=
nil
{
if
err
!=
BlockEqualTSErr
{
return
return
}
err
=
nil
uncle
=
true
}
}
// There can be at most two uncles
// There can be at most two uncles
...
@@ -231,23 +225,14 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big
...
@@ -231,23 +225,14 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big
// Sync the current block's state to the database
// Sync the current block's state to the database
state
.
Sync
()
state
.
Sync
()
if
!
uncle
{
// Remove transactions from the pool
// Remove transactions from the pool
sm
.
txpool
.
RemoveSet
(
block
.
Transactions
())
sm
.
txpool
.
RemoveSet
(
block
.
Transactions
())
}
// This puts transactions in a extra db for rpc
// This puts transactions in a extra db for rpc
for
i
,
tx
:=
range
block
.
Transactions
()
{
for
i
,
tx
:=
range
block
.
Transactions
()
{
putTx
(
sm
.
extraDb
,
tx
,
block
,
uint64
(
i
))
putTx
(
sm
.
extraDb
,
tx
,
block
,
uint64
(
i
))
}
}
if
uncle
{
chainlogger
.
Infof
(
"found possible uncle block #%d (%x...)
\n
"
,
header
.
Number
,
block
.
Hash
()
.
Bytes
()[
0
:
4
])
return
td
,
nil
,
BlockEqualTSErr
}
else
{
chainlogger
.
Infof
(
"processed block #%d (%d TXs %d UNCs) (%x...)
\n
"
,
header
.
Number
,
len
(
block
.
Transactions
()),
len
(
block
.
Uncles
()),
block
.
Hash
()
.
Bytes
()[
0
:
4
])
}
return
td
,
state
.
Logs
(),
nil
return
td
,
state
.
Logs
(),
nil
}
}
...
@@ -272,7 +257,8 @@ func (sm *BlockProcessor) ValidateHeader(block, parent *types.Header) error {
...
@@ -272,7 +257,8 @@ func (sm *BlockProcessor) ValidateHeader(block, parent *types.Header) error {
return
fmt
.
Errorf
(
"GasLimit check failed for block %v (%v > %v)"
,
block
.
GasLimit
,
a
,
b
)
return
fmt
.
Errorf
(
"GasLimit check failed for block %v (%v > %v)"
,
block
.
GasLimit
,
a
,
b
)
}
}
if
int64
(
block
.
Time
)
>
time
.
Now
()
.
Unix
()
{
// Allow future blocks up to 4 seconds
if
int64
(
block
.
Time
)
+
4
>
time
.
Now
()
.
Unix
()
{
return
BlockFutureErr
return
BlockFutureErr
}
}
...
...
core/chain_manager.go
View file @
a0e44e32
...
@@ -12,6 +12,7 @@ import (
...
@@ -12,6 +12,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rlp"
)
)
...
@@ -494,6 +495,10 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
...
@@ -494,6 +495,10 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
queue
[
i
]
=
ChainEvent
{
block
,
logs
}
queue
[
i
]
=
ChainEvent
{
block
,
logs
}
queueEvent
.
canonicalCount
++
queueEvent
.
canonicalCount
++
if
glog
.
V
(
logger
.
Debug
)
{
glog
.
Infof
(
"inserted block #%d (%d TXs %d UNCs) (%x...)
\n
"
,
block
.
Number
(),
len
(
block
.
Transactions
()),
len
(
block
.
Uncles
()),
block
.
Hash
()
.
Bytes
()[
0
:
4
])
}
}
else
{
}
else
{
queue
[
i
]
=
ChainSideEvent
{
block
,
logs
}
queue
[
i
]
=
ChainSideEvent
{
block
,
logs
}
queueEvent
.
sideCount
++
queueEvent
.
sideCount
++
...
@@ -503,6 +508,11 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
...
@@ -503,6 +508,11 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
}
}
if
len
(
chain
)
>
0
&&
glog
.
V
(
logger
.
Info
)
{
start
,
end
:=
chain
[
0
],
chain
[
len
(
chain
)
-
1
]
glog
.
Infof
(
"imported %d blocks [%x / %x] #%v
\n
"
,
len
(
chain
),
start
.
Hash
()
.
Bytes
()[
:
4
],
end
.
Hash
()
.
Bytes
()[
:
4
],
end
.
Number
())
}
go
self
.
eventMux
.
Post
(
queueEvent
)
go
self
.
eventMux
.
Post
(
queueEvent
)
return
nil
return
nil
...
...
core/state/state_object.go
View file @
a0e44e32
...
@@ -7,6 +7,8 @@ import (
...
@@ -7,6 +7,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie"
)
)
...
@@ -121,7 +123,10 @@ func NewStateObjectFromBytes(address common.Address, data []byte, db common.Data
...
@@ -121,7 +123,10 @@ func NewStateObjectFromBytes(address common.Address, data []byte, db common.Data
func
(
self
*
StateObject
)
MarkForDeletion
()
{
func
(
self
*
StateObject
)
MarkForDeletion
()
{
self
.
remove
=
true
self
.
remove
=
true
self
.
dirty
=
true
self
.
dirty
=
true
statelogger
.
Debugf
(
"%x: #%d %v X
\n
"
,
self
.
Address
(),
self
.
nonce
,
self
.
balance
)
if
glog
.
V
(
logger
.
Debug
)
{
glog
.
Infof
(
"%x: #%d %v X
\n
"
,
self
.
Address
(),
self
.
nonce
,
self
.
balance
)
}
}
}
func
(
c
*
StateObject
)
getAddr
(
addr
common
.
Hash
)
*
common
.
Value
{
func
(
c
*
StateObject
)
getAddr
(
addr
common
.
Hash
)
*
common
.
Value
{
...
@@ -185,13 +190,17 @@ func (c *StateObject) GetInstr(pc *big.Int) *common.Value {
...
@@ -185,13 +190,17 @@ func (c *StateObject) GetInstr(pc *big.Int) *common.Value {
func
(
c
*
StateObject
)
AddBalance
(
amount
*
big
.
Int
)
{
func
(
c
*
StateObject
)
AddBalance
(
amount
*
big
.
Int
)
{
c
.
SetBalance
(
new
(
big
.
Int
)
.
Add
(
c
.
balance
,
amount
))
c
.
SetBalance
(
new
(
big
.
Int
)
.
Add
(
c
.
balance
,
amount
))
statelogger
.
Debugf
(
"%x: #%d %v (+ %v)
\n
"
,
c
.
Address
(),
c
.
nonce
,
c
.
balance
,
amount
)
if
glog
.
V
(
logger
.
Debug
)
{
glog
.
Infof
(
"%x: #%d %v (+ %v)
\n
"
,
c
.
Address
(),
c
.
nonce
,
c
.
balance
,
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
)
if
glog
.
V
(
logger
.
Debug
)
{
glog
.
Infof
(
"%x: #%d %v (- %v)
\n
"
,
c
.
Address
(),
c
.
nonce
,
c
.
balance
,
amount
)
}
}
}
func
(
c
*
StateObject
)
SetBalance
(
amount
*
big
.
Int
)
{
func
(
c
*
StateObject
)
SetBalance
(
amount
*
big
.
Int
)
{
...
@@ -225,7 +234,9 @@ func (c *StateObject) ConvertGas(gas, price *big.Int) error {
...
@@ -225,7 +234,9 @@ func (c *StateObject) ConvertGas(gas, price *big.Int) error {
func
(
self
*
StateObject
)
SetGasPool
(
gasLimit
*
big
.
Int
)
{
func
(
self
*
StateObject
)
SetGasPool
(
gasLimit
*
big
.
Int
)
{
self
.
gasPool
=
new
(
big
.
Int
)
.
Set
(
gasLimit
)
self
.
gasPool
=
new
(
big
.
Int
)
.
Set
(
gasLimit
)
statelogger
.
Debugf
(
"%x: gas (+ %v)"
,
self
.
Address
(),
self
.
gasPool
)
if
glog
.
V
(
logger
.
Debug
)
{
glog
.
Infof
(
"%x: gas (+ %v)"
,
self
.
Address
(),
self
.
gasPool
)
}
}
}
func
(
self
*
StateObject
)
BuyGas
(
gas
,
price
*
big
.
Int
)
error
{
func
(
self
*
StateObject
)
BuyGas
(
gas
,
price
*
big
.
Int
)
error
{
...
...
core/state/statedb.go
View file @
a0e44e32
...
@@ -6,12 +6,10 @@ import (
...
@@ -6,12 +6,10 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie"
"github.com/golang/glog"
)
)
var
statelogger
=
logger
.
NewLogger
(
"STATE"
)
// StateDBs within the ethereum protocol are used to store anything
// StateDBs within the ethereum protocol are used to store anything
// within the merkle trie. StateDBs take care of caching and storing
// within the merkle trie. StateDBs 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:
...
...
core/vm/common.go
View file @
a0e44e32
...
@@ -5,11 +5,9 @@ import (
...
@@ -5,11 +5,9 @@ import (
"math/big"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger
/glog
"
)
)
var
vmlogger
=
logger
.
NewLogger
(
"VM"
)
// Global Debug flag indicating Debug VM (full logging)
// Global Debug flag indicating Debug VM (full logging)
var
Debug
bool
var
Debug
bool
...
@@ -41,7 +39,7 @@ func NewVm(env Environment) VirtualMachine {
...
@@ -41,7 +39,7 @@ func NewVm(env Environment) VirtualMachine {
case
JitVmTy
:
case
JitVmTy
:
return
NewJitVm
(
env
)
return
NewJitVm
(
env
)
default
:
default
:
vmlogger
.
Infoln
(
"unsupported vm type %d"
,
env
.
VmType
())
glog
.
V
(
0
)
.
Infoln
(
"unsupported vm type %d"
,
env
.
VmType
())
fallthrough
fallthrough
case
StdVmTy
:
case
StdVmTy
:
return
New
(
env
)
return
New
(
env
)
...
...
core/vm/vm.go
View file @
a0e44e32
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params"
)
)
...
@@ -885,9 +886,7 @@ func (self *Vm) RunPrecompiled(p *PrecompiledAccount, callData []byte, context *
...
@@ -885,9 +886,7 @@ func (self *Vm) RunPrecompiled(p *PrecompiledAccount, callData []byte, context *
func
(
self
*
Vm
)
Printf
(
format
string
,
v
...
interface
{})
VirtualMachine
{
func
(
self
*
Vm
)
Printf
(
format
string
,
v
...
interface
{})
VirtualMachine
{
if
self
.
debug
{
if
self
.
debug
{
if
self
.
logTy
==
LogTyPretty
{
self
.
logStr
+=
fmt
.
Sprintf
(
format
,
v
...
)
self
.
logStr
+=
fmt
.
Sprintf
(
format
,
v
...
)
}
}
}
return
self
return
self
...
@@ -895,10 +894,8 @@ func (self *Vm) Printf(format string, v ...interface{}) VirtualMachine {
...
@@ -895,10 +894,8 @@ func (self *Vm) Printf(format string, v ...interface{}) VirtualMachine {
func
(
self
*
Vm
)
Endl
()
VirtualMachine
{
func
(
self
*
Vm
)
Endl
()
VirtualMachine
{
if
self
.
debug
{
if
self
.
debug
{
if
self
.
logTy
==
LogTyPretty
{
glog
.
V
(
0
)
.
Infoln
(
self
.
logStr
)
vmlogger
.
Infoln
(
self
.
logStr
)
self
.
logStr
=
""
self
.
logStr
=
""
}
}
}
return
self
return
self
...
...
logger/glog/glog.go
View file @
a0e44e32
...
@@ -1055,6 +1055,7 @@ func (v Verbose) Infoln(args ...interface{}) {
...
@@ -1055,6 +1055,7 @@ func (v Verbose) Infoln(args ...interface{}) {
// Infof is equivalent to the global Infof function, guarded by the value of v.
// Infof is equivalent to the global Infof function, guarded by the value of v.
// See the documentation of V for usage.
// See the documentation of V for usage.
func
(
v
Verbose
)
Infof
(
format
string
,
args
...
interface
{})
{
func
(
v
Verbose
)
Infof
(
format
string
,
args
...
interface
{})
{
fmt
.
Println
(
v
)
if
v
{
if
v
{
logging
.
printf
(
infoLog
,
format
,
args
...
)
logging
.
printf
(
infoLog
,
format
,
args
...
)
}
}
...
...
tests/vm/gh_test.go
View file @
a0e44e32
...
@@ -9,8 +9,10 @@ import (
...
@@ -9,8 +9,10 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/tests/helper"
"github.com/ethereum/go-ethereum/tests/helper"
)
)
...
@@ -80,14 +82,13 @@ func RunVmTest(p string, t *testing.T) {
...
@@ -80,14 +82,13 @@ func RunVmTest(p string, t *testing.T) {
tests
:=
make
(
map
[
string
]
VmTest
)
tests
:=
make
(
map
[
string
]
VmTest
)
helper
.
CreateFileTests
(
t
,
p
,
&
tests
)
helper
.
CreateFileTests
(
t
,
p
,
&
tests
)
vm
.
Debug
=
true
glog
.
SetV
(
4
)
glog
.
SetToStderr
(
true
)
for
name
,
test
:=
range
tests
{
for
name
,
test
:=
range
tests
{
/*
if
name
!=
"stackLimitPush32_1024"
{
vm.Debug = true
continue
helper.Logger.SetLogLevel(5)
}
if name != "Call1MB1024Calldepth" {
continue
}
*/
db
,
_
:=
ethdb
.
NewMemDatabase
()
db
,
_
:=
ethdb
.
NewMemDatabase
()
statedb
:=
state
.
New
(
common
.
Hash
{},
db
)
statedb
:=
state
.
New
(
common
.
Hash
{},
db
)
for
addr
,
account
:=
range
test
.
Pre
{
for
addr
,
account
:=
range
test
.
Pre
{
...
...
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