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
4f0bda40
Commit
4f0bda40
authored
Aug 05, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added vm options for object execution
parent
c215bbad
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
39 deletions
+58
-39
config.go
ethpipe/config.go
+4
-22
object.go
ethpipe/object.go
+26
-0
pipe.go
ethpipe/pipe.go
+22
-11
world.go
ethpipe/world.go
+6
-6
No files found.
ethpipe/config.go
View file @
4f0bda40
package
ethpipe
package
ethpipe
import
(
import
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethstate"
"github.com/ethereum/eth-go/ethutil"
)
var
cnfCtr
=
ethutil
.
Hex2Bytes
(
"661005d2720d855f1d9976f88bb10c1a3398c77f"
)
var
cnfCtr
=
ethutil
.
Hex2Bytes
(
"661005d2720d855f1d9976f88bb10c1a3398c77f"
)
type
object
struct
{
*
ethstate
.
StateObject
}
func
(
self
object
)
StorageString
(
str
string
)
*
ethutil
.
Value
{
if
ethutil
.
IsHex
(
str
)
{
return
self
.
Storage
(
ethutil
.
Hex2Bytes
(
str
[
2
:
]))
}
else
{
return
self
.
Storage
(
ethutil
.
RightPadBytes
([]
byte
(
str
),
32
))
}
}
func
(
self
object
)
Storage
(
addr
[]
byte
)
*
ethutil
.
Value
{
return
self
.
StateObject
.
GetStorage
(
ethutil
.
BigD
(
addr
))
}
type
config
struct
{
type
config
struct
{
pipe
*
Pipe
pipe
*
Pipe
}
}
func
(
self
*
config
)
Get
(
name
string
)
object
{
func
(
self
*
config
)
Get
(
name
string
)
*
object
{
configCtrl
:=
self
.
pipe
.
World
()
.
safeGet
(
cnfCtr
)
configCtrl
:=
self
.
pipe
.
World
()
.
safeGet
(
cnfCtr
)
var
addr
[]
byte
var
addr
[]
byte
...
@@ -39,7 +20,8 @@ func (self *config) Get(name string) object {
...
@@ -39,7 +20,8 @@ func (self *config) Get(name string) object {
}
}
objectAddr
:=
configCtrl
.
GetStorage
(
ethutil
.
BigD
(
addr
))
objectAddr
:=
configCtrl
.
GetStorage
(
ethutil
.
BigD
(
addr
))
return
object
{
self
.
pipe
.
World
()
.
safeGet
(
objectAddr
.
Bytes
())}
return
&
object
{
self
.
pipe
.
World
()
.
safeGet
(
objectAddr
.
Bytes
())}
}
}
func
(
self
*
config
)
Exist
()
bool
{
func
(
self
*
config
)
Exist
()
bool
{
...
...
ethpipe/object.go
0 → 100644
View file @
4f0bda40
package
ethpipe
import
(
"github.com/ethereum/eth-go/ethstate"
"github.com/ethereum/eth-go/ethutil"
)
type
object
struct
{
*
ethstate
.
StateObject
}
func
(
self
*
object
)
StorageString
(
str
string
)
*
ethutil
.
Value
{
if
ethutil
.
IsHex
(
str
)
{
return
self
.
Storage
(
ethutil
.
Hex2Bytes
(
str
[
2
:
]))
}
else
{
return
self
.
Storage
(
ethutil
.
RightPadBytes
([]
byte
(
str
),
32
))
}
}
func
(
self
*
object
)
StorageValue
(
addr
*
ethutil
.
Value
)
*
ethutil
.
Value
{
return
self
.
Storage
(
addr
.
Bytes
())
}
func
(
self
*
object
)
Storage
(
addr
[]
byte
)
*
ethutil
.
Value
{
return
self
.
StateObject
.
GetStorage
(
ethutil
.
BigD
(
addr
))
}
ethpipe/pipe.go
View file @
4f0bda40
...
@@ -13,11 +13,17 @@ import (
...
@@ -13,11 +13,17 @@ import (
var
logger
=
ethlog
.
NewLogger
(
"PIPE"
)
var
logger
=
ethlog
.
NewLogger
(
"PIPE"
)
type
VmVars
struct
{
State
*
ethstate
.
State
}
type
Pipe
struct
{
type
Pipe
struct
{
obj
ethchain
.
EthManager
obj
ethchain
.
EthManager
stateManager
*
ethchain
.
StateManager
stateManager
*
ethchain
.
StateManager
blockChain
*
ethchain
.
BlockChain
blockChain
*
ethchain
.
BlockChain
world
*
world
world
*
world
Vm
VmVars
}
}
func
New
(
obj
ethchain
.
EthManager
)
*
Pipe
{
func
New
(
obj
ethchain
.
EthManager
)
*
Pipe
{
...
@@ -40,19 +46,22 @@ func (self *Pipe) Nonce(addr []byte) uint64 {
...
@@ -40,19 +46,22 @@ func (self *Pipe) Nonce(addr []byte) uint64 {
}
}
func
(
self
*
Pipe
)
Execute
(
addr
[]
byte
,
data
[]
byte
,
value
,
gas
,
price
*
ethutil
.
Value
)
([]
byte
,
error
)
{
func
(
self
*
Pipe
)
Execute
(
addr
[]
byte
,
data
[]
byte
,
value
,
gas
,
price
*
ethutil
.
Value
)
([]
byte
,
error
)
{
return
self
.
ExecuteObject
(
self
.
World
()
.
safeGet
(
addr
)
,
data
,
value
,
gas
,
price
)
return
self
.
ExecuteObject
(
&
object
{
self
.
World
()
.
safeGet
(
addr
)}
,
data
,
value
,
gas
,
price
)
}
}
func
(
self
*
Pipe
)
ExecuteObject
(
object
*
ethstate
.
StateO
bject
,
data
[]
byte
,
value
,
gas
,
price
*
ethutil
.
Value
)
([]
byte
,
error
)
{
func
(
self
*
Pipe
)
ExecuteObject
(
object
*
o
bject
,
data
[]
byte
,
value
,
gas
,
price
*
ethutil
.
Value
)
([]
byte
,
error
)
{
var
(
var
(
initiator
=
ethstate
.
NewStateObject
([]
byte
{
0
})
initiator
=
ethstate
.
NewStateObject
([]
byte
{
0
})
state
=
self
.
World
()
.
State
()
.
Copy
()
block
=
self
.
blockChain
.
CurrentBlock
block
=
self
.
blockChain
.
CurrentBlock
stateObject
=
object
.
StateObject
)
)
if
self
.
Vm
.
State
==
nil
{
self
.
Vm
.
State
=
self
.
World
()
.
State
()
.
Copy
()
}
vm
:=
ethvm
.
New
(
NewEnv
(
state
,
block
,
value
.
BigInt
(),
initiator
.
Address
()))
vm
:=
ethvm
.
New
(
NewEnv
(
s
elf
.
Vm
.
S
tate
,
block
,
value
.
BigInt
(),
initiator
.
Address
()))
closure
:=
ethvm
.
NewClosure
(
initiator
,
o
bject
,
object
.
Code
,
gas
.
BigInt
(),
price
.
BigInt
())
closure
:=
ethvm
.
NewClosure
(
initiator
,
stateO
bject
,
object
.
Code
,
gas
.
BigInt
(),
price
.
BigInt
())
ret
,
_
,
err
:=
closure
.
Call
(
vm
,
data
)
ret
,
_
,
err
:=
closure
.
Call
(
vm
,
data
)
return
ret
,
err
return
ret
,
err
...
@@ -79,7 +88,7 @@ func (self *Pipe) Exists(addr []byte) bool {
...
@@ -79,7 +88,7 @@ func (self *Pipe) Exists(addr []byte) bool {
return
self
.
World
()
.
Get
(
addr
)
!=
nil
return
self
.
World
()
.
Get
(
addr
)
!=
nil
}
}
func
(
self
*
Pipe
)
TransactString
(
key
*
ethcrypto
.
KeyPair
,
rec
string
,
value
,
gas
,
price
*
ethutil
.
Value
,
data
[]
byte
)
error
{
func
(
self
*
Pipe
)
TransactString
(
key
*
ethcrypto
.
KeyPair
,
rec
string
,
value
,
gas
,
price
*
ethutil
.
Value
,
data
[]
byte
)
([]
byte
,
error
)
{
// Check if an address is stored by this address
// Check if an address is stored by this address
var
hash
[]
byte
var
hash
[]
byte
addr
:=
self
.
World
()
.
Config
()
.
Get
(
"NameReg"
)
.
StorageString
(
rec
)
.
Bytes
()
addr
:=
self
.
World
()
.
Config
()
.
Get
(
"NameReg"
)
.
StorageString
(
rec
)
.
Bytes
()
...
@@ -94,7 +103,7 @@ func (self *Pipe) TransactString(key *ethcrypto.KeyPair, rec string, value, gas,
...
@@ -94,7 +103,7 @@ func (self *Pipe) TransactString(key *ethcrypto.KeyPair, rec string, value, gas,
return
self
.
Transact
(
key
,
hash
,
value
,
gas
,
price
,
data
)
return
self
.
Transact
(
key
,
hash
,
value
,
gas
,
price
,
data
)
}
}
func
(
self
*
Pipe
)
Transact
(
key
*
ethcrypto
.
KeyPair
,
rec
[]
byte
,
value
,
gas
,
price
*
ethutil
.
Value
,
data
[]
byte
)
error
{
func
(
self
*
Pipe
)
Transact
(
key
*
ethcrypto
.
KeyPair
,
rec
[]
byte
,
value
,
gas
,
price
*
ethutil
.
Value
,
data
[]
byte
)
([]
byte
,
error
)
{
var
hash
[]
byte
var
hash
[]
byte
var
contractCreation
bool
var
contractCreation
bool
if
rec
==
nil
{
if
rec
==
nil
{
...
@@ -106,7 +115,7 @@ func (self *Pipe) Transact(key *ethcrypto.KeyPair, rec []byte, value, gas, price
...
@@ -106,7 +115,7 @@ func (self *Pipe) Transact(key *ethcrypto.KeyPair, rec []byte, value, gas, price
if
contractCreation
{
if
contractCreation
{
script
,
err
:=
ethutil
.
Compile
(
string
(
data
),
false
)
script
,
err
:=
ethutil
.
Compile
(
string
(
data
),
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
nil
,
err
}
}
tx
=
ethchain
.
NewContractCreationTx
(
value
.
BigInt
(),
gas
.
BigInt
(),
price
.
BigInt
(),
script
)
tx
=
ethchain
.
NewContractCreationTx
(
value
.
BigInt
(),
gas
.
BigInt
(),
price
.
BigInt
(),
script
)
...
@@ -133,7 +142,9 @@ func (self *Pipe) Transact(key *ethcrypto.KeyPair, rec []byte, value, gas, price
...
@@ -133,7 +142,9 @@ func (self *Pipe) Transact(key *ethcrypto.KeyPair, rec []byte, value, gas, price
if
contractCreation
{
if
contractCreation
{
logger
.
Infof
(
"Contract addr %x"
,
tx
.
CreationAddress
())
logger
.
Infof
(
"Contract addr %x"
,
tx
.
CreationAddress
())
return
tx
.
CreationAddress
(),
nil
}
}
return
nil
return
tx
.
Hash
(),
nil
}
}
ethpipe/world.go
View file @
4f0bda40
...
@@ -26,17 +26,17 @@ func (self *world) State() *ethstate.State {
...
@@ -26,17 +26,17 @@ func (self *world) State() *ethstate.State {
return
self
.
pipe
.
stateManager
.
CurrentState
()
return
self
.
pipe
.
stateManager
.
CurrentState
()
}
}
func
(
self
*
world
)
Get
(
addr
[]
byte
)
*
ethstate
.
StateO
bject
{
func
(
self
*
world
)
Get
(
addr
[]
byte
)
*
o
bject
{
return
self
.
State
()
.
GetStateObject
(
addr
)
return
&
object
{
self
.
State
()
.
GetStateObject
(
addr
)}
}
}
func
(
self
*
world
)
safeGet
(
addr
[]
byte
)
*
ethstate
.
StateObject
{
func
(
self
*
world
)
safeGet
(
addr
[]
byte
)
*
ethstate
.
StateObject
{
object
:=
self
.
Ge
t
(
addr
)
object
:=
self
.
State
()
.
GetStateObjec
t
(
addr
)
if
object
!
=
nil
{
if
object
=
=
nil
{
return
object
object
=
ethstate
.
NewStateObject
(
addr
)
}
}
return
ethstate
.
NewStateObject
(
addr
)
return
object
}
}
func
(
self
*
world
)
Coinbase
()
*
ethstate
.
StateObject
{
func
(
self
*
world
)
Coinbase
()
*
ethstate
.
StateObject
{
...
...
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