-
Notifications
You must be signed in to change notification settings - Fork 157
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
Ban unsafe arithmetic operations #485
Conversation
looks like some conflicts + CI failures now @keithtensor |
e5f07f0
to
c5620f9
Compare
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 had gpt 4o go over the diff of this in detail with me as well and it is satisfied all of these preserve the original behavior after a long convo
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.
Approved but lets wait for @sam0x17 on merging this
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.
changes look good, next step would be for a companion PR to open, with a link to this branch, that merges a this branch into devnet-ready
So yeah again, should have a companion that merges this branch into |
but yeah if this is already tested on devnet, should add the |
3f1763c
3f1763c
to
d98e663
Compare
355e3ce
to
d98e663
Compare
d98e663
to
847da3d
Compare
I'm curious about the outright ban of the operations + - / *, since these are rather common operations. Have you considered an alternative of catching overflow exceptions? To me, it seems like an overkill, but I'm open to being convinced otherwise. Is it considered good practice in the Rust community to ban these operations? What are the tradeoffs (how much slower does it make things run)? |
main reason being panicking in an extrinsic is enough to brick a substrate-based chain. On parity's end they have always said you should only use checked math in extrinsics. |
Devnet Companion: #529
This PR bans raw arithmetic operations such as those with the
+ - / *
symbols, and instead replaces them with either the saturating equivalent, or the checked equivalent.Resolves #303.