diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d2eb162853..88011905992 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Changed +-[2076](https://github.com/FuelLabs/fuel-core/pull/2076): Replace usages of `iter_all` with `iter_all_keys` where necessary. + ## [Version 0.32.1] ### Added diff --git a/bin/fuel-core/chainspec/local-testnet/state_transition_bytecode.wasm b/bin/fuel-core/chainspec/local-testnet/state_transition_bytecode.wasm index e850e13ba25..267515cba00 100755 Binary files a/bin/fuel-core/chainspec/local-testnet/state_transition_bytecode.wasm and b/bin/fuel-core/chainspec/local-testnet/state_transition_bytecode.wasm differ diff --git a/crates/fuel-core/src/database.rs b/crates/fuel-core/src/database.rs index f642f2dbcb7..0b085c5165c 100644 --- a/crates/fuel-core/src/database.rs +++ b/crates/fuel-core/src/database.rs @@ -127,10 +127,9 @@ pub type GenesisDatabase = Database StorageResult { - self.iter_all::(Some(IterDirection::Reverse)) + self.iter_all_keys::(Some(IterDirection::Reverse)) .next() .ok_or(not_found!("BlockHeight"))? - .map(|(height, _)| height) } pub fn latest_block(&self) -> StorageResult { @@ -328,8 +327,7 @@ where impl Modifiable for Database { fn commit_changes(&mut self, changes: Changes) -> StorageResult<()> { commit_changes_with_height_update(self, changes, |iter| { - iter.iter_all::(Some(IterDirection::Reverse)) - .map(|result| result.map(|(height, _)| height)) + iter.iter_all_keys::(Some(IterDirection::Reverse)) .try_collect() }) } @@ -348,8 +346,7 @@ impl Modifiable for Database { impl Modifiable for Database { fn commit_changes(&mut self, changes: Changes) -> StorageResult<()> { commit_changes_with_height_update(self, changes, |iter| { - iter.iter_all::(Some(IterDirection::Reverse)) - .map(|result| result.map(|(height, _)| height)) + iter.iter_all_keys::(Some(IterDirection::Reverse)) .try_collect() }) } @@ -359,10 +356,9 @@ impl Modifiable for Database { impl Modifiable for Database { fn commit_changes(&mut self, changes: Changes) -> StorageResult<()> { commit_changes_with_height_update(self, changes, |iter| { - iter.iter_all::(Some( + iter.iter_all_keys::(Some( IterDirection::Reverse, )) - .map(|result| result.map(|(height, _)| height)) .try_collect() }) } diff --git a/crates/fuel-core/src/database/coin.rs b/crates/fuel-core/src/database/coin.rs index b2d0ee2fbdf..4c94d202bd7 100644 --- a/crates/fuel-core/src/database/coin.rs +++ b/crates/fuel-core/src/database/coin.rs @@ -35,18 +35,18 @@ impl OffChainIterableKeyValueView { direction: Option, ) -> impl Iterator> + '_ { let start_coin = start_coin.map(|b| owner_coin_id_key(owner, &b)); - self.iter_all_filtered::( - Some(*owner), start_coin.as_ref(), + self.iter_all_filtered_keys::( + Some(*owner), + start_coin.as_ref(), direction, ) - // Safety: key is always 64 bytes .map(|res| { - res.map(|(key, _)| { + res.map(|key| { UtxoId::new( TxId::try_from(&key[32..64]).expect("The slice has size 32"), u16::from_be_bytes( key[64..].try_into().expect("The slice has size 2"), - ) + ), ) }) }) diff --git a/crates/fuel-core/src/database/message.rs b/crates/fuel-core/src/database/message.rs index 03ea65f6eee..b50fd53a232 100644 --- a/crates/fuel-core/src/database/message.rs +++ b/crates/fuel-core/src/database/message.rs @@ -36,12 +36,12 @@ impl OffChainIterableKeyValueView { ) -> impl Iterator> + '_ { let start_message_id = start_message_id.map(|msg_id| OwnedMessageKey::new(owner, &msg_id)); - self.iter_all_filtered::( + self.iter_all_filtered_keys::( Some(*owner), start_message_id.as_ref(), direction, ) - .map(|res| res.map(|(key, _)| *key.nonce())) + .map(|res| res.map(|key| *key.nonce())) } pub fn message_is_spent(&self, id: &Nonce) -> StorageResult { diff --git a/crates/fuel-core/src/database/sealed_block.rs b/crates/fuel-core/src/database/sealed_block.rs index 4cddb716fed..23bfe717fe9 100644 --- a/crates/fuel-core/src/database/sealed_block.rs +++ b/crates/fuel-core/src/database/sealed_block.rs @@ -52,11 +52,9 @@ impl OnChainIterableKeyValueView { } pub fn genesis_height(&self) -> StorageResult> { - Ok(self - .iter_all::(Some(IterDirection::Forward)) + self.iter_all_keys::(Some(IterDirection::Forward)) .next() - .transpose()? - .map(|(height, _)| height)) + .transpose() } pub fn genesis_block(&self) -> StorageResult> { diff --git a/crates/fuel-core/src/service/adapters/block_importer.rs b/crates/fuel-core/src/service/adapters/block_importer.rs index c4085ecddb7..bd94e36f9a1 100644 --- a/crates/fuel-core/src/service/adapters/block_importer.rs +++ b/crates/fuel-core/src/service/adapters/block_importer.rs @@ -85,11 +85,9 @@ impl BlockVerifier for VerifierAdapter { impl ImporterDatabase for Database { fn latest_block_height(&self) -> StorageResult> { - Ok(self - .iter_all::(Some(IterDirection::Reverse)) + self.iter_all_keys::(Some(IterDirection::Reverse)) .next() - .transpose()? - .map(|(height, _)| height)) + .transpose() } fn latest_block_root(&self) -> StorageResult> { diff --git a/crates/fuel-core/src/service/genesis.rs b/crates/fuel-core/src/service/genesis.rs index a2ba7f211de..b7b3363db49 100644 --- a/crates/fuel-core/src/service/genesis.rs +++ b/crates/fuel-core/src/service/genesis.rs @@ -83,13 +83,11 @@ pub async fn execute_genesis_block( let genesis_progress_on_chain: Vec = db .on_chain() - .iter_all::>(None) - .map_ok(|(k, _)| k) + .iter_all_keys::>(None) .try_collect()?; let genesis_progress_off_chain: Vec = db .off_chain() - .iter_all::>(None) - .map_ok(|(k, _)| k) + .iter_all_keys::>(None) .try_collect()?; let chain_config = config.snapshot_reader.chain_config();