Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better errors for --genesis-block and --bft-leaders #517

Merged
merged 6 commits into from
Jul 9, 2019

Conversation

KtorZ
Copy link
Member

@KtorZ KtorZ commented Jul 9, 2019

Issue Number

#357

Overview

  • I have improved error handling when passing non-existing files via --genesis-block or --bft-leaders options
  • I have improved error handling when parsing the serialized block given via --genesis-block
  • I have handled gracefully network errors when initializing Jörmungandr

Comments

$ cardano-wallet launch --genesis-block ./patate --bft-leaders secret.yaml 
I couldn't find any file at the given location: ./patate

$ cardano-wallet launch --genesis-block secret.yaml --bft-leaders secret.yaml 
As far as I can tell, this isn't a valid block file: secret.yaml

$ cardano-wallet launch --genesis-block block0.bin --bft-leaders ./patate
I couldn't find any file at the given location: ./patate

$ cardano-wallet-jormungandr serve --genesis-hash 1234
[iohk.cardano-wallet.serve:Info:ThreadId 4] [2019-07-09 14:57:17.08 UTC] Wallet backend server starting...
[iohk.cardano-wallet.serve:Info:ThreadId 4] [2019-07-09 14:57:17.08 UTC] Running as v2019.6.24
[iohk.cardano-wallet.serve:Info:ThreadId 4] [2019-07-09 14:57:17.08 UTC] Node is Jörmungandr on testnet
[iohk.cardano-wallet.serve.database:Notice:ThreadId 4] [2019-07-09 14:57:17.08 UTC] 13 migrations were applied to the database.
[iohk.cardano-wallet.serve:Info:ThreadId 4] [2019-07-09 14:57:17.10 UTC] Waiting for Jörmungandr to be ready on tcp/8080
[iohk.cardano-wallet.serve:Alert:ThreadId 4] [2019-07-09 14:57:17.10 UTC] Failed to retrieve the genesis block. The block doesn't exist!
Hint: double-check the genesis hash you've just gave me via '--genesis-hash' (i.e. 1234).

$ cardano-wallet-jormungandr serve --genesis-hash 1234
[iohk.cardano-wallet.serve:Info:ThreadId 4] [2019-07-09 14:58:05.58 UTC] Wallet backend server starting...
[iohk.cardano-wallet.serve:Info:ThreadId 4] [2019-07-09 14:58:05.58 UTC] Running as v2019.6.24
[iohk.cardano-wallet.serve:Info:ThreadId 4] [2019-07-09 14:58:05.58 UTC] Node is Jörmungandr on testnet
[iohk.cardano-wallet.serve.database:Notice:ThreadId 4] [2019-07-09 14:58:05.59 UTC] 13 migrations were applied to the database.
[iohk.cardano-wallet.serve:Info:ThreadId 4] [2019-07-09 14:58:05.60 UTC] Waiting for Jörmungandr to be ready on tcp/8080
[iohk.cardano-wallet.serve:Alert:ThreadId 4] [2019-07-09 14:58:06.60 UTC] Waited too long for Jörmungandr to become available. Giving up!
Hint (1): If you're launching the wallet server on your own, double-check that Jörmungandr is up-and-running and listening on the same port given to '--node-port' (i.e. tcp/8080).
Hint (2): Should you be starting from scratch, make sure to have a good-enough network connection to synchronize the first blocks in a timely manner.

$ cardano-wallet-http-bridge serve 
[iohk.cardano-wallet.serve:Info:ThreadId 4] [2019-07-09 14:58:25.13 UTC] Wallet backend server starting...
[iohk.cardano-wallet.serve:Info:ThreadId 4] [2019-07-09 14:58:25.13 UTC] Running as v2019.6.24
[iohk.cardano-wallet.serve:Info:ThreadId 4] [2019-07-09 14:58:25.13 UTC] Node is Http-Bridge on testnet
[iohk.cardano-wallet.serve.database:Notice:ThreadId 4] [2019-07-09 14:58:25.14 UTC] 13 migrations were applied to the database.
[iohk.cardano-wallet.serve:Info:ThreadId 4] [2019-07-09 14:58:25.15 UTC] Waiting for http-bridge to be ready on tcp/8080
[iohk.cardano-wallet.serve:Alert:ThreadId 4] [2019-07-09 14:58:26.15 UTC] Waited too long for http-bridge to become available. Giving up!
Hint (1): If you're launching the wallet server on your own, double-check that http-bridge is up-and-running and listening on the same port given to '--node-port' (i.e. tcp/8080).
Hint (2): Should you be starting from scratch, make sure to have a good-enough network connection to synchronize the first blocks in a timely manner.

@KtorZ KtorZ requested a review from piotr-iohk July 9, 2019 08:49
@KtorZ KtorZ self-assigned this Jul 9, 2019
getBlockId :: Get (Hash "BlockHeader")
getBlockId = do
getBlockId = lookAhead getBlock *> (label "getBlockId" $ do
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't thought of it initially but, we don't have to actually unserialize and re-serialize the block. We can simply "lookAhead". If this fails, we know that we haven't a block and the rest is irrelevant. Hence I removed the note.

Copy link
Contributor

@piotr-iohk piotr-iohk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good (although CI complains about code style)

It would be good to polish also error for serve --genesis-hash, (which might be done in another PR though) :

$ cardano-wallet-jormungandr serve --genesis-hash a074427d61ec13c4401cc3c7ead26c49d53baa5e8c1391189dd1cef13bd38031
[iohk.cardano-wallet.serve:Info:ThreadId 4] [2019-07-09 09:31:52.84 UTC] Wallet backend server starting...
[iohk.cardano-wallet.serve:Info:ThreadId 4] [2019-07-09 09:31:52.84 UTC] Running as v2019.6.24
[iohk.cardano-wallet.serve:Info:ThreadId 4] [2019-07-09 09:31:52.84 UTC] Node is Jörmungandr on testnet
cardano-wallet-jormungandr: user error (unexpected error: ErrGetBlockNotFound (Hash {getHash = "\160tB}a\236\DC3\196@\FS\195\199\234\210lI\213;\170^\140\DC3\145\CAN\157\209\206\241;\211\128\&1"}))

KtorZ added 5 commits July 9, 2019 17:04
…y manner

This could happen when launching the wallet 'from scratch', where the bridge would have to sync the first part of the chain. This can be
rather long depending on the available network connection.
This is because 20 seconds seems to be too small when launching the chain from scratch in the case of http-bridge.
@KtorZ KtorZ force-pushed the KtorZ/jormungandr-better-error branch from 52a843c to 5e68106 Compare July 9, 2019 15:04
@KtorZ KtorZ merged commit 56060c7 into master Jul 9, 2019
@KtorZ KtorZ deleted the KtorZ/jormungandr-better-error branch July 9, 2019 19:26
@KtorZ KtorZ added this to the Bugs & Debts - Sprint 27-28 milestone Jul 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants