cardano-rosetta icon indicating copy to clipboard operation
cardano-rosetta copied to clipboard

Improve /construction/submit response errors by making them less ambiguous

Open catch-21 opened this issue 4 years ago • 1 comments

Description

Two scenarios have been identified where, if an error occurs, then the response from /construction/submit returns a generic message when it would be more useful to see a specific error so the user can instantly identify the problem. Both examples result in a response with statusCode 500, statusMessage "Internal Server Error", data.code 5006 and data.message "Error when sending the transaction". This is ambiguous for the user and could be improved.

Scenario 1 - Delegating to an address that is not registered as a stake pool

In this scenario I manually modified the delegate-stake-example to attempt delegation using a stake pool address that is not registered. Cardano-node logs error DelegateeNotRegisteredDELEG, this is the only way I can tell what the problem is. We should return a more specific error via the Rosetta api.

How to reproduce

  1. Edit cardano-rosetta/example/delegate-stake-example.ts and modify STAKE_POOL_KEY_HASH slightly.
  2. Run $ yarn delegate-stake-example
  3. Transfer ADA so that example script may proceed

Actual Result: Script ends and logs message: 'Error when sending the transaction' from POST /construction/submit

Scenario 2 - Withdrawing less than balance of staking reward funds

In this scenario I attempted to withdraw less than the balance of the staking rewards. This was done manually using Rosetta endpoints for building payload and submitting. Cardano-node logs error WithdrawalsNotInRewardsDELEGS, this is the only indication of what the problem is. This error is probably also shown when attempting to withdraw more than the balance of rewards. We should return a more specific error via the Rosetta api.

Scenario 3 - Fee too low

This is simply where a transaction is submitted with a fee lower than required. It causes cardano-node to error FeeTooSmallUTxO. We should return a more specific error via the Rosetta api.


There are quite possibly other errors than are not handled by this Rosetta implementation. We should keep track of them all here.

catch-21 avatar Jan 18 '21 14:01 catch-21

Example scripts represent response details as details: [Object]. This was overlooked during my testing. Actual response does include parsed node error.

catch-21 avatar Feb 03 '21 11:02 catch-21