decred / dcrdex

The Decred Decentralized Exchange (DEX), powered by atomic-swaps.
Other
186 stars 95 forks source link

eth: MaxSell panic with no AssetConfig set #1696

Closed JoeGruffins closed 2 years ago

JoeGruffins commented 2 years ago

On master 1961b68a38a4c886f9708166f7b64eff438a2f30

Get a panic when trading on simnet. Have been trading on dcr_eth so probably related. I see something about redeem gas.:

panic ``` 2022/07/06 11:39:23 http: panic serving 127.0.0.1:37618: runtime error: slice bounds out of range [-1:] goroutine 8408 [running]: net/http.(*conn).serve.func1() /usr/lib/go/src/net/http/server.go:1825 +0xbf panic({0x1415620, 0xc001c9e120}) /usr/lib/go/src/runtime/panic.go:844 +0x258 github.com/go-chi/chi/v5/middleware.prettyStack.decorateFuncCallLine({}, {0xc000ab8c7b, 0x1d}, 0xc1?, 0x8) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/middleware/recoverer.go:130 +0x545 github.com/go-chi/chi/v5/middleware.prettyStack.decorateLine({}, {0xc000ab8c7b?, 0xc000601000?}, 0x90?, 0x1?) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/middleware/recoverer.go:106 +0x15d github.com/go-chi/chi/v5/middleware.prettyStack.parse({}, {0xc001dd0000, 0x141a, 0xc004bfce40?}, {0x12f6d00, 0x21956d0}) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/middleware/recoverer.go:89 +0x4e5 github.com/go-chi/chi/v5/middleware.PrintPrettyStack({0x12f6d00, 0x21956d0}) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/middleware/recoverer.go:46 +0x45 github.com/go-chi/chi/v5/middleware.(*defaultLogEntry).Panic(0x900000000?, {0x12f6d00?, 0x21956d0?}, {0x19bca8a79bbc?, 0x203000?, 0xc001d83800?}) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/middleware/logger.go:165 +0x29 github.com/go-chi/chi/v5/middleware.Recoverer.func1.1() /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/middleware/recoverer.go:28 +0xcc panic({0x12f6d00, 0x21956d0}) /usr/lib/go/src/runtime/panic.go:838 +0x207 decred.org/dcrdex/client/asset/eth.(*assetWallet).redeemGas(0xc0003370e0, 0x6e8a, 0x0) /home/joe/git/dcrdex/client/asset/eth/eth.go:1036 +0x33 decred.org/dcrdex/client/asset/eth.(*assetWallet).PreRedeem(0xc0004f8180?, 0xc002211760) /home/joe/git/dcrdex/client/asset/eth/eth.go:826 +0x31 decred.org/dcrdex/client/core.(*Core).MaxSell(0x7f9a74054bf8?, {0xc0018962d0, 0xf}, 0x1242340?, 0x0?) /home/joe/git/dcrdex/client/core/core.go:3793 +0x2ce decred.org/dcrdex/client/webserver.(*WebServer).apiMaxSell(0xc0003e3c20, {0x7f9a74054bf8, 0xc000120f40}, 0xc001d184e0?) /home/joe/git/dcrdex/client/webserver/api.go:945 +0x9b net/http.HandlerFunc.ServeHTTP(0xc004bfd3f8?, {0x7f9a74054bf8?, 0xc000120f40?}, 0xc0021e05a0?) /usr/lib/go/src/net/http/server.go:2084 +0x2f decred.org/dcrdex/client/webserver.(*WebServer).rejectUnauthed.func1({0x7f9a74054bf8, 0xc000120f40}, 0x8?) /home/joe/git/dcrdex/client/webserver/middleware.go:119 +0x6a net/http.HandlerFunc.ServeHTTP(0xc00091aa50?, {0x7f9a74054bf8?, 0xc000120f40?}, 0xc0022147f0?) /usr/lib/go/src/net/http/server.go:2084 +0x2f github.com/go-chi/chi/v5.(*ChainHandler).ServeHTTP(0x12e50e0?, {0x7f9a74054bf8?, 0xc000120f40?}, 0xc0018962a8?) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/chain.go:31 +0x2c github.com/go-chi/chi/v5.(*Mux).routeHTTP(0xc000301680, {0x7f9a74054bf8, 0xc000120f40}, 0xc001ba8700) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/mux.go:437 +0x1f9 net/http.HandlerFunc.ServeHTTP(0x12e5d40?, {0x7f9a74054bf8?, 0xc000120f40?}, 0x10?) /usr/lib/go/src/net/http/server.go:2084 +0x2f github.com/go-chi/chi/v5/middleware.AllowContentType.func1.1({0x7f9a74054bf8, 0xc000120f40}, 0xc001ba8700) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/middleware/content_type.go:41 +0xeb net/http.HandlerFunc.ServeHTTP(0x0?, {0x7f9a74054bf8?, 0xc000120f40?}, 0x454d10?) /usr/lib/go/src/net/http/server.go:2084 +0x2f github.com/go-chi/chi/v5.(*Mux).ServeHTTP(0xc000301680, {0x7f9a74054bf8, 0xc000120f40}, 0xc001ba8700) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/mux.go:71 +0x48d github.com/go-chi/chi/v5.(*Mux).Mount.func1({0x7f9a74054bf8, 0xc000120f40}, 0xc001ba8700) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/mux.go:312 +0x19c net/http.HandlerFunc.ServeHTTP(0x12e50e0?, {0x7f9a74054bf8?, 0xc000120f40?}, 0xc0007cabc5?) /usr/lib/go/src/net/http/server.go:2084 +0x2f github.com/go-chi/chi/v5.(*Mux).routeHTTP(0xc000401f20, {0x7f9a74054bf8, 0xc000120f40}, 0xc001ba8700) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/mux.go:437 +0x1f9 net/http.HandlerFunc.ServeHTTP(0x19778e0?, {0x7f9a74054bf8?, 0xc000120f40?}, 0x1969790?) /usr/lib/go/src/net/http/server.go:2084 +0x2f decred.org/dcrdex/client/webserver.(*WebServer).authMiddleware.func1({0x7f9a74054bf8, 0xc000120f40}, 0xc001ba8600) /home/joe/git/dcrdex/client/webserver/middleware.go:49 +0x382 net/http.HandlerFunc.ServeHTTP(0x10?, {0x7f9a74054bf8?, 0xc000120f40?}, 0x4167b9?) /usr/lib/go/src/net/http/server.go:2084 +0x2f github.com/go-chi/chi/v5/middleware.Recoverer.func1({0x7f9a74054bf8?, 0xc000120f40?}, 0xc00041af20?) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/middleware/recoverer.go:37 +0x83 net/http.HandlerFunc.ServeHTTP(0x13e1bc0?, {0x7f9a74054bf8?, 0xc000120f40?}, 0xe?) /usr/lib/go/src/net/http/server.go:2084 +0x2f decred.org/dcrdex/client/webserver.(*WebServer).securityMiddleware.func1({0x7f9a74054bf8, 0xc000120f40}, 0xc001d18200?) /home/joe/git/dcrdex/client/webserver/middleware.go:34 +0x4ed net/http.HandlerFunc.ServeHTTP(0xc001ba8500?, {0x7f9a74054bf8?, 0xc000120f40?}, 0x203000?) /usr/lib/go/src/net/http/server.go:2084 +0x2f github.com/go-chi/chi/v5/middleware.RequestLogger.func1.1({0x1976d28, 0xc00223e1c0}, 0xc001ba8500) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/middleware/logger.go:57 +0x3aa net/http.HandlerFunc.ServeHTTP(0x1977838?, {0x1976d28?, 0xc00223e1c0?}, 0x21953e0?) /usr/lib/go/src/net/http/server.go:2084 +0x2f github.com/go-chi/chi/v5.(*Mux).ServeHTTP(0xc000401f20, {0x1976d28, 0xc00223e1c0}, 0xc001ba8400) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/mux.go:88 +0x442 net/http.serverHandler.ServeHTTP({0x1974868?}, {0x1976d28, 0xc00223e1c0}, 0xc001ba8400) /usr/lib/go/src/net/http/server.go:2916 +0x43b net/http.(*conn).serve(0xc00034a960, {0x19778e0, 0xc00067c810}) /usr/lib/go/src/net/http/server.go:1966 +0x5d7 created by net/http.(*Server).Serve /usr/lib/go/src/net/http/server.go:3071 +0x4db 2022/07/06 11:39:23 http: panic serving 127.0.0.1:37622: runtime error: slice bounds out of range [-1:] goroutine 7881 [running]: net/http.(*conn).serve.func1() /usr/lib/go/src/net/http/server.go:1825 +0xbf panic({0x1415620, 0xc0022fa0d8}) /usr/lib/go/src/runtime/panic.go:844 +0x258 github.com/go-chi/chi/v5/middleware.prettyStack.decorateFuncCallLine({}, {0xc000d5f77b, 0x1d}, 0xc1?, 0x8) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/middleware/recoverer.go:130 +0x545 github.com/go-chi/chi/v5/middleware.prettyStack.decorateLine({}, {0xc000d5f77b?, 0xc002410800?}, 0x90?, 0x1?) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/middleware/recoverer.go:106 +0x15d github.com/go-chi/chi/v5/middleware.prettyStack.parse({}, {0xc0026d0000, 0x141a, 0xc002152e40?}, {0x12f6d00, 0x21956d0}) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/middleware/recoverer.go:89 +0x4e5 github.com/go-chi/chi/v5/middleware.PrintPrettyStack({0x12f6d00, 0x21956d0}) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/middleware/recoverer.go:46 +0x45 github.com/go-chi/chi/v5/middleware.(*defaultLogEntry).Panic(0x900000000?, {0x12f6d00?, 0x21956d0?}, {0x19bca8a79bbc?, 0x203000?, 0xc002681800?}) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/middleware/logger.go:165 +0x29 github.com/go-chi/chi/v5/middleware.Recoverer.func1.1() /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/middleware/recoverer.go:28 +0xcc panic({0x12f6d00, 0x21956d0}) /usr/lib/go/src/runtime/panic.go:838 +0x207 decred.org/dcrdex/client/asset/eth.(*assetWallet).redeemGas(0xc0003370e0, 0x6e8a, 0x0) /home/joe/git/dcrdex/client/asset/eth/eth.go:1036 +0x33 decred.org/dcrdex/client/asset/eth.(*assetWallet).PreRedeem(0xc0004f8180?, 0xc000d4c680) /home/joe/git/dcrdex/client/asset/eth/eth.go:826 +0x31 decred.org/dcrdex/client/core.(*Core).MaxSell(0x7f9a74054bf8?, {0xc001cf85d0, 0xf}, 0x1242340?, 0x0?) /home/joe/git/dcrdex/client/core/core.go:3793 +0x2ce decred.org/dcrdex/client/webserver.(*WebServer).apiMaxSell(0xc0003e3c20, {0x7f9a74054bf8, 0xc000d40600}, 0xc002414d80?) /home/joe/git/dcrdex/client/webserver/api.go:945 +0x9b net/http.HandlerFunc.ServeHTTP(0xc0021533f8?, {0x7f9a74054bf8?, 0xc000d40600?}, 0xc000b39520?) /usr/lib/go/src/net/http/server.go:2084 +0x2f decred.org/dcrdex/client/webserver.(*WebServer).rejectUnauthed.func1({0x7f9a74054bf8, 0xc000d40600}, 0x8?) /home/joe/git/dcrdex/client/webserver/middleware.go:119 +0x6a net/http.HandlerFunc.ServeHTTP(0xc00091aa50?, {0x7f9a74054bf8?, 0xc000d40600?}, 0xc0004f5830?) /usr/lib/go/src/net/http/server.go:2084 +0x2f github.com/go-chi/chi/v5.(*ChainHandler).ServeHTTP(0x12e50e0?, {0x7f9a74054bf8?, 0xc000d40600?}, 0xc001cf85a8?) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/chain.go:31 +0x2c github.com/go-chi/chi/v5.(*Mux).routeHTTP(0xc000301680, {0x7f9a74054bf8, 0xc000d40600}, 0xc000179000) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/mux.go:437 +0x1f9 net/http.HandlerFunc.ServeHTTP(0x12e5d40?, {0x7f9a74054bf8?, 0xc000d40600?}, 0x10?) /usr/lib/go/src/net/http/server.go:2084 +0x2f github.com/go-chi/chi/v5/middleware.AllowContentType.func1.1({0x7f9a74054bf8, 0xc000d40600}, 0xc000179000) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/middleware/content_type.go:41 +0xeb net/http.HandlerFunc.ServeHTTP(0x0?, {0x7f9a74054bf8?, 0xc000d40600?}, 0x454d10?) /usr/lib/go/src/net/http/server.go:2084 +0x2f github.com/go-chi/chi/v5.(*Mux).ServeHTTP(0xc000301680, {0x7f9a74054bf8, 0xc000d40600}, 0xc000179000) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/mux.go:71 +0x48d github.com/go-chi/chi/v5.(*Mux).Mount.func1({0x7f9a74054bf8, 0xc000d40600}, 0xc000179000) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/mux.go:312 +0x19c net/http.HandlerFunc.ServeHTTP(0x12e50e0?, {0x7f9a74054bf8?, 0xc000d40600?}, 0xc000d06925?) /usr/lib/go/src/net/http/server.go:2084 +0x2f github.com/go-chi/chi/v5.(*Mux).routeHTTP(0xc000401f20, {0x7f9a74054bf8, 0xc000d40600}, 0xc000179000) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/mux.go:437 +0x1f9 net/http.HandlerFunc.ServeHTTP(0x19778e0?, {0x7f9a74054bf8?, 0xc000d40600?}, 0x1969790?) /usr/lib/go/src/net/http/server.go:2084 +0x2f decred.org/dcrdex/client/webserver.(*WebServer).authMiddleware.func1({0x7f9a74054bf8, 0xc000d40600}, 0xc000178f00) /home/joe/git/dcrdex/client/webserver/middleware.go:49 +0x382 net/http.HandlerFunc.ServeHTTP(0x10?, {0x7f9a74054bf8?, 0xc000d40600?}, 0x4167b9?) /usr/lib/go/src/net/http/server.go:2084 +0x2f github.com/go-chi/chi/v5/middleware.Recoverer.func1({0x7f9a74054bf8?, 0xc000d40600?}, 0xc0001ec580?) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/middleware/recoverer.go:37 +0x83 net/http.HandlerFunc.ServeHTTP(0x13e1bc0?, {0x7f9a74054bf8?, 0xc000d40600?}, 0xe?) /usr/lib/go/src/net/http/server.go:2084 +0x2f decred.org/dcrdex/client/webserver.(*WebServer).securityMiddleware.func1({0x7f9a74054bf8, 0xc000d40600}, 0xc002414a00?) /home/joe/git/dcrdex/client/webserver/middleware.go:34 +0x4ed net/http.HandlerFunc.ServeHTTP(0xc000178e00?, {0x7f9a74054bf8?, 0xc000d40600?}, 0x203000?) /usr/lib/go/src/net/http/server.go:2084 +0x2f github.com/go-chi/chi/v5/middleware.RequestLogger.func1.1({0x1976d28, 0xc000d46620}, 0xc000178e00) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/middleware/logger.go:57 +0x3aa net/http.HandlerFunc.ServeHTTP(0x1977838?, {0x1976d28?, 0xc000d46620?}, 0x21953e0?) /usr/lib/go/src/net/http/server.go:2084 +0x2f github.com/go-chi/chi/v5.(*Mux).ServeHTTP(0xc000401f20, {0x1976d28, 0xc000d46620}, 0xc000178d00) /home/joe/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.1/mux.go:88 +0x442 net/http.serverHandler.ServeHTTP({0x1974868?}, {0x1976d28, 0xc000d46620}, 0xc000178d00) /usr/lib/go/src/net/http/server.go:2916 +0x43b net/http.(*conn).serve(0xc000bee0a0, {0x19778e0, 0xc00067c810}) /usr/lib/go/src/net/http/server.go:1966 +0x5d7 created by net/http.(*Server).Serve /usr/lib/go/src/net/http/server.go:3071 +0x4db ```
chappjc commented 2 years ago

The panic is in PreRedeem>redeemGas. The web stuff is just the recover middleware

chappjc commented 2 years ago

This is resolved at https://github.com/decred/dcrdex/pull/1622/files#diff-13a4a6b12c1ae844ef90151638f194427cfdc545fceb58d52c0f6f33b81d859bR4062 adding the missing AssetConfig field to PreRedeem from MaxSell.

JoeGruffins commented 2 years ago

Probably resolved by #1713