-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add overflow checks to change and fee calculations (#5834)
Description --- - Added 3x overflow checks to the change calculation in the sender transaction protocol. - Added an additional unit test (`fn test_sender_transaction_protocol_for_overflow`) to verify three sender transaction protocol overflow errors are handled. - **Edit:** Added overflow checks to kernel fee calculation in blocks. - **Edit:** Added overflow checks to transaction fee calculation. - **Edit:** Added an additional unit test (`fn test_fee_overflow`) to verify the two fee overflow errors are handled. - **Edit:** Fixed `Minotari` and `MicroMinotari` string conversion issue (#5839) for big numbers (_with unit test_) to allow for the proper error message to be printed in the `fn test_fee_overflow` unit test. Motivation and Context --- It is possible to crash the system in the change calculation before the transaction is validated; this PR prevents it. It is possible to crash the system with carefully crafted fees added to transactions and blocks; this PR prevents it. How Has This Been Tested? --- Added additional unit tests. What process can a PR reviewer use to test or verify this change? --- See unit tests and code changes. <!-- Checklist --> <!-- 1. Is the title of your PR in the form that would make nice release notes? The title, excluding the conventional commit tag, will be included exactly as is in the CHANGELOG, so please think about it carefully. --> Breaking Changes --- - [x] None - [ ] Requires data directory on base node to be deleted - [ ] Requires hard fork - [ ] Other - Please specify <!-- Does this include a breaking change? If so, include this line as a footer --> <!-- BREAKING CHANGE: Description what the user should do, e.g. delete a database, resync the chain -->
- Loading branch information
1 parent
1d1332d
commit 9725fbd
Showing
9 changed files
with
451 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.