Skip to content

feat: katana gas oracle #2558

Closed
Closed
@kariy

Description

@kariy

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;
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestkatanaThis issue is related to Katana

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions