cmd/evm, core/vm, test: refactored VM and core
* Moved `vm.Transfer` to `core` package and changed execution to call `env.Transfer` instead of `core.Transfer` directly. * core/vm: byte code VM moved to jump table instead of switch * Moved `vm.Transfer` to `core` package and changed execution to call `env.Transfer` instead of `core.Transfer` directly. * Byte code VM now shares the same code as the JITVM * Renamed Context to Contract * Changed initialiser of state transition & unexported methods * Removed the Execution object and refactor `Call`, `CallCode` & `Create` in to their own functions instead of being methods. * Removed the hard dep on the state for the VM. The VM now depends on a Database interface returned by the environment. In the process the core now depends less on the statedb by usage of the env * Moved `Log` from package `core/state` to package `core/vm`.
This commit is contained in:
17
xeth/xeth.go
17
xeth/xeth.go
@ -33,6 +33,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/eth"
|
||||
"github.com/ethereum/go-ethereum/eth/filters"
|
||||
@ -541,7 +542,7 @@ func (self *XEth) NewLogFilter(earliest, latest int64, skip, max int, address []
|
||||
filter.SetMax(max)
|
||||
filter.SetAddress(cAddress(address))
|
||||
filter.SetTopics(cTopics(topics))
|
||||
filter.LogsCallback = func(logs state.Logs) {
|
||||
filter.LogsCallback = func(logs vm.Logs) {
|
||||
self.logMu.Lock()
|
||||
defer self.logMu.Unlock()
|
||||
|
||||
@ -580,7 +581,7 @@ func (self *XEth) NewBlockFilter() int {
|
||||
id := self.filterManager.Add(filter)
|
||||
self.blockQueue[id] = &hashQueue{timeout: time.Now()}
|
||||
|
||||
filter.BlockCallback = func(block *types.Block, logs state.Logs) {
|
||||
filter.BlockCallback = func(block *types.Block, logs vm.Logs) {
|
||||
self.blockMu.Lock()
|
||||
defer self.blockMu.Unlock()
|
||||
|
||||
@ -603,7 +604,7 @@ func (self *XEth) GetFilterType(id int) byte {
|
||||
return UnknownFilterTy
|
||||
}
|
||||
|
||||
func (self *XEth) LogFilterChanged(id int) state.Logs {
|
||||
func (self *XEth) LogFilterChanged(id int) vm.Logs {
|
||||
self.logMu.Lock()
|
||||
defer self.logMu.Unlock()
|
||||
|
||||
@ -633,7 +634,7 @@ func (self *XEth) TransactionFilterChanged(id int) []common.Hash {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *XEth) Logs(id int) state.Logs {
|
||||
func (self *XEth) Logs(id int) vm.Logs {
|
||||
filter := self.filterManager.Get(id)
|
||||
if filter != nil {
|
||||
return filter.Find()
|
||||
@ -642,7 +643,7 @@ func (self *XEth) Logs(id int) state.Logs {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *XEth) AllLogs(earliest, latest int64, skip, max int, address []string, topics [][]string) state.Logs {
|
||||
func (self *XEth) AllLogs(earliest, latest int64, skip, max int, address []string, topics [][]string) vm.Logs {
|
||||
filter := filters.New(self.backend.ChainDb())
|
||||
filter.SetEarliestBlock(earliest)
|
||||
filter.SetLatestBlock(latest)
|
||||
@ -1029,19 +1030,19 @@ func (m callmsg) Data() []byte { return m.data }
|
||||
type logQueue struct {
|
||||
mu sync.Mutex
|
||||
|
||||
logs state.Logs
|
||||
logs vm.Logs
|
||||
timeout time.Time
|
||||
id int
|
||||
}
|
||||
|
||||
func (l *logQueue) add(logs ...*state.Log) {
|
||||
func (l *logQueue) add(logs ...*vm.Log) {
|
||||
l.mu.Lock()
|
||||
defer l.mu.Unlock()
|
||||
|
||||
l.logs = append(l.logs, logs...)
|
||||
}
|
||||
|
||||
func (l *logQueue) get() state.Logs {
|
||||
func (l *logQueue) get() vm.Logs {
|
||||
l.mu.Lock()
|
||||
defer l.mu.Unlock()
|
||||
|
||||
|
Reference in New Issue
Block a user