* Run `sc-executor-wasmtime` unit tests for all instantiation strategies
* Adjust maximum memory pages hard limit for the pooling instantiation strategy
* Switch to pooling copy-on-write instantiation strategy for WASM
* Fix benchmark compilation
* Fix `cargo fmt`
* Fix compilation of another benchmark I've missed
* Cleanups according to review comments
* Move `max_memory_size` to `Semantics`
* Set `memory_guaranteed_dense_image_size` to `max_memory_size`
* Rename `wasm_instantiation_strategy` to `wasmtime_instantiation_strategy`
* Update the doc-comments regarding the instantiation strategy
* Extend the integration tests to test every instantiation strategy
* Don't drop the temporary directory until the runtime is dropped in benchmarks
* Don't drop the temporary directory until the runtime is dropped in tests
* Add extra WASM heap pages when precompiling the runtime blob
* Fix compilation
* Fix rustdoc
* Fix rustdoc for real this time
* Fix benches compilation
* Improve the builder in `sc-executor-wasmtime`'s tests
* Refactor WASM module instantiation; enable WASM instance pooling
* Disable the `uffd` feature on `wasmtime`
* Restore the original behavior regarding the initial WASM memory size
* Adjust error message
* Remove unnecessary import in the benchmarks
* Preinstantiate the WASM runtime for a slight speedup
* Delete the asserts in `convert_memory_import_into_export`
* `return` -> `break`
* Revert WASM instance pooling for now
* Have `convert_memory_import_into_export` return an error instead of panic
* Update the warning when an import is missing
* Rustfmt and clippy fix
* Fix executor benchmarks' compilation without `wasmtime` being enabled
* rustfmt again
* Align to review comments
* Extend tests so that both imported and exported memories are tested
* Increase the number of heap pages for exported memories too
* Fix `decommit_works` test
* Add a new host function for reporting fatal errors
* Fix one of the wasmtime executor tests
* Have `#[runtime_interface(wasm_only)]` actually mean WASM-only, and not no_std-only
* Print out errors through `Display` instead of `Debug`
* Switch one more trait to require `Error` for its error instead of only `Debug`
* Align to review comments
* Statically register host WASM functions
* Fix `substrate-test-client` compilation
* Move `ExtendedHostFunctions` to `sp-wasm-interface`
* Fix `sp-runtime-interface` tests' compilation
* Fix `sc-executor-wasmtime` tests' compilation
* Use `runtime_interface` macro in `test-runner`
* Fix `sc-executor` tests' compilation
* Reformatting/`rustfmt`
* Add an extra comment regarding the `H` generic arg in `create_runtime`
* Even more `rustfmt`
* Depend on `wasmtime` without default features in `sp-wasm-interface`
* Bump version of `sp-wasm-interface` to 4.0.1
* Bump `sp-wasm-interface` in `Cargo.lock` too
* Bump all of the `sp-wasm-interface` requirements to 4.0.1
Maybe this will appease cargo-unleash?
* Revert "Bump all of the `sp-wasm-interface` requirements to 4.0.1"
This reverts commit 0f7ccf8e0f371542861121b145ab87af6541ac30.
* Make `cargo-unleash` happy (maybe)
* Use `cargo-unleash` to bump the crates' versions
* Align to review comments
* Fix WASM executor without instance reuse; cleanups and refactoring
* Align to review comments
* Move the functions for reading/writing memory to `util.rs`
* Only `#[ignore]` the test in debug builds
* More review comments and minor extra comments
* sc-executor-wasmtime: upgrade wasmtime to 0.30.0
Changes related to memory64 proposal implementation,
for additional details see bytecodealliance/wasmtime#3153
* sc-executor-wasmtime: introduce parallel_compilation flag
* typos
* add feature wasmtime-jitdump
* remove unwrap
* always enable wasmtime/jitdump feature
* env WASMTIME_PROFILING_STRATEGY: retun an error for unknown value
* Add doc for env var WASMTIME_PROFILING_STRATEGY
* Update client/executor/wasmtime/Cargo.toml
Co-authored-by: Sergei Shulepov <s.pepyakin@gmail.com>
* warning instead of error
* Update client/executor/wasmtime/src/runtime.rs
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
* update doc: unknown value cause warning instead of error
* log warning only once
* static right next to the usage
Co-authored-by: Sergei Shulepov <s.pepyakin@gmail.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
* Start
* Move to ctx
* Make it compile for now
* More work
* Get rid off state-holder
* Use less Refcells
* 🤦
* Don't use RefCell
* Use names for parameters
* Fixes after merge
* Fixes after merge
* Review feedback
* FMT
* Improve sandbox internal api
This improves the internal sandbox api for the executor implementations.
The main point is to hide the tls in the internal api and not having it
exposed to the outside.
This is especially needed for wasmtime 0.29.0
* Fmt
* Make it nicer
* Add comments and refactor Sandbox module
* Adds some comments
* Add wasmtime instance to the sandbox and delegate calls
* Adds module imports stub
* WIP state holder via *mut
* My take at the problem
* Brings back invoke and instantiate implementation details
* Removes redundant bound
* Code cleanup
* Fixes invoke closure
* Refactors FunctionExecutor to eliminate lifetime
* Wraps `FunctionExecutor::sandbox_store` in `RefCell`
* Renames `FunctionExecutor::heap` to `allocator`
* Wraps `FunctionExecutor::allocator` in `RefCell`
* Refactors FunctionExecutor to `Rc<Inner>` pattern
* Implements scoped TLS for FunctionExecutor
* Fixes wasmi instancing
* Fixes sandbox asserts
* Makes sandbox compile after wasmtime API change
* Uses Vurich/wasmtime for the Lightbeam backend
* Uses wasmtime instead of wasmi for sandbox API results
* Refactors sandbox to use one of the execution backends at a time
* Fixes wasmtime module instantiation
* TEMP vurich branch stuff
* Adds wasmer impl stub
* Adds get global
* Fixes warnings
* Adds wasmer invoke impl
* Implements host function interface for wasmer
* Fixes wasmer instantiation result
* Adds workaround to remove debug_assert
* Fixes import object generation for wasmer
* Attempt to propagate wasmer::Store through sandbox::Store
* Wraps `sandbox::Store::memories` in `RefCell`
* Moves `sandbox::instantiate` to `sandbox::Store`
* Eliminate `RefCell<memories>`
* Implements `HostState::memory_get/set`, removes accidental `borrow_mut`
* Fixes sandbox memory handling for wasmi
* Fix memory allocation
* Resets Cargo.lock to match master
* Fixes compilation
* Refactors sandbox to use TLS for dispatch_thunk propagation to wasmer
* Pass dispatch thunk to the sandbox as a TLS
* Initialize dispatch thunk holder in `SandboxInstance`
* Comment out Wasmtime/Lightbeam sandbox backend
* Revert wasmtime back to mainstream
* Adds SandboxExecutionMethod enum for cli param
* Cleanup sandbox code
* Allow wasmi to access wasmer memory regions
* More cleanup
* Remove debug logging, replace asserts with runtime errors
* Revert "Adds SandboxExecutionMethod enum for cli param"
This reverts commit dcb2b1d3b54145ab51ad2e3fef0d980ba215b596.
* Fixes warnings
* Fixes indentation and line width
* Fix return types condition
* Puts everything related under the `wasmer-sandbox` feature flag
* Fixes warnings
* Address grumbles
* Split instantiate per backend
* More splits
* Refacmemory allocation
* Nitpicks
* Attempt to wrap wasmer memory in protoco enforcing type
* Revert renaming
* WIP wasm buffer proxy API
* Reimplement util::wasmer::MemoryRef to use buffers instead of memory slices
* Adds WasmiMemoryWrapper and MemoryTransfer trait
* Refactor naming
* Perform all memory transfers using MemoryTransfer
* Adds allocating `read`
* Adds comments
* Removes unused imports
* Removes now unused function
* Pulls Cargo.lock from origin/master
* Fix rustdoc
* Removes unused `TransferError`
* Update Cargo.lock
* Removes unused import
* cargo fmt
* Fix feature dependency graph
* Feature should flow from the top level crate
* We should not assume a specific workspace structure
* sc-executor-wasmi does not use the feature
* sc-executor-wasmtime should not know about the feature
* Fix doc typo
* Enable wasmer-sandbox by default (for now)
It will be removed before merge. It is so that the benchbot
uses the wasmer sandbox.
* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_contracts --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/contracts/src/weights.rs --template=./.maintain/frame-weight-template.hbs
* Revert "cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_contracts --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/contracts/src/weights.rs --template=./.maintain/frame-weight-template.hbs"
This reverts commit d713590ba45387c4204b2ad97c8bd6f6ebabda4e.
* cargo fmt
* Add ci-check to prevent wasmer sandbox build breaking
* Run tests with wasmer-sandbox enabled
* Revert "Run tests with wasmer-sandbox enabled"
This reverts commit cff63156a162f9ffdab23e7cb94a30f44e320f8a.
Co-authored-by: Sergei Shulepov <s.pepyakin@gmail.com>
Co-authored-by: Andrew Jones <ascjones@gmail.com>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
* Run cargo fmt on the whole code base
* Second run
* Add CI check
* Fix compilation
* More unnecessary braces
* Handle weights
* Use --all
* Use correct attributes...
* Fix UI tests
* AHHHHHHHHH
* 🤦
* Docs
* Fix compilation
* 🤷
* Please stop
* 🤦 x 2
* More
* make rustfmt.toml consistent with polkadot
Co-authored-by: André Silva <andrerfosilva@gmail.com>
* NaN canonicalization
* Introduce a simple stack depth metering
* Be explicit about the wasm features we enable
* Pull the latest latast fix for the pwasm-utils crate
* Disable `wasm_threads` as well.
* Factor out deterministic stack params
* Add more docs
* Remove redundant dep
* Refine comments
* Typo
Co-authored-by: Andronik Ordian <write@reusable.software>
Co-authored-by: Andronik Ordian <write@reusable.software>
* Move alloc primitive (not used in /pallets)
* Move to alternative location as not shared
* moved crates to different dir
* ren sp_chain_spec to sc_chain_spec_primatives
* merged sc-chain-spec and moved allocation up one.
* no no_std
* nudge
* Bump CI
* Decommit instance memory after a runtime call on Linux
* Update documentation for the test
* Remove unfinished comment
* Use saturating_sub.
Also update the doc comment.
* Precise RSS tracking in the test
Instead of tracking RSS for the whole process we just look at the particular mapping that is associated with the linear memory of the runtime instance
* Remove unused import
* Fix unused imports
* Fix the unused imports error for good
* Rollback an accidental change to benches
* Fix the test
* Remove now unneeded code
* Update wasmtime to 0.27
A couple of notes:
- Now we are fair about unsafeness of runtime creation via an compiled artifact.
This change was prompted by the change in wasmtime which made
`deserialize` rightfully unsafe. Now `CodeSupplyMode` was hidden and
the `create_runtime` now takes the blob again and there is now a new
fn for creating a runtime with a compiled artifact.
- This is a big change for wasmtime. They switched to the modern backend
for code generation. While this can bring performance improvements, it
can also introduce some problems. In fact, 0.27 fixed a serious issue
that could lead to sandbox escape. Hence we need a proper burn in.
This would require a change to PVF validation host as well.
* Filter regalloc logging
* Establish the runtime_blob module
Seed it with the existing contents of the `util` module.
* Port wasmtime mutable globals instrumentation into runtime blob APIs
* Opt-out from fast instance reuse
* Minor clean up
* Spaces
* Docs clean up
* Apply suggestions from code review
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
* Factor out the expects
* Fix the suggestion
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
* refactor globals snapshot
* ignore test
* update pwasm-utils ref
* line width
* add doc comment for internal struct
* add explanation for iteration
* Demote rustdoc to a comment
* use 0.14
Co-authored-by: Sergei Shulepov <sergei@parity.io>