Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ MSP stop storing buckets for insolvent user task #366

Merged
merged 51 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
1421e29
refactor: :zap: update move bucket requests for clarity and storage e…
TDemeco Feb 9, 2025
fa14694
chore: :label: run typegen
TDemeco Feb 9, 2025
17bade5
fix: :bug: remove `previous_msp_id` from move bucket request metadata
TDemeco Feb 9, 2025
9b0541c
feat: :construction: initial impl of stop storing bucket for insolven…
TDemeco Feb 9, 2025
b7a61dd
chore: :art: run cargo fmt
TDemeco Feb 9, 2025
eb171df
fix: :rotating_light: update file system benchmark
TDemeco Feb 9, 2025
e15eca3
Merge branch 'refactor/move-bucket-requests' into feat/stop-storing-b…
TDemeco Feb 10, 2025
dfad1c6
fix: :adhesive_bandage: update `get_provider_id` call
TDemeco Feb 10, 2025
df1a96c
Merge branch 'main' into refactor/move-bucket-requests
TDemeco Feb 10, 2025
4d3c631
chore: :label: run typegen
TDemeco Feb 10, 2025
626095e
Merge branch 'refactor/move-bucket-requests' into feat/stop-storing-b…
TDemeco Feb 10, 2025
afd1c60
test: :white_check_mark: add tests for `msp_stop_storing_bucket_for_i…
TDemeco Feb 11, 2025
39352b2
test: :white_check_mark: fix testing
TDemeco Feb 11, 2025
7fa22f4
chore: :label: run typegen
TDemeco Feb 11, 2025
c7fe2c3
fix: :bug: add solvency check when issuing storage requests
TDemeco Feb 11, 2025
6339d65
chore: :label: run typegen
TDemeco Feb 11, 2025
90c9102
feat: :sparkles: add task for MSP to stop storing buckets of insolven…
TDemeco Feb 12, 2025
142ee74
fix: :bug: avoid the task processing multiple times the same bucket
TDemeco Feb 12, 2025
8b58d2b
fix: :bug: get only buckets stored by the current MSP (instead of all)
TDemeco Feb 12, 2025
06fb7e0
perf: :zap: remove unneeded fetch from indexer db
TDemeco Feb 12, 2025
5ab7eb1
Merge branch 'main' into refactor/move-bucket-requests
TDemeco Feb 12, 2025
8dc456a
Merge branch 'refactor/move-bucket-requests' into feat/stop-storing-b…
TDemeco Feb 12, 2025
229b9cb
Merge branch 'feat/stop-storing-bucket-insolvent-user' into feat/msp-…
TDemeco Feb 12, 2025
f175c66
feat: :chart_with_upwards_trend: benchmark file system
TDemeco Feb 12, 2025
ee7a994
perf: :zap: drop file write lock asap
TDemeco Feb 12, 2025
0158435
test: :white_check_mark: add integration test for MSP stop storing bu…
TDemeco Feb 12, 2025
7c2bb19
Merge branch 'feat/stop-storing-bucket-insolvent-user' into feat/msp-…
TDemeco Feb 12, 2025
86a6ede
Merge branch 'main' into refactor/move-bucket-requests
ffarall Feb 13, 2025
150ee80
chore: :label: Update api-augment after merge
ffarall Feb 14, 2025
d362ab5
fix: :rotating_light: Fix compiler errors in test after merge
ffarall Feb 14, 2025
54b74d1
refactor: :recycle: Rename `MoveBucketRequestedForNewMsp` -> `MoveBuc…
ffarall Feb 14, 2025
c9da002
Merge branch 'refactor/move-bucket-requests' into feat/stop-storing-b…
TDemeco Feb 14, 2025
242fcaa
fix: :adhesive_bandage: fix after merge from main
TDemeco Feb 14, 2025
53b853b
Merge branch 'main' into feat/stop-storing-bucket-insolvent-user
ffarall Feb 14, 2025
f56ef13
chore: :label: Update `api-augment` after merge
ffarall Feb 14, 2025
fb21c7c
fix: :adhesive_bandage: Fix typo
ffarall Feb 14, 2025
0acfad1
Merge branch 'feat/stop-storing-bucket-insolvent-user' into feat/msp-…
TDemeco Feb 14, 2025
adf814c
fix: :adhesive_bandage: minor fixes after merge from main
TDemeco Feb 14, 2025
c116cc3
Merge branch 'main' into feat/msp-task-stop-storing-insolvent-user
ffarall Feb 14, 2025
b9b3948
docs: :bulb: Minor improvement of doc comment of task
ffarall Feb 14, 2025
f9ff4c7
impl query_buckets_for_insolvent_user runtime api in favor of queryin…
snowmead Feb 17, 2025
c713742
Merge branch 'main' into feat/msp-task-stop-storing-insolvent-user
snowmead Feb 17, 2025
2ec2cb1
remove `get_by_msp_id_and_owner` indexer db function. remove `Process…
snowmead Feb 18, 2025
99a2174
Merge branch 'main' into feat/msp-task-stop-storing-insolvent-user
TDemeco Feb 24, 2025
bac1e1d
refactor: :fire: remove now unneeded handling of `MspStopStoringBucke…
TDemeco Feb 24, 2025
1065480
refactor: :zap: make stop storing buckets for insolvent user task par…
TDemeco Feb 24, 2025
5d3dd45
test: :white_check_mark: fix integration test after changes
TDemeco Feb 25, 2025
1efaae1
test: :fire: remove `only` from MSP stop storing bucket for insolvent…
TDemeco Feb 25, 2025
ed17bc9
Update node/src/tasks/msp_stop_storing_insolvent_user.rs
TDemeco Feb 27, 2025
0d70e94
Merge branch 'main' into feat/msp-task-stop-storing-insolvent-user
TDemeco Feb 27, 2025
217b84e
chore: :label: run typegen
TDemeco Feb 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions api-augment/dist/types/interfaces/augment-api-runtime.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import type {
QueryAvailableStorageCapacityError,
QueryBspConfirmChunksToProveForFileError,
QueryBucketsForMspError,
QueryBucketsOfUserStoredByMspError,
QueryEarliestChangeCapacityBlockError,
QueryFileEarliestVolunteerBlockError,
QueryMspConfirmChunksToProveForFileError,
Expand Down Expand Up @@ -689,6 +690,16 @@ declare module "@polkadot/api-base/types/calls" {
mspId: MainStorageProviderId | string | Uint8Array
) => Observable<Result<Vec<BucketId>, QueryBucketsForMspError>>
>;
/**
* Query the buckets stored by an MSP that belong to a specific user.
**/
queryBucketsOfUserStoredByMsp: AugmentedCall<
ApiType,
(
mspId: ProviderId | string | Uint8Array,
user: AccountId | string | Uint8Array
) => Observable<Result<Vec<H256>, QueryBucketsOfUserStoredByMspError>>
>;
/**
* Query the earliest block number that a BSP can change its capacity.
**/
Expand Down
2 changes: 2 additions & 0 deletions api-augment/dist/types/interfaces/augment-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,7 @@ import type {
QueryAvailableStorageCapacityError,
QueryBspConfirmChunksToProveForFileError,
QueryBucketsForMspError,
QueryBucketsOfUserStoredByMspError,
QueryConfirmChunksToProveForFileError,
QueryEarliestChangeCapacityBlockError,
QueryFileEarliestVolunteerBlockError,
Expand Down Expand Up @@ -2219,6 +2220,7 @@ declare module "@polkadot/types/types/registry" {
QueryAvailableStorageCapacityError: QueryAvailableStorageCapacityError;
QueryBspConfirmChunksToProveForFileError: QueryBspConfirmChunksToProveForFileError;
QueryBucketsForMspError: QueryBucketsForMspError;
QueryBucketsOfUserStoredByMspError: QueryBucketsOfUserStoredByMspError;
QueryConfirmChunksToProveForFileError: QueryConfirmChunksToProveForFileError;
QueryEarliestChangeCapacityBlockError: QueryEarliestChangeCapacityBlockError;
QueryFileEarliestVolunteerBlockError: QueryFileEarliestVolunteerBlockError;
Expand Down
6 changes: 6 additions & 0 deletions api-augment/dist/types/interfaces/storagehubclient/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ export interface QueryBucketsForMspError extends Enum {
readonly isInternalError: boolean;
readonly type: "ProviderNotRegistered" | "InternalError";
}
/** @name QueryBucketsOfUserStoredByMspError */
export interface QueryBucketsOfUserStoredByMspError extends Enum {
readonly isNotAnMsp: boolean;
readonly isInternalError: boolean;
readonly type: "NotAnMsp" | "InternalError";
}
/** @name QueryConfirmChunksToProveForFileError */
export interface QueryConfirmChunksToProveForFileError extends Enum {
readonly isChallengedChunkToChunkIdError: boolean;
Expand Down
11 changes: 11 additions & 0 deletions api-augment/src/interfaces/augment-api-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import type {
QueryAvailableStorageCapacityError,
QueryBspConfirmChunksToProveForFileError,
QueryBucketsForMspError,
QueryBucketsOfUserStoredByMspError,
QueryEarliestChangeCapacityBlockError,
QueryFileEarliestVolunteerBlockError,
QueryMspConfirmChunksToProveForFileError,
Expand Down Expand Up @@ -639,6 +640,16 @@ declare module "@polkadot/api-base/types/calls" {
mspId: MainStorageProviderId | string | Uint8Array
) => Observable<Result<Vec<BucketId>, QueryBucketsForMspError>>
>;
/**
* Query the buckets stored by an MSP that belong to a specific user.
**/
queryBucketsOfUserStoredByMsp: AugmentedCall<
ApiType,
(
mspId: ProviderId | string | Uint8Array,
user: AccountId | string | Uint8Array
) => Observable<Result<Vec<H256>, QueryBucketsOfUserStoredByMspError>>
>;
/**
* Query the earliest block number that a BSP can change its capacity.
**/
Expand Down
2 changes: 2 additions & 0 deletions api-augment/src/interfaces/augment-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,7 @@ import type {
QueryAvailableStorageCapacityError,
QueryBspConfirmChunksToProveForFileError,
QueryBucketsForMspError,
QueryBucketsOfUserStoredByMspError,
QueryConfirmChunksToProveForFileError,
QueryEarliestChangeCapacityBlockError,
QueryFileEarliestVolunteerBlockError,
Expand Down Expand Up @@ -2226,6 +2227,7 @@ declare module "@polkadot/types/types/registry" {
QueryAvailableStorageCapacityError: QueryAvailableStorageCapacityError;
QueryBspConfirmChunksToProveForFileError: QueryBspConfirmChunksToProveForFileError;
QueryBucketsForMspError: QueryBucketsForMspError;
QueryBucketsOfUserStoredByMspError: QueryBucketsOfUserStoredByMspError;
QueryConfirmChunksToProveForFileError: QueryConfirmChunksToProveForFileError;
QueryEarliestChangeCapacityBlockError: QueryEarliestChangeCapacityBlockError;
QueryFileEarliestVolunteerBlockError: QueryFileEarliestVolunteerBlockError;
Expand Down
7 changes: 7 additions & 0 deletions api-augment/src/interfaces/storagehubclient/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ export interface QueryBucketsForMspError extends Enum {
readonly type: "ProviderNotRegistered" | "InternalError";
}

/** @name QueryBucketsOfUserStoredByMspError */
export interface QueryBucketsOfUserStoredByMspError extends Enum {
readonly isNotAnMsp: boolean;
readonly isInternalError: boolean;
readonly type: "NotAnMsp" | "InternalError";
}

/** @name QueryConfirmChunksToProveForFileError */
export interface QueryConfirmChunksToProveForFileError extends Enum {
readonly isChallengedChunkToChunkIdError: boolean;
Expand Down
34 changes: 32 additions & 2 deletions client/blockchain-service/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ use pallet_proofs_dealer_runtime_api::{
GetChallengePeriodError, GetCheckpointChallengesError, GetProofSubmissionRecordError,
};
use pallet_storage_providers_runtime_api::{
GetBspInfoError, QueryAvailableStorageCapacityError, QueryEarliestChangeCapacityBlockError,
QueryMspIdOfBucketIdError, QueryProviderMultiaddressesError, QueryStorageProviderCapacityError,
GetBspInfoError, QueryAvailableStorageCapacityError, QueryBucketsOfUserStoredByMspError,
QueryEarliestChangeCapacityBlockError, QueryMspIdOfBucketIdError,
QueryProviderMultiaddressesError, QueryStorageProviderCapacityError,
};
use shc_actors_framework::actor::ActorHandle;
use shc_common::types::{
Expand Down Expand Up @@ -201,6 +202,12 @@ pub enum BlockchainServiceCommand {
request: FileDeletionRequest,
callback: tokio::sync::oneshot::Sender<Result<()>>,
},
QueryBucketsOfUserStoredByMsp {
msp_id: ProviderId,
user: AccountId,
callback:
tokio::sync::oneshot::Sender<Result<Vec<BucketId>, QueryBucketsOfUserStoredByMspError>>,
},
}

/// Interface for interacting with the BlockchainService actor.
Expand Down Expand Up @@ -395,6 +402,13 @@ pub trait BlockchainServiceInterface {
&self,
forest_root_write_tx: tokio::sync::oneshot::Sender<()>,
) -> Result<()>;

/// Helper function to query all the buckets stored by an MSP that belong to a specific user.
async fn query_buckets_of_user_stored_by_msp(
&self,
msp_id: ProviderId,
user: AccountId,
) -> Result<Vec<BucketId>, QueryBucketsOfUserStoredByMspError>;
}

/// Implement the BlockchainServiceInterface for the ActorHandle<BlockchainService>.
Expand Down Expand Up @@ -903,4 +917,20 @@ where
self.send(message).await;
rx.await.expect("Failed to receive response from BlockchainService. Probably means BlockchainService has crashed.")
}

/// Helper function to query all the buckets stored by an MSP that belong to a specific user.
async fn query_buckets_of_user_stored_by_msp(
&self,
msp_id: ProviderId,
user: AccountId,
) -> Result<Vec<BucketId>, QueryBucketsOfUserStoredByMspError> {
let (callback, rx) = tokio::sync::oneshot::channel();
let message = BlockchainServiceCommand::QueryBucketsOfUserStoredByMsp {
msp_id,
user,
callback,
};
self.send(message).await;
rx.await.expect("Failed to receive response from BlockchainService. Probably means BlockchainService has crashed.")
}
}
23 changes: 23 additions & 0 deletions client/blockchain-service/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,18 @@ pub struct SpStopStoringInsolventUser {
}
impl EventBusMessage for SpStopStoringInsolventUser {}

/// A MSP stopped storing a bucket for an insolvent user event was finalised.
///
/// This event is emitted when the relay chain block to which a block in which a MSP stopped storing a bucket
/// for an insolvent user event is anchored has been finalised.
#[derive(Debug, Clone)]
pub struct FinalisedMspStopStoringBucketInsolventUser {
pub msp_id: ProofsDealerProviderId,
pub bucket_id: BucketId,
}

impl EventBusMessage for FinalisedMspStopStoringBucketInsolventUser {}

/// A user has requested to move one of its bucket to a new MSP.
///
/// This event is emitted so the BSP can allow the new MSP to download the files from the bucket.
Expand Down Expand Up @@ -462,6 +474,8 @@ pub struct BlockchainServiceEventBusProvider {
last_chargeable_info_updated_event_bus: EventBus<LastChargeableInfoUpdated>,
user_without_funds_event_bus: EventBus<UserWithoutFunds>,
sp_stop_storing_insolvent_user_event_bus: EventBus<SpStopStoringInsolventUser>,
finalised_msp_stop_storing_bucket_insolvent_user_event_bus:
EventBus<FinalisedMspStopStoringBucketInsolventUser>,
finalised_msp_stopped_storing_bucket_event_bus: EventBus<FinalisedMspStoppedStoringBucket>,
move_bucket_requested_event_bus: EventBus<MoveBucketRequested>,
move_bucket_rejected_event_bus: EventBus<MoveBucketRejected>,
Expand Down Expand Up @@ -496,6 +510,7 @@ impl BlockchainServiceEventBusProvider {
last_chargeable_info_updated_event_bus: EventBus::new(),
user_without_funds_event_bus: EventBus::new(),
sp_stop_storing_insolvent_user_event_bus: EventBus::new(),
finalised_msp_stop_storing_bucket_insolvent_user_event_bus: EventBus::new(),
finalised_msp_stopped_storing_bucket_event_bus: EventBus::new(),
move_bucket_requested_event_bus: EventBus::new(),
move_bucket_rejected_event_bus: EventBus::new(),
Expand Down Expand Up @@ -599,6 +614,14 @@ impl ProvidesEventBus<SpStopStoringInsolventUser> for BlockchainServiceEventBusP
}
}

impl ProvidesEventBus<FinalisedMspStopStoringBucketInsolventUser>
for BlockchainServiceEventBusProvider
{
fn event_bus(&self) -> &EventBus<FinalisedMspStopStoringBucketInsolventUser> {
&self.finalised_msp_stop_storing_bucket_insolvent_user_event_bus
}
}

impl ProvidesEventBus<FinalisedMspStoppedStoringBucket> for BlockchainServiceEventBusProvider {
fn event_bus(&self) -> &EventBus<FinalisedMspStoppedStoringBucket> {
&self.finalised_msp_stopped_storing_bucket_event_bus
Expand Down
56 changes: 47 additions & 9 deletions client/blockchain-service/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ use pallet_proofs_dealer_runtime_api::{
ProofsDealerApi,
};
use pallet_storage_providers_runtime_api::{
GetBspInfoError, QueryAvailableStorageCapacityError, QueryEarliestChangeCapacityBlockError,
QueryMspIdOfBucketIdError, QueryProviderMultiaddressesError, QueryStorageProviderCapacityError,
StorageProvidersApi,
GetBspInfoError, QueryAvailableStorageCapacityError, QueryBucketsOfUserStoredByMspError,
QueryEarliestChangeCapacityBlockError, QueryMspIdOfBucketIdError,
QueryProviderMultiaddressesError, QueryStorageProviderCapacityError, StorageProvidersApi,
};
use shc_actors_framework::actor::{Actor, ActorEventLoop};
use shc_common::{
Expand All @@ -52,11 +52,11 @@ use crate::{
events::{
AcceptedBspVolunteer, BlockchainServiceEventBusProvider, BspConfirmStoppedStoring,
FileDeletionRequest, FinalisedBspConfirmStoppedStoring, FinalisedBucketMovedAway,
FinalisedMspStoppedStoringBucket, FinalisedProofSubmittedForPendingFileDeletionRequest,
FinalisedTrieRemoveMutationsApplied, LastChargeableInfoUpdated, MoveBucketAccepted,
MoveBucketExpired, MoveBucketRejected, MoveBucketRequested, MoveBucketRequestedForMsp,
NewStorageRequest, SlashableProvider, SpStopStoringInsolventUser, StartMovedBucketDownload,
UserWithoutFunds,
FinalisedMspStopStoringBucketInsolventUser, FinalisedMspStoppedStoringBucket,
FinalisedProofSubmittedForPendingFileDeletionRequest, FinalisedTrieRemoveMutationsApplied,
LastChargeableInfoUpdated, MoveBucketAccepted, MoveBucketExpired, MoveBucketRejected,
MoveBucketRequested, MoveBucketRequestedForMsp, NewStorageRequest, SlashableProvider,
SpStopStoringInsolventUser, StartMovedBucketDownload, UserWithoutFunds,
},
state::{
BlockchainServiceStateStore, LastProcessedBlockNumberCf,
Expand Down Expand Up @@ -986,6 +986,29 @@ where
}
}
}
BlockchainServiceCommand::QueryBucketsOfUserStoredByMsp {
msp_id,
user,
callback,
} => {
let current_block_hash = self.client.info().best_hash;

let buckets = self
.client
.runtime_api()
.query_buckets_of_user_stored_by_msp(current_block_hash, &msp_id, &user)
.unwrap_or_else(|e| {
error!(target: LOG_TARGET, "{}", e);
Err(QueryBucketsOfUserStoredByMspError::InternalError)
});

match callback.send(buckets) {
Ok(_) => {}
Err(e) => {
error!(target: LOG_TARGET, "Failed to send back buckets: {:?}", e);
}
}
}
BlockchainServiceCommand::ReleaseForestRootWriteLock {
forest_root_write_tx,
callback,
Expand All @@ -1007,7 +1030,7 @@ where
match callback.send(forest_root_write_result) {
Ok(_) => {}
Err(e) => {
error!(target: LOG_TARGET, "Failed to send forest write lock release result: {:?}", e);
error!(target: LOG_TARGET, "Failed to send back forest root write result: {:?}", e);
}
}
}
Expand Down Expand Up @@ -1627,6 +1650,21 @@ where
}
}
}
RuntimeEvent::FileSystem(pallet_file_system::Event::MspStopStoringBucketInsolventUser {
msp_id,
owner: _,
bucket_id
}) => {
// This event is relevant in case the Provider managed is the MSP of the event.
if let Some(StorageProviderId::MainStorageProvider(managed_msp_id)) = &self.provider_id {
if msp_id == *managed_msp_id {
self.emit(FinalisedMspStopStoringBucketInsolventUser {
msp_id,
bucket_id
})
}
}
}
RuntimeEvent::FileSystem(
pallet_file_system::Event::BspConfirmStoppedStoring {
bsp_id,
Expand Down
40 changes: 33 additions & 7 deletions node/src/services/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ use shc_actors_framework::{
use shc_blockchain_service::{
events::{
AcceptedBspVolunteer, FileDeletionRequest, FinalisedBspConfirmStoppedStoring,
FinalisedBucketMovedAway, FinalisedMspStoppedStoringBucket,
FinalisedProofSubmittedForPendingFileDeletionRequest, LastChargeableInfoUpdated,
MoveBucketAccepted, MoveBucketExpired, MoveBucketRejected, MoveBucketRequested,
MoveBucketRequestedForMsp, MultipleNewChallengeSeeds, NewStorageRequest, NotifyPeriod,
ProcessConfirmStoringRequest, ProcessFileDeletionRequest, ProcessMspRespondStoringRequest,
ProcessStopStoringForInsolventUserRequest, ProcessSubmitProofRequest, SlashableProvider,
SpStopStoringInsolventUser, StartMovedBucketDownload, UserWithoutFunds,
FinalisedBucketMovedAway, FinalisedMspStopStoringBucketInsolventUser,
FinalisedMspStoppedStoringBucket, FinalisedProofSubmittedForPendingFileDeletionRequest,
LastChargeableInfoUpdated, MoveBucketAccepted, MoveBucketExpired, MoveBucketRejected,
MoveBucketRequested, MoveBucketRequestedForMsp, MultipleNewChallengeSeeds,
NewStorageRequest, NotifyPeriod, ProcessConfirmStoringRequest, ProcessFileDeletionRequest,
ProcessMspRespondStoringRequest, ProcessStopStoringForInsolventUserRequest,
ProcessSubmitProofRequest, SlashableProvider, SpStopStoringInsolventUser,
StartMovedBucketDownload, UserWithoutFunds,
},
BlockchainService,
};
Expand All @@ -38,6 +39,7 @@ use crate::{
bsp_submit_proof::BspSubmitProofTask, bsp_upload_file::BspUploadFileTask,
msp_charge_fees::MspChargeFeesTask, msp_delete_bucket::MspDeleteBucketTask,
msp_delete_file::MspDeleteFileTask, msp_move_bucket::MspRespondMoveBucketTask,
msp_stop_storing_insolvent_user::MspStopStoringInsolventUserTask,
msp_upload_file::MspUploadFileTask, sp_slash_provider::SlashProviderTask,
user_sends_file::UserSendsFileTask,
},
Expand Down Expand Up @@ -290,6 +292,30 @@ where

let msp_charge_fees_task = MspChargeFeesTask::new(self.clone());

// MspStopStoringInsolventUserTask handles events for deleting buckets owned by users that have become insolvent.
let msp_stop_storing_insolvent_user = MspStopStoringInsolventUserTask::new(self.clone());

// Subscribing to UserInsolvent event from the BlockchainService to delete all stored buckets owned by a
// user that has been declared as without funds.
let user_without_funds_event_bus_listener: EventBusListener<UserWithoutFunds, _> =
msp_stop_storing_insolvent_user.clone().subscribe_to(
&self.task_spawner,
&self.blockchain,
true,
);
user_without_funds_event_bus_listener.start();

// Subscribing to FinalisedMspStopStoringBucketInsolventUser event from the BlockchainService.
let finalised_msp_stop_storing_bucket_insolvent_user_event_bus_listener: EventBusListener<
FinalisedMspStopStoringBucketInsolventUser,
_,
> = msp_stop_storing_insolvent_user.clone().subscribe_to(
&self.task_spawner,
&self.blockchain,
true,
);
finalised_msp_stop_storing_bucket_insolvent_user_event_bus_listener.start();

// Subscribing to NotifyPeriod event from the BlockchainService.
let notify_period_event_bus_listener: EventBusListener<NotifyPeriod, _> =
msp_charge_fees_task
Expand Down
1 change: 1 addition & 0 deletions node/src/tasks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub mod msp_charge_fees;
pub mod msp_delete_bucket;
pub mod msp_delete_file;
pub mod msp_move_bucket;
pub mod msp_stop_storing_insolvent_user;
pub mod msp_upload_file;
pub mod sp_slash_provider;
pub mod user_sends_file;
Loading
Loading