moonbeam-foundation/moonbeam

Remove panics from service

Closed this issue · 1 comments

There is some code in the Moonbeam node's service (that I wrote three years ago 😬) that could potentially panic.

create_inherent_data_providers: move |block: H256, ()| {
let current_para_block = client_set_aside_for_cidp
.number(block)
.expect("Header lookup should succeed")
.expect("Header passed in as parent should be present in backend.");

I don't know that it has ever paniced in production, and certainly it doesn't happen often, but of course it is best to handle errors more gracefully when possible.

I recently used similar code in Tuxedo, the UTXO framework for Substrate. And @muraca encouraged me to try to remove the panics. In the end we found a technique that can be used in your node as well. Off-Narrative-Labs/Tuxedo#126

Thank you @JoshOrndorff ;) , someone in the team will look at it.