Skip to content

Commit

Permalink
pallet-revive: Add env var to allow skipping of validation for testing (
Browse files Browse the repository at this point in the history
paritytech#7562)

When trying to reproduce bugs we sometimes need to deploy code that
wouldn't pass validation. This PR adds a new environment variable
`REVIVE_SKIP_VALIDATION` that when set will skip all validation except
the contract blob size limit.

Please note that this only applies to when the pallet is compiled for
`std` and hence will never be part of on-chain.

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
athei and github-actions[bot] authored Feb 14, 2025
1 parent 7aac886 commit b44dc3a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions prdoc/pr_7562.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: 'pallet-revive: Add env var to allow skipping of validation for testing'
doc:
- audience: Runtime Dev
description: |-
When trying to reproduce bugs we sometimes need to deploy code that wouldn't pass validation. This PR adds a new environment variable `REVIVE_SKIP_VALIDATION` that when set will skip all validation except the contract blob size limit.

Please note that this only applies to when the pallet is compiled for `std` and hence will never be part of on-chain.
crates:
- name: pallet-revive
bump: patch
6 changes: 6 additions & 0 deletions substrate/frame/revive/src/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ pub mod code {

let blob: CodeVec = blob.try_into().map_err(|_| <Error<T>>::BlobTooLarge)?;

#[cfg(feature = "std")]
if std::env::var_os("REVIVE_SKIP_VALIDATION").is_some() {
log::warn!(target: LOG_TARGET, "Skipping validation because env var REVIVE_SKIP_VALIDATION is set");
return Ok(blob)
}

let program = polkavm::ProgramBlob::parse(blob.as_slice().into()).map_err(|err| {
log::debug!(target: LOG_TARGET, "failed to parse polkavm blob: {err:?}");
Error::<T>::CodeRejected
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/revive/src/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ impl<T: Config> WasmBlob<T> {
config.set_cache_enabled(false);
#[cfg(feature = "std")]
if std::env::var_os("REVIVE_USE_COMPILER").is_some() {
log::warn!(target: LOG_TARGET, "Using PolkaVM compiler backend because env var REVIVE_USE_COMPILER is set");
config.set_backend(Some(polkavm::BackendKind::Compiler));
}
let engine = polkavm::Engine::new(&config).expect(
Expand Down

0 comments on commit b44dc3a

Please sign in to comment.