Skip to content

Commit

Permalink
feat(starknet_l1_provider): add the trait interface for L1 gas price …
Browse files Browse the repository at this point in the history
…provider
  • Loading branch information
guy-starkware committed Feb 4, 2025
1 parent 643d16f commit 24cada3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions crates/starknet_l1_provider/src/l1_gas_price_provider.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use starknet_api::block::{BlockNumber, BlockTimestamp};
use thiserror::Error;

// TODO(guyn): both these constants need to go into VersionedConstants.
pub const MEAN_NUMBER_OF_BLOCKS: u64 = 300;
pub const LAG_MARGIN_SECONDS: u64 = 60;

// TODO(guyn, Gilad): consider moving this to starknet_l1_provider_types/lib.rs?
// This is an interface that allows sharing the provider with the scraper across threads.
pub trait L1GasPriceProviderClient: Send + Sync {
fn add_price_info(
&self,
height: BlockNumber,
timestamp: BlockTimestamp,
gas_price: u128,
data_gas_price: u128,
) -> Result<(), L1GasPriceProviderError>;

fn get_price_info(
&self,
timestamp: BlockTimestamp,
) -> Result<(u128, u128), L1GasPriceProviderError>;
}

#[derive(Clone, Debug, Error)]
pub enum L1GasPriceProviderError {
#[error("Failed to add price info: {0}")]
AddPriceInfoError(String),
#[error("Failed to get price info: {0}")]
GetPriceInfoError(String),
}
1 change: 1 addition & 0 deletions crates/starknet_l1_provider/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub mod bootstrapper;

use papyrus_config::converters::deserialize_float_seconds_to_duration;
pub mod communication;
pub mod l1_gas_price_provider;
pub mod l1_provider;
pub mod l1_scraper;
pub mod soft_delete_index_map;
Expand Down

0 comments on commit 24cada3

Please sign in to comment.