-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Avoid Ext calls from outside of runtime #647
Conversation
substrate/state-machine/src/ext.rs
Outdated
| fn storage(&self, key: &[u8]) -> Option<Vec<u8>> { | ||
| self.overlay.storage(key).map(|x| x.map(|x| x.to_vec())).unwrap_or_else(|| | ||
| self.backend.storage(key).expect("Externalities not allowed to fail within runtime")) | ||
| use {try_read_overlay_value}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are the {s needed here?
| self.backend.storage(key).expect("Externalities not allowed to fail within runtime")) | ||
| use {try_read_overlay_value}; | ||
| try_read_overlay_value(self.overlay, self.backend, key) | ||
| .expect("Externalities not allowed to fail within runtime") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can probably just do .map_err(|e| error!(target: "state-machine", "Externalities call failed! {:?}", e)).ok().and_then(|inner| inner), which then will at least avoid the panic. better would be to shuffle the Err through into the wasm interpreter so the execution can be early-exited. not sure if that's possible yet, though.
|
I'm not feeling good implementing the option#1 - it is just the ignoring of an error. Like if it was implemented in that way, we would never see today's panic => there would never be a #648 . Everyone ignore logs until something bad happens && in this case nothing bad will happen (except for that guy who has tried to run a light client). Looks like option#2 is available for So I would prefer to close this PR if it is a |
* Remove Sudo * Bump versions * Fixes * Remove other mentions of sudo * Remove sudo from Cargo
* Add Staking Miner and Introspector to usage list * Update README.md Co-authored-by: Niklas Adolfsson <[email protected]>
Alternative fix of this panic:
It should be fixed as @arkpar suggested - by checking if the state is not pruned (he's preparing PR). However, calling 'unsafe'
Extmethods (storage&&exists_storage) from outside of runtime should be avoided (sinceExtexpect-s backend calls to succeed) => this PR removes temporaryExtcreation for those calls.