Skip to content

Commit

Permalink
Set Latest Recorded Height on startup (#2603)
Browse files Browse the repository at this point in the history
## Linked Issues/PRs
<!-- List of related issues/PRs -->
closes #2613

## Description
<!-- List of detailed changes -->
This improves the behavior for debugging the code--for long-running
sessions it won't change anything. If this isn't set on. startup, it
will be delayed each time you restart the node unless it runs long
enough to receive DA costs. These changes persists the expectations from
the _first_ run.

## Checklist
- [x] New behavior is reflected in tests
  • Loading branch information
MitchTurner authored Jan 22, 2025
1 parent 8c553d6 commit fbe2f87
Show file tree
Hide file tree
Showing 10 changed files with 347 additions and 33 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
- [2551](https://github.com/FuelLabs/fuel-core/pull/2551): Enhanced the DA compressed block header to include block id.

### Changed
- [2603](https://github.com/FuelLabs/fuel-core/pull/2603): Sets the latest recorded height on initialization, not just when DA costs are received

### Fixed
- [2612](https://github.com/FuelLabs/fuel-core/pull/2612): Use latest gas price to estimate next block gas price in tx pool instead of using algorithm directly
- [2609](https://github.com/FuelLabs/fuel-core/pull/2609): Check response before trying to deserialize, return error instead
Expand Down
7 changes: 7 additions & 0 deletions bin/fuel-core/src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ pub struct Command {
#[arg(long = "da-poll-interval", env)]
pub da_poll_interval: Option<humantime::Duration>,

/// The L2 height the Gas Price Service will assume is already recorded on DA
/// i.e. If you want the Gas Price Service to look for the costs of block 1000, set to 999
#[arg(long = "da-starting-recorded-height", env)]
da_starting_recorded_height: Option<u32>,

/// The signing key used when producing blocks.
/// Setting via the `CONSENSUS_KEY_SECRET` ENV var is preferred.
#[arg(long = "consensus-key", env = "CONSENSUS_KEY_SECRET")]
Expand Down Expand Up @@ -377,6 +382,7 @@ impl Command {
da_gas_price_d_component,
da_committer_url,
da_poll_interval,
da_starting_recorded_height: starting_recorded_height,
consensus_key,
#[cfg(feature = "aws-kms")]
consensus_aws_kms,
Expand Down Expand Up @@ -698,6 +704,7 @@ impl Command {
time_until_synced: time_until_synced.into(),
memory_pool_size,
da_gas_price_factor: NonZeroU64::new(100).expect("100 is not zero"),
starting_recorded_height,
min_da_gas_price,
max_da_gas_price,
max_da_gas_price_change_percent: gas_price_change_percent,
Expand Down
3 changes: 3 additions & 0 deletions crates/fuel-core/src/service/adapters/gas_price_adapters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ impl From<Config> for V1AlgorithmConfig {
block_activity_threshold: value.block_activity_threshold,
da_poll_interval: value.da_poll_interval,
gas_price_factor: value.da_gas_price_factor,
starting_recorded_height: value
.starting_recorded_height
.map(BlockHeight::from),
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/fuel-core/src/service/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pub struct Config {
/// The size of the memory pool in number of `MemoryInstance`s.
pub memory_pool_size: usize,
pub da_gas_price_factor: NonZeroU64,
pub starting_recorded_height: Option<u32>,
pub min_da_gas_price: u64,
pub max_da_gas_price: u64,
pub max_da_gas_price_change_percent: u16,
Expand Down Expand Up @@ -208,6 +209,7 @@ impl Config {
time_until_synced: Duration::ZERO,
memory_pool_size: 4,
da_gas_price_factor: NonZeroU64::new(100).expect("100 is not zero"),
starting_recorded_height: None,
min_da_gas_price: 0,
max_da_gas_price: 1,
max_da_gas_price_change_percent: 0,
Expand Down
2 changes: 2 additions & 0 deletions crates/services/gas_price_service/src/v1/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::v0::metadata::V0Metadata;
use fuel_core_types::fuel_types::BlockHeight;
use fuel_gas_price_algorithm::v1::{
AlgorithmUpdaterV1,
L2ActivityTracker,
Expand Down Expand Up @@ -80,6 +81,7 @@ pub struct V1AlgorithmConfig {
pub block_activity_threshold: u8,
/// The interval at which the `DaSourceService` polls for new data
pub da_poll_interval: Option<Duration>,
pub starting_recorded_height: Option<BlockHeight>,
}

pub fn updater_from_config(
Expand Down
Loading

0 comments on commit fbe2f87

Please sign in to comment.