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
f0440e85
Commit
f0440e85
authored
May 08, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed value from closure.
parent
554f4f6f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
15 deletions
+21
-15
closure.go
ethchain/closure.go
+1
-3
state_manager.go
ethchain/state_manager.go
+1
-1
types.go
ethchain/types.go
+2
-2
vm.go
ethchain/vm.go
+17
-9
No files found.
ethchain/closure.go
View file @
f0440e85
...
...
@@ -24,20 +24,18 @@ type Closure struct {
Gas
*
big
.
Int
Price
*
big
.
Int
Value
*
big
.
Int
Args
[]
byte
}
// Create a new closure for the given data items
func
NewClosure
(
callee
,
object
*
StateObject
,
script
[]
byte
,
state
*
State
,
gas
,
price
,
val
*
big
.
Int
)
*
Closure
{
func
NewClosure
(
callee
,
object
*
StateObject
,
script
[]
byte
,
state
*
State
,
gas
,
price
*
big
.
Int
)
*
Closure
{
c
:=
&
Closure
{
callee
:
callee
,
object
:
object
,
Script
:
script
,
State
:
state
,
Args
:
nil
}
// In most cases gas, price and value are pointers to transaction objects
// and we don't want the transaction's values to change.
c
.
Gas
=
new
(
big
.
Int
)
.
Set
(
gas
)
c
.
Price
=
new
(
big
.
Int
)
.
Set
(
price
)
c
.
Value
=
new
(
big
.
Int
)
.
Set
(
val
)
return
c
}
...
...
ethchain/state_manager.go
View file @
f0440e85
...
...
@@ -323,7 +323,7 @@ func (sm *StateManager) EvalScript(script []byte, object *StateObject, tx *Trans
return
}
closure
:=
NewClosure
(
account
,
object
,
script
,
sm
.
procState
,
tx
.
Gas
,
tx
.
GasPrice
,
tx
.
Value
)
closure
:=
NewClosure
(
account
,
object
,
script
,
sm
.
procState
,
tx
.
Gas
,
tx
.
GasPrice
)
vm
:=
NewVm
(
sm
.
procState
,
sm
,
RuntimeVars
{
Origin
:
account
.
Address
(),
BlockNumber
:
block
.
BlockInfo
()
.
Number
,
...
...
ethchain/types.go
View file @
f0440e85
...
...
@@ -97,8 +97,8 @@ const (
// 0xf0 range - closures
oCREATE
=
0xf0
oCALL
=
0xf
2
oRETURN
=
0xf
3
oCALL
=
0xf
1
oRETURN
=
0xf
2
// 0x70 range - other
oLOG
=
0xfe
// XXX Unofficial
...
...
ethchain/vm.go
View file @
f0440e85
...
...
@@ -5,7 +5,6 @@ import (
"fmt"
"github.com/ethereum/eth-go/ethutil"
_
"github.com/obscuren/secp256k1-go"
"log"
_
"math"
"math/big"
)
...
...
@@ -96,7 +95,6 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
if
ethutil
.
Config
.
Debug
{
ethutil
.
Config
.
Log
.
Debugf
(
"# op
\n
"
)
}
fmt
.
Println
(
closure
.
Script
)
for
{
...
...
@@ -320,13 +318,12 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
case
oADDRESS
:
stack
.
Push
(
ethutil
.
BigD
(
closure
.
Object
()
.
Address
()))
case
oBALANCE
:
stack
.
Push
(
closure
.
Value
)
stack
.
Push
(
closure
.
object
.
Amount
)
case
oORIGIN
:
stack
.
Push
(
ethutil
.
BigD
(
vm
.
vars
.
Origin
))
case
oCALLER
:
stack
.
Push
(
ethutil
.
BigD
(
closure
.
Callee
()
.
Address
()))
case
oCALLVALUE
:
log
.
Println
(
"Value:"
,
vm
.
vars
.
Value
)
stack
.
Push
(
vm
.
vars
.
Value
)
case
oCALLDATALOAD
:
require
(
1
)
...
...
@@ -406,13 +403,15 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
require
(
1
)
pc
=
stack
.
Pop
()
// Reduce pc by one because of the increment that's at the end of this for loop
pc
.
Sub
(
pc
,
ethutil
.
Big1
)
//pc.Sub(pc, ethutil.Big1)
continue
case
oJUMPI
:
require
(
2
)
cond
,
pos
:=
stack
.
Popn
()
if
cond
.
Cmp
(
ethutil
.
BigTrue
)
==
0
{
pc
=
pos
pc
.
Sub
(
pc
,
ethutil
.
Big1
)
//pc.Sub(pc, ethutil.Big1)
continue
}
case
oPC
:
stack
.
Push
(
pc
)
...
...
@@ -441,8 +440,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
contract
.
initScript
,
vm
.
state
,
gas
,
closure
.
Price
,
value
)
closure
.
Price
)
// Call the closure and set the return value as
// main script.
closure
.
Script
,
err
=
closure
.
Call
(
vm
,
nil
,
hook
)
...
...
@@ -469,10 +467,13 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
break
}
// Get the arguments from the memory
args
:=
mem
.
Get
(
inOffset
.
Int64
(),
inSize
.
Int64
())
// Fetch the contract which will serve as the closure body
contract
:=
vm
.
state
.
GetContract
(
addr
.
Bytes
())
fmt
.
Println
(
"before"
,
contract
.
Amount
)
if
contract
!=
nil
{
// Prepay for the gas
...
...
@@ -482,8 +483,12 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
gas
=
new
(
big
.
Int
)
.
Set
(
closure
.
Gas
)
}
closure
.
Gas
.
Sub
(
closure
.
Gas
,
gas
)
// Add the value to the state object
contract
.
AddAmount
(
value
)
// Create a new callable closure
closure
:=
NewClosure
(
closure
.
Object
(),
contract
,
contract
.
script
,
vm
.
state
,
gas
,
closure
.
Price
,
value
)
closure
:=
NewClosure
(
closure
.
Object
(),
contract
,
contract
.
script
,
vm
.
state
,
gas
,
closure
.
Price
)
// Executer the closure and get the return value (if any)
ret
,
err
:=
closure
.
Call
(
vm
,
args
,
hook
)
if
err
!=
nil
{
...
...
@@ -496,6 +501,9 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
vm
.
stateManager
.
manifest
.
AddObjectChange
(
contract
)
}
vm
.
state
.
SetStateObject
(
contract
)
fmt
.
Println
(
"after"
,
contract
.
Amount
)
mem
.
Set
(
retOffset
.
Int64
(),
retSize
.
Int64
(),
ret
)
}
else
{
ethutil
.
Config
.
Log
.
Debugf
(
"Contract %x not found
\n
"
,
addr
.
Bytes
())
...
...
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