stellar / django-polaris

An extendable Django app for building modular Stellar services
https://django-polaris.readthedocs.io
Apache License 2.0
95 stars 70 forks source link

Deposits completed but polaris says they failed #640

Closed nikita-gorodeckij closed 2 years ago

nikita-gorodeckij commented 2 years ago

https://github.com/stellar/django-polaris/blob/a2bdb49c3a48bd3a6f9a74e7b7b342769c0db164/polaris/management/commands/process_pending_deposits.py#L602

Why don't you use submit response?

Looks like it is not great solution to retrieve details from horizon right after submit - there's a high probability to get NotFoundError.

I don't know exactly how horizon works, but looks like there are a bunch of servers behind load balancer. Because of it submit request could be send on Server#1 but request for transaction details could be send on Server#2. It is possible because of short time period servers won 't have time to sync history, and this will lead to NotFoundError.

Probably I'm wrong in reasons, but I have logs and see that problem with this line. status_message for transactions failed because of this line:

NotFoundError: {
  "type": "https://stellar.org/horizon-errors/not_found",
  "title": "Resource Missing",
  "status": 404,
  "detail": "The resource at the url requested was not found.  This usually occurs for one of two reasons:  The url requested is not valid, or no data in our database could be found with the parameters provided."
}

Error in logs:

transaction: ea393ff2-e8bf-4f0b-bcb1-2f919feb952b encountered an error: NotFoundError: {
  "type": "https://stellar.org/horizon-errors/not_found",
  "title": "Resource Missing",
  "status": 404,
  "detail": "The resource at the url requested was not found.  This usually occurs for one of two reasons:  The url requested is not valid, or no data in our database could be found with the parameters provided."
}

And logs point to this line:

https://github.com/stellar/django-polaris/blob/a2bdb49c3a48bd3a6f9a74e7b7b342769c0db164/polaris/management/commands/process_pending_deposits.py#L602

JakeUrban commented 2 years ago

Hi @nikita-gorodeckij,

Polaris doesn't use the submit response because Polaris supports using third-party custodians. So if I use Polaris for my anchor but I use Circle or Fireblocks for my custody, I won't have a submit response, I'll just have the transaction hash.

JakeUrban commented 2 years ago

But if this is what you're seeing in the application's behavior, you might be right. Let me follow up with the Horizon team to see if this is likely.

The fix would be to retry the request until the transaction is found. If the transaction isn't found have X retries or Y seconds, fail. What do you think?

JakeUrban commented 2 years ago

Wait @nikita-gorodeckij, in your example, ea393ff2-e8bf-4f0b-bcb1-2f919feb952b is not a valid transaction hash or ID. Trying to fetch a transaction with this ID would certainly fail.

nikita-gorodeckij commented 2 years ago

@JakeUrban It is not transaction hash. It is valid uuid. It should be output of this line

https://github.com/stellar/django-polaris/blob/73f4bbe7f874f67ad3f6d6476c64feb2f6dd3c83/polaris/management/commands/process_pending_deposits.py#L727

JakeUrban commented 2 years ago

Hi @nikita-gorodeckij, you're right about the transaction ID, my mistake. Have you been experiencing this issue still?