[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 issueExpected 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)
- Create a custom transaction without
pushError
calls incanEnterTransactionPool
and make it returnfalse
. - Post a transaction to the transactions api endpoint.
- Observe empty payload.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
Yes, the interface is not very robust -
canEnterTransactionPool()
may forget to push the error and returnfalse
.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 aftercanEnterTransactionPool()
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 callpushError()
. If it needs theprocessor
argument just for that, then drop that argument.true
/false
it would return an array of errors with an empty array designating success / no errors.canEnterTransactionPool()
doespushError()
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.Closing now that https://github.com/ArkEcosystem/core/pull/3342 is merged.