-
Notifications
You must be signed in to change notification settings - Fork 5
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
fix: 🚑 add missing update_payment_stream
calls when deleting files
#300
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TDemeco
changed the title
fix: 🚑 add missing
fix: 🚑 add missing Dec 24, 2024
update_payment_stream
calls when adding/deleting files update_payment_stream
calls when deleting files
Fantastic PR! Thank you for spotting all these issues and taking the time to fix them! 💪 |
ffarall
requested changes
Dec 26, 2024
ffarall
approved these changes
Dec 27, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes some lingering issues in the runtime regarding payment streams not being correctly updated for Buckets and BSPs when deleting files. Those fixes are:
bsp_confirm_stop_storing
, after the proof has been verified and the used capacity of the BSP has been decreased, added a calculation of the new amount provided from the BSP to the corresponding user and the update (or delete if this new amount is zero) of the payment stream between them. Since the user of the file was not available at this time I added it to the tuple found inPendingStopStoringRequests
, which is set in thebsp_request_stop_storing
extrinsic.delete_file
extrinsic, if the user supplied an inclusion proof for the file key it wants to delete, the bucket size was being decreased (and the payment stream was updated accordingly) but the new bucket root after the file deletion was not being calculated nor updated. Added that.pending_file_deletion_request_submit_proof
(used by MSPs when a user requests a file deletion), if the proof submitted by the MSP includes the file key to delete, the bucket size nor root were being updated (and the payment stream wasn't either). Added the bucket root update and the bucket size update (which also updates the payment stream).PendingFileDeletionRequests
. This gets set when the user calls thedelete_file
extrinsic and gets verified in thepending_file_deletion_request_submit_proof
call.update_provider_after_key_removal
logic to delete the payment stream if the new amount provided after the file key deletion is zero. Previously, it was always calling update instead of delete and the call would fail. This function gets called after the mutations get applied in asubmit_proof
extrinsic call, to update the BSP's used capacity and payment streams.apply_delta
logic to first get the value (encoded file metadata) under the key to remove with.get()
and then remove it with.remove()
. This was needed as calling.remove()
directly and handling the returned value as the leaf value was not giving correct results, because the.remove()
call from theTrieDBMut
structure returns the literal value under the key in the trie, which is almost always a node that contains the hash that points to the actual leaf value, and since the actual leaf value gets removed in the call, calling.get()
afterwards for the obtained hash returnedNone
. I believe this behaviour is quite confusing and should be fixed (or at least clarified) intrie-db
.submit_proof
, which meant that there was a new worst-case scenario to handle for this extrinsic (updating a payment stream for each mutation). I added a payment stream creation in the setup of thesubmit_proof
benchmarks and recalculated the results.