Skip to content

Commit

Permalink
feat(concensus): add versioned constants to Concensus
Browse files Browse the repository at this point in the history
  • Loading branch information
ayeletstarkware committed Jan 9, 2025
1 parent f6f7f30 commit e9d58e3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions crates/sequencing/papyrus_consensus_orchestrator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ async-trait.workspace = true
chrono.workspace = true
futures.workspace = true
indexmap.workspace = true
infra_utils.workspace = true
papyrus_config.workspace = true
papyrus_consensus.workspace = true
papyrus_network.workspace = true
papyrus_protobuf.workspace = true
papyrus_storage.workspace = true
paste.workspace = true
reqwest = { workspace = true, features = ["json"] }
serde.workspace = true
serde_json.workspace = true
starknet-types-core.workspace = true
starknet_api.workspace = true
starknet_batcher_types = { workspace = true, features = ["testing"] }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"gas_price_max_change_denominator": 48,
"gas_target": 2000000000,
"max_block_size": 4000000000,
"min_gas_price": 100000
}
3 changes: 3 additions & 0 deletions crates/sequencing/papyrus_consensus_orchestrator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ pub mod cende;

/// Fee market logic.
pub mod fee_market;

/// Consensus' versioned constants.
pub mod versioned_constants;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use serde::Deserialize;
use starknet_api::define_versioned_constants;

/// Versioned constants for the Consensus.
#[derive(Clone, Deserialize)]
pub struct VersionedConstants {
/// This is used to calculate the base gas price for the next block according to EIP-1559 and
/// serves as a sensitivity parameter that limits the maximum rate of change of the gas price
/// between consecutive blocks.
pub gas_price_max_change_denominator: u128,
/// The minimum gas price in fri.
pub min_gas_price: u64,
/// The maximum block size in gas units.
pub max_block_size: u64,
/// The target gas usage per block (usually half of a block's gas limit).
pub gas_target: u64,
}

// TODO(Ayelet): Change version and path to 0.14 once added.
define_versioned_constants!(
VersionedConstants,
(V0_13_4, "../resources/versioned_constants_0_13_4.json"),
);

0 comments on commit e9d58e3

Please sign in to comment.