Skip to content

Commit

Permalink
MOD: deserialize program.
Browse files Browse the repository at this point in the history
  • Loading branch information
web3Softcloud committed Jan 11, 2024
1 parent cb442da commit 624780f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

11 changes: 6 additions & 5 deletions zk-vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ola-core = { package = "core", path = "../core", version = "0.1.0"}
ola-core = { package = "core", path = "../core", version = "0.1.0" }
executor = { package = "executor", path = "../executor", version = "0.1.0", default-features = false }
serde_json = "1"
serde = {version = "1" }
serde_derive = {version = "1"}
serde = { version = "1" }
serde_derive = { version = "1" }
env_logger = "0.6"
log = "0.4"
thiserror = "1.0"
tokio = { version = "1", features = ["full","test-util"] }
tokio = { version = "1", features = ["full", "test-util"] }
tempfile = "3"
rand = "0.8.5"
rand = "0.8.5"
bincode = "1.3.3"
8 changes: 6 additions & 2 deletions zk-vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,12 @@ impl OlaVM {

if get_code {
let contract = self.get_program(&code_hash)?;
let bin_program: BinaryProgram =
serde_json::from_str(std::str::from_utf8(&contract.to_vec()).unwrap()).unwrap();
let bin_program: BinaryProgram = match bincode::deserialize(&contract) {
Ok(data) => data,
Err(e) => {
return Err(StateError::GetProgramError(format!("{:?}", e)));
}
};

let instructions = bin_program.bytecode.split("\n");
let code: Vec<_> = instructions
Expand Down

0 comments on commit 624780f

Please sign in to comment.