From e6bb9c1cadd311475f54ed60630fc20eb2f54871 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Mon, 6 Jul 2015 11:54:11 +0200 Subject: core, miner: removed vm errors from consensus err checking Removed VM errors from the consensus errors. They now used for output only. --- core/block_processor.go | 5 ++--- core/state_transition.go | 7 +++++++ core/types/transaction.go | 4 +++- core/vm/errors.go | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) (limited to 'core') diff --git a/core/block_processor.go b/core/block_processor.go index 660c917e4..9a7478381 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -9,7 +9,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/crypto" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" @@ -73,7 +72,7 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated cb := statedb.GetStateObject(coinbase.Address()) _, gas, err := ApplyMessage(NewEnv(statedb, self.bc, tx, header), tx, cb) - if err != nil && err != vm.OutOfGasError { + if err != nil { return nil, nil, err } @@ -119,7 +118,7 @@ func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, state statedb.StartRecord(tx.Hash(), block.Hash(), i) receipt, txGas, err := self.ApplyTransaction(coinbase, statedb, header, tx, totalUsedGas, transientProcess) - if err != nil && err != vm.OutOfGasError { + if err != nil { return nil, err } diff --git a/core/state_transition.go b/core/state_transition.go index 465000e87..5bcf6c45d 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -203,16 +203,23 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er glog.V(logger.Core).Infoln("Insufficient gas for creating code. Require", dataGas, "and have", self.gas) } } + glog.V(logger.Core).Infoln("VM create err:", err) } else { // Increment the nonce for the next transaction self.state.SetNonce(sender.Address(), sender.Nonce()+1) ret, err = vmenv.Call(sender, self.To().Address(), self.data, self.gas, self.gasPrice, self.value) + glog.V(logger.Core).Infoln("VM call err:", err) } if err != nil && IsValueTransferErr(err) { return nil, nil, InvalidTxError(err) } + // We aren't interested in errors here. Errors returned by the VM are non-consensus errors and therefor shouldn't bubble up + if err != nil { + err = nil + } + if vm.Debug { vm.StdErrFormat(vmenv.StructLogs()) } diff --git a/core/types/transaction.go b/core/types/transaction.go index c381fc5f3..f5392382b 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -15,6 +15,8 @@ import ( "github.com/ethereum/go-ethereum/rlp" ) +var ErrInvalidSig = errors.New("invalid v, r, s values") + func IsContractAddr(addr []byte) bool { return len(addr) == 0 } @@ -177,7 +179,7 @@ func (tx *Transaction) SignatureValues() (v byte, r *big.Int, s *big.Int) { func (tx *Transaction) publicKey() ([]byte, error) { if !crypto.ValidateSignatureValues(tx.data.V, tx.data.R, tx.data.S) { - return nil, errors.New("invalid v, r, s values") + return nil, ErrInvalidSig } // encode the signature in uncompressed format diff --git a/core/vm/errors.go b/core/vm/errors.go index 75b9c0f10..209b64c7d 100644 --- a/core/vm/errors.go +++ b/core/vm/errors.go @@ -22,7 +22,7 @@ func (self StackError) Error() string { return fmt.Sprintf("stack error! require %v, have %v", self.req, self.has) } -func IsStack(err error) bool { +func IsStackErr(err error) bool { _, ok := err.(StackError) return ok } -- cgit v1.2.3