Remove runtime registered extensions after execution (#7236)

* Remove runtime registered extensions after execution

This prevents a bug when an extension was registered in native, but the
native execution aborted without removing the extension again. Now, when
executing the wasm code the extension is still registered and it fails
of being registered. So, the wasm execution fails as well. This can
happen for example for the `VerificationExt`.

* Make it better
This commit is contained in:
Bastian Köcher
2020-10-01 11:12:05 +02:00
committed by GitHub
parent 8656a34289
commit dbf4558633
7 changed files with 180 additions and 39 deletions
@@ -233,10 +233,11 @@ impl<H, N> sp_externalities::ExtensionStore for TestExternalities<H, N> where
}
fn deregister_extension_by_type_id(&mut self, type_id: TypeId) -> Result<(), sp_externalities::Error> {
self.extensions
.deregister(type_id)
.expect("There should be an extension we try to remove in TestExternalities");
Ok(())
if self.extensions.deregister(type_id) {
Ok(())
} else {
Err(sp_externalities::Error::ExtensionIsNotRegistered(type_id))
}
}
}