forked from cerc-io/plugeth
Do not return error on VM exception
This commit is contained in:
parent
69e745c537
commit
ca18b3f1e9
@ -136,13 +136,6 @@ func (self *StateTransition) preCheck() (err error) {
|
|||||||
func (self *StateTransition) TransitionState() (err error) {
|
func (self *StateTransition) TransitionState() (err error) {
|
||||||
statelogger.Debugf("(~) %x\n", self.tx.Hash())
|
statelogger.Debugf("(~) %x\n", self.tx.Hash())
|
||||||
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
statelogger.Infoln(r)
|
|
||||||
err = fmt.Errorf("state transition err %v", r)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// XXX Transactions after this point are considered valid.
|
// XXX Transactions after this point are considered valid.
|
||||||
if err = self.preCheck(); err != nil {
|
if err = self.preCheck(); err != nil {
|
||||||
return
|
return
|
||||||
@ -184,7 +177,7 @@ func (self *StateTransition) TransitionState() (err error) {
|
|||||||
snapshot = self.state.Copy()
|
snapshot = self.state.Copy()
|
||||||
|
|
||||||
// Create a new state object for the contract
|
// Create a new state object for the contract
|
||||||
receiver := MakeContract(tx, self.state)
|
receiver = MakeContract(tx, self.state)
|
||||||
self.rec = receiver
|
self.rec = receiver
|
||||||
if receiver == nil {
|
if receiver == nil {
|
||||||
return fmt.Errorf("Unable to create contract")
|
return fmt.Errorf("Unable to create contract")
|
||||||
@ -218,22 +211,22 @@ func (self *StateTransition) TransitionState() (err error) {
|
|||||||
// script section for the state object.
|
// script section for the state object.
|
||||||
self.data = nil
|
self.data = nil
|
||||||
|
|
||||||
code, err := self.Eval(msg, receiver.Init(), receiver)
|
code, evmerr := self.Eval(msg, receiver.Init(), receiver)
|
||||||
if err != nil {
|
if evmerr != nil {
|
||||||
self.state.Set(snapshot)
|
self.state.Set(snapshot)
|
||||||
|
|
||||||
return fmt.Errorf("Error during init execution %v", err)
|
statelogger.Debugf("Error during init execution %v", evmerr)
|
||||||
}
|
}
|
||||||
|
|
||||||
receiver.Code = code
|
receiver.Code = code
|
||||||
msg.Output = code
|
msg.Output = code
|
||||||
} else {
|
} else {
|
||||||
if len(receiver.Code) > 0 {
|
if len(receiver.Code) > 0 {
|
||||||
ret, err := self.Eval(msg, receiver.Code, receiver)
|
ret, evmerr := self.Eval(msg, receiver.Code, receiver)
|
||||||
if err != nil {
|
if evmerr != nil {
|
||||||
self.state.Set(snapshot)
|
self.state.Set(snapshot)
|
||||||
|
|
||||||
return fmt.Errorf("Error during code execution %v", err)
|
statelogger.Debugf("Error during code execution %v", evmerr)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.Output = ret
|
msg.Output = ret
|
||||||
@ -267,8 +260,6 @@ func (self *StateTransition) Eval(msg *ethstate.Message, script []byte, context
|
|||||||
|
|
||||||
// Converts an transaction in to a state object
|
// Converts an transaction in to a state object
|
||||||
func MakeContract(tx *Transaction, state *ethstate.State) *ethstate.StateObject {
|
func MakeContract(tx *Transaction, state *ethstate.State) *ethstate.StateObject {
|
||||||
// Create contract if there's no recipient
|
|
||||||
if tx.IsContract() {
|
|
||||||
addr := tx.CreationAddress(state)
|
addr := tx.CreationAddress(state)
|
||||||
|
|
||||||
contract := state.GetOrNewStateObject(addr)
|
contract := state.GetOrNewStateObject(addr)
|
||||||
@ -277,6 +268,3 @@ func MakeContract(tx *Transaction, state *ethstate.State) *ethstate.StateObject
|
|||||||
|
|
||||||
return contract
|
return contract
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user