diff --git a/core/chain_makers.go b/core/chain_makers.go index e1dafb32dc..4a838a5aa7 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -108,7 +108,7 @@ func (b *BlockGen) AddTx(tx *types.Transaction) { b.SetCoinbase(common.Address{}) } b.statedb.StartRecord(tx.Hash(), common.Hash{}, len(b.txs)) - receipt, _, _, err := ApplyTransaction(b.config, nil, b.gasPool, b.statedb, b.header, tx, b.header.GasUsed, vm.Config{}) + receipt, _, err := ApplyTransaction(b.config, nil, b.gasPool, b.statedb, b.header, tx, b.header.GasUsed, vm.Config{}) if err != nil { panic(err) } diff --git a/core/state_processor.go b/core/state_processor.go index 67a7ad5a12..bc715cfc67 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -74,12 +74,12 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg for i, tx := range block.Transactions() { //fmt.Println("tx:", i) statedb.StartRecord(tx.Hash(), block.Hash(), i) - receipt, logs, _, err := ApplyTransaction(p.config, p.bc, gp, statedb, header, tx, totalUsedGas, cfg) + receipt, _, err := ApplyTransaction(p.config, p.bc, gp, statedb, header, tx, totalUsedGas, cfg) if err != nil { return nil, nil, nil, err } receipts = append(receipts, receipt) - allLogs = append(allLogs, logs...) + allLogs = append(allLogs, receipt.Logs...) } AccumulateRewards(statedb, header, block.Uncles()) @@ -87,14 +87,13 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg } // ApplyTransaction attempts to apply a transaction to the given state database -// and uses the input parameters for its environment. -// -// ApplyTransactions returns the generated receipts and vm logs during the -// execution of the state transition phase. -func ApplyTransaction(config *params.ChainConfig, bc *BlockChain, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *big.Int, cfg vm.Config) (*types.Receipt, vm.Logs, *big.Int, error) { +// and uses the input parameters for its environment. It returns the receipt +// for the transaction, gas used and an error if the transaction failed, +// indicating the block was invalid. +func ApplyTransaction(config *params.ChainConfig, bc *BlockChain, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *big.Int, cfg vm.Config) (*types.Receipt, *big.Int, error) { msg, err := tx.AsMessage(types.MakeSigner(config, header.Number)) if err != nil { - return nil, nil, nil, err + return nil, nil, err } // Create a new context to be used in the EVM environment context := NewEVMContext(msg, header, bc) @@ -104,7 +103,7 @@ func ApplyTransaction(config *params.ChainConfig, bc *BlockChain, gp *GasPool, s // Apply the transaction to the current state (included in the env) _, gas, err := ApplyMessage(vmenv, msg, gp) if err != nil { - return nil, nil, nil, err + return nil, nil, err } // Update the state with pending changes @@ -125,7 +124,7 @@ func ApplyTransaction(config *params.ChainConfig, bc *BlockChain, gp *GasPool, s glog.V(logger.Debug).Infoln(receipt) - return receipt, receipt.Logs, gas, err + return receipt, gas, err } // AccumulateRewards credits the coinbase of the given block with the diff --git a/core/vm_env.go b/core/vm_env.go deleted file mode 100644 index 58e71e305d..0000000000 --- a/core/vm_env.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package core diff --git a/miner/worker.go b/miner/worker.go index f29566c0a9..3ae51d1208 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -616,7 +616,7 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB func (env *Work) commitTransaction(tx *types.Transaction, bc *core.BlockChain, gp *core.GasPool) (error, vm.Logs) { snap := env.state.Snapshot() - receipt, logs, _, err := core.ApplyTransaction(env.config, bc, gp, env.state, env.header, tx, env.header.GasUsed, vm.Config{}) + receipt, _, err := core.ApplyTransaction(env.config, bc, gp, env.state, env.header, tx, env.header.GasUsed, vm.Config{}) if err != nil { env.state.RevertToSnapshot(snap) return err, nil @@ -624,7 +624,7 @@ func (env *Work) commitTransaction(tx *types.Transaction, bc *core.BlockChain, g env.txs = append(env.txs, tx) env.receipts = append(env.receipts, receipt) - return nil, logs + return nil, receipt.Logs } // TODO: remove or use