Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(runtime): borsh deserialized wasmer 0.x #4448

Merged
merged 23 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 77 additions & 33 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,10 @@ skip = [

# hashbrown uses an older version
{ name = "ahash", version = "=0.4.7" },

# zeropool-bn use borsh 0.8.1
{ name = "borsh", version = "=0.8.1" },
{ name = "borsh-derive", version = "=0.8.1" },
{ name = "borsh-derive-internal", version = "=0.8.1" },
{ name = "borsh-schema-derive-internal", version = "=0.8.1" },
]
4 changes: 2 additions & 2 deletions runtime/near-vm-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ This crate implements the specification of the interface that Near blockchain ex
[dependencies]
borsh = "0.8.1"
serde = { version = "1", features = ["derive"] }
wasmer-runtime = { version="0.17.1", features = ["default-backend-singlepass"], default-features = false, package = "wasmer-runtime-near", optional = true }
wasmer-runtime = { git = "https://github.com/near/wasmer", rev = "f1d5f06a3b42215524290652af52d079da9f5b22", features = ["default-backend-singlepass"], default-features = false, package = "wasmer-runtime-near", optional = true }
# Always used even for wasmer 1.0 for validating wasm, will be replaced when refactor prepare.rs
wasmer-runtime-core = {version = "0.17.4", package = "wasmer-runtime-core-near" }
wasmer-runtime-core = {git = "https://github.com/near/wasmer", rev = "f1d5f06a3b42215524290652af52d079da9f5b22", package = "wasmer-runtime-core-near" }
wasmer = { version = "1.0.2", optional = true }
wasmer-types = { version = "1.0.2", optional = true }
wasmer-compiler-singlepass = { version = "1.0.2", optional = true, default-features = false, features = ["std", "enable-serde"] } # disable `rayon` feature.
Expand Down
9 changes: 8 additions & 1 deletion runtime/near-vm-runner/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ enum ContractCacheKey {
vm_kind: VMKind,
vm_hash: u64,
},
// bump to depreciate bincode/serde-bench based wasmer 0.x cache
Version3 {
ailisp marked this conversation as resolved.
Show resolved Hide resolved
code_hash: CryptoHash,
vm_config_non_crypto_hash: u64,
vm_kind: VMKind,
vm_hash: u64,
},
}

#[derive(Debug, Clone, BorshDeserialize, BorshSerialize)]
Expand All @@ -52,7 +59,7 @@ pub fn get_contract_cache_key(
config: &VMConfig,
) -> CryptoHash {
let _span = tracing::debug_span!(target: "vm", "get_key").entered();
let key = ContractCacheKey::Version2 {
let key = ContractCacheKey::Version3 {
Copy link
Member Author

Choose a reason for hiding this comment

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

@olonho This change invalidated old keys in cache and make it pass the upgradable test. Without this change it fails of deserialization cache failed

Copy link
Member Author

Choose a reason for hiding this comment

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

code_hash: code.hash,
vm_config_non_crypto_hash: config.non_crypto_hash(),
vm_kind,
Expand Down
2 changes: 1 addition & 1 deletion runtime/near-vm-runner/src/wasmer_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use wasmer_runtime::{ImportObject, Module};
fn check_method(module: &Module, method_name: &str) -> Result<(), VMError> {
let info = module.info();
use wasmer_runtime_core::module::ExportIndex::Func;
if let Some(Func(index)) = info.exports.get(method_name) {
if let Some(Func(index)) = info.exports.map.get(method_name) {
let func = info.func_assoc.get(index.clone()).unwrap();
let sig = info.signatures.get(func.clone()).unwrap();
if sig.params().is_empty() && sig.returns().is_empty() {
Expand Down