aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-01-05 21:03:50 +0800
committerFelix Lange <fjl@twurst.com>2017-01-06 21:15:22 +0800
commit7731061903bb992f7630ab389863951efb360258 (patch)
treeea706da87ce002a631cba30b171cb44dbdd7c2c6 /core
parentb9683d3748dcb73ab5a5474334eaf157267d9c4a (diff)
downloaddexon-7731061903bb992f7630ab389863951efb360258.tar
dexon-7731061903bb992f7630ab389863951efb360258.tar.gz
dexon-7731061903bb992f7630ab389863951efb360258.tar.bz2
dexon-7731061903bb992f7630ab389863951efb360258.tar.lz
dexon-7731061903bb992f7630ab389863951efb360258.tar.xz
dexon-7731061903bb992f7630ab389863951efb360258.tar.zst
dexon-7731061903bb992f7630ab389863951efb360258.zip
core/vm: move Log to core/types
This significantly reduces the dependency closure of ethclient, which no longer depends on core/vm as of this change. All uses of vm.Logs are replaced by []*types.Log. NewLog is gone too, the constructor simply returned a literal.
Diffstat (limited to 'core')
-rw-r--r--core/block_validator_test.go3
-rw-r--r--core/blockchain.go6
-rw-r--r--core/blockchain_test.go2
-rw-r--r--core/database_util_test.go54
-rw-r--r--core/events.go11
-rw-r--r--core/state/statedb.go21
-rw-r--r--core/state/statedb_test.go4
-rw-r--r--core/state_processor.go4
-rw-r--r--core/types.go2
-rw-r--r--core/types/bloom9.go3
-rw-r--r--core/types/log.go (renamed from core/vm/log.go)8
-rw-r--r--core/types/log_test.go (renamed from core/vm/log_test.go)2
-rw-r--r--core/types/receipt.go21
-rw-r--r--core/vm/instructions.go11
-rw-r--r--core/vm/interface.go3
-rw-r--r--core/vm/noop.go3
16 files changed, 76 insertions, 82 deletions
diff --git a/core/block_validator_test.go b/core/block_validator_test.go
index 6fcab1e5f..054686612 100644
--- a/core/block_validator_test.go
+++ b/core/block_validator_test.go
@@ -24,7 +24,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"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/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/params"
@@ -77,7 +76,7 @@ func TestPutReceipt(t *testing.T) {
hash[0] = 2
receipt := new(types.Receipt)
- receipt.Logs = vm.Logs{&vm.Log{
+ receipt.Logs = []*types.Log{{
Address: addr,
Topics: []common.Hash{hash},
Data: []byte("hi"),
diff --git a/core/blockchain.go b/core/blockchain.go
index 0de529480..2081457a9 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -883,7 +883,7 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) {
var (
stats = insertStats{startTime: time.Now()}
events = make([]interface{}, 0, len(chain))
- coalescedLogs vm.Logs
+ coalescedLogs []*types.Log
nonceChecked = make([]bool, len(chain))
)
@@ -1094,7 +1094,7 @@ func (self *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
oldStart = oldBlock
newStart = newBlock
deletedTxs types.Transactions
- deletedLogs vm.Logs
+ deletedLogs []*types.Log
// collectLogs collects the logs that were generated during the
// processing of the block that corresponds with the given hash.
// These logs are later announced as deleted.
@@ -1210,7 +1210,7 @@ func (self *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
// postChainEvents iterates over the events generated by a chain insertion and
// posts them into the event mux.
-func (self *BlockChain) postChainEvents(events []interface{}, logs vm.Logs) {
+func (self *BlockChain) postChainEvents(events []interface{}, logs []*types.Log) {
// post event logs for further processing
self.eventMux.Post(logs)
for _, event := range events {
diff --git a/core/blockchain_test.go b/core/blockchain_test.go
index 62d85e2e5..a2c350479 100644
--- a/core/blockchain_test.go
+++ b/core/blockchain_test.go
@@ -435,7 +435,7 @@ func (bproc) ValidateHeader(*types.Header, *types.Header, bool) error { return n
func (bproc) ValidateState(block, parent *types.Block, state *state.StateDB, receipts types.Receipts, usedGas *big.Int) error {
return nil
}
-func (bproc) Process(block *types.Block, statedb *state.StateDB, cfg vm.Config) (types.Receipts, vm.Logs, *big.Int, error) {
+func (bproc) Process(block *types.Block, statedb *state.StateDB, cfg vm.Config) (types.Receipts, []*types.Log, *big.Int, error) {
return nil, nil, new(big.Int), nil
}
diff --git a/core/database_util_test.go b/core/database_util_test.go
index 83750aa60..c8fd857ea 100644
--- a/core/database_util_test.go
+++ b/core/database_util_test.go
@@ -26,7 +26,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"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/crypto/sha3"
"github.com/ethereum/go-ethereum/ethdb"
@@ -393,9 +392,9 @@ func TestReceiptStorage(t *testing.T) {
receipt1 := &types.Receipt{
PostState: []byte{0x01},
CumulativeGasUsed: big.NewInt(1),
- Logs: vm.Logs{
- &vm.Log{Address: common.BytesToAddress([]byte{0x11})},
- &vm.Log{Address: common.BytesToAddress([]byte{0x01, 0x11})},
+ Logs: []*types.Log{
+ {Address: common.BytesToAddress([]byte{0x11})},
+ {Address: common.BytesToAddress([]byte{0x01, 0x11})},
},
TxHash: common.BytesToHash([]byte{0x11, 0x11}),
ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}),
@@ -404,9 +403,9 @@ func TestReceiptStorage(t *testing.T) {
receipt2 := &types.Receipt{
PostState: []byte{0x02},
CumulativeGasUsed: big.NewInt(2),
- Logs: vm.Logs{
- &vm.Log{Address: common.BytesToAddress([]byte{0x22})},
- &vm.Log{Address: common.BytesToAddress([]byte{0x02, 0x22})},
+ Logs: []*types.Log{
+ {Address: common.BytesToAddress([]byte{0x22})},
+ {Address: common.BytesToAddress([]byte{0x02, 0x22})},
},
TxHash: common.BytesToHash([]byte{0x22, 0x22}),
ContractAddress: common.BytesToAddress([]byte{0x02, 0x22, 0x22}),
@@ -452,9 +451,9 @@ func TestBlockReceiptStorage(t *testing.T) {
receipt1 := &types.Receipt{
PostState: []byte{0x01},
CumulativeGasUsed: big.NewInt(1),
- Logs: vm.Logs{
- &vm.Log{Address: common.BytesToAddress([]byte{0x11})},
- &vm.Log{Address: common.BytesToAddress([]byte{0x01, 0x11})},
+ Logs: []*types.Log{
+ {Address: common.BytesToAddress([]byte{0x11})},
+ {Address: common.BytesToAddress([]byte{0x01, 0x11})},
},
TxHash: common.BytesToHash([]byte{0x11, 0x11}),
ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}),
@@ -463,9 +462,9 @@ func TestBlockReceiptStorage(t *testing.T) {
receipt2 := &types.Receipt{
PostState: []byte{0x02},
CumulativeGasUsed: big.NewInt(2),
- Logs: vm.Logs{
- &vm.Log{Address: common.BytesToAddress([]byte{0x22})},
- &vm.Log{Address: common.BytesToAddress([]byte{0x02, 0x22})},
+ Logs: []*types.Log{
+ {Address: common.BytesToAddress([]byte{0x22})},
+ {Address: common.BytesToAddress([]byte{0x02, 0x22})},
},
TxHash: common.BytesToHash([]byte{0x22, 0x22}),
ContractAddress: common.BytesToAddress([]byte{0x02, 0x22, 0x22}),
@@ -505,14 +504,14 @@ func TestMipmapBloom(t *testing.T) {
db, _ := ethdb.NewMemDatabase()
receipt1 := new(types.Receipt)
- receipt1.Logs = vm.Logs{
- &vm.Log{Address: common.BytesToAddress([]byte("test"))},
- &vm.Log{Address: common.BytesToAddress([]byte("address"))},
+ receipt1.Logs = []*types.Log{
+ {Address: common.BytesToAddress([]byte("test"))},
+ {Address: common.BytesToAddress([]byte("address"))},
}
receipt2 := new(types.Receipt)
- receipt2.Logs = vm.Logs{
- &vm.Log{Address: common.BytesToAddress([]byte("test"))},
- &vm.Log{Address: common.BytesToAddress([]byte("address1"))},
+ receipt2.Logs = []*types.Log{
+ {Address: common.BytesToAddress([]byte("test"))},
+ {Address: common.BytesToAddress([]byte("address1"))},
}
WriteMipmapBloom(db, 1, types.Receipts{receipt1})
@@ -528,14 +527,14 @@ func TestMipmapBloom(t *testing.T) {
// reset
db, _ = ethdb.NewMemDatabase()
receipt := new(types.Receipt)
- receipt.Logs = vm.Logs{
- &vm.Log{Address: common.BytesToAddress([]byte("test"))},
+ receipt.Logs = []*types.Log{
+ {Address: common.BytesToAddress([]byte("test"))},
}
WriteMipmapBloom(db, 999, types.Receipts{receipt1})
receipt = new(types.Receipt)
- receipt.Logs = vm.Logs{
- &vm.Log{Address: common.BytesToAddress([]byte("test 1"))},
+ receipt.Logs = []*types.Log{
+ {Address: common.BytesToAddress([]byte("test 1"))},
}
WriteMipmapBloom(db, 1000, types.Receipts{receipt})
@@ -568,17 +567,12 @@ func TestMipmapChain(t *testing.T) {
switch i {
case 1:
receipt := types.NewReceipt(nil, new(big.Int))
- receipt.Logs = vm.Logs{
- &vm.Log{
- Address: addr,
- Topics: []common.Hash{hash1},
- },
- }
+ receipt.Logs = []*types.Log{{Address: addr, Topics: []common.Hash{hash1}}}
gen.AddUncheckedReceipt(receipt)
receipts = types.Receipts{receipt}
case 1000:
receipt := types.NewReceipt(nil, new(big.Int))
- receipt.Logs = vm.Logs{&vm.Log{Address: addr2}}
+ receipt.Logs = []*types.Log{{Address: addr2}}
gen.AddUncheckedReceipt(receipt)
receipts = types.Receipts{receipt}
diff --git a/core/events.go b/core/events.go
index 414493fbf..31ad8364b 100644
--- a/core/events.go
+++ b/core/events.go
@@ -21,7 +21,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/core/vm"
)
// TxPreEvent is posted when a transaction enters the transaction pool.
@@ -32,7 +31,7 @@ type TxPostEvent struct{ Tx *types.Transaction }
// PendingLogsEvent is posted pre mining and notifies of pending logs.
type PendingLogsEvent struct {
- Logs vm.Logs
+ Logs []*types.Log
}
// PendingStateEvent is posted pre mining and notifies of pending state changes.
@@ -45,18 +44,18 @@ type NewMinedBlockEvent struct{ Block *types.Block }
type RemovedTransactionEvent struct{ Txs types.Transactions }
// RemovedLogEvent is posted when a reorg happens
-type RemovedLogsEvent struct{ Logs vm.Logs }
+type RemovedLogsEvent struct{ Logs []*types.Log }
// ChainSplit is posted when a new head is detected
type ChainSplitEvent struct {
Block *types.Block
- Logs vm.Logs
+ Logs []*types.Log
}
type ChainEvent struct {
Block *types.Block
Hash common.Hash
- Logs vm.Logs
+ Logs []*types.Log
}
type ChainSideEvent struct {
@@ -65,7 +64,7 @@ type ChainSideEvent struct {
type PendingBlockEvent struct {
Block *types.Block
- Logs vm.Logs
+ Logs []*types.Log
}
type ChainUncleEvent struct {
diff --git a/core/state/statedb.go b/core/state/statedb.go
index 82e2ec7c1..bbcde9443 100644
--- a/core/state/statedb.go
+++ b/core/state/statedb.go
@@ -24,6 +24,7 @@ import (
"sync"
"github.com/ethereum/go-ethereum/common"
+ "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/ethdb"
@@ -71,7 +72,7 @@ type StateDB struct {
thash, bhash common.Hash
txIndex int
- logs map[common.Hash]vm.Logs
+ logs map[common.Hash][]*types.Log
logSize uint
// Journal of state modifications. This is the backbone of
@@ -97,7 +98,7 @@ func New(root common.Hash, db ethdb.Database) (*StateDB, error) {
stateObjects: make(map[common.Address]*StateObject),
stateObjectsDirty: make(map[common.Address]struct{}),
refund: new(big.Int),
- logs: make(map[common.Hash]vm.Logs),
+ logs: make(map[common.Hash][]*types.Log),
}, nil
}
@@ -118,7 +119,7 @@ func (self *StateDB) New(root common.Hash) (*StateDB, error) {
stateObjects: make(map[common.Address]*StateObject),
stateObjectsDirty: make(map[common.Address]struct{}),
refund: new(big.Int),
- logs: make(map[common.Hash]vm.Logs),
+ logs: make(map[common.Hash][]*types.Log),
}, nil
}
@@ -138,7 +139,7 @@ func (self *StateDB) Reset(root common.Hash) error {
self.thash = common.Hash{}
self.bhash = common.Hash{}
self.txIndex = 0
- self.logs = make(map[common.Hash]vm.Logs)
+ self.logs = make(map[common.Hash][]*types.Log)
self.logSize = 0
self.clearJournalAndRefund()
@@ -175,7 +176,7 @@ func (self *StateDB) StartRecord(thash, bhash common.Hash, ti int) {
self.txIndex = ti
}
-func (self *StateDB) AddLog(log *vm.Log) {
+func (self *StateDB) AddLog(log *types.Log) {
self.journal = append(self.journal, addLogChange{txhash: self.thash})
log.TxHash = self.thash
@@ -186,12 +187,12 @@ func (self *StateDB) AddLog(log *vm.Log) {
self.logSize++
}
-func (self *StateDB) GetLogs(hash common.Hash) vm.Logs {
+func (self *StateDB) GetLogs(hash common.Hash) []*types.Log {
return self.logs[hash]
}
-func (self *StateDB) Logs() vm.Logs {
- var logs vm.Logs
+func (self *StateDB) Logs() []*types.Log {
+ var logs []*types.Log
for _, lgs := range self.logs {
logs = append(logs, lgs...)
}
@@ -474,7 +475,7 @@ func (self *StateDB) Copy() *StateDB {
stateObjects: make(map[common.Address]*StateObject, len(self.stateObjectsDirty)),
stateObjectsDirty: make(map[common.Address]struct{}, len(self.stateObjectsDirty)),
refund: new(big.Int).Set(self.refund),
- logs: make(map[common.Hash]vm.Logs, len(self.logs)),
+ logs: make(map[common.Hash][]*types.Log, len(self.logs)),
logSize: self.logSize,
}
// Copy the dirty states and logs
@@ -483,7 +484,7 @@ func (self *StateDB) Copy() *StateDB {
state.stateObjectsDirty[addr] = struct{}{}
}
for hash, logs := range self.logs {
- state.logs[hash] = make(vm.Logs, len(logs))
+ state.logs[hash] = make([]*types.Log, len(logs))
copy(state.logs[hash], logs)
}
return state
diff --git a/core/state/statedb_test.go b/core/state/statedb_test.go
index f91820378..874317300 100644
--- a/core/state/statedb_test.go
+++ b/core/state/statedb_test.go
@@ -29,7 +29,7 @@ import (
"testing/quick"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/vm"
+ "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
)
@@ -221,7 +221,7 @@ func newTestAction(addr common.Address, r *rand.Rand) testAction {
fn: func(a testAction, s *StateDB) {
data := make([]byte, 2)
binary.BigEndian.PutUint16(data, uint16(a.args[0]))
- s.AddLog(&vm.Log{Address: addr, Data: data})
+ s.AddLog(&types.Log{Address: addr, Data: data})
},
args: make([]int64, 1),
},
diff --git a/core/state_processor.go b/core/state_processor.go
index 82a371a9e..4f6ca651e 100644
--- a/core/state_processor.go
+++ b/core/state_processor.go
@@ -57,13 +57,13 @@ func NewStateProcessor(config *params.ChainConfig, bc *BlockChain) *StateProcess
// Process returns the receipts and logs accumulated during the process and
// returns the amount of gas that was used in the process. If any of the
// transactions failed to execute due to insufficient gas it will return an error.
-func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg vm.Config) (types.Receipts, vm.Logs, *big.Int, error) {
+func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg vm.Config) (types.Receipts, []*types.Log, *big.Int, error) {
var (
receipts types.Receipts
totalUsedGas = big.NewInt(0)
err error
header = block.Header()
- allLogs vm.Logs
+ allLogs []*types.Log
gp = new(GasPool).AddGas(block.GasLimit())
)
// Mutate the the block and state according to any hard-fork specs
diff --git a/core/types.go b/core/types.go
index d84d0987f..7fd658979 100644
--- a/core/types.go
+++ b/core/types.go
@@ -58,5 +58,5 @@ type HeaderValidator interface {
// of gas used in the process and return an error if any of the internal rules
// failed.
type Processor interface {
- Process(block *types.Block, statedb *state.StateDB, cfg vm.Config) (types.Receipts, vm.Logs, *big.Int, error)
+ Process(block *types.Block, statedb *state.StateDB, cfg vm.Config) (types.Receipts, []*types.Log, *big.Int, error)
}
diff --git a/core/types/bloom9.go b/core/types/bloom9.go
index a1d13e218..bcca59907 100644
--- a/core/types/bloom9.go
+++ b/core/types/bloom9.go
@@ -22,7 +22,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
)
@@ -95,7 +94,7 @@ func CreateBloom(receipts Receipts) Bloom {
return BytesToBloom(bin.Bytes())
}
-func LogsBloom(logs vm.Logs) *big.Int {
+func LogsBloom(logs []*Log) *big.Int {
bin := new(big.Int)
for _, log := range logs {
data := make([]common.Hash, len(log.Topics))
diff --git a/core/vm/log.go b/core/types/log.go
index 347bd6e5d..7efb06b5c 100644
--- a/core/vm/log.go
+++ b/core/types/log.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-package vm
+package types
import (
"encoding/json"
@@ -79,10 +79,6 @@ type jsonLog struct {
Removed bool `json:"removed"`
}
-func NewLog(address common.Address, topics []common.Hash, data []byte, number uint64) *Log {
- return &Log{Address: address, Topics: topics, Data: data, BlockNumber: number}
-}
-
// EncodeRLP implements rlp.Encoder.
func (l *Log) EncodeRLP(w io.Writer) error {
return rlp.Encode(w, rlpLog{Address: l.Address, Topics: l.Topics, Data: l.Data})
@@ -150,8 +146,6 @@ func (l *Log) UnmarshalJSON(input []byte) error {
return nil
}
-type Logs []*Log
-
// LogForStorage is a wrapper around a Log that flattens and parses the entire content of
// a log including non-consensus fields.
type LogForStorage Log
diff --git a/core/vm/log_test.go b/core/types/log_test.go
index 994753c62..bf742ccac 100644
--- a/core/vm/log_test.go
+++ b/core/types/log_test.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-package vm
+package types
import (
"encoding/json"
diff --git a/core/types/receipt.go b/core/types/receipt.go
index 70c10d422..0a6a35e33 100644
--- a/core/types/receipt.go
+++ b/core/types/receipt.go
@@ -25,7 +25,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/rlp"
)
@@ -40,7 +39,7 @@ type Receipt struct {
PostState []byte
CumulativeGasUsed *big.Int
Bloom Bloom
- Logs vm.Logs
+ Logs []*Log
// Implementation fields (don't reorder!)
TxHash common.Hash
@@ -52,7 +51,7 @@ type jsonReceipt struct {
PostState *common.Hash `json:"root"`
CumulativeGasUsed *hexutil.Big `json:"cumulativeGasUsed"`
Bloom *Bloom `json:"logsBloom"`
- Logs *vm.Logs `json:"logs"`
+ Logs []*Log `json:"logs"`
TxHash *common.Hash `json:"transactionHash"`
ContractAddress *common.Address `json:"contractAddress"`
GasUsed *hexutil.Big `json:"gasUsed"`
@@ -76,7 +75,7 @@ func (r *Receipt) DecodeRLP(s *rlp.Stream) error {
PostState []byte
CumulativeGasUsed *big.Int
Bloom Bloom
- Logs vm.Logs
+ Logs []*Log
}
if err := s.Decode(&receipt); err != nil {
return err
@@ -93,7 +92,7 @@ func (r *Receipt) MarshalJSON() ([]byte, error) {
PostState: &root,
CumulativeGasUsed: (*hexutil.Big)(r.CumulativeGasUsed),
Bloom: &r.Bloom,
- Logs: &r.Logs,
+ Logs: r.Logs,
TxHash: &r.TxHash,
ContractAddress: &r.ContractAddress,
GasUsed: (*hexutil.Big)(r.GasUsed),
@@ -120,7 +119,7 @@ func (r *Receipt) UnmarshalJSON(input []byte) error {
PostState: (*dec.PostState)[:],
CumulativeGasUsed: (*big.Int)(dec.CumulativeGasUsed),
Bloom: *dec.Bloom,
- Logs: *dec.Logs,
+ Logs: dec.Logs,
TxHash: *dec.TxHash,
GasUsed: (*big.Int)(dec.GasUsed),
}
@@ -142,9 +141,9 @@ type ReceiptForStorage Receipt
// EncodeRLP implements rlp.Encoder, and flattens all content fields of a receipt
// into an RLP stream.
func (r *ReceiptForStorage) EncodeRLP(w io.Writer) error {
- logs := make([]*vm.LogForStorage, len(r.Logs))
+ logs := make([]*LogForStorage, len(r.Logs))
for i, log := range r.Logs {
- logs[i] = (*vm.LogForStorage)(log)
+ logs[i] = (*LogForStorage)(log)
}
return rlp.Encode(w, []interface{}{r.PostState, r.CumulativeGasUsed, r.Bloom, r.TxHash, r.ContractAddress, logs, r.GasUsed})
}
@@ -158,7 +157,7 @@ func (r *ReceiptForStorage) DecodeRLP(s *rlp.Stream) error {
Bloom Bloom
TxHash common.Hash
ContractAddress common.Address
- Logs []*vm.LogForStorage
+ Logs []*LogForStorage
GasUsed *big.Int
}
if err := s.Decode(&receipt); err != nil {
@@ -166,9 +165,9 @@ func (r *ReceiptForStorage) DecodeRLP(s *rlp.Stream) error {
}
// Assign the consensus fields
r.PostState, r.CumulativeGasUsed, r.Bloom = receipt.PostState, receipt.CumulativeGasUsed, receipt.Bloom
- r.Logs = make(vm.Logs, len(receipt.Logs))
+ r.Logs = make([]*Log, len(receipt.Logs))
for i, log := range receipt.Logs {
- r.Logs[i] = (*vm.Log)(log)
+ r.Logs[i] = (*Log)(log)
}
// Assign the implementation fields
r.TxHash, r.ContractAddress, r.GasUsed = receipt.TxHash, receipt.ContractAddress, receipt.GasUsed
diff --git a/core/vm/instructions.go b/core/vm/instructions.go
index 2839b7109..5bfa73a30 100644
--- a/core/vm/instructions.go
+++ b/core/vm/instructions.go
@@ -22,6 +22,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
+ "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"
)
@@ -605,8 +606,14 @@ func makeLog(size int) executionFunc {
}
d := memory.Get(mStart.Int64(), mSize.Int64())
- log := NewLog(contract.Address(), topics, d, env.BlockNumber.Uint64())
- env.StateDB.AddLog(log)
+ env.StateDB.AddLog(&types.Log{
+ Address: contract.Address(),
+ Topics: topics,
+ Data: d,
+ // This is a non-consensus field, but assigned here because
+ // core/state doesn't know the current block number.
+ BlockNumber: env.BlockNumber.Uint64(),
+ })
return nil, nil
}
}
diff --git a/core/vm/interface.go b/core/vm/interface.go
index b81f59125..8617b2d0f 100644
--- a/core/vm/interface.go
+++ b/core/vm/interface.go
@@ -20,6 +20,7 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/core/types"
)
// StateDB is an EVM database for full state querying.
@@ -58,7 +59,7 @@ type StateDB interface {
RevertToSnapshot(int)
Snapshot() int
- AddLog(*Log)
+ AddLog(*types.Log)
}
// Account represents a contract or basic ethereum account.
diff --git a/core/vm/noop.go b/core/vm/noop.go
index ca7d1055a..ef6837273 100644
--- a/core/vm/noop.go
+++ b/core/vm/noop.go
@@ -20,6 +20,7 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/core/types"
)
func NoopCanTransfer(db StateDB, from common.Address, balance *big.Int) bool {
@@ -65,4 +66,4 @@ func (NoopStateDB) Exist(common.Address) bool { return f
func (NoopStateDB) Empty(common.Address) bool { return false }
func (NoopStateDB) RevertToSnapshot(int) {}
func (NoopStateDB) Snapshot() int { return 0 }
-func (NoopStateDB) AddLog(*Log) {}
+func (NoopStateDB) AddLog(*types.Log) {}