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
6d99c03d
Commit
6d99c03d
authored
Dec 03, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated environments according to the new interface set
parent
99853ac3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
18 deletions
+83
-18
debugger.go
cmd/mist/debugger.go
+12
-8
vm_env.go
cmd/utils/vm_env.go
+33
-1
pipe.go
xeth/pipe.go
+9
-8
vm_env.go
xeth/vm_env.go
+29
-1
No files found.
cmd/mist/debugger.go
View file @
6d99c03d
...
@@ -144,24 +144,28 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
...
@@ -144,24 +144,28 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
statedb
:=
self
.
lib
.
eth
.
BlockManager
()
.
TransState
()
statedb
:=
self
.
lib
.
eth
.
BlockManager
()
.
TransState
()
account
:=
self
.
lib
.
eth
.
BlockManager
()
.
TransState
()
.
GetAccount
(
keyPair
.
Address
())
account
:=
self
.
lib
.
eth
.
BlockManager
()
.
TransState
()
.
GetAccount
(
keyPair
.
Address
())
contract
:=
statedb
.
NewStateObject
([]
byte
{
0
})
contract
:=
statedb
.
NewStateObject
([]
byte
{
0
})
contract
.
SetCode
(
script
)
contract
.
SetBalance
(
value
)
contract
.
SetBalance
(
value
)
self
.
SetAsm
(
script
)
self
.
SetAsm
(
script
)
block
:=
self
.
lib
.
eth
.
ChainManager
()
.
CurrentBlock
block
:=
self
.
lib
.
eth
.
ChainManager
()
.
CurrentBlock
callerClosure
:=
vm
.
NewClosure
(
&
state
.
Message
{},
account
,
contract
,
script
,
gas
,
gasPrice
)
env
:=
utils
.
NewEnv
(
statedb
,
block
,
account
.
Address
(),
value
)
env
:=
utils
.
NewEnv
(
statedb
,
block
,
account
.
Address
(),
value
)
evm
:=
vm
.
NewDebugVm
(
env
)
/*
evm
.
Dbg
=
self
.
Db
callerClosure := vm.NewClosure(&state.Message{}, account, contract, script, gas, gasPrice)
evm := vm.NewDebugVm(env)
evm.Dbg = self.Db
self.vm = evm
self.Db.done = false
*/
self
.
vm
=
evm
self
.
Db
.
done
=
false
self
.
Logf
(
"callsize %d"
,
len
(
script
))
self
.
Logf
(
"callsize %d"
,
len
(
script
))
go
func
()
{
go
func
()
{
ret
,
g
,
err
:=
callerClosure
.
Call
(
evm
,
data
)
ret
,
err
:=
env
.
Call
(
account
,
contract
.
Address
(),
data
,
gas
,
gasPrice
,
ethutil
.
Big0
)
tot
:=
new
(
big
.
Int
)
.
Mul
(
g
,
gasPrice
)
//ret, g, err := callerClosure.Call(evm, data)
self
.
Logf
(
"gas usage %v total price = %v (%v)"
,
g
,
tot
,
ethutil
.
CurrencyToString
(
tot
))
tot
:=
new
(
big
.
Int
)
.
Mul
(
env
.
Gas
,
gasPrice
)
self
.
Logf
(
"gas usage %v total price = %v (%v)"
,
env
.
Gas
,
tot
,
ethutil
.
CurrencyToString
(
tot
))
if
err
!=
nil
{
if
err
!=
nil
{
self
.
Logln
(
"exited with errors:"
,
err
)
self
.
Logln
(
"exited with errors:"
,
err
)
}
else
{
}
else
{
...
...
cmd/utils/vm_env.go
View file @
6d99c03d
...
@@ -2,6 +2,8 @@ package utils
...
@@ -2,6 +2,8 @@ package utils
import
(
import
(
"math/big"
"math/big"
"github.com/ethereum/go-ethereum/chain"
"github.com/ethereum/go-ethereum/chain/types"
"github.com/ethereum/go-ethereum/chain/types"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/vm"
"github.com/ethereum/go-ethereum/vm"
...
@@ -13,6 +15,9 @@ type VMEnv struct {
...
@@ -13,6 +15,9 @@ type VMEnv struct {
transactor
[]
byte
transactor
[]
byte
value
*
big
.
Int
value
*
big
.
Int
depth
int
Gas
*
big
.
Int
}
}
func
NewEnv
(
state
*
state
.
State
,
block
*
types
.
Block
,
transactor
[]
byte
,
value
*
big
.
Int
)
*
VMEnv
{
func
NewEnv
(
state
*
state
.
State
,
block
*
types
.
Block
,
transactor
[]
byte
,
value
*
big
.
Int
)
*
VMEnv
{
...
@@ -34,7 +39,34 @@ func (self *VMEnv) BlockHash() []byte { return self.block.Hash() }
...
@@ -34,7 +39,34 @@ 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
{
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
)
AddLog
(
*
state
.
Log
)
{}
func
(
self
*
VMEnv
)
Depth
()
int
{
return
self
.
depth
}
func
(
self
*
VMEnv
)
SetDepth
(
i
int
)
{
self
.
depth
=
i
}
func
(
self
*
VMEnv
)
AddLog
(
log
*
state
.
Log
)
{
self
.
state
.
AddLog
(
log
)
}
func
(
self
*
VMEnv
)
Transfer
(
from
,
to
vm
.
Account
,
amount
*
big
.
Int
)
error
{
func
(
self
*
VMEnv
)
Transfer
(
from
,
to
vm
.
Account
,
amount
*
big
.
Int
)
error
{
return
vm
.
Transfer
(
from
,
to
,
amount
)
return
vm
.
Transfer
(
from
,
to
,
amount
)
}
}
func
(
self
*
VMEnv
)
vm
(
addr
,
data
[]
byte
,
gas
,
price
,
value
*
big
.
Int
)
*
chain
.
Execution
{
evm
:=
vm
.
New
(
self
,
vm
.
DebugVmTy
)
return
chain
.
NewExecution
(
evm
,
addr
,
data
,
gas
,
price
,
value
)
}
func
(
self
*
VMEnv
)
Call
(
caller
vm
.
ClosureRef
,
addr
,
data
[]
byte
,
gas
,
price
,
value
*
big
.
Int
)
([]
byte
,
error
)
{
exe
:=
self
.
vm
(
addr
,
data
,
gas
,
price
,
value
)
ret
,
err
:=
exe
.
Call
(
addr
,
caller
)
self
.
Gas
=
exe
.
Gas
return
ret
,
err
}
func
(
self
*
VMEnv
)
CallCode
(
caller
vm
.
ClosureRef
,
addr
,
data
[]
byte
,
gas
,
price
,
value
*
big
.
Int
)
([]
byte
,
error
)
{
exe
:=
self
.
vm
(
caller
.
Address
(),
data
,
gas
,
price
,
value
)
return
exe
.
Call
(
addr
,
caller
)
}
func
(
self
*
VMEnv
)
Create
(
caller
vm
.
ClosureRef
,
addr
,
data
[]
byte
,
gas
,
price
,
value
*
big
.
Int
)
([]
byte
,
error
,
vm
.
ClosureRef
)
{
exe
:=
self
.
vm
(
addr
,
data
,
gas
,
price
,
value
)
return
exe
.
Create
(
caller
)
}
xeth/pipe.go
View file @
6d99c03d
...
@@ -5,15 +5,12 @@ package xeth
...
@@ -5,15 +5,12 @@ package xeth
*/
*/
import
(
import
(
"fmt"
"github.com/ethereum/go-ethereum/chain"
"github.com/ethereum/go-ethereum/chain"
"github.com/ethereum/go-ethereum/chain/types"
"github.com/ethereum/go-ethereum/chain/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/vm"
)
)
var
pipelogger
=
logger
.
NewLogger
(
"XETH"
)
var
pipelogger
=
logger
.
NewLogger
(
"XETH"
)
...
@@ -62,14 +59,18 @@ func (self *XEth) ExecuteObject(object *Object, data []byte, value, gas, price *
...
@@ -62,14 +59,18 @@ func (self *XEth) ExecuteObject(object *Object, data []byte, value, gas, price *
self
.
Vm
.
State
=
self
.
World
()
.
State
()
.
Copy
()
self
.
Vm
.
State
=
self
.
World
()
.
State
()
.
Copy
()
evm
:=
vm
.
New
(
NewEnv
(
self
.
Vm
.
State
,
block
,
value
.
BigInt
(),
initiator
.
Address
()),
vm
.
Type
(
ethutil
.
Config
.
VmType
))
vmenv
:=
NewEnv
(
self
.
Vm
.
State
,
block
,
value
.
BigInt
(),
initiator
.
Address
())
return
vmenv
.
Call
(
initiator
,
object
.
Address
(),
data
,
gas
.
BigInt
(),
price
.
BigInt
(),
value
.
BigInt
())
/*
evm := vm.New(, vm.Type(ethutil.Config.VmType))
msg
:=
vm
.
NewExecution
(
evm
,
object
.
Address
(),
data
,
gas
.
BigInt
(),
price
.
BigInt
(),
value
.
BigInt
())
msg := vm.NewExecution(evm, 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)
return
ret
,
err
return ret, err
*/
}
}
func
(
self
*
XEth
)
Block
(
hash
[]
byte
)
*
types
.
Block
{
func
(
self
*
XEth
)
Block
(
hash
[]
byte
)
*
types
.
Block
{
...
...
xeth/vm_env.go
View file @
6d99c03d
...
@@ -2,6 +2,8 @@ package xeth
...
@@ -2,6 +2,8 @@ package xeth
import
(
import
(
"math/big"
"math/big"
"github.com/ethereum/go-ethereum/chain"
"github.com/ethereum/go-ethereum/chain/types"
"github.com/ethereum/go-ethereum/chain/types"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/vm"
"github.com/ethereum/go-ethereum/vm"
...
@@ -12,6 +14,8 @@ type VMEnv struct {
...
@@ -12,6 +14,8 @@ type VMEnv struct {
block
*
types
.
Block
block
*
types
.
Block
value
*
big
.
Int
value
*
big
.
Int
sender
[]
byte
sender
[]
byte
depth
int
}
}
func
NewEnv
(
state
*
state
.
State
,
block
*
types
.
Block
,
value
*
big
.
Int
,
sender
[]
byte
)
*
VMEnv
{
func
NewEnv
(
state
*
state
.
State
,
block
*
types
.
Block
,
value
*
big
.
Int
,
sender
[]
byte
)
*
VMEnv
{
...
@@ -33,7 +37,31 @@ func (self *VMEnv) BlockHash() []byte { return self.block.Hash() }
...
@@ -33,7 +37,31 @@ 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
{
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
)
AddLog
(
*
state
.
Log
)
{}
func
(
self
*
VMEnv
)
Depth
()
int
{
return
self
.
depth
}
func
(
self
*
VMEnv
)
SetDepth
(
i
int
)
{
self
.
depth
=
i
}
func
(
self
*
VMEnv
)
AddLog
(
log
*
state
.
Log
)
{
self
.
state
.
AddLog
(
log
)
}
func
(
self
*
VMEnv
)
Transfer
(
from
,
to
vm
.
Account
,
amount
*
big
.
Int
)
error
{
func
(
self
*
VMEnv
)
Transfer
(
from
,
to
vm
.
Account
,
amount
*
big
.
Int
)
error
{
return
vm
.
Transfer
(
from
,
to
,
amount
)
return
vm
.
Transfer
(
from
,
to
,
amount
)
}
}
func
(
self
*
VMEnv
)
vm
(
addr
,
data
[]
byte
,
gas
,
price
,
value
*
big
.
Int
)
*
chain
.
Execution
{
evm
:=
vm
.
New
(
self
,
vm
.
DebugVmTy
)
return
chain
.
NewExecution
(
evm
,
addr
,
data
,
gas
,
price
,
value
)
}
func
(
self
*
VMEnv
)
Call
(
me
vm
.
ClosureRef
,
addr
,
data
[]
byte
,
gas
,
price
,
value
*
big
.
Int
)
([]
byte
,
error
)
{
exe
:=
self
.
vm
(
addr
,
data
,
gas
,
price
,
value
)
return
exe
.
Call
(
addr
,
me
)
}
func
(
self
*
VMEnv
)
CallCode
(
me
vm
.
ClosureRef
,
addr
,
data
[]
byte
,
gas
,
price
,
value
*
big
.
Int
)
([]
byte
,
error
)
{
exe
:=
self
.
vm
(
me
.
Address
(),
data
,
gas
,
price
,
value
)
return
exe
.
Call
(
addr
,
me
)
}
func
(
self
*
VMEnv
)
Create
(
me
vm
.
ClosureRef
,
addr
,
data
[]
byte
,
gas
,
price
,
value
*
big
.
Int
)
([]
byte
,
error
,
vm
.
ClosureRef
)
{
exe
:=
self
.
vm
(
addr
,
data
,
gas
,
price
,
value
)
return
exe
.
Create
(
me
)
}
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