This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
executor docs refresh #9446
Closed
gilescope
wants to merge
2
commits into
paritytech:master
from
gilescope:giles-executor-docs-refresh
Closed
executor docs refresh #9446
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,43 @@ | ||
A crate that provides means of executing/dispatching calls into the runtime. | ||
sp_executor provides means of executing/dispatching calls into the runtime. | ||
|
||
The executor is responsible for executing the runtime's state transition function (which could be native or an on-chain wasm blob). | ||
For wasm, while executing the state transition function the executor facilitates the [thunking](https://en.wikipedia.org/wiki/Thunk) | ||
of calls between wasm pallets and native pallets. | ||
|
||
|
||
There are a few responsibilities of this crate at the moment: | ||
|
||
- It provides an implementation of a common entrypoint for calling into the runtime, both | ||
wasm and compiled. | ||
- It defines the environment for the wasm execution, namely the host functions that are to be | ||
provided into the wasm runtime module. | ||
- It also provides the required infrastructure for executing the current wasm runtime (specified | ||
by the current value of `:code` in the provided externalities), i.e. interfacing with | ||
wasm engine used, instance cache. | ||
- It provides a common entrypoint for calling into the runtime whether the | ||
runtime is wasm, native or a mix of wasm and native pallets. | ||
|
||
- It defines the guest environment for the wasm execution ( `EnvironmentDefinition` ), namely the host functions that are to be | ||
exposed to the wasm runtime module. | ||
|
||
- It also provides the required infrastructure for executing the current wasm runtime (specified | ||
by the current value of `:code` in the provided externalities), i.e. interfacing with | ||
wasm engine used, instance cache. | ||
|
||
## Execution Strategies | ||
Several different implementations are available for executing runtimes: | ||
|
||
* [`sc_executor_wasmtime`] - Wasmtime compiles wasm to native machine code before executing the code so is faster, | ||
but only certain platforms are supported. (This is enabled by compiling with the `wasmtime` feature) | ||
|
||
* [`sc_executor_wasmi`] - Wasmi is a wasm interpreter and thus slower but it is cross-platform. | ||
It supports sandboxing execution of untrusted code. | ||
|
||
* [`native_executor_instance`] - Fastest, but not on-chain so harder to automatically upgrade. | ||
|
||
A combination of the above strategies can be used - this is controlled by the `ExecutionStrategy` enum. | ||
|
||
## Other | ||
|
||
* [`sc_executor_common`] details sandboxing and how to do wasm instrumentation. | ||
|
||
## References | ||
|
||
See [`sp_runtime_interface`] for an example of how to export a host function to the runtime. | ||
|
||
See also the substrate docs on [executor](https://substrate.dev/docs/en/knowledgebase/advanced/executor) | ||
|
||
License: GPL-3.0-or-later WITH Classpath-exception-2.0 | ||
License: GPL-3.0-or-later WITH Classpath-exception-2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
A set of common definitions that are needed for defining execution engines. | ||
|
||
License: GPL-3.0-or-later WITH Classpath-exception-2.0 | ||
Notably: | ||
|
||
* [`runtime_blob`] module allows for inspection and instrumentation of wasm code. | ||
|
||
* [`sandbox::SandboxInstance`] struct allows safe execution of untrusted wasm. | ||
|
||
* [`wasm_runtime::WasmInstance`] trait for defining the interface of a deserialised wasm module. | ||
|
||
License: GPL-3.0-or-later WITH Classpath-exception-2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you please move the docs back here.
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.
Ok, I can see I'm too early somehow for this change. Will do.
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 also don't use this anywhere and I'm not sure that stuff like intra doc links would still work. I honestly would not loose such a good feature for having an external file that some editor can understand better.