ethstate => state
This commit is contained in:
parent
0ed1a8b50a
commit
af8f5f0b69
@ -8,9 +8,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethtrie"
|
"github.com/ethereum/go-ethereum/ethtrie"
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BlockInfo struct {
|
type BlockInfo struct {
|
||||||
@ -77,7 +77,7 @@ type Block struct {
|
|||||||
Coinbase []byte
|
Coinbase []byte
|
||||||
// Block Trie state
|
// Block Trie state
|
||||||
//state *ethutil.Trie
|
//state *ethutil.Trie
|
||||||
state *ethstate.State
|
state *state.State
|
||||||
// Difficulty for the current block
|
// Difficulty for the current block
|
||||||
Difficulty *big.Int
|
Difficulty *big.Int
|
||||||
// Creation time
|
// Creation time
|
||||||
@ -137,7 +137,7 @@ func CreateBlock(root interface{},
|
|||||||
}
|
}
|
||||||
block.SetUncles([]*Block{})
|
block.SetUncles([]*Block{})
|
||||||
|
|
||||||
block.state = ethstate.New(ethtrie.New(ethutil.Config.Db, root))
|
block.state = state.New(ethtrie.New(ethutil.Config.Db, root))
|
||||||
|
|
||||||
return block
|
return block
|
||||||
}
|
}
|
||||||
@ -152,7 +152,7 @@ func (block *Block) HashNoNonce() []byte {
|
|||||||
return crypto.Sha3(ethutil.Encode(block.miningHeader()))
|
return crypto.Sha3(ethutil.Encode(block.miningHeader()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (block *Block) State() *ethstate.State {
|
func (block *Block) State() *state.State {
|
||||||
return block.state
|
return block.state
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,7 +294,7 @@ func (self *Block) setHeader(header *ethutil.Value) {
|
|||||||
self.PrevHash = header.Get(0).Bytes()
|
self.PrevHash = header.Get(0).Bytes()
|
||||||
self.UncleSha = header.Get(1).Bytes()
|
self.UncleSha = header.Get(1).Bytes()
|
||||||
self.Coinbase = header.Get(2).Bytes()
|
self.Coinbase = header.Get(2).Bytes()
|
||||||
self.state = ethstate.New(ethtrie.New(ethutil.Config.Db, header.Get(3).Val))
|
self.state = state.New(ethtrie.New(ethutil.Config.Db, header.Get(3).Val))
|
||||||
self.TxSha = header.Get(4).Bytes()
|
self.TxSha = header.Get(4).Bytes()
|
||||||
self.ReceiptSha = header.Get(5).Bytes()
|
self.ReceiptSha = header.Get(5).Bytes()
|
||||||
self.LogsBloom = header.Get(6).Bytes()
|
self.LogsBloom = header.Get(6).Bytes()
|
||||||
|
@ -3,8 +3,8 @@ package chain
|
|||||||
import (
|
import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateBloom(block *Block) []byte {
|
func CreateBloom(block *Block) []byte {
|
||||||
@ -17,7 +17,7 @@ func CreateBloom(block *Block) []byte {
|
|||||||
return bin.Bytes()
|
return bin.Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
func LogsBloom(logs ethstate.Logs) *big.Int {
|
func LogsBloom(logs state.Logs) *big.Int {
|
||||||
bin := new(big.Int)
|
bin := new(big.Int)
|
||||||
for _, log := range logs {
|
for _, log := range logs {
|
||||||
data := [][]byte{log.Address}
|
data := [][]byte{log.Address}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
"github.com/ethereum/go-ethereum/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AccountChange struct {
|
type AccountChange struct {
|
||||||
@ -23,7 +23,7 @@ type Filter struct {
|
|||||||
Altered []AccountChange
|
Altered []AccountChange
|
||||||
|
|
||||||
BlockCallback func(*Block)
|
BlockCallback func(*Block)
|
||||||
MessageCallback func(ethstate.Messages)
|
MessageCallback func(state.Messages)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new filter which uses a bloom filter on blocks to figure out whether a particular block
|
// Create a new filter which uses a bloom filter on blocks to figure out whether a particular block
|
||||||
@ -72,7 +72,7 @@ func (self *Filter) SetSkip(skip int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run filters messages with the current parameters set
|
// Run filters messages with the current parameters set
|
||||||
func (self *Filter) Find() []*ethstate.Message {
|
func (self *Filter) Find() []*state.Message {
|
||||||
var earliestBlockNo uint64 = uint64(self.earliest)
|
var earliestBlockNo uint64 = uint64(self.earliest)
|
||||||
if self.earliest == -1 {
|
if self.earliest == -1 {
|
||||||
earliestBlockNo = self.eth.ChainManager().CurrentBlock.Number.Uint64()
|
earliestBlockNo = self.eth.ChainManager().CurrentBlock.Number.Uint64()
|
||||||
@ -83,7 +83,7 @@ func (self *Filter) Find() []*ethstate.Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
messages []*ethstate.Message
|
messages []*state.Message
|
||||||
block = self.eth.ChainManager().GetBlockByNumber(latestBlockNo)
|
block = self.eth.ChainManager().GetBlockByNumber(latestBlockNo)
|
||||||
quit bool
|
quit bool
|
||||||
)
|
)
|
||||||
@ -128,8 +128,8 @@ func includes(addresses [][]byte, a []byte) (found bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Filter) FilterMessages(msgs []*ethstate.Message) []*ethstate.Message {
|
func (self *Filter) FilterMessages(msgs []*state.Message) []*state.Message {
|
||||||
var messages []*ethstate.Message
|
var messages []*state.Message
|
||||||
|
|
||||||
// Filter the messages for interesting stuff
|
// Filter the messages for interesting stuff
|
||||||
for _, message := range msgs {
|
for _, message := range msgs {
|
||||||
|
@ -10,11 +10,11 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
"github.com/ethereum/go-ethereum/ethwire"
|
"github.com/ethereum/go-ethereum/ethwire"
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
"github.com/ethereum/go-ethereum/logger"
|
"github.com/ethereum/go-ethereum/logger"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
var statelogger = logger.NewLogger("BLOCK")
|
var statelogger = logger.NewLogger("BLOCK")
|
||||||
@ -61,10 +61,10 @@ type StateManager struct {
|
|||||||
// Transiently state. The trans state isn't ever saved, validated and
|
// Transiently state. The trans state isn't ever saved, validated and
|
||||||
// it could be used for setting account nonces without effecting
|
// it could be used for setting account nonces without effecting
|
||||||
// the main states.
|
// the main states.
|
||||||
transState *ethstate.State
|
transState *state.State
|
||||||
// Mining state. The mining state is used purely and solely by the mining
|
// Mining state. The mining state is used purely and solely by the mining
|
||||||
// operation.
|
// operation.
|
||||||
miningState *ethstate.State
|
miningState *state.State
|
||||||
|
|
||||||
// The last attempted block is mainly used for debugging purposes
|
// The last attempted block is mainly used for debugging purposes
|
||||||
// This does not have to be a valid block and will be set during
|
// This does not have to be a valid block and will be set during
|
||||||
@ -112,19 +112,19 @@ func (self *StateManager) updateThread() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StateManager) CurrentState() *ethstate.State {
|
func (sm *StateManager) CurrentState() *state.State {
|
||||||
return sm.eth.ChainManager().CurrentBlock.State()
|
return sm.eth.ChainManager().CurrentBlock.State()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StateManager) TransState() *ethstate.State {
|
func (sm *StateManager) TransState() *state.State {
|
||||||
return sm.transState
|
return sm.transState
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StateManager) MiningState() *ethstate.State {
|
func (sm *StateManager) MiningState() *state.State {
|
||||||
return sm.miningState
|
return sm.miningState
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StateManager) NewMiningState() *ethstate.State {
|
func (sm *StateManager) NewMiningState() *state.State {
|
||||||
sm.miningState = sm.eth.ChainManager().CurrentBlock.State().Copy()
|
sm.miningState = sm.eth.ChainManager().CurrentBlock.State().Copy()
|
||||||
|
|
||||||
return sm.miningState
|
return sm.miningState
|
||||||
@ -134,7 +134,7 @@ func (sm *StateManager) ChainManager() *ChainManager {
|
|||||||
return sm.bc
|
return sm.bc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *StateManager) ProcessTransactions(coinbase *ethstate.StateObject, state *ethstate.State, block, parent *Block, txs Transactions) (Receipts, Transactions, Transactions, Transactions, error) {
|
func (self *StateManager) ProcessTransactions(coinbase *state.StateObject, state *state.State, block, parent *Block, txs Transactions) (Receipts, Transactions, Transactions, Transactions, error) {
|
||||||
var (
|
var (
|
||||||
receipts Receipts
|
receipts Receipts
|
||||||
handled, unhandled Transactions
|
handled, unhandled Transactions
|
||||||
@ -296,7 +296,7 @@ func (sm *StateManager) Process(block *Block) (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StateManager) ApplyDiff(state *ethstate.State, parent, block *Block) (receipts Receipts, err error) {
|
func (sm *StateManager) ApplyDiff(state *state.State, parent, block *Block) (receipts Receipts, err error) {
|
||||||
coinbase := state.GetOrNewStateObject(block.Coinbase)
|
coinbase := state.GetOrNewStateObject(block.Coinbase)
|
||||||
coinbase.SetGasPool(block.CalcGasLimit(parent))
|
coinbase.SetGasPool(block.CalcGasLimit(parent))
|
||||||
|
|
||||||
@ -372,7 +372,7 @@ func (sm *StateManager) ValidateBlock(block *Block) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StateManager) AccumelateRewards(state *ethstate.State, block, parent *Block) error {
|
func (sm *StateManager) AccumelateRewards(state *state.State, block, parent *Block) error {
|
||||||
reward := new(big.Int).Set(BlockReward)
|
reward := new(big.Int).Set(BlockReward)
|
||||||
|
|
||||||
knownUncles := ethutil.Set(parent.Uncles)
|
knownUncles := ethutil.Set(parent.Uncles)
|
||||||
@ -416,7 +416,7 @@ func (sm *StateManager) AccumelateRewards(state *ethstate.State, block, parent *
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Manifest will handle both creating notifications and generating bloom bin data
|
// Manifest will handle both creating notifications and generating bloom bin data
|
||||||
func (sm *StateManager) createBloomFilter(state *ethstate.State) *BloomFilter {
|
func (sm *StateManager) createBloomFilter(state *state.State) *BloomFilter {
|
||||||
bloomf := NewBloomFilter(nil)
|
bloomf := NewBloomFilter(nil)
|
||||||
|
|
||||||
for _, msg := range state.Manifest().Messages {
|
for _, msg := range state.Manifest().Messages {
|
||||||
@ -429,7 +429,7 @@ func (sm *StateManager) createBloomFilter(state *ethstate.State) *BloomFilter {
|
|||||||
return bloomf
|
return bloomf
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StateManager) GetMessages(block *Block) (messages []*ethstate.Message, err error) {
|
func (sm *StateManager) GetMessages(block *Block) (messages []*state.Message, err error) {
|
||||||
if !sm.bc.HasBlock(block.PrevHash) {
|
if !sm.bc.HasBlock(block.PrevHash) {
|
||||||
return nil, ParentError(block.PrevHash)
|
return nil, ParentError(block.PrevHash)
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
"github.com/ethereum/go-ethereum/vm"
|
"github.com/ethereum/go-ethereum/vm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -31,17 +31,17 @@ type StateTransition struct {
|
|||||||
gas, gasPrice *big.Int
|
gas, gasPrice *big.Int
|
||||||
value *big.Int
|
value *big.Int
|
||||||
data []byte
|
data []byte
|
||||||
state *ethstate.State
|
state *state.State
|
||||||
block *Block
|
block *Block
|
||||||
|
|
||||||
cb, rec, sen *ethstate.StateObject
|
cb, rec, sen *state.StateObject
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStateTransition(coinbase *ethstate.StateObject, tx *Transaction, state *ethstate.State, block *Block) *StateTransition {
|
func NewStateTransition(coinbase *state.StateObject, tx *Transaction, state *state.State, block *Block) *StateTransition {
|
||||||
return &StateTransition{coinbase.Address(), tx.Recipient, tx, new(big.Int), new(big.Int).Set(tx.GasPrice), tx.Value, tx.Data, state, block, coinbase, nil, nil}
|
return &StateTransition{coinbase.Address(), tx.Recipient, tx, new(big.Int), new(big.Int).Set(tx.GasPrice), tx.Value, tx.Data, state, block, coinbase, nil, nil}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *StateTransition) Coinbase() *ethstate.StateObject {
|
func (self *StateTransition) Coinbase() *state.StateObject {
|
||||||
if self.cb != nil {
|
if self.cb != nil {
|
||||||
return self.cb
|
return self.cb
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ func (self *StateTransition) Coinbase() *ethstate.StateObject {
|
|||||||
self.cb = self.state.GetOrNewStateObject(self.coinbase)
|
self.cb = self.state.GetOrNewStateObject(self.coinbase)
|
||||||
return self.cb
|
return self.cb
|
||||||
}
|
}
|
||||||
func (self *StateTransition) Sender() *ethstate.StateObject {
|
func (self *StateTransition) Sender() *state.StateObject {
|
||||||
if self.sen != nil {
|
if self.sen != nil {
|
||||||
return self.sen
|
return self.sen
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ func (self *StateTransition) Sender() *ethstate.StateObject {
|
|||||||
|
|
||||||
return self.sen
|
return self.sen
|
||||||
}
|
}
|
||||||
func (self *StateTransition) Receiver() *ethstate.StateObject {
|
func (self *StateTransition) Receiver() *state.StateObject {
|
||||||
if self.tx != nil && self.tx.CreatesContract() {
|
if self.tx != nil && self.tx.CreatesContract() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -143,7 +143,7 @@ func (self *StateTransition) TransitionState() (err error) {
|
|||||||
var (
|
var (
|
||||||
tx = self.tx
|
tx = self.tx
|
||||||
sender = self.Sender()
|
sender = self.Sender()
|
||||||
receiver *ethstate.StateObject
|
receiver *state.StateObject
|
||||||
)
|
)
|
||||||
|
|
||||||
defer self.RefundGas()
|
defer self.RefundGas()
|
||||||
@ -167,7 +167,7 @@ func (self *StateTransition) TransitionState() (err error) {
|
|||||||
return fmt.Errorf("Insufficient funds to transfer value. Req %v, has %v", self.value, sender.Balance)
|
return fmt.Errorf("Insufficient funds to transfer value. Req %v, has %v", self.value, sender.Balance)
|
||||||
}
|
}
|
||||||
|
|
||||||
var snapshot *ethstate.State
|
var snapshot *state.State
|
||||||
// If the receiver is nil it's a contract (\0*32).
|
// If the receiver is nil it's a contract (\0*32).
|
||||||
if tx.CreatesContract() {
|
if tx.CreatesContract() {
|
||||||
// Subtract the (irreversible) amount from the senders account
|
// Subtract the (irreversible) amount from the senders account
|
||||||
@ -195,7 +195,7 @@ func (self *StateTransition) TransitionState() (err error) {
|
|||||||
snapshot = self.state.Copy()
|
snapshot = self.state.Copy()
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := self.state.Manifest().AddMessage(ðstate.Message{
|
msg := self.state.Manifest().AddMessage(&state.Message{
|
||||||
To: receiver.Address(), From: sender.Address(),
|
To: receiver.Address(), From: sender.Address(),
|
||||||
Input: self.tx.Data,
|
Input: self.tx.Data,
|
||||||
Origin: sender.Address(),
|
Origin: sender.Address(),
|
||||||
@ -232,14 +232,14 @@ func (self *StateTransition) TransitionState() (err error) {
|
|||||||
} else {
|
} else {
|
||||||
// Add default LOG. Default = big(sender.addr) + 1
|
// Add default LOG. Default = big(sender.addr) + 1
|
||||||
addr := ethutil.BigD(receiver.Address())
|
addr := ethutil.BigD(receiver.Address())
|
||||||
self.state.AddLog(ethstate.Log{sender.Address(), [][]byte{ethutil.U256(addr.Add(addr, ethutil.Big1)).Bytes()}, nil})
|
self.state.AddLog(state.Log{sender.Address(), [][]byte{ethutil.U256(addr.Add(addr, ethutil.Big1)).Bytes()}, nil})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *StateTransition) Eval(msg *ethstate.Message, script []byte, context *ethstate.StateObject) (ret []byte, err error) {
|
func (self *StateTransition) Eval(msg *state.Message, script []byte, context *state.StateObject) (ret []byte, err error) {
|
||||||
var (
|
var (
|
||||||
transactor = self.Sender()
|
transactor = self.Sender()
|
||||||
state = self.state
|
state = self.state
|
||||||
@ -254,7 +254,7 @@ func (self *StateTransition) Eval(msg *ethstate.Message, script []byte, context
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Converts an transaction in to a state object
|
// Converts an transaction in to a state object
|
||||||
func MakeContract(tx *Transaction, state *ethstate.State) *ethstate.StateObject {
|
func MakeContract(tx *Transaction, state *state.State) *state.StateObject {
|
||||||
addr := tx.CreationAddress(state)
|
addr := tx.CreationAddress(state)
|
||||||
|
|
||||||
contract := state.GetOrNewStateObject(addr)
|
contract := state.GetOrNewStateObject(addr)
|
||||||
|
@ -6,8 +6,8 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
"github.com/obscuren/secp256k1-go"
|
"github.com/obscuren/secp256k1-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ func (tx *Transaction) IsContract() bool {
|
|||||||
return tx.CreatesContract()
|
return tx.CreatesContract()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tx *Transaction) CreationAddress(state *ethstate.State) []byte {
|
func (tx *Transaction) CreationAddress(state *state.State) []byte {
|
||||||
// Generate a new address
|
// Generate a new address
|
||||||
addr := crypto.Sha3(ethutil.NewValue([]interface{}{tx.Sender(), tx.Nonce}).Encode())[12:]
|
addr := crypto.Sha3(ethutil.NewValue([]interface{}{tx.Sender(), tx.Nonce}).Encode())[12:]
|
||||||
//for i := uint64(0); state.GetStateObject(addr) != nil; i++ {
|
//for i := uint64(0); state.GetStateObject(addr) != nil; i++ {
|
||||||
@ -205,7 +205,7 @@ type Receipt struct {
|
|||||||
PostState []byte
|
PostState []byte
|
||||||
CumulativeGasUsed *big.Int
|
CumulativeGasUsed *big.Int
|
||||||
Bloom []byte
|
Bloom []byte
|
||||||
logs ethstate.Logs
|
logs state.Logs
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRecieptFromValue(val *ethutil.Value) *Receipt {
|
func NewRecieptFromValue(val *ethutil.Value) *Receipt {
|
||||||
@ -222,7 +222,7 @@ func (self *Receipt) RlpValueDecode(decoder *ethutil.Value) {
|
|||||||
|
|
||||||
it := decoder.Get(3).NewIterator()
|
it := decoder.Get(3).NewIterator()
|
||||||
for it.Next() {
|
for it.Next() {
|
||||||
self.logs = append(self.logs, ethstate.NewLogFromValue(it.Value()))
|
self.logs = append(self.logs, state.NewLogFromValue(it.Value()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethwire"
|
"github.com/ethereum/go-ethereum/ethwire"
|
||||||
"github.com/ethereum/go-ethereum/logger"
|
"github.com/ethereum/go-ethereum/logger"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
var txplogger = logger.NewLogger("TXP")
|
var txplogger = logger.NewLogger("TXP")
|
||||||
@ -193,7 +193,7 @@ func (pool *TxPool) CurrentTransactions() []*Transaction {
|
|||||||
return txList
|
return txList
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pool *TxPool) RemoveInvalid(state *ethstate.State) {
|
func (pool *TxPool) RemoveInvalid(state *state.State) {
|
||||||
pool.mutex.Lock()
|
pool.mutex.Lock()
|
||||||
defer pool.mutex.Unlock()
|
defer pool.mutex.Unlock()
|
||||||
|
|
||||||
|
@ -3,17 +3,17 @@ package chain
|
|||||||
import (
|
import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
"github.com/ethereum/go-ethereum/state"
|
||||||
"github.com/ethereum/go-ethereum/vm"
|
"github.com/ethereum/go-ethereum/vm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type VMEnv struct {
|
type VMEnv struct {
|
||||||
state *ethstate.State
|
state *state.State
|
||||||
block *Block
|
block *Block
|
||||||
tx *Transaction
|
tx *Transaction
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEnv(state *ethstate.State, tx *Transaction, block *Block) *VMEnv {
|
func NewEnv(state *state.State, tx *Transaction, block *Block) *VMEnv {
|
||||||
return &VMEnv{
|
return &VMEnv{
|
||||||
state: state,
|
state: state,
|
||||||
block: block,
|
block: block,
|
||||||
@ -29,9 +29,9 @@ func (self *VMEnv) Time() int64 { return self.block.Time }
|
|||||||
func (self *VMEnv) Difficulty() *big.Int { return self.block.Difficulty }
|
func (self *VMEnv) Difficulty() *big.Int { return self.block.Difficulty }
|
||||||
func (self *VMEnv) BlockHash() []byte { return self.block.Hash() }
|
func (self *VMEnv) BlockHash() []byte { return self.block.Hash() }
|
||||||
func (self *VMEnv) Value() *big.Int { return self.tx.Value }
|
func (self *VMEnv) Value() *big.Int { return self.tx.Value }
|
||||||
func (self *VMEnv) State() *ethstate.State { return self.state }
|
func (self *VMEnv) State() *state.State { return self.state }
|
||||||
func (self *VMEnv) GasLimit() *big.Int { return self.block.GasLimit }
|
func (self *VMEnv) GasLimit() *big.Int { return self.block.GasLimit }
|
||||||
func (self *VMEnv) AddLog(log ethstate.Log) {
|
func (self *VMEnv) AddLog(log state.Log) {
|
||||||
self.state.AddLog(log)
|
self.state.AddLog(log)
|
||||||
}
|
}
|
||||||
func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) error {
|
func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) error {
|
||||||
|
@ -26,8 +26,8 @@ import (
|
|||||||
|
|
||||||
"github.com/ethereum/go-ethereum/chain"
|
"github.com/ethereum/go-ethereum/chain"
|
||||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
"github.com/ethereum/go-ethereum/vm"
|
"github.com/ethereum/go-ethereum/vm"
|
||||||
"gopkg.in/qml.v1"
|
"gopkg.in/qml.v1"
|
||||||
)
|
)
|
||||||
@ -40,7 +40,7 @@ type DebuggerWindow struct {
|
|||||||
vm *vm.DebugVm
|
vm *vm.DebugVm
|
||||||
Db *Debugger
|
Db *Debugger
|
||||||
|
|
||||||
state *ethstate.State
|
state *state.State
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDebuggerWindow(lib *UiLib) *DebuggerWindow {
|
func NewDebuggerWindow(lib *UiLib) *DebuggerWindow {
|
||||||
@ -141,17 +141,17 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
|
|||||||
keyPair = self.lib.eth.KeyManager().KeyPair()
|
keyPair = self.lib.eth.KeyManager().KeyPair()
|
||||||
)
|
)
|
||||||
|
|
||||||
state := self.lib.eth.StateManager().TransState()
|
statedb := self.lib.eth.StateManager().TransState()
|
||||||
account := self.lib.eth.StateManager().TransState().GetAccount(keyPair.Address())
|
account := self.lib.eth.StateManager().TransState().GetAccount(keyPair.Address())
|
||||||
contract := ethstate.NewStateObject([]byte{0})
|
contract := statedb.NewStateObject([]byte{0})
|
||||||
contract.SetBalance(value)
|
contract.SetBalance(value)
|
||||||
|
|
||||||
self.SetAsm(script)
|
self.SetAsm(script)
|
||||||
|
|
||||||
block := self.lib.eth.ChainManager().CurrentBlock
|
block := self.lib.eth.ChainManager().CurrentBlock
|
||||||
|
|
||||||
callerClosure := vm.NewClosure(ðstate.Message{}, account, contract, script, gas, gasPrice)
|
callerClosure := vm.NewClosure(&state.Message{}, account, contract, script, gas, gasPrice)
|
||||||
env := utils.NewEnv(state, block, account.Address(), value)
|
env := utils.NewEnv(statedb, block, account.Address(), value)
|
||||||
evm := vm.NewDebugVm(env)
|
evm := vm.NewDebugVm(env)
|
||||||
evm.Dbg = self.Db
|
evm.Dbg = self.Db
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state.Reset()
|
statedb.Reset()
|
||||||
|
|
||||||
if !self.Db.interrupt {
|
if !self.Db.interrupt {
|
||||||
self.Db.done = true
|
self.Db.done = true
|
||||||
@ -267,13 +267,13 @@ type storeVal struct {
|
|||||||
Key, Value string
|
Key, Value string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Debugger) BreakHook(pc int, op vm.OpCode, mem *vm.Memory, stack *vm.Stack, stateObject *ethstate.StateObject) bool {
|
func (self *Debugger) BreakHook(pc int, op vm.OpCode, mem *vm.Memory, stack *vm.Stack, stateObject *state.StateObject) bool {
|
||||||
self.main.Logln("break on instr:", pc)
|
self.main.Logln("break on instr:", pc)
|
||||||
|
|
||||||
return self.halting(pc, op, mem, stack, stateObject)
|
return self.halting(pc, op, mem, stack, stateObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Debugger) StepHook(pc int, op vm.OpCode, mem *vm.Memory, stack *vm.Stack, stateObject *ethstate.StateObject) bool {
|
func (self *Debugger) StepHook(pc int, op vm.OpCode, mem *vm.Memory, stack *vm.Stack, stateObject *state.StateObject) bool {
|
||||||
return self.halting(pc, op, mem, stack, stateObject)
|
return self.halting(pc, op, mem, stack, stateObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ func (self *Debugger) BreakPoints() []int64 {
|
|||||||
return self.breakPoints
|
return self.breakPoints
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Debugger) halting(pc int, op vm.OpCode, mem *vm.Memory, stack *vm.Stack, stateObject *ethstate.StateObject) bool {
|
func (d *Debugger) halting(pc int, op vm.OpCode, mem *vm.Memory, stack *vm.Stack, stateObject *state.StateObject) bool {
|
||||||
d.win.Root().Call("setInstruction", pc)
|
d.win.Root().Call("setInstruction", pc)
|
||||||
d.win.Root().Call("clearMem")
|
d.win.Root().Call("clearMem")
|
||||||
d.win.Root().Call("clearStack")
|
d.win.Root().Call("clearStack")
|
||||||
|
@ -21,9 +21,9 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/chain"
|
"github.com/ethereum/go-ethereum/chain"
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
"github.com/ethereum/go-ethereum/javascript"
|
"github.com/ethereum/go-ethereum/javascript"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
"github.com/ethereum/go-ethereum/ui/qt"
|
"github.com/ethereum/go-ethereum/ui/qt"
|
||||||
"github.com/ethereum/go-ethereum/xeth"
|
"github.com/ethereum/go-ethereum/xeth"
|
||||||
"gopkg.in/qml.v1"
|
"gopkg.in/qml.v1"
|
||||||
@ -38,7 +38,7 @@ type AppContainer interface {
|
|||||||
|
|
||||||
NewBlock(*chain.Block)
|
NewBlock(*chain.Block)
|
||||||
NewWatcher(chan bool)
|
NewWatcher(chan bool)
|
||||||
Messages(ethstate.Messages, string)
|
Messages(state.Messages, string)
|
||||||
Post(string, int)
|
Post(string, int)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ func (app *ExtApplication) run() {
|
|||||||
|
|
||||||
// Subscribe to events
|
// Subscribe to events
|
||||||
mux := app.lib.eth.EventMux()
|
mux := app.lib.eth.EventMux()
|
||||||
app.events = mux.Subscribe(chain.NewBlockEvent{}, ethstate.Messages(nil))
|
app.events = mux.Subscribe(chain.NewBlockEvent{}, state.Messages(nil))
|
||||||
|
|
||||||
// Call the main loop
|
// Call the main loop
|
||||||
go app.mainLoop()
|
go app.mainLoop()
|
||||||
@ -109,7 +109,7 @@ func (app *ExtApplication) mainLoop() {
|
|||||||
case chain.NewBlockEvent:
|
case chain.NewBlockEvent:
|
||||||
app.container.NewBlock(ev.Block)
|
app.container.NewBlock(ev.Block)
|
||||||
|
|
||||||
case ethstate.Messages:
|
case state.Messages:
|
||||||
for id, filter := range app.filters {
|
for id, filter := range app.filters {
|
||||||
msgs := filter.FilterMessages(ev)
|
msgs := filter.FilterMessages(ev)
|
||||||
if len(msgs) > 0 {
|
if len(msgs) > 0 {
|
||||||
|
@ -28,9 +28,9 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/chain"
|
"github.com/ethereum/go-ethereum/chain"
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
"github.com/ethereum/go-ethereum/javascript"
|
"github.com/ethereum/go-ethereum/javascript"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
"github.com/ethereum/go-ethereum/xeth"
|
"github.com/ethereum/go-ethereum/xeth"
|
||||||
"github.com/howeyc/fsnotify"
|
"github.com/howeyc/fsnotify"
|
||||||
"gopkg.in/qml.v1"
|
"gopkg.in/qml.v1"
|
||||||
@ -143,7 +143,7 @@ func (app *HtmlApplication) NewBlock(block *chain.Block) {
|
|||||||
app.webView.Call("onNewBlockCb", b)
|
app.webView.Call("onNewBlockCb", b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *HtmlApplication) Messages(messages ethstate.Messages, id string) {
|
func (self *HtmlApplication) Messages(messages state.Messages, id string) {
|
||||||
var msgs []javascript.JSMessage
|
var msgs []javascript.JSMessage
|
||||||
for _, m := range messages {
|
for _, m := range messages {
|
||||||
msgs = append(msgs, javascript.NewJSMessage(m))
|
msgs = append(msgs, javascript.NewJSMessage(m))
|
||||||
|
@ -22,8 +22,8 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/chain"
|
"github.com/ethereum/go-ethereum/chain"
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
"github.com/ethereum/go-ethereum/xeth"
|
"github.com/ethereum/go-ethereum/xeth"
|
||||||
"gopkg.in/qml.v1"
|
"gopkg.in/qml.v1"
|
||||||
)
|
)
|
||||||
@ -70,7 +70,7 @@ func (app *QmlApplication) NewBlock(block *chain.Block) {
|
|||||||
app.win.Call("onNewBlockCb", pblock)
|
app.win.Call("onNewBlockCb", pblock)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *QmlApplication) Messages(msgs ethstate.Messages, id string) {
|
func (self *QmlApplication) Messages(msgs state.Messages, id string) {
|
||||||
fmt.Println("IMPLEMENT QML APPLICATION MESSAGES METHOD")
|
fmt.Println("IMPLEMENT QML APPLICATION MESSAGES METHOD")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,9 +27,9 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum"
|
"github.com/ethereum/go-ethereum"
|
||||||
"github.com/ethereum/go-ethereum/chain"
|
"github.com/ethereum/go-ethereum/chain"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
"github.com/ethereum/go-ethereum/javascript"
|
"github.com/ethereum/go-ethereum/javascript"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
"github.com/ethereum/go-ethereum/ui/qt"
|
"github.com/ethereum/go-ethereum/ui/qt"
|
||||||
"github.com/ethereum/go-ethereum/xeth"
|
"github.com/ethereum/go-ethereum/xeth"
|
||||||
"gopkg.in/qml.v1"
|
"gopkg.in/qml.v1"
|
||||||
@ -213,7 +213,7 @@ func (self *UiLib) StartDebugger() {
|
|||||||
|
|
||||||
func (self *UiLib) NewFilter(object map[string]interface{}) (id int) {
|
func (self *UiLib) NewFilter(object map[string]interface{}) (id int) {
|
||||||
filter := qt.NewFilterFromMap(object, self.eth)
|
filter := qt.NewFilterFromMap(object, self.eth)
|
||||||
filter.MessageCallback = func(messages ethstate.Messages) {
|
filter.MessageCallback = func(messages state.Messages) {
|
||||||
self.win.Root().Call("invokeFilterCallback", xeth.ToJSMessages(messages), id)
|
self.win.Root().Call("invokeFilterCallback", xeth.ToJSMessages(messages), id)
|
||||||
}
|
}
|
||||||
id = self.eth.InstallFilter(filter)
|
id = self.eth.InstallFilter(filter)
|
||||||
|
@ -4,19 +4,19 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/chain"
|
"github.com/ethereum/go-ethereum/chain"
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
"github.com/ethereum/go-ethereum/state"
|
||||||
"github.com/ethereum/go-ethereum/vm"
|
"github.com/ethereum/go-ethereum/vm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type VMEnv struct {
|
type VMEnv struct {
|
||||||
state *ethstate.State
|
state *state.State
|
||||||
block *chain.Block
|
block *chain.Block
|
||||||
|
|
||||||
transactor []byte
|
transactor []byte
|
||||||
value *big.Int
|
value *big.Int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEnv(state *ethstate.State, block *chain.Block, transactor []byte, value *big.Int) *VMEnv {
|
func NewEnv(state *state.State, block *chain.Block, transactor []byte, value *big.Int) *VMEnv {
|
||||||
return &VMEnv{
|
return &VMEnv{
|
||||||
state: state,
|
state: state,
|
||||||
block: block,
|
block: block,
|
||||||
@ -33,9 +33,9 @@ func (self *VMEnv) Time() int64 { return self.block.Time }
|
|||||||
func (self *VMEnv) Difficulty() *big.Int { return self.block.Difficulty }
|
func (self *VMEnv) Difficulty() *big.Int { return self.block.Difficulty }
|
||||||
func (self *VMEnv) BlockHash() []byte { return self.block.Hash() }
|
func (self *VMEnv) BlockHash() []byte { return self.block.Hash() }
|
||||||
func (self *VMEnv) Value() *big.Int { return self.value }
|
func (self *VMEnv) Value() *big.Int { return self.value }
|
||||||
func (self *VMEnv) State() *ethstate.State { return self.state }
|
func (self *VMEnv) State() *state.State { return self.state }
|
||||||
func (self *VMEnv) GasLimit() *big.Int { return self.block.GasLimit }
|
func (self *VMEnv) GasLimit() *big.Int { return self.block.GasLimit }
|
||||||
func (self *VMEnv) AddLog(ethstate.Log) {}
|
func (self *VMEnv) AddLog(state.Log) {}
|
||||||
func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) error {
|
func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) error {
|
||||||
return vm.Transfer(from, to, amount)
|
return vm.Transfer(from, to, amount)
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,12 @@ import (
|
|||||||
|
|
||||||
"github.com/ethereum/go-ethereum/chain"
|
"github.com/ethereum/go-ethereum/chain"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
"github.com/ethereum/go-ethereum/ethwire"
|
"github.com/ethereum/go-ethereum/ethwire"
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
"github.com/ethereum/go-ethereum/logger"
|
"github.com/ethereum/go-ethereum/logger"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -615,7 +615,7 @@ func (self *Ethereum) GetFilter(id int) *chain.Filter {
|
|||||||
|
|
||||||
func (self *Ethereum) filterLoop() {
|
func (self *Ethereum) filterLoop() {
|
||||||
// Subscribe to events
|
// Subscribe to events
|
||||||
events := self.eventMux.Subscribe(chain.NewBlockEvent{}, ethstate.Messages(nil))
|
events := self.eventMux.Subscribe(chain.NewBlockEvent{}, state.Messages(nil))
|
||||||
for event := range events.Chan() {
|
for event := range events.Chan() {
|
||||||
switch event := event.(type) {
|
switch event := event.(type) {
|
||||||
case chain.NewBlockEvent:
|
case chain.NewBlockEvent:
|
||||||
@ -627,7 +627,7 @@ func (self *Ethereum) filterLoop() {
|
|||||||
}
|
}
|
||||||
self.filterMu.RUnlock()
|
self.filterMu.RUnlock()
|
||||||
|
|
||||||
case ethstate.Messages:
|
case state.Messages:
|
||||||
self.filterMu.RLock()
|
self.filterMu.RLock()
|
||||||
for _, filter := range self.filters {
|
for _, filter := range self.filters {
|
||||||
if filter.MessageCallback != nil {
|
if filter.MessageCallback != nil {
|
||||||
|
@ -10,10 +10,10 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum"
|
"github.com/ethereum/go-ethereum"
|
||||||
"github.com/ethereum/go-ethereum/chain"
|
"github.com/ethereum/go-ethereum/chain"
|
||||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
"github.com/ethereum/go-ethereum/logger"
|
"github.com/ethereum/go-ethereum/logger"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
"github.com/ethereum/go-ethereum/xeth"
|
"github.com/ethereum/go-ethereum/xeth"
|
||||||
"github.com/obscuren/otto"
|
"github.com/obscuren/otto"
|
||||||
)
|
)
|
||||||
@ -127,7 +127,7 @@ func (self *JSRE) initStdFuncs() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
func (self *JSRE) dump(call otto.FunctionCall) otto.Value {
|
func (self *JSRE) dump(call otto.FunctionCall) otto.Value {
|
||||||
var state *ethstate.State
|
var state *state.State
|
||||||
|
|
||||||
if len(call.ArgumentList) > 0 {
|
if len(call.ArgumentList) > 0 {
|
||||||
var block *chain.Block
|
var block *chain.Block
|
||||||
|
@ -4,8 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum"
|
"github.com/ethereum/go-ethereum"
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
"github.com/ethereum/go-ethereum/ui"
|
"github.com/ethereum/go-ethereum/ui"
|
||||||
"github.com/ethereum/go-ethereum/xeth"
|
"github.com/ethereum/go-ethereum/xeth"
|
||||||
"github.com/obscuren/otto"
|
"github.com/obscuren/otto"
|
||||||
@ -51,7 +51,7 @@ type JSMessage struct {
|
|||||||
Number int32 `json:"number"`
|
Number int32 `json:"number"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewJSMessage(message *ethstate.Message) JSMessage {
|
func NewJSMessage(message *state.Message) JSMessage {
|
||||||
return JSMessage{
|
return JSMessage{
|
||||||
To: ethutil.Bytes2Hex(message.To),
|
To: ethutil.Bytes2Hex(message.To),
|
||||||
From: ethutil.Bytes2Hex(message.From),
|
From: ethutil.Bytes2Hex(message.From),
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package ethstate
|
package state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
@ -1,4 +1,4 @@
|
|||||||
package ethstate
|
package state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -1,4 +1,4 @@
|
|||||||
package ethstate
|
package state
|
||||||
|
|
||||||
import "github.com/ethereum/go-ethereum/ethutil"
|
import "github.com/ethereum/go-ethereum/ethutil"
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package ethstate
|
package state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -1,4 +1,4 @@
|
|||||||
package ethstate
|
package state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/big"
|
"math/big"
|
@ -1,4 +1,4 @@
|
|||||||
package ethstate
|
package state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -1,4 +1,4 @@
|
|||||||
package ethstate
|
package state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
@ -5,14 +5,14 @@ package vm
|
|||||||
import (
|
import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ClosureRef interface {
|
type ClosureRef interface {
|
||||||
ReturnGas(*big.Int, *big.Int)
|
ReturnGas(*big.Int, *big.Int)
|
||||||
Address() []byte
|
Address() []byte
|
||||||
Object() *ethstate.StateObject
|
Object() *state.StateObject
|
||||||
GetStorage(*big.Int) *ethutil.Value
|
GetStorage(*big.Int) *ethutil.Value
|
||||||
SetStorage(*big.Int, *ethutil.Value)
|
SetStorage(*big.Int, *ethutil.Value)
|
||||||
}
|
}
|
||||||
@ -20,9 +20,9 @@ type ClosureRef interface {
|
|||||||
// Basic inline closure object which implement the 'closure' interface
|
// Basic inline closure object which implement the 'closure' interface
|
||||||
type Closure struct {
|
type Closure struct {
|
||||||
caller ClosureRef
|
caller ClosureRef
|
||||||
object *ethstate.StateObject
|
object *state.StateObject
|
||||||
Code []byte
|
Code []byte
|
||||||
message *ethstate.Message
|
message *state.Message
|
||||||
exe *Execution
|
exe *Execution
|
||||||
|
|
||||||
Gas, UsedGas, Price *big.Int
|
Gas, UsedGas, Price *big.Int
|
||||||
@ -31,7 +31,7 @@ type Closure struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a new closure for the given data items
|
// Create a new closure for the given data items
|
||||||
func NewClosure(msg *ethstate.Message, caller ClosureRef, object *ethstate.StateObject, code []byte, gas, price *big.Int) *Closure {
|
func NewClosure(msg *state.Message, caller ClosureRef, object *state.StateObject, code []byte, gas, price *big.Int) *Closure {
|
||||||
c := &Closure{message: msg, caller: caller, object: object, Code: code, Args: nil}
|
c := &Closure{message: msg, caller: caller, object: object, Code: code, Args: nil}
|
||||||
|
|
||||||
// Gas should be a pointer so it can safely be reduced through the run
|
// Gas should be a pointer so it can safely be reduced through the run
|
||||||
@ -131,7 +131,7 @@ func (c *Closure) ReturnGas(gas, price *big.Int) {
|
|||||||
c.UsedGas.Sub(c.UsedGas, gas)
|
c.UsedGas.Sub(c.UsedGas, gas)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Closure) Object() *ethstate.StateObject {
|
func (c *Closure) Object() *state.StateObject {
|
||||||
return c.object
|
return c.object
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package vm
|
package vm
|
||||||
|
|
||||||
import "github.com/ethereum/go-ethereum/ethstate"
|
import "github.com/ethereum/go-ethereum/state"
|
||||||
|
|
||||||
type Debugger interface {
|
type Debugger interface {
|
||||||
BreakHook(step int, op OpCode, mem *Memory, stack *Stack, object *ethstate.StateObject) bool
|
BreakHook(step int, op OpCode, mem *Memory, stack *Stack, object *state.StateObject) bool
|
||||||
StepHook(step int, op OpCode, mem *Memory, stack *Stack, object *ethstate.StateObject) bool
|
StepHook(step int, op OpCode, mem *Memory, stack *Stack, object *state.StateObject) bool
|
||||||
BreakPoints() []int64
|
BreakPoints() []int64
|
||||||
SetCode(byteCode []byte)
|
SetCode(byteCode []byte)
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,12 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Environment interface {
|
type Environment interface {
|
||||||
State() *ethstate.State
|
State() *state.State
|
||||||
|
|
||||||
Origin() []byte
|
Origin() []byte
|
||||||
BlockNumber() *big.Int
|
BlockNumber() *big.Int
|
||||||
@ -20,7 +20,7 @@ type Environment interface {
|
|||||||
BlockHash() []byte
|
BlockHash() []byte
|
||||||
GasLimit() *big.Int
|
GasLimit() *big.Int
|
||||||
Transfer(from, to Account, amount *big.Int) error
|
Transfer(from, to Account, amount *big.Int) error
|
||||||
AddLog(ethstate.Log)
|
AddLog(state.Log)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Object interface {
|
type Object interface {
|
||||||
|
@ -4,15 +4,15 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Execution struct {
|
type Execution struct {
|
||||||
vm VirtualMachine
|
vm VirtualMachine
|
||||||
address, input []byte
|
address, input []byte
|
||||||
Gas, price, value *big.Int
|
Gas, price, value *big.Int
|
||||||
object *ethstate.StateObject
|
object *state.StateObject
|
||||||
SkipTransfer bool
|
SkipTransfer bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ func (self *Execution) exec(code, caddr []byte, caller ClosureRef) (ret []byte,
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
msg := env.State().Manifest().AddMessage(ðstate.Message{
|
msg := env.State().Manifest().AddMessage(&state.Message{
|
||||||
To: self.address, From: caller.Address(),
|
To: self.address, From: caller.Address(),
|
||||||
Input: self.input,
|
Input: self.input,
|
||||||
Origin: env.Origin(),
|
Origin: env.Origin(),
|
||||||
|
@ -5,8 +5,8 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DebugVm struct {
|
type DebugVm struct {
|
||||||
@ -49,7 +49,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
|
|||||||
pc = big.NewInt(0)
|
pc = big.NewInt(0)
|
||||||
step = 0
|
step = 0
|
||||||
prevStep = 0
|
prevStep = 0
|
||||||
state = self.env.State()
|
statedb = self.env.State()
|
||||||
require = func(m int) {
|
require = func(m int) {
|
||||||
if stack.Len() < m {
|
if stack.Len() < m {
|
||||||
panic(fmt.Sprintf("%04v (%v) stack err size = %d, required = %d", pc, op, stack.Len(), m))
|
panic(fmt.Sprintf("%04v (%v) stack err size = %d, required = %d", pc, op, stack.Len(), m))
|
||||||
@ -115,7 +115,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
|
|||||||
if self.logTy == LogTyDiff {
|
if self.logTy == LogTyDiff {
|
||||||
switch op {
|
switch op {
|
||||||
case STOP, RETURN, SUICIDE:
|
case STOP, RETURN, SUICIDE:
|
||||||
state.GetStateObject(closure.Address()).EachStorage(func(key string, value *ethutil.Value) {
|
statedb.GetStateObject(closure.Address()).EachStorage(func(key string, value *ethutil.Value) {
|
||||||
value.Decode()
|
value.Decode()
|
||||||
fmt.Printf("%x %x\n", new(big.Int).SetBytes([]byte(key)).Bytes(), value.Bytes())
|
fmt.Printf("%x %x\n", new(big.Int).SetBytes([]byte(key)).Bytes(), value.Bytes())
|
||||||
})
|
})
|
||||||
@ -184,7 +184,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
|
|||||||
// 0 => non 0
|
// 0 => non 0
|
||||||
mult = ethutil.Big3
|
mult = ethutil.Big3
|
||||||
} else if val.BigInt().Cmp(ethutil.Big0) != 0 && len(y.Bytes()) == 0 {
|
} else if val.BigInt().Cmp(ethutil.Big0) != 0 && len(y.Bytes()) == 0 {
|
||||||
state.Refund(closure.caller.Address(), GasSStoreRefund, closure.Price)
|
statedb.Refund(closure.caller.Address(), GasSStoreRefund, closure.Price)
|
||||||
|
|
||||||
mult = ethutil.Big0
|
mult = ethutil.Big0
|
||||||
} else {
|
} else {
|
||||||
@ -532,7 +532,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
|
|||||||
case BALANCE:
|
case BALANCE:
|
||||||
|
|
||||||
addr := stack.Pop().Bytes()
|
addr := stack.Pop().Bytes()
|
||||||
balance := state.GetBalance(addr)
|
balance := statedb.GetBalance(addr)
|
||||||
|
|
||||||
stack.Push(balance)
|
stack.Push(balance)
|
||||||
|
|
||||||
@ -599,7 +599,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
|
|||||||
if op == EXTCODESIZE {
|
if op == EXTCODESIZE {
|
||||||
addr := stack.Pop().Bytes()
|
addr := stack.Pop().Bytes()
|
||||||
|
|
||||||
code = state.GetCode(addr)
|
code = statedb.GetCode(addr)
|
||||||
} else {
|
} else {
|
||||||
code = closure.Code
|
code = closure.Code
|
||||||
}
|
}
|
||||||
@ -613,7 +613,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
|
|||||||
if op == EXTCODECOPY {
|
if op == EXTCODECOPY {
|
||||||
addr := stack.Pop().Bytes()
|
addr := stack.Pop().Bytes()
|
||||||
|
|
||||||
code = state.GetCode(addr)
|
code = statedb.GetCode(addr)
|
||||||
} else {
|
} else {
|
||||||
code = closure.Code
|
code = closure.Code
|
||||||
}
|
}
|
||||||
@ -711,7 +711,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
|
|||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
topics[i] = stack.Pop().Bytes()
|
topics[i] = stack.Pop().Bytes()
|
||||||
}
|
}
|
||||||
self.env.AddLog(ethstate.Log{closure.Address(), topics, data})
|
self.env.AddLog(state.Log{closure.Address(), topics, data})
|
||||||
case MLOAD:
|
case MLOAD:
|
||||||
offset := stack.Pop()
|
offset := stack.Pop()
|
||||||
val := ethutil.BigD(mem.Get(offset.Int64(), 32))
|
val := ethutil.BigD(mem.Get(offset.Int64(), 32))
|
||||||
@ -733,13 +733,13 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
|
|||||||
self.Printf(" => [%v] 0x%x", off, val)
|
self.Printf(" => [%v] 0x%x", off, val)
|
||||||
case SLOAD:
|
case SLOAD:
|
||||||
loc := stack.Pop()
|
loc := stack.Pop()
|
||||||
val := ethutil.BigD(state.GetState(closure.Address(), loc.Bytes()))
|
val := ethutil.BigD(statedb.GetState(closure.Address(), loc.Bytes()))
|
||||||
stack.Push(val)
|
stack.Push(val)
|
||||||
|
|
||||||
self.Printf(" {0x%x : 0x%x}", loc.Bytes(), val.Bytes())
|
self.Printf(" {0x%x : 0x%x}", loc.Bytes(), val.Bytes())
|
||||||
case SSTORE:
|
case SSTORE:
|
||||||
val, loc := stack.Popn()
|
val, loc := stack.Popn()
|
||||||
state.SetState(closure.Address(), loc.Bytes(), val)
|
statedb.SetState(closure.Address(), loc.Bytes(), val)
|
||||||
|
|
||||||
// Debug sessions are allowed to run without message
|
// Debug sessions are allowed to run without message
|
||||||
if closure.message != nil {
|
if closure.message != nil {
|
||||||
@ -784,9 +784,9 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Generate a new address
|
// Generate a new address
|
||||||
n := state.GetNonce(closure.Address())
|
n := statedb.GetNonce(closure.Address())
|
||||||
addr := crypto.CreateAddress(closure.Address(), n)
|
addr := crypto.CreateAddress(closure.Address(), n)
|
||||||
state.SetNonce(closure.Address(), n+1)
|
statedb.SetNonce(closure.Address(), n+1)
|
||||||
|
|
||||||
self.Printf(" (*) %x", addr).Endl()
|
self.Printf(" (*) %x", addr).Endl()
|
||||||
|
|
||||||
@ -861,10 +861,10 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
|
|||||||
return closure.Return(ret), nil
|
return closure.Return(ret), nil
|
||||||
case SUICIDE:
|
case SUICIDE:
|
||||||
|
|
||||||
receiver := state.GetOrNewStateObject(stack.Pop().Bytes())
|
receiver := statedb.GetOrNewStateObject(stack.Pop().Bytes())
|
||||||
|
|
||||||
receiver.AddAmount(state.GetBalance(closure.Address()))
|
receiver.AddAmount(statedb.GetBalance(closure.Address()))
|
||||||
state.Delete(closure.Address())
|
statedb.Delete(closure.Address())
|
||||||
|
|
||||||
fallthrough
|
fallthrough
|
||||||
case STOP: // Stop the closure
|
case STOP: // Stop the closure
|
||||||
@ -889,11 +889,11 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
|
|||||||
if pc.Cmp(big.NewInt(instrNo)) == 0 {
|
if pc.Cmp(big.NewInt(instrNo)) == 0 {
|
||||||
self.Stepping = true
|
self.Stepping = true
|
||||||
|
|
||||||
if !self.Dbg.BreakHook(prevStep, op, mem, stack, state.GetStateObject(closure.Address())) {
|
if !self.Dbg.BreakHook(prevStep, op, mem, stack, statedb.GetStateObject(closure.Address())) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
} else if self.Stepping {
|
} else if self.Stepping {
|
||||||
if !self.Dbg.StepHook(prevStep, op, mem, stack, state.GetStateObject(closure.Address())) {
|
if !self.Dbg.StepHook(prevStep, op, mem, stack, statedb.GetStateObject(closure.Address())) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
|
|
||||||
"github.com/ethereum/go-ethereum/chain"
|
"github.com/ethereum/go-ethereum/chain"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
type JSXEth struct {
|
type JSXEth struct {
|
||||||
@ -254,7 +254,7 @@ func (self *JSXEth) CompileMutan(code string) string {
|
|||||||
return ethutil.Bytes2Hex(data)
|
return ethutil.Bytes2Hex(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ToJSMessages(messages ethstate.Messages) *ethutil.List {
|
func ToJSMessages(messages state.Messages) *ethutil.List {
|
||||||
var msgs []JSMessage
|
var msgs []JSMessage
|
||||||
for _, m := range messages {
|
for _, m := range messages {
|
||||||
msgs = append(msgs, NewJSMessage(m))
|
msgs = append(msgs, NewJSMessage(m))
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
|
|
||||||
"github.com/ethereum/go-ethereum/chain"
|
"github.com/ethereum/go-ethereum/chain"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Block interface exposed to QML
|
// Block interface exposed to QML
|
||||||
@ -90,7 +90,7 @@ type JSTransaction struct {
|
|||||||
Confirmations int `json:"confirmations"`
|
Confirmations int `json:"confirmations"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewJSTx(tx *chain.Transaction, state *ethstate.State) *JSTransaction {
|
func NewJSTx(tx *chain.Transaction, state *state.State) *JSTransaction {
|
||||||
hash := ethutil.Bytes2Hex(tx.Hash())
|
hash := ethutil.Bytes2Hex(tx.Hash())
|
||||||
receiver := ethutil.Bytes2Hex(tx.Recipient)
|
receiver := ethutil.Bytes2Hex(tx.Recipient)
|
||||||
if receiver == "0000000000000000000000000000000000000000" {
|
if receiver == "0000000000000000000000000000000000000000" {
|
||||||
@ -212,7 +212,7 @@ type JSMessage struct {
|
|||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewJSMessage(message *ethstate.Message) JSMessage {
|
func NewJSMessage(message *state.Message) JSMessage {
|
||||||
return JSMessage{
|
return JSMessage{
|
||||||
To: ethutil.Bytes2Hex(message.To),
|
To: ethutil.Bytes2Hex(message.To),
|
||||||
From: ethutil.Bytes2Hex(message.From),
|
From: ethutil.Bytes2Hex(message.From),
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package xeth
|
package xeth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Object struct {
|
type Object struct {
|
||||||
*ethstate.StateObject
|
*state.StateObject
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Object) StorageString(str string) *ethutil.Value {
|
func (self *Object) StorageString(str string) *ethutil.Value {
|
||||||
|
@ -10,16 +10,16 @@ import (
|
|||||||
|
|
||||||
"github.com/ethereum/go-ethereum/chain"
|
"github.com/ethereum/go-ethereum/chain"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
|
||||||
"github.com/ethereum/go-ethereum/ethutil"
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
"github.com/ethereum/go-ethereum/logger"
|
"github.com/ethereum/go-ethereum/logger"
|
||||||
|
"github.com/ethereum/go-ethereum/state"
|
||||||
"github.com/ethereum/go-ethereum/vm"
|
"github.com/ethereum/go-ethereum/vm"
|
||||||
)
|
)
|
||||||
|
|
||||||
var pipelogger = logger.NewLogger("XETH")
|
var pipelogger = logger.NewLogger("XETH")
|
||||||
|
|
||||||
type VmVars struct {
|
type VmVars struct {
|
||||||
State *ethstate.State
|
State *state.State
|
||||||
}
|
}
|
||||||
|
|
||||||
type XEth struct {
|
type XEth struct {
|
||||||
@ -56,7 +56,7 @@ func (self *XEth) Execute(addr []byte, data []byte, value, gas, price *ethutil.V
|
|||||||
|
|
||||||
func (self *XEth) ExecuteObject(object *Object, data []byte, value, gas, price *ethutil.Value) ([]byte, error) {
|
func (self *XEth) ExecuteObject(object *Object, data []byte, value, gas, price *ethutil.Value) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
initiator = ethstate.NewStateObject(self.obj.KeyManager().KeyPair().Address())
|
initiator = state.NewStateObject(self.obj.KeyManager().KeyPair().Address())
|
||||||
block = self.blockChain.CurrentBlock
|
block = self.blockChain.CurrentBlock
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,18 +4,18 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/chain"
|
"github.com/ethereum/go-ethereum/chain"
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
"github.com/ethereum/go-ethereum/state"
|
||||||
"github.com/ethereum/go-ethereum/vm"
|
"github.com/ethereum/go-ethereum/vm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type VMEnv struct {
|
type VMEnv struct {
|
||||||
state *ethstate.State
|
state *state.State
|
||||||
block *chain.Block
|
block *chain.Block
|
||||||
value *big.Int
|
value *big.Int
|
||||||
sender []byte
|
sender []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEnv(state *ethstate.State, block *chain.Block, value *big.Int, sender []byte) *VMEnv {
|
func NewEnv(state *state.State, block *chain.Block, value *big.Int, sender []byte) *VMEnv {
|
||||||
return &VMEnv{
|
return &VMEnv{
|
||||||
state: state,
|
state: state,
|
||||||
block: block,
|
block: block,
|
||||||
@ -32,9 +32,9 @@ func (self *VMEnv) Time() int64 { return self.block.Time }
|
|||||||
func (self *VMEnv) Difficulty() *big.Int { return self.block.Difficulty }
|
func (self *VMEnv) Difficulty() *big.Int { return self.block.Difficulty }
|
||||||
func (self *VMEnv) BlockHash() []byte { return self.block.Hash() }
|
func (self *VMEnv) BlockHash() []byte { return self.block.Hash() }
|
||||||
func (self *VMEnv) Value() *big.Int { return self.value }
|
func (self *VMEnv) Value() *big.Int { return self.value }
|
||||||
func (self *VMEnv) State() *ethstate.State { return self.state }
|
func (self *VMEnv) State() *state.State { return self.state }
|
||||||
func (self *VMEnv) GasLimit() *big.Int { return self.block.GasLimit }
|
func (self *VMEnv) GasLimit() *big.Int { return self.block.GasLimit }
|
||||||
func (self *VMEnv) AddLog(ethstate.Log) {}
|
func (self *VMEnv) AddLog(state.Log) {}
|
||||||
func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) error {
|
func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) error {
|
||||||
return vm.Transfer(from, to, amount)
|
return vm.Transfer(from, to, amount)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package xeth
|
|||||||
import (
|
import (
|
||||||
"container/list"
|
"container/list"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/ethstate"
|
"github.com/ethereum/go-ethereum/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
type World struct {
|
type World struct {
|
||||||
@ -22,7 +22,7 @@ func (self *XEth) World() *World {
|
|||||||
return self.world
|
return self.world
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *World) State() *ethstate.State {
|
func (self *World) State() *state.State {
|
||||||
return self.pipe.stateManager.CurrentState()
|
return self.pipe.stateManager.CurrentState()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,16 +34,16 @@ func (self *World) SafeGet(addr []byte) *Object {
|
|||||||
return &Object{self.safeGet(addr)}
|
return &Object{self.safeGet(addr)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *World) safeGet(addr []byte) *ethstate.StateObject {
|
func (self *World) safeGet(addr []byte) *state.StateObject {
|
||||||
object := self.State().GetStateObject(addr)
|
object := self.State().GetStateObject(addr)
|
||||||
if object == nil {
|
if object == nil {
|
||||||
object = ethstate.NewStateObject(addr)
|
object = state.NewStateObject(addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
return object
|
return object
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *World) Coinbase() *ethstate.StateObject {
|
func (self *World) Coinbase() *state.StateObject {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user