Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Overflow checker in initialize#36

Open
girazoki wants to merge 8 commits intomainfrom
overflow_checker_in_initialize
Open

Overflow checker in initialize#36
girazoki wants to merge 8 commits intomainfrom
overflow_checker_in_initialize

Conversation

@girazoki
Copy link
Copy Markdown
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
// 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
Copy Markdown
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
Copy Markdown
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
};

// 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
Copy Markdown
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
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants