tdex-network / tdex-daemon

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

Tdex-daemon unexpected crash after calling sell grpc function #541

Closed mattiaferrari02 closed 2 years ago

mattiaferrari02 commented 2 years ago

With this request payload of trade.sell method of the TypeScript tdex-sdk module :

{
  "market": {
    "quoteAsset": "30973a9164ea895605161bb9f81c87938984620e102fa95f2564bd5ddf4ca5e1",
    "provider": "Tdex test",
    "feeBasisPoint": 25,
    "baseAsset": "5ac9f65c0efcc4775e0baec4ec03abdde22473cd3cf33c0419ca290e0751b225"
  },
  "amount": 50000000,
  "asset": "5ac9f65c0efcc4775e0baec4ec03abdde22473cd3cf33c0419ca290e0751b225",
  "identity": {
    "type": 4,
    "restorer": {
      "esploraEndpoint": "http://localhost:5001"
    },
    "network": {
      "messagePrefix": "\u0018Liquid Signed Message:\n",
      "bech32": "ert",
      "blech32": "el",
      "bip32": {
        "public": 70617039,
        "private": 70615956
      },
      "pubKeyHash": 235,
      "scriptHash": 75,
      "wif": 239,
      "confidentialPrefix": 4,
      "assetHash": "5ac9f65c0efcc4775e0baec4ec03abdde22473cd3cf33c0419ca290e0751b225"
    },
    "isRestored": {
      "_h": 0,
      "_i": 1,
      "_j": true,
      "_k": null
    }
  }
}

The daemon crashes and after restarting it is still broken and I've had to delete and create the container again. The version that I'm using is 0.8.1 These are the logs that i can see:

panic: runtime error: index out of range [0] with length 0

goroutine 4603 [running]:

github.com/tdex-network/tdex-daemon/pkg/wallet.extractScriptTypesFromPset(0x400043da40, 0x459d50, 0x40101f7f00, 0x10, 0x10, 0xcce920, 0xcce920, 0x14d6060, 0x0, 0x0, ...)

/tdex-daemon/pkg/wallet/util.go:192 +0xc14

github.com/tdex-network/tdex-daemon/pkg/wallet.calcFeeAmount(0x400043da40, 0x1, 0x1, 0x64, 0x1)

/tdex-daemon/pkg/wallet/util.go:252 +0x30

github.com/tdex-network/tdex-daemon/pkg/wallet.(*Wallet).UpdateTx(0x40000af560, 0x4010397a80, 0x198c, 0x4010287680, 0x3, 0x3, 0x0, 0x0, 0x0, 0x4010287bf0, ...)

/tdex-daemon/pkg/wallet/transaction.go:429 +0x8d4

github.com/tdex-network/tdex-daemon/internal/core/application.fillProposal(0x40006d4900, 0x18, 0x18, 0xfa8068, 0x400067d0e0, 0x4010320800, 0x4, 0x4, 0x4010287680, 0x3, ...)

/tdex-daemon/internal/core/application/trade_service.go:675 +0x3b8

github.com/tdex-network/tdex-daemon/internal/core/application.tradeManager.FillProposal(...)

/tdex-daemon/internal/core/application/types.go:377

github.com/tdex-network/tdex-daemon/internal/core/application.(*tradeService).TradePropose(0x4000090880, 0xfa0f20, 0x4010237d10, 0x4000686c40, 0x40, 0x4000686c80, 0x40, 0x1, 0xfa8068, 0x400067d0e0, ...)

/tdex-daemon/internal/core/application/trade_service.go:342 +0x8cc

github.com/tdex-network/tdex-daemon/internal/interfaces/grpc/handler.traderHandler.proposeTrade(0xfa3078, 0x4000090880, 0xfa0f20, 0x4010237d10, 0x401021f948, 0x419328, 0x400011f490, 0x10)

/tdex-daemon/internal/interfaces/grpc/handler/trade.go:221 +0x228

github.com/tdex-network/tdex-daemon/internal/interfaces/grpc/handler.traderHandler.tradePropose(0xfa3078, 0x4000090880, 0xfa70c8, 0x400011f490, 0x4000569400, 0xcc7920, 0xcba901)

/tdex-daemon/internal/interfaces/grpc/handler/trade.go:298 +0x94

github.com/tdex-network/tdex-daemon/internal/interfaces/grpc/handler.traderHandler.TradePropose(...)

/tdex-daemon/internal/interfaces/grpc/handler/trade.go:64

github.com/tdex-network/tdex-protobuf/generated/go/trade._Trade_TradePropose_Handler(0xcf73a0, 0x400038ae10, 0xfa4a50, 0x40006a60c0, 0x40001f2040, 0xd2f540)

/go/pkg/mod/github.com/tdex-network/tdex-protobuf@v0.0.0-20211025103804-7ead2ca5a7b3/generated/go/trade/trade_grpc.pb.go:314 +0xf8

github.com/grpc-ecosystem/go-grpc-middleware.ChainStreamServer.func1.1(0xcf73a0, 0x400038ae10, 0xfa4a50, 0x40006a60c0, 0x1, 0x50)

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

github.com/tdex-network/tdex-daemon/internal/interfaces/grpc/interceptor.streamLogger(0xcf73a0, 0x400038ae10, 0xfa4a50, 0x40006a60c0, 0x40006530e0, 0x4000116b90, 0x48, 0xffff98623f18)

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

github.com/grpc-ecosystem/go-grpc-middleware.ChainStreamServer.func1.1(0xcf73a0, 0x400038ae10, 0xfa4a50, 0x40006a60c0, 0x0, 0x0)

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

github.com/tdex-network/tdex-daemon/internal/interfaces/grpc/interceptor.streamMacaroonAuthHandler.func1(0xcf73a0, 0x400038ae10, 0xfa4a50, 0x40006a60c0, 0x40006530e0, 0x4000116b90, 0x40106bb408, 0x9002bc)

/tdex-daemon/internal/interfaces/grpc/interceptor/auth.go:42 +0xb8

github.com/grpc-ecosystem/go-grpc-middleware.ChainStreamServer.func1(0xcf73a0, 0x400038ae10, 0xfa4a50, 0x40006a60c0, 0x40006530e0, 0xec5f58, 0xfa0f20, 0x4010237d10)

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

google.golang.org/grpc.(*Server).processStreamingRPC(0x40003c6c40, 0xfa8a38, 0x401133e780, 0x40006547e0, 0x4000126b40, 0x143e2a0, 0x0, 0x0, 0x0)

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

google.golang.org/grpc.(*Server).handleStream(0x40003c6c40, 0xfa8a38, 0x401133e780, 0x40006547e0, 0x0)

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

google.golang.org/grpc.(*Server).serveStreams.func1.2(0x400043b280, 0x40003c6c40, 0xfa8a38, 0x401133e780, 0x40006547e0)

/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
tiero commented 2 years ago

Can you share also:

tiero commented 2 years ago

assiging to @altafan from @sekulicd

altafan commented 2 years ago

identity.restorer.esploraEndpoint doesn't seem correct, it should be http://localhost:3001.

Can you share also the partial transaction of the gRPC request (ie. what you send inside the transaction field of the TradePropose)?

mattiaferrari02 commented 2 years ago

Ok this is the transaction that we are sending via grpc:

cHNldP8BALoCAAAAAAFQo5WlWQER2Ym3ghda4ozhc1XwhU9hhA0dahfI5lZU4AAAAAAA/////wIBu2f0+zST5n4KaMKLjW63rHHOw2SbI8wZykyFGweqQ1UBAAAAqfLFdaAAF6kUZijGKT18vjv0+n66iQQ8MT3JdwiHASWyUQcOKcoZBDzzPM1zJOLdqwPsxK4LXnfE/A5c9slaAQAAAAAEeGjAABepFB8lUfufBxlMLlwuV3W7grw+lDrdhwAAAAAAAQH9EBELXsA0oxNYpKgfBhvBBc0yCjBt4raPR1fciuB2Ifiln3EJF4muqWg6xDJAFJYlHB71b1I+GMAlIS5yVULrJkAOK0MCDE6SE/FLzZMFg81Tipy59qlnoDDbuyMx5ADzb6Fsd0kXqRRK/hXVSjm4FyrOGUQPojRqGwGYmIdDAQABgVAL4x4wk7NP2DQIEQc5KQ3tP5Rxr0VNKTh9RbUrzsF1NwH5LO67PN1cC2lQNJb7Y6fKITs8otGK8g3ais0ggP1OEGAzAAAAAAAAAAHWbiMBCvyYguG2a7tvr5ZpPXJIy1F1Dz45zX+kRFXrxtdp85WNcXKgwYtKZOkyuBYQepA3TDsuc3qlvthfYdlkdBH4ZUEQndAE3RJbhqF1wMlXzrAlVxGqDWDh1mLAXKjo7nMaLhU8ZmFBCXl8qIa0NIsiIhCgRQAF8GxT6PvooGxURMhUQINIyVnuoZP55hd1JS1M3F/9QBZGK3E2e9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mkBmaTdHD/kHn6rPHIo5YUUiW202PpO3PPPisxjkUKI8E0jT5cw90NEN7Bcr79oFHJ50/keEtTVDRHuoe71Hjn4Idz+GzmX301sCdiaGOBjqU+z9B23ljsEFA5ZyoUunGn4VF6SOgyQeBB5D4qCcbrxuVEo9i/QiGsIcavXQiyMP8Ehj4wWBwibsbIICfQ+DozdO14qA8rpJx8OluCiSY+ZwLvWv/L6o0geFovVc0NP57Df3Sa21fjenOduTE0sXO2ozTo4I9h8NFcOTM8yxocZIZAOcqFP3oAqyMr/mpd1CLJnL9TAsveKwIGvwfkgMycA3d8YN8d4cBV4h1ZxKNz6WKfMOhX/TlY1o/81kUvJHdd1or0apXKgDWHvrgvw+1fU+zQyz5soLQF2HoLwdMc3hxpPKvim1HTdkg0CjOm7X4V7sxNXcYxulJiW30HEI4/5D0GD5XMGvOhwEmSlPGEZ8b/yP8p5uwdCcKnw8SS5HMolnyROLzsu094mU1bm5gmG9IjSE5op74gknsteCS3jfUMEhL7Ym98ogI12KD5m7S2t1O2rpda+UFWuIhXbo5DhMgsqW3VLauCjUT6TU/DZ1qLFgrv6WLmS7tdwf0iZo1cdjoB45xoMXZcU+ndNHGoHYP56uzP+9+oNJ9NAKEUjbOWzgou2KK7MtD1ta86/QCTVJlz6cpLrSpegw9bA10g718QGtwt3OG7lE+0P8wpplQiRZ/6YgqV9gzpZvJrMFpq/1aagIg1mQTCeki0ENVKat1aTA2y4YmB9cf7EJWuHyNuozdAYaz8fFcemQ5mdOToGpKcP5TcqxTGV0tVPtanOz2IzOn4URb8VVDxnFAiLi6dTEvuWqG0bA7y5YbBjG1jK4XxYEb8NeXL0SqU/yvNG+BMCkuwJQ1RrJRsIzgmQfsxK4jBzEb2zBoMRTqaduSCDp8QS2Wh8FiOIHoG+4HpFkOs2/itqEMj4PoazxHwwvkARIUxdEBBBYAFEqTsDItLoaGV7h/hUs5DC1YTEqHAAAA

And for identity.restorer.esploraEndpoint I'm using the port of esplora-liquid from nigiri that is 5001, should I use chopsticks-liquid that is running on port 3001?

altafan commented 2 years ago

There's already an open PR that fixes the bug on the daemon side, preventing it from crashing. Soon a new rc will be published including the hotfix.

And for identity.restorer.esploraEndpoint I'm using the port of esplora-liquid from nigiri that is 5001, should I use chopsticks-liquid that is running on port 3001?

Yes, use http://localhost:3001 like done in the tdex-sdk integration test.

mattiaferrari02 commented 2 years ago

There's already an open PR that fixes the bug on the daemon side, preventing it from crashing. Soon a new rc will be published including the hotfix.

Ok so why it was crashing? We still can't figure out how to make a successful trade, so maybe it could be helpful...

altafan commented 2 years ago

@IlSassone v0.8.2 has been released. Please, try testing against this version.