Skip to content

Commit

Permalink
Merge branch 'master' into fix_message_receipts_proofs
Browse files Browse the repository at this point in the history
  • Loading branch information
AurelienFT authored Dec 10, 2024
2 parents 0db9967 + ab053a8 commit 6966c0b
Show file tree
Hide file tree
Showing 17 changed files with 934 additions and 21 deletions.
4 changes: 3 additions & 1 deletion .cargo/audit.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[advisories]
ignore = []
ignore = [
"RUSTSEC-2024-0421" # https://github.com/FuelLabs/fuel-core/issues/2488
]
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]

### Added
- [2442](https://github.com/FuelLabs/fuel-core/pull/2442): Add uninitialized task for V1 gas price service
- [2154](https://github.com/FuelLabs/fuel-core/pull/2154): Added `Unknown` variant to `ConsensusParameters` graphql queries
- [2154](https://github.com/FuelLabs/fuel-core/pull/2154): Added `Unknown` variant to `Block` graphql queries
- [2154](https://github.com/FuelLabs/fuel-core/pull/2154): Added `TransactionType` type in `fuel-client`
Expand Down Expand Up @@ -36,6 +37,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- [2413](https://github.com/FuelLabs/fuel-core/issues/2413): block production immediately errors if unable to lock the mutex.
- [2389](https://github.com/FuelLabs/fuel-core/pull/2389): Fix construction of reverse iterator in RocksDB.
- [2478](https://github.com/FuelLabs/fuel-core/pull/2478): Fix proof created by `message_receipts_proof` function by ignoring the receipts from failed transactions to match `message_outbox_root`.
- [2485](https://github.com/FuelLabs/fuel-core/pull/2485): Hardcode the timestamp of the genesis block and version of `tai64` to avoid breaking changes for us.

### Changed
- [2295](https://github.com/FuelLabs/fuel-core/pull/2295): `CombinedDb::from_config` now respects `state_rewind_policy` with tmp RocksDB.
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion crates/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ itertools = { workspace = true }
reqwest = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { version = "1.0", features = ["raw_value"] }
tai64 = { version = "4.1", features = ["serde"] }
# We force the version because 4.1.0 update leap seconds that breaks our timestamps
tai64 = { version = "=4.0.0", features = ["serde"] }
thiserror = "1.0"
tracing = "0.1"

Expand Down
3 changes: 2 additions & 1 deletion crates/fuel-core/src/service/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ pub fn create_genesis_block(config: &Config) -> Block {
consensus: ConsensusHeader::<Empty> {
prev_root,
height,
time: fuel_core_types::tai64::Tai64::UNIX_EPOCH,
// The time is set to UNIX_EPOCH + 10 leap seconds to make backward compatibility
time: fuel_core_types::tai64::Tai64(4611686018427387914),
generated: Empty,
},
},
Expand Down
2 changes: 1 addition & 1 deletion crates/fuel-gas-price-algorithm/src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub enum Error {
#[error("Could not calculate cost per byte: {bytes:?} bytes, {cost:?} cost")]
CouldNotCalculateCostPerByte { bytes: u128, cost: u128 },
#[error("Failed to include L2 block data: {0}")]
FailedTooIncludeL2BlockData(String),
FailedToIncludeL2BlockData(String),
#[error("L2 block expected but not found in unrecorded blocks: {height}")]
L2BlockExpectedNotFound { height: u32 },
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub fn get_block_info(
Ok(info)
}

fn mint_values(block: &Block<Transaction>) -> GasPriceResult<(u64, u64)> {
pub(crate) fn mint_values(block: &Block<Transaction>) -> GasPriceResult<(u64, u64)> {
let mint = block
.transactions()
.last()
Expand All @@ -121,6 +121,13 @@ fn mint_values(block: &Block<Transaction>) -> GasPriceResult<(u64, u64)> {
})?;
Ok((*mint.mint_amount(), *mint.gas_price()))
}

// TODO: Don't take a direct dependency on `Postcard` as it's not guaranteed to be the encoding format
// https://github.com/FuelLabs/fuel-core/issues/2443
pub(crate) fn block_bytes(block: &Block<Transaction>) -> u64 {
Postcard::encode(block).len() as u64
}

fn block_used_gas(
fee: u64,
gas_price: u64,
Expand Down
2 changes: 2 additions & 0 deletions crates/services/gas_price_service/src/v0/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,15 @@ where
Metadata: MetadataStorage,
{
async fn run(&mut self, watcher: &mut StateWatcher) -> TaskNextAction {
tracing::trace!("Call of `run` function of the gas price service v0");
tokio::select! {
biased;
_ = watcher.while_started() => {
tracing::debug!("Stopping gas price service");
TaskNextAction::Stop
}
l2_block_res = self.l2_block_source.get_l2_block() => {
tracing::debug!("Received L2 block");
let res = self.process_l2_block_res(l2_block_res).await;
TaskNextAction::always_continue(res)
}
Expand Down
22 changes: 11 additions & 11 deletions crates/services/gas_price_service/src/v0/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,16 @@ async fn next_gas_price__affected_by_new_l2_block() {
algo_updater,
);

tracing::debug!("service created");

let read_algo = service.next_block_algorithm();
let initial = read_algo.next_gas_price();
let mut watcher = StateWatcher::default();
let mut watcher = StateWatcher::started();
tokio::spawn(async move { service.run(&mut watcher).await });

// when
service.run(&mut watcher).await;
l2_block_sender.send(l2_block).await.unwrap();
service.shutdown().await.unwrap();
tokio::time::sleep(std::time::Duration::from_millis(10)).await;

// then
let new = read_algo.next_gas_price();
Expand Down Expand Up @@ -212,18 +214,16 @@ async fn next__new_l2_block_saves_old_metadata() {
algo_updater,
);

// when
let read_algo = service.next_block_algorithm();
let mut watcher = StateWatcher::default();
let start = read_algo.next_gas_price();
let mut watcher = StateWatcher::started();
tokio::spawn(async move { service.run(&mut watcher).await });

service.run(&mut watcher).await;
// when
l2_block_sender.send(l2_block).await.unwrap();
service.shutdown().await.unwrap();
tokio::time::sleep(std::time::Duration::from_millis(10)).await;

// then
let new = read_algo.next_gas_price();
assert_ne!(start, new);
let metadata_has_been_updated = metadata_inner.lock().unwrap().is_some();
assert!(metadata_has_been_updated);
}

#[derive(Clone)]
Expand Down
4 changes: 4 additions & 0 deletions crates/services/gas_price_service/src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ pub mod algorithm;
pub mod da_source_service;
pub mod metadata;
pub mod service;

#[cfg(test)]
mod tests;
pub mod uninitialized_task;
6 changes: 5 additions & 1 deletion crates/services/gas_price_service/src/v1/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ impl From<&V1AlgorithmConfig> for AlgorithmUpdaterV1 {
.map(|size| u128::from(*size))
.sum();
Self {
new_scaled_exec_price: value.new_exec_gas_price,
// TODO:We don't need this after we implement
// https://github.com/FuelLabs/fuel-core/issues/2481
new_scaled_exec_price: value
.new_exec_gas_price
.saturating_mul(value.gas_price_factor.get()),
l2_block_height: 0,
new_scaled_da_gas_price: value.min_da_gas_price,
gas_price_factor: value.gas_price_factor,
Expand Down
2 changes: 1 addition & 1 deletion crates/services/gas_price_service/src/v1/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ where
async fn shutdown(mut self) -> anyhow::Result<()> {
// handle all the remaining l2 blocks
while let Some(Ok(block)) = self.l2_block_source.get_l2_block().now_or_never() {
tracing::debug!("Updating gas price algorithm");
tracing::debug!("Updating gas price algorithm before shutdown");
self.apply_block_info_to_gas_algorithm(block).await?;
}

Expand Down
Loading

0 comments on commit 6966c0b

Please sign in to comment.