-
Notifications
You must be signed in to change notification settings - Fork 116
Check price of data object bloat bonds #3693
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
Check price of data object bloat bonds #3693
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
bedeho
left a comment
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.
This implementation is doing too much. You should not be checking and verifying lots of checks that are not relevant for fee estimation, those will be checked later as part of actual call to upload. Checking for existance of bag is OK, since we need contained informatino to do actual evaluation, but the other stuff is not.
runtime-modules/storage/src/lib.rs
Outdated
| let storage_fee = Self::calculate_data_storage_fee(new_voucher_update.objects_total_size); | ||
| //Only the case where the net deletion prize (NDP) is positive will be returned, as the | ||
| //function will be used to validate whether the actor has enough balance to update the assets. | ||
| let funds_needed_for_upload = match net_prize.add_balance(storage_fee) { |
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.
Won't net_prize include old deletin prize? If so, wouldn't funds_needed_for_upload in fact be the new total cost, rather than cost of doing this additional upload, which is what we care about?
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.
When we call upload_data_objects this function will call try_mutating_storage_state with
BagOperationParams::Update(object_creation_list)
then
- we will ensure bag exists and bag has a deletion prize, that is some for dynamic bags or none for static ones.
- Construct objects to upload where deletion prize is the old one
- we compute net prize init_value + (deletion_prize * num_obj_to_create)
- We add net_prize to storage_fee
So net prize include deletion prize in the calculation, but that is what try_mutating_storage_state is doing to do the ensure_funds validation
I think the goal here is to separate funds validation from try_mutate_storage, right?
Check price of data object bloat bonds Joystream#3607 funds_needed_for_upload Joystream#3607
2128411 to
b2e396c
Compare
|
Now we have a much simpler funds calculation function. This function doesn't fail. fn funds_needed_for_upload(
num_of_objs_to_upload: usize,
objs_total_size_in_bytes: u64,
) -> BalanceOf<T>;I tested for overflow saturation, but I'm thinking now, these numbers are so huge, that no quantity of memory will ever amount to that. I also move to fixtures some helper functions, that were in the middle of the unit tests. |
bedeho
left a comment
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.
This looks very simple and correct, originally, this is what I thought we would need, something very very simple. Why were you able to simplify so much only now?
|
I thought your goal was to separate the |
funds_needed_for_upload(params: UploadParameters<T>)created in pallet storageI think It's more advantageous to use
UploadParametersas a parameter than to separate the fields into params.This function calculates the storage fee and the net prize an actor has to pay if he wants to update X amount of data objects.
It only works on updates, so the net deletion prize is always positive (
NetDeletionPrize::<T>::Pos(b)).net_prize = number of objects to update * DataObjectDeletionPrizeValue.storage_fee = DataObjectPerMegabyteFee * round_up_to_nearest_integer(size of total objects in bytes / 1_048_576)funds_needed_for_upload = net_prize + storage_fee