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
0fa7859b
Commit
0fa7859b
authored
10 years ago
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed VM & Tests w/ conversion
parent
ff55c6f5
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
22 deletions
+30
-22
types_test.go
common/types_test.go
+15
-0
state_transition.go
core/state_transition.go
+9
-10
vm_env.go
core/vm_env.go
+2
-2
vm.go
tests/helper/vm.go
+2
-2
gh_test.go
tests/vm/gh_test.go
+0
-6
environment.go
vm/environment.go
+1
-1
vm.go
vm/vm.go
+1
-1
No files found.
common/types_test.go
0 → 100644
View file @
0fa7859b
package
common
import
"testing"
func
TestBytesConversion
(
t
*
testing
.
T
)
{
bytes
:=
[]
byte
{
5
}
hash
:=
BytesToHash
(
bytes
)
var
exp
Hash
exp
[
31
]
=
5
if
hash
!=
exp
{
t
.
Errorf
(
"expected %x got %x"
,
exp
,
hash
)
}
}
This diff is collapsed.
Click to expand it.
core/state_transition.go
View file @
0fa7859b
...
...
@@ -5,6 +5,7 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/vm"
)
...
...
@@ -195,9 +196,9 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
vmenv
:=
self
.
env
var
ref
vm
.
ContextRef
if
MessageCreatesContract
(
msg
)
{
//
contract := makeContract(msg, self.state)
//
addr := contract.Address()
ret
,
err
,
ref
=
vmenv
.
Create
(
sender
,
self
.
msg
.
Data
(),
self
.
gas
,
self
.
gasPrice
,
self
.
value
)
contract
:=
makeContract
(
msg
,
self
.
state
)
addr
:=
contract
.
Address
()
ret
,
err
,
ref
=
vmenv
.
Create
(
sender
,
&
addr
,
self
.
msg
.
Data
(),
self
.
gas
,
self
.
gasPrice
,
self
.
value
)
if
err
==
nil
{
dataGas
:=
big
.
NewInt
(
int64
(
len
(
ret
)))
dataGas
.
Mul
(
dataGas
,
vm
.
GasCreateByte
)
...
...
@@ -243,13 +244,11 @@ func (self *StateTransition) gasUsed() *big.Int {
// Converts an message in to a state object
func
makeContract
(
msg
Message
,
state
*
state
.
StateDB
)
*
state
.
StateObject
{
/*
addr := AddressFromMessage(msg
)
faddr
,
_
:=
msg
.
From
()
addr
:=
crypto
.
CreateAddress
(
faddr
,
msg
.
Nonce
()
)
contract := state.GetOrNewStateObject(addr)
contract.SetInitCode(msg.Data())
contract
:=
state
.
GetOrNewStateObject
(
addr
)
contract
.
SetInitCode
(
msg
.
Data
())
return contract
*/
return
nil
return
contract
}
This diff is collapsed.
Click to expand it.
core/vm_env.go
View file @
0fa7859b
...
...
@@ -68,7 +68,7 @@ func (self *VMEnv) CallCode(me vm.ContextRef, addr common.Address, data []byte,
return
exe
.
Call
(
addr
,
me
)
}
func
(
self
*
VMEnv
)
Create
(
me
vm
.
ContextRef
,
data
[]
byte
,
gas
,
price
,
value
*
big
.
Int
)
([]
byte
,
error
,
vm
.
ContextRef
)
{
exe
:=
self
.
vm
(
nil
,
data
,
gas
,
price
,
value
)
func
(
self
*
VMEnv
)
Create
(
me
vm
.
ContextRef
,
addr
*
common
.
Address
,
data
[]
byte
,
gas
,
price
,
value
*
big
.
Int
)
([]
byte
,
error
,
vm
.
ContextRef
)
{
exe
:=
self
.
vm
(
addr
,
data
,
gas
,
price
,
value
)
return
exe
.
Create
(
me
)
}
This diff is collapsed.
Click to expand it.
tests/helper/vm.go
View file @
0fa7859b
...
...
@@ -119,8 +119,8 @@ func (self *Env) CallCode(caller vm.ContextRef, addr common.Address, data []byte
return
exe
.
Call
(
addr
,
caller
)
}
func
(
self
*
Env
)
Create
(
caller
vm
.
ContextRef
,
data
[]
byte
,
gas
,
price
,
value
*
big
.
Int
)
([]
byte
,
error
,
vm
.
ContextRef
)
{
exe
:=
self
.
vm
(
nil
,
data
,
gas
,
price
,
value
)
func
(
self
*
Env
)
Create
(
caller
vm
.
ContextRef
,
addr
*
common
.
Address
,
data
[]
byte
,
gas
,
price
,
value
*
big
.
Int
)
([]
byte
,
error
,
vm
.
ContextRef
)
{
exe
:=
self
.
vm
(
addr
,
data
,
gas
,
price
,
value
)
if
self
.
vmTest
{
caller
.
ReturnGas
(
gas
,
price
)
...
...
This diff is collapsed.
Click to expand it.
tests/vm/gh_test.go
View file @
0fa7859b
...
...
@@ -11,7 +11,6 @@ import (
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/tests/helper"
"github.com/ethereum/go-ethereum/vm"
)
type
Account
struct
{
...
...
@@ -81,11 +80,6 @@ func RunVmTest(p string, t *testing.T) {
helper
.
CreateFileTests
(
t
,
p
,
&
tests
)
for
name
,
test
:=
range
tests
{
helper
.
Logger
.
SetLogLevel
(
5
)
vm
.
Debug
=
true
if
name
!=
"TransactionCreateSuicideContract"
{
continue
}
db
,
_
:=
ethdb
.
NewMemDatabase
()
statedb
:=
state
.
New
(
common
.
Hash
{},
db
)
for
addr
,
account
:=
range
test
.
Pre
{
...
...
This diff is collapsed.
Click to expand it.
vm/environment.go
View file @
0fa7859b
...
...
@@ -31,7 +31,7 @@ type Environment interface {
Call
(
me
ContextRef
,
addr
common
.
Address
,
data
[]
byte
,
gas
,
price
,
value
*
big
.
Int
)
([]
byte
,
error
)
CallCode
(
me
ContextRef
,
addr
common
.
Address
,
data
[]
byte
,
gas
,
price
,
value
*
big
.
Int
)
([]
byte
,
error
)
Create
(
me
ContextRef
,
data
[]
byte
,
gas
,
price
,
value
*
big
.
Int
)
([]
byte
,
error
,
ContextRef
)
Create
(
me
ContextRef
,
addr
*
common
.
Address
,
data
[]
byte
,
gas
,
price
,
value
*
big
.
Int
)
([]
byte
,
error
,
ContextRef
)
}
type
Account
interface
{
...
...
This diff is collapsed.
Click to expand it.
vm/vm.go
View file @
0fa7859b
...
...
@@ -641,7 +641,7 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
self
.
Endl
()
context
.
UseGas
(
context
.
Gas
)
ret
,
suberr
,
ref
:=
self
.
env
.
Create
(
context
,
input
,
gas
,
price
,
value
)
ret
,
suberr
,
ref
:=
self
.
env
.
Create
(
context
,
nil
,
input
,
gas
,
price
,
value
)
if
suberr
!=
nil
{
stack
.
push
(
common
.
BigFalse
)
...
...
This diff is collapsed.
Click to expand it.
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