Skip to content

Commit

Permalink
Attempt to fix sporadic issue on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
chevdor committed May 9, 2022
1 parent a2066e0 commit f95f346
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
6 changes: 3 additions & 3 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ignore = [
# * Medium - CVSS Score 4.0 - 6.9
# * High - CVSS Score 7.0 - 8.9
# * Critical - CVSS Score 9.0 - 10.0
#severity-threshold =
#severity-threshold =

# This section is considered when running `cargo deny check licenses`
# More documentation for the licenses section can be found here:
Expand Down Expand Up @@ -176,8 +176,8 @@ deny = [
skip = [
#{ name = "ansi_term", version = "=0.11.0" },
]
# Similarly to `skip` allows you to skip certain crates during duplicate
# detection. Unlike skip, it also includes the entire tree of transitive
# Similarly to `skip` allows you to skip certain crates during duplicate
# detection. Unlike skip, it also includes the entire tree of transitive
# dependencies starting at the specified crate, up to a certain depth, which is
# by default infinite
skip-tree = [
Expand Down
17 changes: 11 additions & 6 deletions libs/wasm-loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ use error::WasmLoaderError;
use jsonrpsee::core::client::ClientT;
use jsonrpsee::core::{Error, JsonValue};
use jsonrpsee::rpc_params;
use log::*;

// use jsonrpsee::types::types::{Error, JsonValue};
use jsonrpsee::{http_client::HttpClientBuilder, ws_client::WsClientBuilder};
use log::debug;
pub use node_endpoint::NodeEndpoint;
pub use onchain_block::{BlockRef, OnchainBlock};
pub use source::Source;

use std::io::Read;
use std::{fs, fs::File, path::Path};
use std::{fs::File, path::Path};
use tokio::runtime::Runtime;

const CODE: &str = "0x3a636f6465"; // :code in hex
Expand Down Expand Up @@ -72,10 +72,15 @@ impl WasmLoader {
/// Load some binary from a file
fn load_from_file(filename: &Path) -> WasmBytes {
let mut f = File::open(&filename).unwrap_or_else(|_| panic!("File {} not found", filename.to_string_lossy()));
let metadata = fs::metadata(&filename).expect("unable to read metadata");
let mut buffer = vec![0; metadata.len() as usize];
f.read_exact(&mut buffer).expect("buffer overflow");

// TODO: Remove the following once issues like https://github.com/chevdor/subwasm/actions/runs/2292032462
// are confirmed to be gone.
// let metadata = fs::metadata(&filename).expect("unable to read metadata");
// log::debug!("metadata size: {:?}", metadata.len());
// let mut buffer = vec![0; metadata.len() as usize];
// f.read_exact(&mut buffer).expect("buffer overflow");
let mut buffer = Vec::new();
f.read_to_end(&mut buffer).expect("failed loading file");
log::debug!("read data from file, buffer size: {:?}", buffer.len());
buffer
}

Expand Down

0 comments on commit f95f346

Please sign in to comment.