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
90108576
Commit
90108576
authored
Jul 11, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Special diff output for execution
parent
ff151f9f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
8 deletions
+57
-8
asm.go
ethchain/asm.go
+4
-0
state.go
ethchain/state.go
+11
-0
state_manager.go
ethchain/state_manager.go
+8
-0
vm.go
ethchain/vm.go
+30
-7
ethereum.go
ethereum.go
+3
-1
config.go
ethutil/config.go
+1
-0
No files found.
ethchain/asm.go
View file @
90108576
...
...
@@ -24,6 +24,10 @@ func Disassemble(script []byte) (asm []string) {
case
PUSH1
,
PUSH2
,
PUSH3
,
PUSH4
,
PUSH5
,
PUSH6
,
PUSH7
,
PUSH8
,
PUSH9
,
PUSH10
,
PUSH11
,
PUSH12
,
PUSH13
,
PUSH14
,
PUSH15
,
PUSH16
,
PUSH17
,
PUSH18
,
PUSH19
,
PUSH20
,
PUSH21
,
PUSH22
,
PUSH23
,
PUSH24
,
PUSH25
,
PUSH26
,
PUSH27
,
PUSH28
,
PUSH29
,
PUSH30
,
PUSH31
,
PUSH32
:
pc
.
Add
(
pc
,
ethutil
.
Big1
)
a
:=
int64
(
op
)
-
int64
(
PUSH1
)
+
1
if
int
(
pc
.
Int64
()
+
a
)
>
len
(
script
)
{
return
nil
}
data
:=
script
[
pc
.
Int64
()
:
pc
.
Int64
()
+
a
]
if
len
(
data
)
==
0
{
data
=
[]
byte
{
0
}
...
...
ethchain/state.go
View file @
90108576
package
ethchain
import
(
"fmt"
"github.com/ethereum/eth-go/ethcrypto"
"github.com/ethereum/eth-go/ethtrie"
"github.com/ethereum/eth-go/ethutil"
...
...
@@ -208,6 +209,16 @@ func (self *State) Update() {
}
}
// Debug stuff
func
(
self
*
State
)
CreateOutputForDiff
()
{
for
addr
,
stateObject
:=
range
self
.
stateObjects
{
fmt
.
Printf
(
"0x%x 0x%x 0x%x 0x%x
\n
"
,
addr
,
stateObject
.
state
.
Root
(),
stateObject
.
Amount
.
Bytes
(),
stateObject
.
Nonce
)
stateObject
.
state
.
EachStorage
(
func
(
addr
string
,
value
*
ethutil
.
Value
)
{
fmt
.
Printf
(
"0x%x 0x%x
\n
"
,
addr
,
value
.
Bytes
())
})
}
}
// Object manifest
//
// The object manifest is used to keep changes to the state so we can keep track of the changes
...
...
ethchain/state_manager.go
View file @
90108576
...
...
@@ -150,6 +150,10 @@ done:
receipts
=
append
(
receipts
,
receipt
)
handled
=
append
(
handled
,
tx
)
if
ethutil
.
Config
.
Diff
{
state
.
CreateOutputForDiff
()
}
}
parent
.
GasUsed
=
totalUsedGas
...
...
@@ -183,6 +187,10 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) {
// before that.
defer
state
.
Reset
()
if
ethutil
.
Config
.
Diff
{
fmt
.
Printf
(
"## 0x%x 0x%x ##
\n
"
,
block
.
Hash
(),
block
.
Number
)
}
receipts
,
err
:=
sm
.
ApplyDiff
(
state
,
parent
,
block
)
defer
func
()
{
if
err
!=
nil
{
...
...
ethchain/vm.go
View file @
90108576
...
...
@@ -31,6 +31,7 @@ type Debugger interface {
BreakHook
(
step
int
,
op
OpCode
,
mem
*
Memory
,
stack
*
Stack
,
stateObject
*
StateObject
)
bool
StepHook
(
step
int
,
op
OpCode
,
mem
*
Memory
,
stack
*
Stack
,
stateObject
*
StateObject
)
bool
BreakPoints
()
[]
int64
SetCode
(
byteCode
[]
byte
)
}
type
Vm
struct
{
...
...
@@ -90,7 +91,12 @@ func (self *Vm) Endl() *Vm {
}
func
NewVm
(
state
*
State
,
stateManager
*
StateManager
,
vars
RuntimeVars
)
*
Vm
{
return
&
Vm
{
vars
:
vars
,
state
:
state
,
stateManager
:
stateManager
,
logTy
:
LogTyPretty
}
lt
:=
LogTyPretty
if
ethutil
.
Config
.
Diff
{
lt
=
LogTyDiff
}
return
&
Vm
{
vars
:
vars
,
state
:
state
,
stateManager
:
stateManager
,
logTy
:
lt
}
}
var
Pow256
=
ethutil
.
BigPow
(
2
,
256
)
...
...
@@ -107,12 +113,17 @@ func (vm *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
}
}()
// Debug hook
if
vm
.
Dbg
!=
nil
{
vm
.
Dbg
.
SetCode
(
closure
.
Script
)
}
// Don't bother with the execution if there's no code.
if
len
(
closure
.
Script
)
==
0
{
return
closure
.
Return
(
nil
),
nil
}
vmlogger
.
Debugf
(
"(%s) %x gas: %v (d) %x
\n
"
,
vm
.
Fn
,
closure
.
object
.
Address
(),
closure
.
Gas
,
closure
.
Args
)
vmlogger
.
Debugf
(
"(%s) %x gas: %v (d) %x
\n
"
,
vm
.
Fn
,
closure
.
Address
(),
closure
.
Gas
,
closure
.
Args
)
var
(
op
OpCode
...
...
@@ -149,7 +160,7 @@ func (vm *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
b
=
[]
byte
{
0
}
}
fmt
.
Printf
(
"%x %x %x %x
\n
"
,
closure
.
object
.
Address
(),
b
,
[]
byte
{
byte
(
op
)},
closure
.
Gas
.
Bytes
())
fmt
.
Printf
(
"%x %x %x %x
\n
"
,
closure
.
Address
(),
b
,
[]
byte
{
byte
(
op
)},
closure
.
Gas
.
Bytes
())
}
gas
:=
new
(
big
.
Int
)
...
...
@@ -456,9 +467,9 @@ func (vm *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
vm
.
Printf
(
" => %x"
,
data
)
// 0x30 range
case
ADDRESS
:
stack
.
Push
(
ethutil
.
BigD
(
closure
.
Object
()
.
Address
()))
stack
.
Push
(
ethutil
.
BigD
(
closure
.
Address
()))
vm
.
Printf
(
" => %x"
,
closure
.
Object
()
.
Address
())
vm
.
Printf
(
" => %x"
,
closure
.
Address
())
case
BALANCE
:
require
(
1
)
...
...
@@ -664,9 +675,9 @@ func (vm *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
)
// Generate a new address
addr
:=
ethcrypto
.
CreateAddress
(
closure
.
object
.
Address
(),
closure
.
object
.
Nonce
)
addr
:=
ethcrypto
.
CreateAddress
(
closure
.
Address
(),
closure
.
N
()
.
Uint64
()
)
for
i
:=
uint64
(
0
);
vm
.
state
.
GetStateObject
(
addr
)
!=
nil
;
i
++
{
ethcrypto
.
CreateAddress
(
closure
.
object
.
Address
(),
closure
.
object
.
Nonce
+
i
)
ethcrypto
.
CreateAddress
(
closure
.
Address
(),
closure
.
N
()
.
Uint64
()
+
i
)
}
closure
.
object
.
Nonce
++
...
...
@@ -706,6 +717,11 @@ func (vm *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
vm
.
Printf
(
"CREATE success"
)
}
vm
.
Endl
()
// Debug hook
if
vm
.
Dbg
!=
nil
{
vm
.
Dbg
.
SetCode
(
closure
.
Script
)
}
case
CALL
:
require
(
7
)
...
...
@@ -749,6 +765,11 @@ func (vm *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
mem
.
Set
(
retOffset
.
Int64
(),
retSize
.
Int64
(),
ret
)
}
// Debug hook
if
vm
.
Dbg
!=
nil
{
vm
.
Dbg
.
SetCode
(
closure
.
Script
)
}
}
case
RETURN
:
require
(
2
)
...
...
@@ -786,6 +807,8 @@ func (vm *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
if
vm
.
Dbg
!=
nil
{
for
_
,
instrNo
:=
range
vm
.
Dbg
.
BreakPoints
()
{
if
pc
.
Cmp
(
big
.
NewInt
(
instrNo
))
==
0
{
vm
.
Stepping
=
true
if
!
vm
.
Dbg
.
BreakHook
(
prevStep
,
op
,
mem
,
stack
,
closure
.
Object
())
{
return
nil
,
nil
}
...
...
ethereum.go
View file @
90108576
...
...
@@ -20,6 +20,8 @@ import (
"time"
)
const
seedTextFileUri
string
=
"http://www.ethereum.org/servers.poc3.txt"
var
ethlogger
=
ethlog
.
NewLogger
(
"SERV"
)
func
eachPeer
(
peers
*
list
.
List
,
callback
func
(
*
Peer
,
*
list
.
Element
))
{
...
...
@@ -416,7 +418,7 @@ func (s *Ethereum) Seed() {
s
.
ProcessPeerList
(
peers
)
}
else
{
// Fallback to servers.poc3.txt
resp
,
err
:=
http
.
Get
(
"http://www.ethereum.org/servers.poc3.txt"
)
resp
,
err
:=
http
.
Get
(
seedTextFileUri
)
if
err
!=
nil
{
ethlogger
.
Warnln
(
"Fetching seed failed:"
,
err
)
return
...
...
ethutil/config.go
View file @
90108576
...
...
@@ -13,6 +13,7 @@ type ConfigManager struct {
ExecPath
string
Debug
bool
Diff
bool
Paranoia
bool
conf
*
globalconf
.
GlobalConf
...
...
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