question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[2.6][T4] Transaction API returns empty response when canEnterTransactionPool is false and no error is pushed by the transaction's handler

See original GitHub issue

Expected Behavior When canEnterTransactionPool fails after a transaction is posted to the api, there should be an error message in the payload.

Current Behavior When a transaction is posted to the API, it goes through core-transaction-pool to validate it and check if it can enter the pool. However, when handler.canEnterTransactionPool(transaction, this.pool, this); (https://github.com/ArkEcosystem/core/blob/develop/packages/core-transaction-pool/src/processor.ts#L220) is false, and the custom transaction doesn’t push any error (just true or false), the validation response becomes {"data":{"accept":[],"broadcast":[],"excess":[],"invalid":[]}}. No error description is in the payload.

Possible Solution If no errors have been pushed but canEnterTransactionPool returns false, core-transaction-pool should push a generic error that the handler’s canEnterTransactionPool validation has failed.

Steps to Reproduce (for bugs)

  1. Create a custom transaction without pushError calls in canEnterTransactionPool and make it return false.
  2. Post a transaction to the transactions api endpoint.
  3. Observe empty payload.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
vasildcommented, Dec 5, 2019

Yes, the interface is not very robust - canEnterTransactionPool() may forget to push the error and return false.

I do not like chasing a sloppy canEnterTransactionPool() after it has been called. That would be slippery - for example the errors array may have some entries from beforehand and be non-empty after canEnterTransactionPool() has completed and still that function may have forgotten to add the error. And even if chased properly - we still have the issue with a nearly useless generic error message, without the actual reason for the rejection.

A more robust interface would be:

  • canEnterTransactionPool() does not call pushError(). If it needs the processor argument just for that, then drop that argument.
  • Instead of true/false it would return an array of errors with an empty array designating success / no errors.
  • Then the caller of canEnterTransactionPool() does pushError() for all elements of the returned array.

The point is that then there is no way for canEnterTransactionPool() to signal an error and still forget to give an explanation about it.

0reactions
vasildcommented, Dec 18, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found