From 4bc41d1f78329ca7fbc76e11f9110668f3efeecd Mon Sep 17 00:00:00 2001 From: Softcloud Date: Sat, 3 Feb 2024 11:30:56 +0800 Subject: [PATCH] MOD: program get error hint. --- core/src/state/error.rs | 2 +- core/src/state/state_storage.rs | 4 +++- zk-vm/src/lib.rs | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/state/error.rs b/core/src/state/error.rs index 5f349288..4cee03f0 100644 --- a/core/src/state/error.rs +++ b/core/src/state/error.rs @@ -16,7 +16,7 @@ pub enum StateError { #[error("VM json serde error")] JsonSerdeError(#[from] serde_json::Error), - #[error("Can not load the program")] + #[error("Can not load the program: {0}")] GetProgramError(String), #[error("Convert string error")] diff --git a/core/src/state/state_storage.rs b/core/src/state/state_storage.rs index 50835357..1b90f967 100644 --- a/core/src/state/state_storage.rs +++ b/core/src/state/state_storage.rs @@ -171,7 +171,9 @@ impl StateStorage { .map_err(StateError::GetProgramError)?; let res = self.db.get_cf(cf, addr_key); res.map_err(StateError::StorageIoError)? - .ok_or(StateError::ColumnFamilyEmpty) + .ok_or(StateError::GetProgramError( + "program hash get failed".to_string(), + )) } pub fn save_prophet(&mut self, code_hash: &TreeValue, prophet: &str) -> Result<(), StateError> { diff --git a/zk-vm/src/lib.rs b/zk-vm/src/lib.rs index d4b2526d..d304617a 100644 --- a/zk-vm/src/lib.rs +++ b/zk-vm/src/lib.rs @@ -211,7 +211,10 @@ impl OlaVM { let bin_program: BinaryProgram = match bincode::deserialize(&contract) { Ok(data) => data, Err(e) => { - return Err(StateError::GetProgramError(format!("{:?}", e))); + return Err(StateError::GetProgramError(format!( + "deserialize program error, {:?}", + e + ))); } };