cardano-foundation / cardano-rosetta

An implementation of Rosetta for Cardano
https://www.rosetta-api.org
Apache License 2.0
98 stars 50 forks source link

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

Open catch-21 opened 3 years ago

catch-21 commented 3 years ago

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 commented 3 years ago

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