Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Offchain execution extensions #4145

Merged
merged 17 commits into from
Nov 22, 2019
Merged

Offchain execution extensions #4145

merged 17 commits into from
Nov 22, 2019

Conversation

tomusdrw
Copy link
Contributor

This PR is an attempt to clean up how we deal with externalities extensions for offchain calls (i.e. the additional APIs available for some contexts), namely: OffchainWorker extensions, TransactionPool and Keystore.

Instead of passing things separately this PR introduces a ExecutionExtensions idea, where all ExternalitiesExtensions can be registered (avoiding cycles though). Later on in the call stack we pass Extensions instead of arbitrary Option<KeystorePtr> or Option<OffchainExt> stuff.
This cleans up some APIs and also avoids uneccesary direct dependencies.

CC @andresilva - finally :)

@tomusdrw tomusdrw added A0-please_review Pull request needs code review. M4-core labels Nov 19, 2019
@@ -497,8 +487,12 @@ where
Exec: CodeExecutor,
{
let proving_backend = proving_backend::ProvingBackend::new(trie_backend);
let mut extensions = Extensions::new();
if let Some(keystore) = keystore {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need keystore here? If that can be invoked from the network context (i.e. light client requesting to prove some execution) we can end up signing something with a local key and giving it back as a response.

@@ -542,8 +536,12 @@ where
H: Hasher<Out=H256>,
Exec: CodeExecutor,
{
let mut extensions = Extensions::new();
if let Some(keystore) = keystore {
extensions.register(keystore);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@tomusdrw tomusdrw marked this pull request as ready for review November 19, 2019 20:21
@tomusdrw tomusdrw requested a review from pepyakin as a code owner November 19, 2019 20:21
@@ -347,18 +349,22 @@ fn with_offchain<R>(f: impl FnOnce(&mut dyn offchain::Externalities) -> R, msg:
}

impl OffchainApi for () {
fn submit_transaction(data: Vec<u8>) -> Result<(), ()> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is not used anymore. It was probably readded in your big refactoring pr.

#4130

@gavofyork gavofyork merged commit 06f6daa into master Nov 22, 2019
@gavofyork gavofyork deleted the td-extensions branch November 22, 2019 16:10
Copy link
Contributor

@andresilva andresilva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. so for my use case I should just provide a client to the grandpa code that has already pre-registered all the necessary extensions, so as to avoid introducing those types into the grandpa crate (e.g. transaction pool).
your comments regarding unnecessary registration of keystore extensions are also pertinent.

recorder: &Option<ProofRecorder<Block>>,
enable_keystore: bool,
extensions: Option<Extensions>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indented with spaces.


pub use error::*;
// TODO: avoid re-exports
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this have been handled?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants