aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/block_processor.go23
-rw-r--r--core/vm/vm.go4
2 files changed, 14 insertions, 13 deletions
diff --git a/core/block_processor.go b/core/block_processor.go
index 14567732f..0fb698614 100644
--- a/core/block_processor.go
+++ b/core/block_processor.go
@@ -61,7 +61,7 @@ func (sm *BlockProcessor) TransitionState(statedb *state.StateDB, parent, block
coinbase.SetGasPool(block.Header().GasLimit)
// Process the transactions on to parent state
- receipts, _, _, _, err = sm.ApplyTransactions(coinbase, statedb, block, block.Transactions(), transientProcess)
+ receipts, err = sm.ApplyTransactions(coinbase, statedb, block, block.Transactions(), transientProcess)
if err != nil {
return nil, err
}
@@ -104,39 +104,38 @@ func (self *BlockProcessor) ChainManager() *ChainManager {
return self.bc
}
-func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, statedb *state.StateDB, block *types.Block, txs types.Transactions, transientProcess bool) (types.Receipts, types.Transactions, types.Transactions, types.Transactions, error) {
+func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, statedb *state.StateDB, block *types.Block, txs types.Transactions, transientProcess bool) (types.Receipts, error) {
var (
- receipts types.Receipts
- handled, unhandled types.Transactions
- erroneous types.Transactions
- totalUsedGas = big.NewInt(0)
- err error
- cumulativeSum = new(big.Int)
+ receipts types.Receipts
+ totalUsedGas = big.NewInt(0)
+ err error
+ cumulativeSum = new(big.Int)
)
for _, tx := range txs {
receipt, txGas, err := self.ApplyTransaction(coinbase, statedb, block, tx, totalUsedGas, transientProcess)
if err != nil && (IsNonceErr(err) || state.IsGasLimitErr(err) || IsInvalidTxErr(err)) {
- return nil, nil, nil, nil, err
+ return nil, err
}
if err != nil {
statelogger.Infoln("TX err:", err)
}
receipts = append(receipts, receipt)
- handled = append(handled, tx)
cumulativeSum.Add(cumulativeSum, new(big.Int).Mul(txGas, tx.GasPrice()))
}
block.Reward = cumulativeSum
- block.Header().GasUsed = totalUsedGas
+ if block.GasUsed().Cmp(totalUsedGas) != 0 {
+ return nil, ValidationError(fmt.Sprintf("gas used error (%v / %v)", block.GasUsed(), totalUsedGas))
+ }
if transientProcess {
go self.eventMux.Post(PendingBlockEvent{block, statedb.Logs()})
}
- return receipts, handled, unhandled, erroneous, err
+ return receipts, err
}
// Process block will attempt to process the given block's transactions and applies them
diff --git a/core/vm/vm.go b/core/vm/vm.go
index f4bf1ca72..2ece5b928 100644
--- a/core/vm/vm.go
+++ b/core/vm/vm.go
@@ -5,8 +5,8 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/core/state"
+ "github.com/ethereum/go-ethereum/crypto"
)
type Vm struct {
@@ -34,6 +34,8 @@ func New(env Environment) *Vm {
func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
self.env.SetDepth(self.env.Depth() + 1)
+ defer self.env.SetDepth(self.env.Depth() - 1)
+
var (
caller = context.caller
code = context.Code