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 authored and GitHub committed 2020-10-01 09:12:05 +00:00
1 parent 8656a34289
commit dbf4558633
7 files changed
+180 -39

No files matched your search

@@ -168,16 +168,20 @@ impl<Block: traits::Block> ExecutionExtensions<Block> {
if capabilities.has(offchain::Capability::TransactionPool) {
if let Some(pool) = self.transaction_pool.read().as_ref().and_then(|x| x.upgrade()) {
extensions.register(TransactionPoolExt(Box::new(TransactionPoolAdapter {
at: *at,
pool,
}) as _));
extensions.register(
TransactionPoolExt(
Box::new(TransactionPoolAdapter {
at: *at,
pool,
}) as _
),
);
}
}
if let ExecutionContext::OffchainCall(Some(ext)) = context {
extensions.register(
OffchainExt::new(offchain::LimitedExternalities::new(capabilities, ext.0))
OffchainExt::new(offchain::LimitedExternalities::new(capabilities, ext.0)),
);
}