tdex-network / tdex-daemon

Go implementation of the TDEX Beta Daemon
https://tdex.network
MIT License
11 stars 13 forks source link

[UpdateMarketPrice] Wrong arguments make daemon crash #549

Closed Janaka-Steph closed 2 years ago

Janaka-Steph commented 2 years ago

There are 2 distincts errors with UpdateMarketPrice. First, if args are { basePrice: '100', quotePrice: undefined } the error message is the amount for base price is invalid. It should say the amount for quote price is invalid

Second, if an argument is NaN the daemon will panic and crash.

DEBU[1286] /Operator/UpdateMarketPrice                  

panic: Cannot create a Decimal from NaN

goroutine 1847 [running]:

github.com/shopspring/decimal.newFromFloat(0x7fffffffe0000000, 0x7fffffff, 0x1459db0, 0x0, 0x0)

/go/pkg/mod/github.com/shopspring/decimal@v1.2.0/decimal.go:233 +0x380

github.com/shopspring/decimal.NewFromFloat32(0x407fffffff, 0x0, 0x400061c2a0)

/go/pkg/mod/github.com/shopspring/decimal@v1.2.0/decimal.go:228 +0xa0

github.com/tdex-network/tdex-daemon/internal/interfaces/grpc/handler.parsePrice(0x40107362d0, 0x4000560900, 0x40, 0x4000560940, 0x40, 0x0, 0x0)

/tdex-daemon/internal/interfaces/grpc/handler/operator.go:1328 +0x11c

github.com/tdex-network/tdex-daemon/internal/interfaces/grpc/handler.operatorHandler.updateMarketPrice(0xfb49f0, 0x400017a9a0, 0xfa6fc0, 0x40107362a0, 0x40004256c0, 0xd3e7a0, 0x0, 0xfb4b50)

/tdex-daemon/internal/interfaces/grpc/handler/operator.go:741 +0x78

github.com/tdex-network/tdex-daemon/internal/interfaces/grpc/handler.operatorHandler.UpdateMarketPrice(...)

/tdex-daemon/internal/interfaces/grpc/handler/operator.go:159

github.com/tdex-network/tdex-daemon/api-spec/protobuf/gen/operator._Operator_UpdateMarketPrice_Handler.func1(0xfa6fc0, 0x40107362a0, 0xcadc60, 0x40004256c0, 0x400061b978, 0xa877bc, 0x400017a040, 0xd345c0)

/tdex-daemon/api-spec/protobuf/gen/operator/operator_grpc.pb.go:1108 +0x7c

github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1(0xfa6fc0, 0x40107362a0, 0xcadc60, 0x40004256c0, 0x1, 0x4000536a80, 0x400061ba48, 0xa8793c)

/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.0.1-0.20190118093823-f849b5445de4/chain.go:31 +0xf8

github.com/tdex-network/tdex-daemon/internal/interfaces/grpc/interceptor.unaryLogger(0xfa6fc0, 0x40107362a0, 0xcadc60, 0x40004256c0, 0x400055fa60, 0x401022ca00, 0xffff528b1b18, 0x1, 0x1, 0x400055fec0)

/tdex-daemon/internal/interfaces/grpc/interceptor/logger.go:17 +0xa8

github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1(0xfa6fc0, 0x40107362a0, 0xcadc60, 0x40004256c0, 0x400026d0e0, 0x0, 0x0, 0x401022ca00)

/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.0.1-0.20190118093823-f849b5445de4/chain.go:34 +0x90

github.com/tdex-network/tdex-daemon/internal/interfaces/grpc/interceptor.unaryMacaroonAuthHandler.func1(0xfa6fc0, 0x40107362a0, 0xcadc60, 0x40004256c0, 0x400055fa60, 0x401022ca00, 0x0, 0x0, 0x400028eb18, 0xa61fd0)

/tdex-daemon/internal/interfaces/grpc/interceptor/auth.go:25 +0xa0

github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1(0xfa6fc0, 0x40107362a0, 0xcadc60, 0x40004256c0, 0x400055fa60, 0x400012f9e0, 0xcc8360, 0x40107362a0, 0x58, 0xcea760)

/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.0.1-0.20190118093823-f849b5445de4/chain.go:39 +0x138

github.com/tdex-network/tdex-daemon/api-spec/protobuf/gen/operator._Operator_UpdateMarketPrice_Handler(0xd3e7a0, 0x40002f1810, 0xfa6fc0, 0x40107362a0, 0x4000268720, 0x4000489260, 0xfa6fc0, 0x40107362a0, 0x4010255e00, 0x93)

/tdex-daemon/api-spec/protobuf/gen/operator/operator_grpc.pb.go:1110 +0x12c

google.golang.org/grpc.(*Server).processUnaryRPC(0x400009c000, 0xfaec78, 0x40104f6120, 0x400060a120, 0x4000489440, 0x144e828, 0x0, 0x0, 0x0)

/go/pkg/mod/google.golang.org/grpc@v1.40.0/server.go:1297 +0x3fc

google.golang.org/grpc.(*Server).handleStream(0x400009c000, 0xfaec78, 0x40104f6120, 0x400060a120, 0x0)

/go/pkg/mod/google.golang.org/grpc@v1.40.0/server.go:1626 +0xa70

google.golang.org/grpc.(*Server).serveStreams.func1.2(0x40101f1d00, 0x400009c000, 0xfaec78, 0x40104f6120, 0x400060a120)

/go/pkg/mod/google.golang.org/grpc@v1.40.0/server.go:941 +0x94

created by google.golang.org/grpc.(*Server).serveStreams.func1

/go/pkg/mod/google.golang.org/grpc@v1.40.0/server.go:939 +0x1f8