Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Proposal: Defensive trait for infallible frame operations #10626

Merged
merged 17 commits into from
Jan 24, 2022

Conversation

kianenigma
Copy link
Contributor

I've had this idea for a while and we've also talked about it internally.

Most ideas pointed to a rather more complicated implementation where you would also flip some storage item that could easily be monitored if any of these operations happened.

This is my quicker and simpler version, to begin with.

I am marking this as draft, as I am not sure if the direction makes all stake holders happy or not: @paritytech/frame-coders. If we want this, then I will scan the runtime and find use cases. I have already counted a few dozens of instances where the defensive-arithmetic could be used.

@github-actions github-actions bot added the A3-in_progress Pull request is in progress. No review needed at this stage. label Jan 10, 2022
@apopiak
Copy link
Contributor

apopiak commented Jan 10, 2022

I've thought about something similar a few times, really like this idea! 👍
I've also thought that it could be introduced as a macro and then we could capture the surrounding context (line number etc.).

@emostov
Copy link
Contributor

emostov commented Jan 10, 2022

This makes sense to me and I think it would improve ergonomics, at least with the style of code I have gotten used to writing the last few months.

@kianenigma kianenigma marked this pull request as ready for review January 13, 2022 07:08
@kianenigma kianenigma added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D9-needsaudit 👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Jan 13, 2022
Copy link
Member

@shawntabrizi shawntabrizi left a comment

Choose a reason for hiding this comment

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

This makes sense to me, and I would have a hard time seeing how this is something we would not want.

Copy link
Contributor

@KiChjang KiChjang left a comment

Choose a reason for hiding this comment

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

Bit unsure about the naming (what does defensive really mean in such a context? conservative?) but the idea makes sense.

@kianenigma kianenigma added A8-mergeoncegreen and removed A0-please_review Pull request needs code review. labels Jan 20, 2022
@jakoblell jakoblell added D1-audited 👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited and removed D9-needsaudit 👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited labels Jan 24, 2022
@kianenigma
Copy link
Contributor Author

bot merge

@paritytech-processbot paritytech-processbot bot merged commit b0c1475 into master Jan 24, 2022
@paritytech-processbot paritytech-processbot bot deleted the kiz-defensive-trait branch January 24, 2022 16:18
@kianenigma
Copy link
Contributor Author

bot merge

@paritytech-processbot
Copy link

Error: Github API says #10626 is not mergeable

@kianenigma
Copy link
Contributor Author

bot merge

@paritytech-processbot
Copy link

Error: Github API says #10626 is not mergeable

@KiChjang
Copy link
Contributor

Leave it be; @paritytech-processbot is stubborn.

@kianenigma
Copy link
Contributor Author

main reason is that I am on a weak Wifi and a consequence of that seems to be github send my comments multiple times :/

eskimor pushed a commit that referenced this pull request Jan 27, 2022
* add a blueprint of how defensive traits could look like

* add something for arithmetic as well

* add some use cases in different pallets

* some build fixing

* Some new stuff and examples

* Fix deadly bug

* add more doc.

* undo faulty change to assets pallet

* Update frame/support/src/traits/misc.rs

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* some review comments

* remove draft comment

* Fix ident test

* Fix proxy tests as well

* a few new ideas

* Fix build

* Fix doc

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Wizdave97 pushed a commit to ComposableFi/substrate that referenced this pull request Feb 4, 2022
…#10626)

* add a blueprint of how defensive traits could look like

* add something for arithmetic as well

* add some use cases in different pallets

* some build fixing

* Some new stuff and examples

* Fix deadly bug

* add more doc.

* undo faulty change to assets pallet

* Update frame/support/src/traits/misc.rs

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* some review comments

* remove draft comment

* Fix ident test

* Fix proxy tests as well

* a few new ideas

* Fix build

* Fix doc

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
grishasobol pushed a commit to gear-tech/substrate that referenced this pull request Mar 28, 2022
…#10626)

* add a blueprint of how defensive traits could look like

* add something for arithmetic as well

* add some use cases in different pallets

* some build fixing

* Some new stuff and examples

* Fix deadly bug

* add more doc.

* undo faulty change to assets pallet

* Update frame/support/src/traits/misc.rs

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* some review comments

* remove draft comment

* Fix ident test

* Fix proxy tests as well

* a few new ideas

* Fix build

* Fix doc

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
…#10626)

* add a blueprint of how defensive traits could look like

* add something for arithmetic as well

* add some use cases in different pallets

* some build fixing

* Some new stuff and examples

* Fix deadly bug

* add more doc.

* undo faulty change to assets pallet

* Update frame/support/src/traits/misc.rs

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* some review comments

* remove draft comment

* Fix ident test

* Fix proxy tests as well

* a few new ideas

* Fix build

* Fix doc

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D1-audited 👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants