Merge pull request #95 from tendermint/vm_panics
label/remove panics in vm
This commit is contained in:
commit
99b94022ee
|
@ -52,6 +52,7 @@ func sha256Func(input []byte, gas *int64) (output []byte, err error) {
|
|||
}
|
||||
// Hash
|
||||
hasher := sha256.New()
|
||||
// CONTRACT: this does not err
|
||||
_, err = hasher.Write(input)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -69,6 +70,7 @@ func ripemd160Func(input []byte, gas *int64) (output []byte, err error) {
|
|||
}
|
||||
// Hash
|
||||
hasher := ripemd160.New()
|
||||
// CONTRACT: this does not err
|
||||
_, err = hasher.Write(input)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
@ -47,6 +47,7 @@ func (st *Stack) Push(d Word256) {
|
|||
st.ptr++
|
||||
}
|
||||
|
||||
// currently only called after Sha3
|
||||
func (st *Stack) PushBytes(bz []byte) {
|
||||
if len(bz) != 32 {
|
||||
panic("Invalid bytes size: expected 32")
|
||||
|
|
3
vm/vm.go
3
vm/vm.go
|
@ -100,6 +100,7 @@ func (vm *VM) Call(caller, callee *Account, code, input []byte, value int64, gas
|
|||
*exception = err.Error()
|
||||
err := transfer(callee, caller, value)
|
||||
if err != nil {
|
||||
// data has been corrupted in ram
|
||||
panic("Could not return value to caller")
|
||||
}
|
||||
}
|
||||
|
@ -784,7 +785,7 @@ func (vm *VM) call(caller, callee *Account, code, input []byte, value int64, gas
|
|||
|
||||
default:
|
||||
dbg.Printf("(pc) %-3v Invalid opcode %X\n", pc, op)
|
||||
panic(fmt.Errorf("Invalid opcode %X", op))
|
||||
return nil, fmt.Errorf("Invalid opcode %X", op)
|
||||
}
|
||||
|
||||
pc++
|
||||
|
|
Loading…
Reference in New Issue