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

Refactor sp-sandbox; make sure both sandbox executors are always tested #10173

Merged

Conversation

koute
Copy link
Contributor

@koute koute commented Nov 4, 2021

This PR refactors sp-sandbox so that (when possible) both execution backends are always compiled, and makes sure that both of them are actually tested in the sc-executor integration tests. (Currently only the embedded_executor codepath is tested; after this PR both embedded_executor and host_executor are.)

Open questions/possible further work

  • I've kept both executors in a single crate; do we want to split them up into two separate crates?
  • I've reexported the executor which was previously selected at compile time as sp_sandbox::default to make sure I don't inadvertently change which executor is used; do we want to get rid of that and explicitly refer to the concrete executor everywhere sp_sandbox::default is currently used? (Or perhaps move the logic of which one should be used to the places it's actually being used?)

@koute koute added A0-please_review Pull request needs code review. I5-tests Tests need fixing, improving or augmenting. I7-refactor Code needs refactoring. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Nov 4, 2021
@koute koute mentioned this pull request Nov 4, 2021
}

impl<T> EnvironmentDefinitionBuilder<T> {
pub trait SandboxEnvironmentBuilder<State, Memory>: Sized {
Copy link
Contributor

Choose a reason for hiding this comment

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

Loving not using <T>. These generic names are great.

Copy link
Contributor

Choose a reason for hiding this comment

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

generic names

Isn't that a contradiction in terms?

I mean a 'generic' name is by definition meaningless and that is why I prefer symbols instead of 'names' for generic type parameters. For me, the semantic of a generic type parameter is not induced by it's name but by the respective type bounds.

Copy link
Member

@athei athei left a comment

Choose a reason for hiding this comment

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

Loving it. This include_file! stuff always bothered me.

've reexported the executor which was previously selected at compile time as sp_sandbox::default to make sure I don't inadvertently change which executor is used; do we want to get rid of that and explicitly refer to the concrete executor everywhere sp_sandbox::default is currently used? (Or perhaps move the logic of which one should be used to the places it's actually being used?)

For contracts I want be able to switch to wasmer by only recompiling without source file changes. This change would complicate that. Ideally, I want be able to switch between wasmi/wasmer at runtime. This does not work because the host API does not allow selecting the execution engine.

I think for now it should stay the way it is. Eventually we want to overhaul the API exposed by the client. This change should also include selecting the execution engine (wasmtime, wasmer, wasmer singlepass).

client/executor/src/integration_tests/sandbox.rs Outdated Show resolved Hide resolved
client/executor/runtime-test/src/lib.rs Outdated Show resolved Hide resolved
@koute
Copy link
Contributor Author

koute commented Nov 8, 2021

@bkchr Okay, I've fixed the duplication; looks good now? (:

@bkchr
Copy link
Member

bkchr commented Nov 8, 2021

@bkchr Okay, I've fixed the duplication; looks good now? (:

Ty ❤️

@koute
Copy link
Contributor Author

koute commented Nov 8, 2021

bot merge

@paritytech-processbot paritytech-processbot bot merged commit 3b2ce54 into paritytech:master Nov 8, 2021
grishasobol pushed a commit to gear-tech/substrate that referenced this pull request Mar 28, 2022
…sted (paritytech#10173)

* sp-sandbox: convert executors into normal `mod`s instead of using `include!`

* sp-sandbox: run `cargo fmt` on `host_executor.rs`

* sp-sandbox: abstract away the executors behind traits

* sp_sandbox: always compile both executors when possible

* sc-executor: make sure all sandbox tests run on both sandbox executors

* sc-executor: fix brainfart: actually call into the sandbox through the trait

* sc-runtime-test: fix cargo fmt

* sc-runtime-test: deduplicate executor-specific sandbox test entrypoints

* sc-executor: test each sandbox executor in a separate test

* cargo fmt (Github's conflict resolving thingy broke indentation)
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
…sted (paritytech#10173)

* sp-sandbox: convert executors into normal `mod`s instead of using `include!`

* sp-sandbox: run `cargo fmt` on `host_executor.rs`

* sp-sandbox: abstract away the executors behind traits

* sp_sandbox: always compile both executors when possible

* sc-executor: make sure all sandbox tests run on both sandbox executors

* sc-executor: fix brainfart: actually call into the sandbox through the trait

* sc-runtime-test: fix cargo fmt

* sc-runtime-test: deduplicate executor-specific sandbox test entrypoints

* sc-executor: test each sandbox executor in a separate test

* cargo fmt (Github's conflict resolving thingy broke indentation)
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
…sted (paritytech#10173)

* sp-sandbox: convert executors into normal `mod`s instead of using `include!`

* sp-sandbox: run `cargo fmt` on `host_executor.rs`

* sp-sandbox: abstract away the executors behind traits

* sp_sandbox: always compile both executors when possible

* sc-executor: make sure all sandbox tests run on both sandbox executors

* sc-executor: fix brainfart: actually call into the sandbox through the trait

* sc-runtime-test: fix cargo fmt

* sc-runtime-test: deduplicate executor-specific sandbox test entrypoints

* sc-executor: test each sandbox executor in a separate test

* cargo fmt (Github's conflict resolving thingy broke indentation)
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. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit I5-tests Tests need fixing, improving or augmenting. I7-refactor Code needs refactoring.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants