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

feat: katana gas oracle #2558

Open
kariy opened this issue Oct 19, 2024 · 0 comments
Open

feat: katana gas oracle #2558

kariy opened this issue Oct 19, 2024 · 0 comments
Labels
enhancement New feature or request katana This issue is related to Katana

Comments

@kariy
Copy link
Member

kariy commented Oct 19, 2024

Problem

Right now, Katana hardcoded the gas prices value. These gas prices are then used for computing the fees that transactions has to pay.

Though it works fine when using Katana just for testing/dev environment but for actual production setting we want to properly sample the L1 gas prices. Refer to the doc below for how starknet sample the l1 gas price:

https://docs.starknet.io/architecture-and-concepts/network-architecture/fee-mechanism/#calculation_of_gas_costs

Implementation for the gas oracle component should be able to (1) perform actual sampling on the underlying L1, (2) hardcoded value when katana is not run with an L1 (ie testing env).

On every new block, we'd then need to update the gas price values that have been sampled, in the block env:

pub fn update_block_env(&self, block_env: &mut BlockEnv) {
let mut context_gen = self.block_context_generator.write();
let current_timestamp_secs = get_current_timestamp().as_secs() as i64;
let timestamp = if context_gen.next_block_start_time == 0 {
(current_timestamp_secs + context_gen.block_timestamp_offset) as u64
} else {
let timestamp = context_gen.next_block_start_time;
context_gen.block_timestamp_offset = timestamp as i64 - current_timestamp_secs;
context_gen.next_block_start_time = 0;
timestamp
};
block_env.number += 1;
block_env.timestamp = timestamp;
}

@kariy kariy added enhancement New feature or request katana This issue is related to Katana labels Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request katana This issue is related to Katana
Projects
None yet
Development

No branches or pull requests

1 participant