-
Notifications
You must be signed in to change notification settings - Fork 10
feat(msp): rejected storage request triggers file clean up if needed #547
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
base: main
Are you sure you want to change the base?
Conversation
…letion. wip: debugging
| if !matches!( | ||
| reason, | ||
| pallet_file_system::types::RejectedStorageRequestReason::RequestExpired | ||
| | pallet_file_system::types::RejectedStorageRequestReason::InternalError | ||
| ) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the storage request failed for any of these reasons, wouldn't we want to delete the file from storage anyways?
ReachedMaximumCapacity
ReceivedInvalidProof
FileKeyAlreadyStored| let bucket_forest_key = event.bucket_id.as_ref().to_vec(); | ||
| let read_fs = self | ||
| .storage_hub_handler | ||
| .forest_storage_handler | ||
| .get(&bucket_forest_key.into()) | ||
| .await | ||
| .ok_or_else(|| { | ||
| anyhow!( | ||
| "CRITICAL❗️❗️ Failed to get forest storage for bucket [{:?}].", | ||
| event.bucket_id | ||
| ) | ||
| })?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Buckets can be removed from MSPs in unfinalized blocks. I don't think this needs to be a critical error.
| warn!( | ||
| target: LOG_TARGET, | ||
| "StorageRequestExpired and finalised for file key {:?} in bucket {:?}, but file key is still in Forest.", | ||
| event.file_key, | ||
| event.bucket_id | ||
| ); | ||
| return Err(anyhow!("File key is still in Forest")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we consider this case a warning and also return an error?
Problem:
File deletion from file storage are only being triggered by
MutationsAppliedevent. This is correct for the happy paths as this event is emitted always that an msp accepted the storage request (thus it root was updated in the runtime) and now is not required anymore, either because the user wants to delete it, or the user revoke the SR.But this leaves us with the edge case where the msp try to accept the SR (thus, it stores the file), but the transaction fails and his root is not updated on-chain. In this case, he will never see
MutationsAppliedevent.Solution:
Make msp react to events that inform that the SR was incomplete (
StorageRequestRejected) but MSP could have sent a tx accepting it that ends up failing.StorageRequestRejectedevent contains two new fields:msp_idandbucket_id. leaving the new struct as follows: