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(starknet_l1_provider): add the trait interface for L1 gas price provider #3792

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ members = [
"crates/starknet_http_server",
"crates/starknet_infra_utils",
"crates/starknet_integration_tests",
"crates/starknet_l1_gas_price",
"crates/starknet_l1_provider",
"crates/starknet_l1_provider_types",
"crates/starknet_mempool",
Expand Down
13 changes: 13 additions & 0 deletions crates/starknet_l1_gas_price/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "starknet_l1_gas_price"
version.workspace = true
edition.workspace = true
repository.workspace = true
license.workspace = true

[dependencies]
starknet_api.workspace = true
thiserror.workspace = true

[lints]
workspace = true
31 changes: 31 additions & 0 deletions crates/starknet_l1_gas_price/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_gas_price/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod l1_gas_price_provider;
Loading