Skip to content

Commit

Permalink
Try #1140:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Jan 13, 2020
2 parents b27c353 + 3d00903 commit 910ec89
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## **[Unreleased]**

- [#1140](https://github.com/wasmerio/wasmer/pull/1140) Use [`blake3`](https://github.com/BLAKE3-team/BLAKE3) as default hashing algorithm for caching.
- [#1128](https://github.com/wasmerio/wasmer/pull/1128) Fix a crash when a host function is missing and the `allow_missing_functions` flag is enabled
- [#1099](https://github.com/wasmerio/wasmer/pull/1099) Remove `backend::Backend` from `wasmer_runtime_core`
- [#1098](https://github.com/wasmerio/wasmer/pull/1098) Remove `backend::Backend` from `wasmer_runtime_core`
Expand Down
14 changes: 8 additions & 6 deletions Cargo.lock

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

10 changes: 5 additions & 5 deletions lib/runtime-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ edition = "2018"
nix = "0.15"
page_size = "0.4"
wasmparser = "0.45.0"
parking_lot = "0.9"
parking_lot = "0.10.0"
lazy_static = "1.4"
errno = "0.2"
libc = "0.2.60"
hex = "0.3"
hex = "0.4"
smallvec = "0.6"
bincode = "1.1"

Expand All @@ -36,16 +36,16 @@ version = "1.0"
version = "0.11"
[dependencies.serde-bench]
version = "0.0.7"
[dependencies.blake2b_simd]
version = "0.5"
[dependencies.blake3]
version = "0.1.0"
[dependencies.digest]
version = "0.8"

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["memoryapi"] }

[build-dependencies]
blake2b_simd = "0.5"
blake3 = "0.1.0"
rustc_version = "0.2"
cc = "1.0"

Expand Down
8 changes: 4 additions & 4 deletions lib/runtime-core/build.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use blake2b_simd::blake2bp;
use blake3;
use std::{env, fs, io::Write, path::PathBuf};

const WASMER_VERSION: &'static str = env!("CARGO_PKG_VERSION");

fn main() {
let mut state = blake2bp::State::new();
state.update(WASMER_VERSION.as_bytes());
let mut hasher = blake3::Hasher::new();
hasher.update(WASMER_VERSION.as_bytes());

let hasher = state.finalize();
let hasher = hasher.finalize();
let hash_string = hasher.to_hex().as_str().to_owned();

let crate_dir = env::var("OUT_DIR").unwrap();
Expand Down
10 changes: 5 additions & 5 deletions lib/runtime-core/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! and loaded to allow skipping compilation and fast startup.
use crate::{module::ModuleInfo, sys::Memory};
use blake2b_simd::blake2bp;
use blake3;
use std::{io, mem, slice};

/// Indicates the invalid type of invalid cache file
Expand Down Expand Up @@ -61,11 +61,11 @@ impl WasmHash {
let mut first_part = [0u8; 32];
let mut second_part = [0u8; 32];

let mut state = blake2bp::State::new();
state.update(wasm);
let mut hasher = blake3::Hasher::new();
hasher.update(wasm);

let hasher = state.finalize();
let generic_array = hasher.as_bytes();
let hash = hasher.finalize();
let generic_array = hash.as_bytes();

first_part.copy_from_slice(&generic_array[0..32]);
second_part.copy_from_slice(&generic_array[32..64]);
Expand Down

0 comments on commit 910ec89

Please sign in to comment.