irisnet / irishub

A BPoS blockchain that enables cross-chain interoperability through a unified service model -- built with Cosmos-SDK
Apache License 2.0
304 stars 128 forks source link

[p1] LCD server Panic caused by trying to withdraw with negative liquidity #1923

Closed shilei-wang closed 5 years ago

shilei-wang commented 5 years ago

To Reproduce step 1. CoinswapUtils.deposit("1 iris", "1 token") step 2. CoinswapUtils.withdraw ("-1 liquidity")

{
  "base_tx": {
    "sequence": "22",
    "account_number": "2",
    "password": "1234567890",
    "chain_id": "shilei-qa",
    "gas_adjustment": "1.2",
    "fee": "0.6iris",
    "name": "node0",
    "gas": "100000"
  },
  "withdraw_liquidity": "-1",
  "min_token": "0",
  "min_iris_amt": "0",
  "deadline": "30m",
  "sender": "faa1rzs74xzxes73ygrs3qglkrmwnuv4nrddwn8c2k"
}

E[2019-08-27|17:14:49.569] Panic in RPC HTTP handler                    module=irislcd err="negative coin amount" stack="goroutine 97 [running]:\nruntime/debug.Stack(0xc00082d330, 0x4a75460, 0x50c1e80)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/runtime/debug/stack.go:24 +0x9d\ngithub.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1.1(0xc001814560, 0x50f7f00, 0xc0000b4a80, 0xbf515b0261e56de0, 0xca2bbaf372, 0x5905780, 0xc00180c600)\n\t/Users/sherlock/go/pkg/mod/github.com/irisnet/tendermint@v0.31.0/rpc/lib/server/http_server.go:133 +0x552\npanic(0x4a75460, 0x50c1e80)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/runtime/panic.go:522 +0x1b5\ngithub.com/irisnet/irishub/types.NewCoin(0xc000ac52d0, 0xd, 0xc001814980, 0x1a3185c5001, 0xbf515cc461e82d00, 0x26d441a012a)\n\t/Users/sherlock/go/src/github.com/irishub/types/coin.go:35 +0xc0\ngithub.com/irisnet/irishub/client/coinswap/lcd.removeLiquidityHandlerFn.func1(0x50f31c0, 0xc001814560, 0xc00180c800)\n\t/Users/sherlock/go/src/github.com/irishub/client/coinswap/lcd/sendtx.go:202 +0x3c1\nnet/http.HandlerFunc.ServeHTTP(0xc0009e40e0, 0x50f31c0, 0xc001814560, 0xc00180c800)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:1995 +0x44\ngithub.com/gorilla/mux.(*Router).ServeHTTP(0xc000032af0, 0x50f31c0, 0xc001814560, 0xc00180c800)\n\t/Users/sherlock/go/pkg/mod/github.com/gorilla/mux@v1.6.2/mux.go:162 +0x105\ngithub.com/tendermint/tendermint/rpc/lib/server.maxBytesHandler.ServeHTTP(0x50dc560, 0xc000032af0, 0xf4240, 0x50f31c0, 0xc001814560, 0xc00180c600)\n\t/Users/sherlock/go/pkg/mod/github.com/irisnet/tendermint@v0.31.0/rpc/lib/server/http_server.go:178 +0xd0\ngithub.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1(0x50f3740, 0xc0000f8700, 0xc00180c600)\n\t/Users/sherlock/go/pkg/mod/github.com/irisnet/tendermint@v0.31.0/rpc/lib/server/http_server.go:151 +0x317\nnet/http.HandlerFunc.ServeHTTP(0xc000142630, 0x50f3740, 0xc0000f8700, 0xc00180c600)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:1995 +0x44\nnet/http.serverHandler.ServeHTTP(0xc0000a7110, 0x50f3740, 0xc0000f8700, 0xc00180c600)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2774 +0xa8\nnet/http.(*conn).serve(0xc000ba3900, 0x50f7200, 0xc000b16100)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:1878 +0x851\ncreated by net/http.(*Server).Serve\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2884 +0x2f4\n"
2019/08/27 17:14:49 http: panic serving 127.0.0.1:56894: interface conversion: string is not error: missing method Error
goroutine 97 [running]:
net/http.(*conn).serve.func1(0xc000ba3900)
    /usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:1769 +0x139
panic(0x4ad7100, 0xc00180eba0)
    /usr/local/Cellar/go/1.12.5/libexec/src/runtime/panic.go:522 +0x1b5
github.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1.1(0xc001814560, 0x50f7f00, 0xc0000b4a80, 0xbf515b0261e56de0, 0xca2bbaf372, 0x5905780, 0xc00180c600)
    /Users/sherlock/go/pkg/mod/github.com/irisnet/tendermint@v0.31.0/rpc/lib/server/http_server.go:135 +0x69a
panic(0x4a75460, 0x50c1e80)
    /usr/local/Cellar/go/1.12.5/libexec/src/runtime/panic.go:522 +0x1b5
github.com/irisnet/irishub/types.NewCoin(0xc000ac52d0, 0xd, 0xc001814980, 0x1a3185c5001, 0xbf515cc461e82d00, 0x26d441a012a)
    /Users/sherlock/go/src/github.com/irishub/types/coin.go:35 +0xc0
github.com/irisnet/irishub/client/coinswap/lcd.removeLiquidityHandlerFn.func1(0x50f31c0, 0xc001814560, 0xc00180c800)
    /Users/sherlock/go/src/github.com/irishub/client/coinswap/lcd/sendtx.go:202 +0x3c1
net/http.HandlerFunc.ServeHTTP(0xc0009e40e0, 0x50f31c0, 0xc001814560, 0xc00180c800)
    /usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:1995 +0x44
github.com/gorilla/mux.(*Router).ServeHTTP(0xc000032af0, 0x50f31c0, 0xc001814560, 0xc00180c800)
    /Users/sherlock/go/pkg/mod/github.com/gorilla/mux@v1.6.2/mux.go:162 +0x105
github.com/tendermint/tendermint/rpc/lib/server.maxBytesHandler.ServeHTTP(0x50dc560, 0xc000032af0, 0xf4240, 0x50f31c0, 0xc001814560, 0xc00180c600)
    /Users/sherlock/go/pkg/mod/github.com/irisnet/tendermint@v0.31.0/rpc/lib/server/http_server.go:178 +0xd0
github.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1(0x50f3740, 0xc0000f8700, 0xc00180c600)
    /Users/sherlock/go/pkg/mod/github.com/irisnet/tendermint@v0.31.0/rpc/lib/server/http_server.go:151 +0x317
net/http.HandlerFunc.ServeHTTP(0xc000142630, 0x50f3740, 0xc0000f8700, 0xc00180c600)
    /usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:1995 +0x44
net/http.serverHandler.ServeHTTP(0xc0000a7110, 0x50f3740, 0xc0000f8700, 0xc00180c600)
    /usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2774 +0xa8
net/http.(*conn).serve(0xc000ba3900, 0x50f7200, 0xc000b16100)
    /usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:1878 +0x851
created by net/http.(*Server).Serve
    /usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2884 +0x2f4
E[2019-08-27|17:14:49.570] Panic in RPC HTTP handler                    module=irislcd err="negative coin amount" stack="goroutine 162 [running]:\nruntime/debug.Stack(0xc0008f1330, 0x4a75460, 0x50c1e80)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/runtime/debug/stack.go:24 +0x9d\ngithub.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1.1(0xc001814a20, 0x50f7f00, 0xc0000b4a80, 0xbf515b0262025068, 0xca2bd7d587, 0x5905780, 0xc00180c900)\n\t/Users/sherlock/go/pkg/mod/github.com/irisnet/tendermint@v0.31.0/rpc/lib/server/http_server.go:133 +0x552\npanic(0x4a75460, 0x50c1e80)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/runtime/panic.go:522 +0x1b5\ngithub.com/irisnet/irishub/types.NewCoin(0xc000ac55c0, 0xd, 0xc001814e40, 0x1a3185c5001, 0xbf515cc46204f818, 0x26d4436cced)\n\t/Users/sherlock/go/src/github.com/irishub/types/coin.go:35 +0xc0\ngithub.com/irisnet/irishub/client/coinswap/lcd.removeLiquidityHandlerFn.func1(0x50f31c0, 0xc001814a20, 0xc00180cb00)\n\t/Users/sherlock/go/src/github.com/irishub/client/coinswap/lcd/sendtx.go:202 +0x3c1\nnet/http.HandlerFunc.ServeHTTP(0xc0009e40e0, 0x50f31c0, 0xc001814a20, 0xc00180cb00)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:1995 +0x44\ngithub.com/gorilla/mux.(*Router).ServeHTTP(0xc000032af0, 0x50f31c0, 0xc001814a20, 0xc00180cb00)\n\t/Users/sherlock/go/pkg/mod/github.com/gorilla/mux@v1.6.2/mux.go:162 +0x105\ngithub.com/tendermint/tendermint/rpc/lib/server.maxBytesHandler.ServeHTTP(0x50dc560, 0xc000032af0, 0xf4240, 0x50f31c0, 0xc001814a20, 0xc00180c900)\n\t/Users/sherlock/go/pkg/mod/github.com/irisnet/tendermint@v0.31.0/rpc/lib/server/http_server.go:178 +0xd0\ngithub.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1(0x50f3740, 0xc0000f87e0, 0xc00180c900)\n\t/Users/sherlock/go/pkg/mod/github.com/irisnet/tendermint@v0.31.0/rpc/lib/server/http_server.go:151 +0x317\nnet/http.HandlerFunc.ServeHTTP(0xc000142630, 0x50f3740, 0xc0000f87e0, 0xc00180c900)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:1995 +0x44\nnet/http.serverHandler.ServeHTTP(0xc0000a7110, 0x50f3740, 0xc0000f87e0, 0xc00180c900)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2774 +0xa8\nnet/http.(*conn).serve(0xc000ba39a0, 0x50f7200, 0xc000b166c0)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:1878 +0x851\ncreated by net/http.(*Server).Serve\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2884 +0x2f4\n"
2019/08/27 17:14:49 http: panic serving 127.0.0.1:56896: interface conversion: string is not error: missing method Error
goroutine 162 [running]:
net/http.(*conn).serve.func1(0xc000ba39a0)
    /usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:1769 +0x139
panic(0x4ad7100, 0xc00180ee40)
    /usr/local/Cellar/go/1.12.5/libexec/src/runtime/panic.go:522 +0x1b5
github.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1.1(0xc001814a20, 0x50f7f00, 0xc0000b4a80, 0xbf515b0262025068, 0xca2bd7d587, 0x5905780, 0xc00180c900)
    /Users/sherlock/go/pkg/mod/github.com/irisnet/tendermint@v0.31.0/rpc/lib/server/http_server.go:135 +0x69a
panic(0x4a75460, 0x50c1e80)
    /usr/local/Cellar/go/1.12.5/libexec/src/runtime/panic.go:522 +0x1b5
github.com/irisnet/irishub/types.NewCoin(0xc000ac55c0, 0xd, 0xc001814e40, 0x1a3185c5001, 0xbf515cc46204f818, 0x26d4436cced)
    /Users/sherlock/go/src/github.com/irishub/types/coin.go:35 +0xc0
github.com/irisnet/irishub/client/coinswap/lcd.removeLiquidityHandlerFn.func1(0x50f31c0, 0xc001814a20, 0xc00180cb00)
    /Users/sherlock/go/src/github.com/irishub/client/coinswap/lcd/sendtx.go:202 +0x3c1
net/http.HandlerFunc.ServeHTTP(0xc0009e40e0, 0x50f31c0, 0xc001814a20, 0xc00180cb00)
    /usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:1995 +0x44
github.com/gorilla/mux.(*Router).ServeHTTP(0xc000032af0, 0x50f31c0, 0xc001814a20, 0xc00180cb00)
    /Users/sherlock/go/pkg/mod/github.com/gorilla/mux@v1.6.2/mux.go:162 +0x105
github.com/tendermint/tendermint/rpc/lib/server.maxBytesHandler.ServeHTTP(0x50dc560, 0xc000032af0, 0xf4240, 0x50f31c0, 0xc001814a20, 0xc00180c900)
    /Users/sherlock/go/pkg/mod/github.com/irisnet/tendermint@v0.31.0/rpc/lib/server/http_server.go:178 +0xd0
github.com/tendermint/tendermint/rpc/lib/server.RecoverAndLogHandler.func1(0x50f3740, 0xc0000f87e0, 0xc00180c900)
    /Users/sherlock/go/pkg/mod/github.com/irisnet/tendermint@v0.31.0/rpc/lib/server/http_server.go:151 +0x317
net/http.HandlerFunc.ServeHTTP(0xc000142630, 0x50f3740, 0xc0000f87e0, 0xc00180c900)
    /usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:1995 +0x44
net/http.serverHandler.ServeHTTP(0xc0000a7110, 0x50f3740, 0xc0000f87e0, 0xc00180c900)
    /usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2774 +0xa8
net/http.(*conn).serve(0xc000ba39a0, 0x50f7200, 0xc000b166c0)
    /usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:1878 +0x851
created by net/http.(*Server).Serve
    /usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2884 +0x2f4
shilei-wang commented 5 years ago

confirm fixed