Skip to content

Commit

Permalink
fix: emit EVM_INTERNAL_ERROR(-1) if polyjuice failed to generate a sy…
Browse files Browse the repository at this point in the history
…stem log
  • Loading branch information
jjyr committed Oct 9, 2022
1 parent 02e0ff3 commit 09f6d58
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion crates/generator/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,11 @@ impl Generator {
raw_tx: &RawL2Transaction,
mut run_result: RunResult,
) -> Result<RunResult, TransactionError> {
/// Error code represents EVM internal error
/// we emit this error from Godwoken side if
/// Polyjuice failed to generate a system log
const ERROR_EVM_INTERNAL: i32 = -1;

let sender_id: u32 = raw_tx.from_id().unpack();
let nonce_raw_key = build_account_field_key(sender_id, GW_ACCOUNT_NONCE_TYPE);
let nonce_before = state.get_nonce(sender_id)?;
Expand Down Expand Up @@ -848,7 +853,7 @@ impl Generator {
gas,
gas,
Default::default(),
0,
ERROR_EVM_INTERNAL,
));
}
let parser = tx.parser().ok_or(TransactionError::NoCost)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/utils/src/script_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ pub fn generate_polyjuice_system_log(
gas_used: u64,
cumulative_gas_used: u64,
created_address: [u8; 20],
status_code: u32,
status_code: i32,
) -> LogItem {
let service_flag: u8 = GW_LOG_POLYJUICE_SYSTEM;
let mut data = [0u8; 40];
Expand Down

0 comments on commit 09f6d58

Please sign in to comment.