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

Fix: calc l1 fee unconditionally but deduct only if tx is ok #283

Merged
merged 2 commits into from
Mar 22, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ impl<EXT: CitreaHandlerContext, DB: Database> CitreaHandler<EXT, DB> {
context: &mut Context<EXT, DB>,
result: FrameResult,
) -> Result<ResultAndState, EVMError<<DB as Database>::Error>> {
if !result.interpreter_result().is_error() {
let diff_size = calc_diff_size(context).map_err(EVMError::Database)? as u64;
let l1_fee_rate = U256::from(context.external.l1_fee_rate());
let l1_fee = U256::from(diff_size) * l1_fee_rate;
context.external.set_tx_info(TxInfo { diff_size });
let diff_size = calc_diff_size(context).map_err(EVMError::Database)? as u64;
let l1_fee_rate = U256::from(context.external.l1_fee_rate());
let l1_fee = U256::from(diff_size) * l1_fee_rate;
context.external.set_tx_info(TxInfo { diff_size });
if result.interpreter_result().is_ok() {
// Deduct L1 fee only if tx is successful.
if let Some(_out_of_funds) = decrease_caller_balance(context, l1_fee)? {
return Err(EVMError::Custom(format!(
"Not enought funds for L1 fee: {}",
Expand Down
Loading