-
Notifications
You must be signed in to change notification settings - Fork 57
feat: use subsidies contract to proxy register blob call #2151
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
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 good! I added a few comments and it would be great to have some tests to make sure that everything works as expected (including for 100% subsidies and empty WAL coins).
full_price * (MAX_SUBSIDY_RATE - subsidies_object.buyer_subsidy_rate as u64) | ||
/ MAX_SUBSIDY_RATE |
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.
Important: I think this calculation is not quite correct, because it rounds towards zero, so if the numerator is not divisible by MAX_SUBSIDY_RATE
, one FROST may be missing in the calculated amount. Instead, we should always round up.
@@ -45,6 +45,9 @@ use crate::{ | |||
wallet::Wallet, | |||
}; | |||
|
|||
/// Max subsidy rate is 100%. | |||
pub const MAX_SUBSIDY_RATE: u64 = 10_000; |
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.
Nit/Remark: Let's call this MAX_BUYER_SUBSIDY_RATE
instead of MAX_SUBSIDY_RATE
just for clarity and future proofing. With the planned changes to the subsidies, we may want to have system subsidies above 100% so that will probably also change in the contracts.
}, | ||
) | ||
.await | ||
if blob_metadata_list.is_empty() { |
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.
Suggestion: This now duplicates a lot of code with reserve_and_register_blobs_without_subsidies
. Can we still keep an "inner" function, but instead of passing two closures for reserve and register, we just pass a flag with_subsidies
(and then make a case distinction at the relevant points in the function)?
Description
Describe the changes or additions included in this PR.
Test plan
How did you test the new or updated feature?
Release notes
Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.
For each box you select, include information after the relevant heading that describes the impact of your changes that
a user might notice and any actions they must take to implement updates. (Add release notes after the colon for each item)