Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Redundant gas fee in block context #1255

@kariy

Description

@kariy

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.

#[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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions