-
Notifications
You must be signed in to change notification settings - Fork 17
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
Overflow checker in initialize #36
base: main
Are you sure you want to change the base?
Conversation
src/lib.rs
Outdated
@@ -478,6 +480,8 @@ pub mod pallet { | |||
// the native account has already some rewards in, we add the new ones | |||
AccountsPayable::<T>::insert( | |||
native_account, | |||
// It should be safe not to use saturating_add here |
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.
I think it is better to still use the saturating_add in those cases no? Is there a cost to it ?
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.
A small one in terms of a couple of checks (the value being greater than the maximum). But I guess they are minimal, so I can also add it here
src/lib.rs
Outdated
@@ -470,6 +470,8 @@ pub mod pallet { | |||
claimed_reward: initial_payment, | |||
}; | |||
|
|||
// It should be safe not to use saturating_add here | |||
// as we already checked before that these rewards do not overflow existing ones |
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.
You could consider using an assert
here to express this. That may or may not be a good idea :)
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.
👍
The initialize_reward_vec did not have overflow checkers assuming this was democracy/sudo call based. I added these for consistency reasons with the rest of the pallet extrinsics