fix(compression): improve robustness on startup and shutdown (#2923)
## Linked Issues/PRs <!-- List of related issues/PRs --> - closes https://github.com/FuelLabs/fuel-core/issues/2921 ## Description <!-- List of detailed changes --> The most important changes include the addition of a new adapter for block importing with compression, the implementation of traits for managing block heights, and the synchronization of previously produced blocks in the compression service. ### Enhancements to Block Importing and Compression: * [`crates/fuel-core/src/service/adapters/compression_adapters.rs`](diffhunk://#diff-9e66cb09255fa99a40c07b24f3002b040d023c09b9469521b2c8ad8736bf33bfL3-R66): Added `CompressionBlockImporterAdapter` to wrap around `BlockImporterAdapter` and handle block importing with compression. Implemented the `block_source::BlockSource` trait for this new adapter. * [`crates/fuel-core/src/service/adapters/import_result_provider.rs`](diffhunk://#diff-f348279c169cadf9d32da0b9f0b0e56b500551043908681479c91d52edb0a38cR37-R45): Introduced the `BlockAt` enum to represent either the Genesis Block or a block at a specific height. ### Implementation of Traits for Managing Block Heights: * [`crates/fuel-core/src/service/adapters/compression_adapters.rs`](diffhunk://#diff-9e66cb09255fa99a40c07b24f3002b040d023c09b9469521b2c8ad8736bf33bfR78-R89): Implemented the `compression_storage::LatestHeight` trait for `Database<CompressionDatabase>` and the `canonical_height::CanonicalHeight` trait for `Database<OnChain>`. * [`crates/services/compression/src/ports/compression_storage.rs`](diffhunk://#diff-766e163ef7ab6dd00944205be543374cd60cefb2fb5605467d2365ca71938cbbR15-R34): Added the `LatestHeight` trait for getting the latest height of the compression storage. * [`crates/services/compression/src/ports/canonical_height.rs`](diffhunk://#diff-4d817b8fba982a301ad44b5df62a6e7543cc6765df8cf92e8a6ec59d378b5ea1R1-R8): Introduced the `CanonicalHeight` trait to provide the canonical height of the blockchain. ### Synchronization of Previously Produced Blocks: * [`crates/services/compression/src/service.rs`](diffhunk://#diff-9fc61045febb6284fa8e01c5c33172787228fe21b8b813c62c8f03d2fec55fe8R143-R176): Enhanced the `CompressionService` to include methods for synchronizing previously produced blocks and handling new blocks during shutdown. [[1]](diffhunk://#diff-9fc61045febb6284fa8e01c5c33172787228fe21b8b813c62c8f03d2fec55fe8R143-R176) [[2]](diffhunk://#diff-9fc61045febb6284fa8e01c5c33172787228fe21b8b813c62c8f03d2fec55fe8L216-R305) ## Checklist - [ ] Breaking changes are clearly marked as such in the PR description and changelog - [ ] New behavior is reflected in tests - [ ] [The specification](https://github.com/FuelLabs/fuel-specs/) matches the implemented behavior (link update PR if changes are needed) ### Before requesting review - [ ] I have reviewed the code myself - [ ] I have created follow-up issues caused by this PR and linked them here ### After merging, notify other teams [Add or remove entries as needed] - [ ] [Rust SDK](https://github.com/FuelLabs/fuels-rs/) - [ ] [Sway compiler](https://github.com/FuelLabs/sway/) - [ ] [Platform documentation](https://github.com/FuelLabs/devrel-requests/issues/new?assignees=&labels=new+request&projects=&template=NEW-REQUEST.yml&title=%5BRequest%5D%3A+) (for out-of-organization contributors, the person merging the PR will do this) - [ ] Someone else? --------- Co-authored-by: green <xgreenx9999@gmail.com>
A
Aaryamann Challani committed
6683ba2d891009e6b68e885945a4b76c3119724b
Parent: 6a1f8e9
Committed by GitHub <noreply@github.com>
on 4/7/2025, 2:20:36 PM