Skip to content

Commit

Permalink
POC: add function for l2 gas price
Browse files Browse the repository at this point in the history
  • Loading branch information
aner-starkware committed Aug 5, 2024
1 parent 770e2ed commit 6d20423
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/blockifier/src/blockifier/block.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::num::NonZeroU128;

use num_rational::Ratio;
use starknet_api::block::{BlockHash, BlockNumber, BlockTimestamp};
use starknet_api::core::ContractAddress;
use starknet_api::state::StorageKey;
Expand All @@ -13,6 +14,11 @@ use crate::transaction::objects::FeeType;
#[cfg(test)]
#[path = "block_test.rs"]
pub mod block_test;
pub const L2_GAS_FOR_CAIRO_STEP: u128 = 100;
pub const CAIRO_STEPS_PER_L1_GAS: u128 = 400;
pub const L2_TO_L1_GAS_PRICE_RATIO: u128 = L2_GAS_FOR_CAIRO_STEP * CAIRO_STEPS_PER_L1_GAS;

pub type L2Cost = Ratio<u128>;

#[derive(Clone, Debug)]
pub struct BlockInfo {
Expand Down Expand Up @@ -47,6 +53,10 @@ impl GasPrices {
FeeType::Eth => self.eth_l1_data_gas_price,
}
}

pub fn get_l2_gas_price_by_fee_type(&self, fee_type: &FeeType) -> L2Cost {
L2Cost::new(self.get_gas_price_by_fee_type(fee_type).into(), L2_TO_L1_GAS_PRICE_RATIO)
}
}

// Block pre-processing.
Expand Down

0 comments on commit 6d20423

Please sign in to comment.