Skip to content

Commit

Permalink
Bump polkavm version to 0.16.0
Browse files Browse the repository at this point in the history
Signed-off-by: Jarkko Sakkinen <[email protected]>
  • Loading branch information
jarkkojs committed Nov 19, 2024
1 parent b71bd53 commit 80a60ee
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 86 deletions.
43 changes: 41 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,8 @@ polkadot-subsystem-bench = { path = "polkadot/node/subsystem-bench" }
polkadot-test-client = { path = "polkadot/node/test/client" }
polkadot-test-runtime = { path = "polkadot/runtime/test-runtime" }
polkadot-test-service = { path = "polkadot/node/test/service" }
polkavm = { version = "0.9.3", default-features = false }
polkavm = { version = "0.16.0", default-features = false }
polkavm-common = "0.16.0"
polkavm-derive = "0.9.1"
polkavm-linker = "0.9.2"
portpicker = { version = "0.1.1" }
Expand Down
19 changes: 8 additions & 11 deletions polkadot/primitives/src/v8/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2134,7 +2134,7 @@ impl<BlockNumber: Default + From<u32>> Default for SchedulerParams<BlockNumber>
#[cfg(test)]
pub mod tests {
use super::*;
use bitvec::bitvec;
use bitvec::{bits, bitvec, order::Lsb0};
use sp_core::sr25519;

pub fn dummy_committed_candidate_receipt() -> CommittedCandidateReceipt {
Expand Down Expand Up @@ -2239,7 +2239,7 @@ pub mod tests {

#[test]
fn test_backed_candidate_injected_core_index() {
let initial_validator_indices = bitvec![u8, bitvec::order::Lsb0; 0, 1, 0, 1];
let initial_validator_indices = bits![u8, Lsb0; 0, 1, 0, 1].to_bitvec();
let mut candidate = BackedCandidate::new(
dummy_committed_candidate_receipt(),
vec![],
Expand Down Expand Up @@ -2268,37 +2268,34 @@ pub mod tests {
let candidate = BackedCandidate::new(
dummy_committed_candidate_receipt(),
vec![],
bitvec![u8, bitvec::order::Lsb0; 0, 1, 0, 1, 0, 1, 0, 1, 0],
bits![u8, Lsb0; 0, 1, 0, 1, 0, 1, 0, 1, 0].to_bitvec(),
None,
);
let (validator_indices, core_index) = candidate.validator_indices_and_core_index(true);
assert_eq!(validator_indices, bitvec![u8, bitvec::order::Lsb0; 0].as_bitslice());
assert_eq!(validator_indices, bits![u8, Lsb0; 0]);
assert!(core_index.is_some());

// Core index supplied, ElasticScalingMVP is off. Core index will be treated as normal
// validator indices. Runtime will check against this.
let candidate = BackedCandidate::new(
dummy_committed_candidate_receipt(),
vec![],
bitvec![u8, bitvec::order::Lsb0; 0, 1, 0, 1],
bits![u8, Lsb0; 0, 1, 0, 1].to_bitvec(),
Some(CoreIndex(10)),
);
let (validator_indices, core_index) = candidate.validator_indices_and_core_index(false);
assert_eq!(
validator_indices,
bitvec![u8, bitvec::order::Lsb0; 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0]
);
assert_eq!(validator_indices, bits![u8, Lsb0; 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0]);
assert!(core_index.is_none());

// Core index supplied, ElasticScalingMVP is on.
let mut candidate = BackedCandidate::new(
dummy_committed_candidate_receipt(),
vec![],
bitvec![u8, bitvec::order::Lsb0; 0, 1, 0, 1],
bits![u8, Lsb0; 0, 1, 0, 1].to_bitvec(),
Some(CoreIndex(10)),
);
let (validator_indices, core_index) = candidate.validator_indices_and_core_index(true);
assert_eq!(validator_indices, bitvec![u8, bitvec::order::Lsb0; 0, 1, 0, 1]);
assert_eq!(validator_indices, bits![u8, Lsb0; 0, 1, 0, 1]);
assert_eq!(core_index, Some(CoreIndex(10)));

let encoded_validator_indices = candidate.validator_indices.clone();
Expand Down
13 changes: 13 additions & 0 deletions prdoc/pr_6533.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
title: "Bump to polkavm 0.16.0"
doc:
- audience: Runtime Dev
description: |
Bumped to polkvm 0.16.0. In addition, fixed the compilation errors from
the tests of polkadot-primitives because Zed was complaining about them.
crates:
- name: polkadot-primitives
bump: none
- name: sc-executor-common
bump: major
- name: sc-executor-polkavm
bump: major
1 change: 1 addition & 0 deletions substrate/client/executor/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ sc-allocator = { workspace = true, default-features = true }
sp-maybe-compressed-blob = { workspace = true, default-features = true }
sp-wasm-interface = { workspace = true, default-features = true }
polkavm = { workspace = true }
polkavm-common = { workspace = true }

[features]
default = []
4 changes: 2 additions & 2 deletions substrate/client/executor/common/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ pub enum WasmError {
Other(String),
}

impl From<polkavm::ProgramParseError> for WasmError {
fn from(error: polkavm::ProgramParseError) -> Self {
impl From<polkavm_common::program::ProgramParseError> for WasmError {
fn from(error: polkavm_common::program::ProgramParseError) -> Self {
WasmError::Other(error.to_string())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct RuntimeBlob(BlobKind);
#[derive(Clone)]
enum BlobKind {
WebAssembly(Module),
PolkaVM(polkavm::ProgramBlob<'static>),
PolkaVM(polkavm::ProgramBlob),
}

impl RuntimeBlob {
Expand All @@ -52,9 +52,7 @@ impl RuntimeBlob {
pub fn new(raw_blob: &[u8]) -> Result<Self, WasmError> {
if raw_blob.starts_with(b"PVM\0") {
if crate::is_polkavm_enabled() {
return Ok(Self(BlobKind::PolkaVM(
polkavm::ProgramBlob::parse(raw_blob)?.into_owned(),
)));
return Ok(Self(BlobKind::PolkaVM(polkavm::ProgramBlob::parse(raw_blob.into())?)));
} else {
return Err(WasmError::Other("expected a WASM runtime blob, found a PolkaVM runtime blob; set the 'SUBSTRATE_ENABLE_POLKAVM' environment variable to enable the experimental PolkaVM-based executor".to_string()));
}
Expand Down Expand Up @@ -192,7 +190,7 @@ impl RuntimeBlob {
match self.0 {
BlobKind::WebAssembly(raw_module) =>
serialize(raw_module).expect("serializing into a vec should succeed; qed"),
BlobKind::PolkaVM(ref blob) => blob.as_bytes().to_vec(),
BlobKind::PolkaVM(ref blob) => blob.code().to_vec(),
}
}

Expand Down
Loading

0 comments on commit 80a60ee

Please sign in to comment.