Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchTurner committed Dec 2, 2024
1 parent 1598c2d commit 434f764
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
23 changes: 19 additions & 4 deletions bin/fuel-core/src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,22 @@ pub struct Command {
#[arg(long = "gas-price-threshold-percent", default_value = "50", env)]
pub gas_price_threshold_percent: u8,

// Minimum DA gas price
/// Minimum DA gas price
#[arg(long = "min-da-gas-price", default_value = "0", env)]
pub min_da_gas_price: u64,

/// P component of DA gas price calculation
#[arg(long = "da-p-component", default_value = "0", env)]
pub da_p_component: i64,

/// D component of DA gas price calculation
#[arg(long = "da-d-component", default_value = "0", env)]
pub da_d_component: i64,

/// Maximum DA gas price change percent
#[arg(long = "max-da-gas-price-change-percent", default_value = "0", env)]
pub max_da_gas_price_change_percent: u16,

/// The URL for the DA Block Committer info
#[arg(long = "da-committer-url", env)]
pub da_committer_url: Option<String>,
Expand Down Expand Up @@ -312,6 +324,9 @@ impl Command {
min_gas_price,
gas_price_threshold_percent,
min_da_gas_price,
da_p_component,
da_d_component,
max_da_gas_price_change_percent,
da_committer_url,
consensus_key,
#[cfg(feature = "aws-kms")]
Expand Down Expand Up @@ -618,9 +633,9 @@ impl Command {
memory_pool_size,
da_gas_price_factor: NonZeroU64::new(100).expect("100 is not zero"),
min_da_gas_price,
max_da_gas_price_change_percent: 0,
da_p_component: 0,
da_d_component: 0,
max_da_gas_price_change_percent,
da_p_component,
da_d_component,
activity_normal_range_size: 100,
activity_capped_range_size: 0,
activity_decrease_range_size: 0,
Expand Down
2 changes: 1 addition & 1 deletion crates/services/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ async fn run<S>(
let mut task = service
.into_task(&state, params)
.await
.expect("The initialization of the service failed.");
.expect("The initialization of the service failed");

sender.send_if_modified(|s| {
if s.starting() {
Expand Down
24 changes: 13 additions & 11 deletions tests/tests/gas_price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,13 @@ use fuel_core_gas_price_service::v1::da_source_service::block_committer_costs::R

#[test]
fn produce_block__l1_committed_block_effects_gas_price() {
let _ = tracing_subscriber::fmt()
.with_max_level(tracing::Level::DEBUG)
.try_init();

let rt = tokio::runtime::Runtime::new().unwrap();
// set up chain with single unrecorded block
let args = vec![
let mut args = vec![
"--debug",
"--poa-instant",
"true",
Expand All @@ -435,6 +439,7 @@ fn produce_block__l1_committed_block_effects_gas_price() {
let driver = FuelCoreDriver::spawn(&args).await.unwrap();
driver.client.produce_blocks(1, None).await.unwrap();
let first_gas_price = driver.client.latest_gas_price().await.unwrap().gas_price;
tokio::time::sleep(Duration::from_millis(100)).await;
let temp_dir = driver.kill().await;
(first_gas_price, temp_dir)
});
Expand All @@ -445,20 +450,17 @@ fn produce_block__l1_committed_block_effects_gas_price() {
let mock = FakeServer::new();
let url = mock.url();

let args = vec![
"--debug",
"--poa-instant",
"true",
"--da-committer-url",
&url,
"--min-da-gas-price",
"100",
];
// add the da committer url to the args
args.extend(&["--da-committer-url", &url]);

rt.block_on(async {
let _driver = FuelCoreDriver::spawn_with_directory(temp_dir, &args)
let driver = FuelCoreDriver::spawn_with_directory(temp_dir, &args)
.await
.unwrap();
tokio::time::sleep(Duration::from_millis(100)).await;
driver.client.produce_blocks(1, None).await.unwrap();
let new_gas_price = driver.client.latest_gas_price().await.unwrap().gas_price;
assert_ne!(first_gas_price, new_gas_price);
});
}

Expand Down

0 comments on commit 434f764

Please sign in to comment.