-
Notifications
You must be signed in to change notification settings - Fork 52
Redundant gas fee in block context #1255
Description
There are two instances of GasPrices
in the whole BlockContext
struct. First one located in StarknetOsConfig
, and the other one in BlockInfo
. Both of these structs are included in BlockContext
.
starknet_in_rust/src/definitions/block_context.rs
Lines 158 to 178 in c90c46b
#[derive(Clone, Debug, CopyGetters, Getters, MutGetters)] | |
pub struct BlockContext { | |
#[getset(get = "pub", get_mut = "pub")] | |
pub(crate) starknet_os_config: StarknetOsConfig, | |
#[get_copy = "pub"] | |
pub(crate) contract_storage_commitment_tree_height: u64, | |
#[get_copy = "pub"] | |
global_state_commitment_tree_height: u64, | |
#[get = "pub"] | |
pub(crate) cairo_resource_fee_weights: HashMap<String, f64>, | |
#[get_copy = "pub"] | |
pub(crate) invoke_tx_max_n_steps: u64, | |
#[get_copy = "pub"] | |
pub(crate) validate_max_n_steps: u64, | |
#[getset(get = "pub", get_mut = "pub")] | |
pub(crate) block_info: BlockInfo, | |
/// Contains the blocks in the range [ current_block - 1024, current_block - 10 ] | |
#[getset(get = "pub", get_mut = "pub")] | |
pub(crate) blocks: HashMap<u64, Block>, | |
pub(crate) enforce_l1_handler_fee: bool, | |
} |
But the one that is used for fee calculation is the one in os config:
starknet_in_rust/src/definitions/block_context.rs
Lines 220 to 222 in c90c46b
pub fn get_gas_price_by_fee_type(&self, fee_type: &FeeType) -> u128 { | |
self.starknet_os_config.gas_price.get_by_fee_type(fee_type) | |
} |
I can't find any usage reference for the one in BlockInfo
.
Also because StarknetOsConfig
doesn't make the individual fields mutable, you can't easily mutate the gas price individually. You have to instead replace the whole struct if you wanna change the gas price.