Skip to content
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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

girazoki
Copy link
Contributor

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

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
Copy link
Contributor

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 ?

Copy link
Contributor Author

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
Copy link
Contributor

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 :)

Copy link
Contributor

@notlesh notlesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants