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
75cd9cd2
Commit
75cd9cd2
authored
Jan 12, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated tests
parent
00348756
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
247 additions
and
13 deletions
+247
-13
execution.go
core/execution.go
+6
-9
201501121148GO.json
tests/files/VMTests/RandomTests/201501121148GO.json
+31
-0
201501121149GO.json
tests/files/VMTests/RandomTests/201501121149GO.json
+31
-0
201501121151GO.json
tests/files/VMTests/RandomTests/201501121151GO.json
+31
-0
201501121256GO.json
tests/files/VMTests/RandomTests/201501121256GO.json
+46
-0
201501121301GO.json
tests/files/VMTests/RandomTests/201501121301GO.json
+47
-0
201501121303GO.json
tests/files/VMTests/RandomTests/201501121303GO.json
+47
-0
vm.go
tests/helper/vm.go
+7
-1
vm_debug.go
vm/vm_debug.go
+1
-3
No files found.
core/execution.go
View file @
75cd9cd2
...
...
@@ -13,7 +13,6 @@ type Execution struct {
env
vm
.
Environment
address
,
input
[]
byte
Gas
,
price
,
value
*
big
.
Int
SkipTransfer
bool
}
func
NewExecution
(
env
vm
.
Environment
,
address
,
input
[]
byte
,
gas
,
gasPrice
,
value
*
big
.
Int
)
*
Execution
{
...
...
@@ -43,15 +42,13 @@ func (self *Execution) exec(code, contextAddr []byte, caller vm.ContextRef) (ret
from
,
to
:=
env
.
State
()
.
GetStateObject
(
caller
.
Address
()),
env
.
State
()
.
GetOrNewStateObject
(
self
.
address
)
// Skipping transfer is used on testing for the initial call
if
!
self
.
SkipTransfer
{
err
=
env
.
Transfer
(
from
,
to
,
self
.
value
)
if
err
!=
nil
{
caller
.
ReturnGas
(
self
.
Gas
,
self
.
price
)
err
=
fmt
.
Errorf
(
"Insufficient funds to transfer value. Req %v, has %v"
,
self
.
value
,
from
.
Balance
)
err
=
fmt
.
Errorf
(
"insufficient funds to transfer value. Req %v, has %v"
,
self
.
value
,
from
.
Balance
()
)
return
}
}
snapshot
:=
env
.
State
()
.
Copy
()
start
:=
time
.
Now
()
...
...
tests/files/VMTests/RandomTests/201501121148GO.json
0 → 100644
View file @
75cd9cd2
{
"randomVMtest"
:
{
"env"
:
{
"currentCoinbase"
:
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
,
"currentDifficulty"
:
"256"
,
"currentGasLimit"
:
"1000000"
,
"currentNumber"
:
"0"
,
"currentTimestamp"
:
"1"
,
"previousHash"
:
"5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec"
:
{
"address"
:
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6"
,
"caller"
:
"cd1722f3947def4cf144679da39c4c32bdc35681"
,
"code"
:
"0x0c"
,
"data"
:
"0x"
,
"gas"
:
"10000"
,
"gasPrice"
:
"100000000000000"
,
"origin"
:
"cd1722f3947def4cf144679da39c4c32bdc35681"
,
"value"
:
"1000000000000000000"
},
"pre"
:
{
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6"
:
{
"balance"
:
"1000000000000000000"
,
"code"
:
"0x0c"
,
"nonce"
:
"0"
,
"storage"
:
{
}
}
}
}
}
tests/files/VMTests/RandomTests/201501121149GO.json
0 → 100644
View file @
75cd9cd2
{
"randomVMtest"
:
{
"env"
:
{
"currentCoinbase"
:
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
,
"currentDifficulty"
:
"256"
,
"currentGasLimit"
:
"1000000"
,
"currentNumber"
:
"0"
,
"currentTimestamp"
:
"1"
,
"previousHash"
:
"5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec"
:
{
"address"
:
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6"
,
"caller"
:
"cd1722f3947def4cf144679da39c4c32bdc35681"
,
"code"
:
"0x0c0b8a4494328e02"
,
"data"
:
"0x"
,
"gas"
:
"10000"
,
"gasPrice"
:
"100000000000000"
,
"origin"
:
"cd1722f3947def4cf144679da39c4c32bdc35681"
,
"value"
:
"1000000000000000000"
},
"pre"
:
{
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6"
:
{
"balance"
:
"1000000000000000000"
,
"code"
:
"0x0c0b8a4494328e02"
,
"nonce"
:
"0"
,
"storage"
:
{
}
}
}
}
}
tests/files/VMTests/RandomTests/201501121151GO.json
0 → 100644
View file @
75cd9cd2
{
"randomVMtest"
:
{
"env"
:
{
"currentCoinbase"
:
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
,
"currentDifficulty"
:
"256"
,
"currentGasLimit"
:
"1000000"
,
"currentNumber"
:
"0"
,
"currentTimestamp"
:
"1"
,
"previousHash"
:
"5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec"
:
{
"address"
:
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6"
,
"caller"
:
"cd1722f3947def4cf144679da39c4c32bdc35681"
,
"code"
:
"0x590c"
,
"data"
:
"0x"
,
"gas"
:
"10000"
,
"gasPrice"
:
"100000000000000"
,
"origin"
:
"cd1722f3947def4cf144679da39c4c32bdc35681"
,
"value"
:
"1000000000000000000"
},
"pre"
:
{
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6"
:
{
"balance"
:
"1000000000000000000"
,
"code"
:
"0x590c"
,
"nonce"
:
"0"
,
"storage"
:
{
}
}
}
}
}
tests/files/VMTests/RandomTests/201501121256GO.json
0 → 100644
View file @
75cd9cd2
{
"randomVMtest"
:
{
"callcreates"
:
[
],
"env"
:
{
"currentCoinbase"
:
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
,
"currentDifficulty"
:
"115792089237316195423570985008687907853269984665640564039457584007913129639935"
,
"currentGasLimit"
:
"1000000"
,
"currentNumber"
:
"0"
,
"currentTimestamp"
:
"2"
,
"previousHash"
:
"5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec"
:
{
"address"
:
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6"
,
"caller"
:
"cd1722f3947def4cf144679da39c4c32bdc35681"
,
"code"
:
"0x4542424283434544f063ff78ff1355"
,
"data"
:
"0x"
,
"gas"
:
"10000"
,
"gasPrice"
:
"100000000000000"
,
"origin"
:
"cd1722f3947def4cf144679da39c4c32bdc35681"
,
"value"
:
"1000000000000000000"
},
"gas"
:
"9791"
,
"logs"
:
[
],
"out"
:
"0x"
,
"post"
:
{
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6"
:
{
"balance"
:
"1000000000000000000"
,
"code"
:
"0x4542424283434544f063ff78ff1355"
,
"nonce"
:
"0"
,
"storage"
:
{
}
}
},
"pre"
:
{
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6"
:
{
"balance"
:
"1000000000000000000"
,
"code"
:
"0x4542424283434544f063ff78ff1355"
,
"nonce"
:
"0"
,
"storage"
:
{
}
}
}
}
}
tests/files/VMTests/RandomTests/201501121301GO.json
0 → 100644
View file @
75cd9cd2
{
"randomVMtest"
:
{
"callcreates"
:
[
],
"env"
:
{
"currentCoinbase"
:
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
,
"currentDifficulty"
:
"115792089237316195423570985008687907853269984665640564039457584007913129639935"
,
"currentGasLimit"
:
"1000000"
,
"currentNumber"
:
"0"
,
"currentTimestamp"
:
"2"
,
"previousHash"
:
"5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec"
:
{
"address"
:
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6"
,
"caller"
:
"cd1722f3947def4cf144679da39c4c32bdc35681"
,
"code"
:
"0x4545434244f04343161755"
,
"data"
:
"0x"
,
"gas"
:
"10000"
,
"gasPrice"
:
"100000000000000"
,
"origin"
:
"cd1722f3947def4cf144679da39c4c32bdc35681"
,
"value"
:
"1000000000000000000"
},
"gas"
:
"9591"
,
"logs"
:
[
],
"out"
:
"0x"
,
"post"
:
{
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6"
:
{
"balance"
:
"1000000000000000000"
,
"code"
:
"0x4545434244f04343161755"
,
"nonce"
:
"0"
,
"storage"
:
{
"0x"
:
"0x0f4240"
}
}
},
"pre"
:
{
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6"
:
{
"balance"
:
"1000000000000000000"
,
"code"
:
"0x4545434244f04343161755"
,
"nonce"
:
"0"
,
"storage"
:
{
}
}
}
}
}
tests/files/VMTests/RandomTests/201501121303GO.json
0 → 100644
View file @
75cd9cd2
{
"randomVMtest"
:
{
"callcreates"
:
[
],
"env"
:
{
"currentCoinbase"
:
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
,
"currentDifficulty"
:
"115792089237316195423570985008687907853269984665640564039457584007913129639935"
,
"currentGasLimit"
:
"1000000"
,
"currentNumber"
:
"0"
,
"currentTimestamp"
:
"2"
,
"previousHash"
:
"5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec"
:
{
"address"
:
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6"
,
"caller"
:
"cd1722f3947def4cf144679da39c4c32bdc35681"
,
"code"
:
"0x4245454345424344f055"
,
"data"
:
"0x"
,
"gas"
:
"10000"
,
"gasPrice"
:
"100000000000000"
,
"origin"
:
"cd1722f3947def4cf144679da39c4c32bdc35681"
,
"value"
:
"1000000000000000000"
},
"gas"
:
"9591"
,
"logs"
:
[
],
"out"
:
"0x"
,
"post"
:
{
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6"
:
{
"balance"
:
"1000000000000000000"
,
"code"
:
"0x4245454345424344f055"
,
"nonce"
:
"0"
,
"storage"
:
{
"0x"
:
"0x0f4240"
}
}
},
"pre"
:
{
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6"
:
{
"balance"
:
"1000000000000000000"
,
"code"
:
"0x4245454345424344f055"
,
"nonce"
:
"0"
,
"storage"
:
{
}
}
}
}
}
tests/helper/vm.go
View file @
75cd9cd2
package
helper
import
(
"errors"
"math/big"
"github.com/ethereum/go-ethereum/core"
...
...
@@ -66,12 +67,16 @@ func (self *Env) AddLog(log state.Log) {
func
(
self
*
Env
)
Depth
()
int
{
return
self
.
depth
}
func
(
self
*
Env
)
SetDepth
(
i
int
)
{
self
.
depth
=
i
}
func
(
self
*
Env
)
Transfer
(
from
,
to
vm
.
Account
,
amount
*
big
.
Int
)
error
{
if
self
.
skipTransfer
{
if
from
.
Balance
()
.
Cmp
(
amount
)
<
0
{
return
errors
.
New
(
"Insufficient balance in account"
)
}
}
return
vm
.
Transfer
(
from
,
to
,
amount
)
}
func
(
self
*
Env
)
vm
(
addr
,
data
[]
byte
,
gas
,
price
,
value
*
big
.
Int
)
*
core
.
Execution
{
exec
:=
core
.
NewExecution
(
self
,
addr
,
data
,
gas
,
price
,
value
)
exec
.
SkipTransfer
=
self
.
skipTransfer
return
exec
}
...
...
@@ -104,6 +109,7 @@ func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, state.Log
)
caller
:=
state
.
GetOrNewStateObject
(
from
)
caller
.
SetBalance
(
ethutil
.
Big
(
"1000000000000000000"
))
vmenv
:=
NewEnvFromMap
(
state
,
env
,
exec
)
vmenv
.
skipTransfer
=
true
...
...
vm/vm_debug.go
View file @
75cd9cd2
...
...
@@ -743,9 +743,7 @@ func (self *DebugVm) Run(me, caller ContextRef, code []byte, value, gas, price *
default
:
vmlogger
.
Debugf
(
"(pc) %-3v Invalid opcode %x
\n
"
,
pc
,
op
)
context
.
ReturnGas
(
big
.
NewInt
(
1
),
nil
)
return
context
.
Return
(
nil
),
fmt
.
Errorf
(
"Invalid opcode %x"
,
op
)
panic
(
fmt
.
Errorf
(
"Invalid opcode %x"
,
op
))
}
pc
++
...
...
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