Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Commit

Permalink
Merge pull request #11 from sudachen/multivm-2
Browse files Browse the repository at this point in the history
fixed vm.Log[s] to state.Log[s]
  • Loading branch information
sudachen authored Oct 4, 2017
2 parents a29557f + ca88bf6 commit 424039d
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 53 deletions.
3 changes: 1 addition & 2 deletions core/block_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/ethereumproject/go-ethereum/common"
"github.com/ethereumproject/go-ethereum/core/state"
"github.com/ethereumproject/go-ethereum/core/types"
"github.com/ethereumproject/go-ethereum/core/vm"
"github.com/ethereumproject/go-ethereum/ethdb"
"github.com/ethereumproject/go-ethereum/event"
)
Expand Down Expand Up @@ -137,7 +136,7 @@ func TestPutReceipt(t *testing.T) {
hash[0] = 2

receipt := new(types.Receipt)
receipt.Logs = vm.Logs{&vm.Log{
receipt.Logs = state.Logs{&state.Log{
Address: addr,
Topics: []common.Hash{hash},
Data: []byte("hi"),
Expand Down
3 changes: 1 addition & 2 deletions core/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/ethereumproject/go-ethereum/common"
"github.com/ethereumproject/go-ethereum/core/state"
"github.com/ethereumproject/go-ethereum/core/types"
"github.com/ethereumproject/go-ethereum/core/vm"
"github.com/ethereumproject/go-ethereum/crypto"
"github.com/ethereumproject/go-ethereum/ethdb"
"github.com/ethereumproject/go-ethereum/event"
Expand Down Expand Up @@ -448,7 +447,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) (types.Receipts, vm.Logs, *big.Int, error) {
func (bproc) Process(block *types.Block, statedb *state.StateDB) (types.Receipts, state.Logs, *big.Int, error) {
return nil, nil, nil, nil
}

Expand Down
52 changes: 26 additions & 26 deletions core/database_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

"github.com/ethereumproject/go-ethereum/common"
"github.com/ethereumproject/go-ethereum/core/types"
"github.com/ethereumproject/go-ethereum/core/vm"
"github.com/ethereumproject/go-ethereum/core/state"
"github.com/ethereumproject/go-ethereum/crypto"
"github.com/ethereumproject/go-ethereum/crypto/sha3"
"github.com/ethereumproject/go-ethereum/ethdb"
Expand Down Expand Up @@ -412,9 +412,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: state.Logs{
&state.Log{Address: common.BytesToAddress([]byte{0x11})},
&state.Log{Address: common.BytesToAddress([]byte{0x01, 0x11})},
},
TxHash: common.BytesToHash([]byte{0x11, 0x11}),
ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}),
Expand All @@ -423,9 +423,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: state.Logs{
&state.Log{Address: common.BytesToAddress([]byte{0x22})},
&state.Log{Address: common.BytesToAddress([]byte{0x02, 0x22})},
},
TxHash: common.BytesToHash([]byte{0x22, 0x22}),
ContractAddress: common.BytesToAddress([]byte{0x02, 0x22, 0x22}),
Expand Down Expand Up @@ -471,9 +471,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: state.Logs{
&state.Log{Address: common.BytesToAddress([]byte{0x11})},
&state.Log{Address: common.BytesToAddress([]byte{0x01, 0x11})},
},
TxHash: common.BytesToHash([]byte{0x11, 0x11}),
ContractAddress: common.BytesToAddress([]byte{0x01, 0x11, 0x11}),
Expand All @@ -482,9 +482,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: state.Logs{
&state.Log{Address: common.BytesToAddress([]byte{0x22})},
&state.Log{Address: common.BytesToAddress([]byte{0x02, 0x22})},
},
TxHash: common.BytesToHash([]byte{0x22, 0x22}),
ContractAddress: common.BytesToAddress([]byte{0x02, 0x22, 0x22}),
Expand Down Expand Up @@ -524,14 +524,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 = state.Logs{
&state.Log{Address: common.BytesToAddress([]byte("test"))},
&state.Log{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 = state.Logs{
&state.Log{Address: common.BytesToAddress([]byte("test"))},
&state.Log{Address: common.BytesToAddress([]byte("address1"))},
}

WriteMipmapBloom(db, 1, types.Receipts{receipt1})
Expand All @@ -547,14 +547,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 = state.Logs{
&state.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 = state.Logs{
&state.Log{Address: common.BytesToAddress([]byte("test 1"))},
}
WriteMipmapBloom(db, 1000, types.Receipts{receipt})

Expand Down Expand Up @@ -587,8 +587,8 @@ func TestMipmapChain(t *testing.T) {
switch i {
case 1:
receipt := types.NewReceipt(nil, new(big.Int))
receipt.Logs = vm.Logs{
&vm.Log{
receipt.Logs = state.Logs{
&state.Log{
Address: addr,
Topics: []common.Hash{hash1},
},
Expand All @@ -597,7 +597,7 @@ func TestMipmapChain(t *testing.T) {
receipts = types.Receipts{receipt}
case 1000:
receipt := types.NewReceipt(nil, new(big.Int))
receipt.Logs = vm.Logs{&vm.Log{Address: addr2}}
receipt.Logs = state.Logs{&state.Log{Address: addr2}}
gen.AddUncheckedReceipt(receipt)
receipts = types.Receipts{receipt}

Expand Down
1 change: 0 additions & 1 deletion core/state/statedb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"testing/quick"

"github.com/ethereumproject/go-ethereum/common"
"github.com/ethereumproject/go-ethereum/core/vm"
"github.com/ethereumproject/go-ethereum/ethdb"
)

Expand Down
6 changes: 3 additions & 3 deletions eth/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/ethereumproject/go-ethereum/common"
"github.com/ethereumproject/go-ethereum/core"
"github.com/ethereumproject/go-ethereum/core/types"
"github.com/ethereumproject/go-ethereum/core/vm"
"github.com/ethereumproject/go-ethereum/core/state"
"github.com/ethereumproject/go-ethereum/ethdb"
)

Expand All @@ -37,12 +37,12 @@ func TestMipmapUpgrade(t *testing.T) {
switch i {
case 1:
receipt := types.NewReceipt(nil, new(big.Int))
receipt.Logs = vm.Logs{&vm.Log{Address: addr}}
receipt.Logs = state.Logs{&state.Log{Address: addr}}
gen.AddUncheckedReceipt(receipt)
receipts = types.Receipts{receipt}
case 2:
receipt := types.NewReceipt(nil, new(big.Int))
receipt.Logs = vm.Logs{&vm.Log{Address: addr}}
receipt.Logs = state.Logs{&state.Log{Address: addr}}
gen.AddUncheckedReceipt(receipt)
receipts = types.Receipts{receipt}
}
Expand Down
16 changes: 8 additions & 8 deletions eth/filters/filter_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/ethereumproject/go-ethereum/core"
"github.com/ethereumproject/go-ethereum/core/types"
"github.com/ethereumproject/go-ethereum/core/vm"
"github.com/ethereumproject/go-ethereum/core/state"
"github.com/ethereumproject/go-ethereum/event"
)

Expand All @@ -38,7 +38,7 @@ func TestCallbacks(t *testing.T) {
)

blockFilter := &Filter{
BlockCallback: func(*types.Block, vm.Logs) {
BlockCallback: func(*types.Block, state.Logs) {
close(blockDone)
},
}
Expand All @@ -48,21 +48,21 @@ func TestCallbacks(t *testing.T) {
},
}
logFilter := &Filter{
LogCallback: func(l *vm.Log, oob bool) {
LogCallback: func(l *state.Log, oob bool) {
if !oob {
close(logDone)
}
},
}
removedLogFilter := &Filter{
LogCallback: func(l *vm.Log, oob bool) {
LogCallback: func(l *state.Log, oob bool) {
if oob {
close(removedLogDone)
}
},
}
pendingLogFilter := &Filter{
LogCallback: func(*vm.Log, bool) {
LogCallback: func(*state.Log, bool) {
close(pendingLogDone)
},
}
Expand All @@ -75,9 +75,9 @@ func TestCallbacks(t *testing.T) {

mux.Post(core.ChainEvent{})
mux.Post(core.TxPreEvent{})
mux.Post(vm.Logs{&vm.Log{}})
mux.Post(core.RemovedLogsEvent{Logs: vm.Logs{&vm.Log{}}})
mux.Post(core.PendingLogsEvent{Logs: vm.Logs{&vm.Log{}}})
mux.Post(state.Logs{&state.Log{}})
mux.Post(core.RemovedLogsEvent{Logs: state.Logs{&state.Log{}}})
mux.Post(core.PendingLogsEvent{Logs: state.Logs{&state.Log{}}})

const dura = 5 * time.Second
failTimer := time.NewTimer(dura)
Expand Down
22 changes: 11 additions & 11 deletions eth/filters/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ import (
"github.com/ethereumproject/go-ethereum/common"
"github.com/ethereumproject/go-ethereum/core"
"github.com/ethereumproject/go-ethereum/core/types"
"github.com/ethereumproject/go-ethereum/core/vm"
"github.com/ethereumproject/go-ethereum/core/state"
"github.com/ethereumproject/go-ethereum/crypto"
"github.com/ethereumproject/go-ethereum/ethdb"
)

func makeReceipt(addr common.Address) *types.Receipt {
receipt := types.NewReceipt(nil, new(big.Int))
receipt.Logs = vm.Logs{
&vm.Log{Address: addr},
receipt.Logs = state.Logs{
&state.Log{Address: addr},
}
receipt.Bloom = types.CreateBloom(types.Receipts{receipt})
return receipt
Expand Down Expand Up @@ -138,8 +138,8 @@ func TestFilters(t *testing.T) {
switch i {
case 1:
receipt := types.NewReceipt(nil, new(big.Int))
receipt.Logs = vm.Logs{
&vm.Log{
receipt.Logs = state.Logs{
&state.Log{
Address: addr,
Topics: []common.Hash{hash1},
},
Expand All @@ -148,8 +148,8 @@ func TestFilters(t *testing.T) {
receipts = types.Receipts{receipt}
case 2:
receipt := types.NewReceipt(nil, new(big.Int))
receipt.Logs = vm.Logs{
&vm.Log{
receipt.Logs = state.Logs{
&state.Log{
Address: addr,
Topics: []common.Hash{hash2},
},
Expand All @@ -158,8 +158,8 @@ func TestFilters(t *testing.T) {
receipts = types.Receipts{receipt}
case 998:
receipt := types.NewReceipt(nil, new(big.Int))
receipt.Logs = vm.Logs{
&vm.Log{
receipt.Logs = state.Logs{
&state.Log{
Address: addr,
Topics: []common.Hash{hash3},
},
Expand All @@ -168,8 +168,8 @@ func TestFilters(t *testing.T) {
receipts = types.Receipts{receipt}
case 999:
receipt := types.NewReceipt(nil, new(big.Int))
receipt.Logs = vm.Logs{
&vm.Log{
receipt.Logs = state.Logs{
&state.Log{
Address: addr,
Topics: []common.Hash{hash4},
},
Expand Down

0 comments on commit 424039d

Please sign in to comment.