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

Redundant gas fee in block context #1255

Open
kariy opened this issue Mar 20, 2024 · 1 comment · May be fixed by #1256
Open

Redundant gas fee in block context #1255

kariy opened this issue Mar 20, 2024 · 1 comment · May be fixed by #1256

Comments

@kariy
Copy link
Contributor

kariy commented Mar 20, 2024

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.

@kariy kariy linked a pull request Mar 20, 2024 that will close this issue
5 tasks
@juanbono
Copy link
Collaborator

@kariy can you open a PR for that so we can take a look?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants