Skip to content

Commit

Permalink
Pass gas_used in TxParamsRequestModel
Browse files Browse the repository at this point in the history
  • Loading branch information
andreisilviudragnea committed Oct 21, 2023
1 parent 15c41b0 commit 3fd2d18
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions evm_loader/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ fn parse_tx(params: &ArgMatches) -> (TxParams, TraceCallConfig) {
data,
value,
gas_limit,
gas_used: None,
access_list,
};

Expand Down
5 changes: 4 additions & 1 deletion evm_loader/lib/src/commands/emulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,10 @@ pub(crate) async fn emulate_trx<'a>(
Ok(evm_loader::evm::tracing::EmulationResult {
exit_status,
steps_executed,
used_gas: steps_gas + begin_end_gas + actions_gas + accounts_gas,
used_gas: tx_params
.gas_used
.map(U256::as_u64)
.unwrap_or(steps_gas + begin_end_gas + actions_gas + accounts_gas),
actions,
state_diff: StateDiff(map),
})
Expand Down
1 change: 1 addition & 0 deletions evm_loader/lib/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub struct TxParams {
pub data: Option<Vec<u8>>,
pub value: Option<U256>,
pub gas_limit: Option<U256>,
pub gas_used: Option<U256>,
pub access_list: Option<Vec<AccessListItem>>,
}

Expand Down
2 changes: 2 additions & 0 deletions evm_loader/lib/src/types/request_models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub struct TxParamsRequestModel {
pub data: Option<Vec<u8>>,
pub value: Option<U256>,
pub gas_limit: Option<U256>,
pub gas_used: Option<U256>,
pub access_list: Option<Vec<AccessListItem>>,
}

Expand Down Expand Up @@ -59,6 +60,7 @@ impl From<TxParamsRequestModel> for TxParams {
data: model.data,
value: model.value,
gas_limit: model.gas_limit,
gas_used: model.gas_used,
access_list: model.access_list,
}
}
Expand Down

0 comments on commit 3fd2d18

Please sign in to comment.