Skip to content
Snippets Groups Projects
Unverified Commit b44dc3a5 authored by Alexander Theißen's avatar Alexander Theißen Committed by GitHub
Browse files

pallet-revive: Add env var to allow skipping of validation for testing (#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: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
parent 7aac8861
Branches
No related merge requests found
Pipeline #515350 waiting for manual action with stages
in 41 minutes and 2 seconds
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
...@@ -119,6 +119,12 @@ pub mod code { ...@@ -119,6 +119,12 @@ pub mod code {
let blob: CodeVec = blob.try_into().map_err(|_| <Error<T>>::BlobTooLarge)?; 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| { let program = polkavm::ProgramBlob::parse(blob.as_slice().into()).map_err(|err| {
log::debug!(target: LOG_TARGET, "failed to parse polkavm blob: {err:?}"); log::debug!(target: LOG_TARGET, "failed to parse polkavm blob: {err:?}");
Error::<T>::CodeRejected Error::<T>::CodeRejected
......
...@@ -312,6 +312,7 @@ impl<T: Config> WasmBlob<T> { ...@@ -312,6 +312,7 @@ impl<T: Config> WasmBlob<T> {
config.set_cache_enabled(false); config.set_cache_enabled(false);
#[cfg(feature = "std")] #[cfg(feature = "std")]
if std::env::var_os("REVIVE_USE_COMPILER").is_some() { 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)); config.set_backend(Some(polkavm::BackendKind::Compiler));
} }
let engine = polkavm::Engine::new(&config).expect( let engine = polkavm::Engine::new(&config).expect(
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment