Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A block producing node, and Amaru, is considered "mission critical" software, for the following reasons:
For that reason, the node should never just hard "crash"; even in error cases, the node should respond to these bad conditions in a more graceful way, perhaps eventually even including raising an alarm via any metrics / alerting systems built into the node.
Therefore, we install a panic hook; if a crash does arise in the wild, we'd love a bug report, so we can address it more appropriately. For that reason, we want to make the process to open the issue as welcoming as possible.
Here's what it looks like for an explicit panic:
Here's what it looks like for an implicit panic, like divide by zero:
Here's what it looks like for a contextual panic, like
.expect()
:I included a commit in the history with an explicit panic; if you want to test it yourself, you can checkout
e9bfdf5931ff6b093e830bf0252c6be29eaa7372
and runcargo run daemon --peer-address 127.0.0.1
.Note that I borrowed a lot of code from Aiken; For this PR, I just included the needed utility functions in the
panic.rs
file, but we might want to pull some of these into their own files / modules, as they are in Aiken.