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
ca747f26
Commit
ca747f26
authored
Apr 11, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the possibility for debug hooks during closure call
parent
7d6ba88d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
44 deletions
+11
-44
closure.go
ethchain/closure.go
+4
-2
state_manager.go
ethchain/state_manager.go
+1
-1
vm.go
ethchain/vm.go
+5
-40
vm_test.go
ethchain/vm_test.go
+1
-1
No files found.
ethchain/closure.go
View file @
ca747f26
...
...
@@ -69,10 +69,12 @@ func (c *Closure) Address() []byte {
return
c
.
object
.
Address
()
}
func
(
c
*
Closure
)
Call
(
vm
*
Vm
,
args
[]
byte
)
[]
byte
{
type
DebugHook
func
(
op
OpCode
)
func
(
c
*
Closure
)
Call
(
vm
*
Vm
,
args
[]
byte
,
hook
DebugHook
)
[]
byte
{
c
.
Args
=
args
return
vm
.
RunClosure
(
c
)
return
vm
.
RunClosure
(
c
,
hook
)
}
func
(
c
*
Closure
)
Return
(
ret
[]
byte
)
[]
byte
{
...
...
ethchain/state_manager.go
View file @
ca747f26
...
...
@@ -327,7 +327,7 @@ func (sm *StateManager) ProcessContract(contract *Contract, tx *Transaction, blo
// XXX Tx data? Could be just an argument to the closure instead
txData
:
nil
,
})
closure
.
Call
(
vm
,
nil
)
closure
.
Call
(
vm
,
nil
,
nil
)
// Update the account (refunds)
sm
.
procState
.
UpdateAccount
(
tx
.
Sender
(),
caller
)
...
...
ethchain/vm.go
View file @
ca747f26
...
...
@@ -48,7 +48,7 @@ func NewVm(state *State, vars RuntimeVars) *Vm {
var
Pow256
=
ethutil
.
BigPow
(
2
,
256
)
func
(
vm
*
Vm
)
RunClosure
(
closure
*
Closure
)
[]
byte
{
func
(
vm
*
Vm
)
RunClosure
(
closure
*
Closure
,
hook
DebugHook
)
[]
byte
{
// If the amount of gas supplied is less equal to 0
if
closure
.
Gas
.
Cmp
(
big
.
NewInt
(
0
))
<=
0
{
// TODO Do something
...
...
@@ -372,7 +372,7 @@ func (vm *Vm) RunClosure(closure *Closure) []byte {
// Create a new callable closure
closure
:=
NewClosure
(
closure
,
contract
,
contract
.
script
,
vm
.
state
,
gas
,
value
)
// Executer the closure and get the return value (if any)
ret
:=
closure
.
Call
(
vm
,
args
)
ret
:=
closure
.
Call
(
vm
,
args
,
hook
)
mem
.
Set
(
retOffset
.
Int64
(),
retSize
.
Int64
(),
ret
)
case
oRETURN
:
...
...
@@ -404,44 +404,9 @@ func (vm *Vm) RunClosure(closure *Closure) []byte {
}
pc
.
Add
(
pc
,
ethutil
.
Big1
)
}
}
/*
func makeInlineTx(addr []byte, value, from, length *big.Int, contract *Contract, state *State) {
ethutil.Config.Log.Debugf(" => creating inline tx %x %v %v %v", addr, value, from, length)
j := int64(0)
dataItems := make([]string, int(length.Uint64()))
for i := from.Int64(); i < length.Int64(); i++ {
dataItems[j] = contract.GetMem(big.NewInt(j)).Str()
j++
}
tx := NewTransaction(addr, value, dataItems)
if tx.IsContract() {
contract := MakeContract(tx, state)
state.UpdateContract(contract)
} else {
account := state.GetAccount(tx.Recipient)
account.Amount.Add(account.Amount, tx.Value)
state.UpdateAccount(tx.Recipient, account)
}
}
// Returns an address from the specified contract's address
func contractMemory(state *State, contractAddr []byte, memAddr *big.Int) *big.Int {
contract := state.GetContract(contractAddr)
if contract == nil {
log.Panicf("invalid contract addr %x", contractAddr)
}
val := state.trie.Get(memAddr.String())
// decode the object as a big integer
decoder := ethutil.NewValueFromBytes([]byte(val))
if decoder.IsNil() {
return ethutil.BigFalse
if
hook
!=
nil
{
hook
(
op
)
}
}
return decoder.BigInt()
}
*/
ethchain/vm_test.go
View file @
ca747f26
...
...
@@ -139,5 +139,5 @@ func TestRun4(t *testing.T) {
// XXX Tx data? Could be just an argument to the closure instead
txData
:
nil
,
})
callerClosure
.
Call
(
vm
,
nil
)
callerClosure
.
Call
(
vm
,
nil
,
nil
)
}
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