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 · 4 comments
Open

feat: katana gas oracle #2558

kariy opened this issue Oct 19, 2024 · 4 comments
Assignees
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
@augustin-v
Copy link

Hi, I would love to work on this issue. I have experience with Rust and also contributing to Kakarot with Cairo. I will make sure to communicate if I encounter any issues along the way

@kariy
Copy link
Member Author

kariy commented Oct 31, 2024

@augustin-v assigned :). you can take a look at madara's implementation for some reference.

@kariy
Copy link
Member Author

kariy commented Nov 6, 2024

@augustin-v i've added a very simple skeleton code for the gas oracle in #2643. its only supporting fixed gas prices as we already have today.

@augustin-v
Copy link

@kariy Nice, I have made a draft pull request for my progress on the gas oracle implementation in #2558. I would love to get a review to see how I could move forward.

augustin-v added a commit to augustin-v/dojo that referenced this issue Nov 16, 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

2 participants