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

Update lib.rs 修复require失效不revert的bug #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all 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
27 changes: 14 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,14 @@ impl evmc_vm::EvmcVm for BcosWasm {
}
};
let future = func.call_async(&mut store, ());
match task::block_on(future) {
let ret = task::block_on(future);
let env = env_interface.lock().unwrap();
// get output from env_interface
let output = env.get_output();
if env.reverted() {
ret = evmc_vm::ExecutionResult::new(evmc_status_code::EVMC_REVERT, 0, 0, Some(output));
}
match ret {
Ok(ret) => ret,
Err(e) => {
error!("Failed to call {} function: {}", call_name, e);
Expand All @@ -634,21 +641,15 @@ impl evmc_vm::EvmcVm for BcosWasm {
);
start = Instant::now();
}
let env = env_interface.lock().unwrap();
// get output from env_interface
let output = env.get_output();
let ret;
if !env.reverted() {
WASM_MODULE_CACHE.lock().unwrap().put(dest, module.clone());
let gas_left = env.get_gas_left(&mut store).unwrap();
if kind == evmc_call_kind::EVMC_CREATE {
ret = evmc_vm::ExecutionResult::success(gas_left, 0, Some(code));
} else {
ret = evmc_vm::ExecutionResult::success(gas_left, 0, Some(output));
}
WASM_MODULE_CACHE.lock().unwrap().put(dest, module.clone());
let gas_left = env.get_gas_left(&mut store).unwrap();
if kind == evmc_call_kind::EVMC_CREATE {
ret = evmc_vm::ExecutionResult::success(gas_left, 0, Some(code));
} else {
ret = evmc_vm::ExecutionResult::new(evmc_status_code::EVMC_REVERT, 0, 0, Some(output));
ret = evmc_vm::ExecutionResult::success(gas_left, 0, Some(output));
}

if log_enabled!(Level::Debug) {
debug!(
"prepare result elapsed: {:?} μs",
Expand Down