Skip to content

Conversation

@8sunyuan
Copy link
Contributor

@8sunyuan 8sunyuan commented Jan 14, 2025

Due to casting not causing a revert in _addInt128, its possible to cast and truncate a value that overflows. This introduces several problems but the one outlined in the added test shows you can manipulate encumberedMagnitude to be 0 and infinitely allocate instead of being capped by maxMagnitude.
This simple fix will now safecast and cause a revert if overflow occurs when downcasting to a uint64. If needed, we can only add a check on the input param so that the new magnitude allocation is <= WAD

@8sunyuan 8sunyuan changed the base branch from slashing-magnitudes to slashing-magnitudes-fixes January 14, 2025 18:11
Copy link
Contributor

@wadealexc wadealexc left a comment

Choose a reason for hiding this comment

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

LGTM

@8sunyuan 8sunyuan merged commit 1637a86 into slashing-magnitudes-fixes Jan 30, 2025
11 checks passed
@8sunyuan 8sunyuan deleted the fix-overflow-bug branch January 30, 2025 21:46
0xClandestine pushed a commit that referenced this pull request Feb 11, 2025
* fix: overflow bug for pendingDiff input

* test: add check to regression test

---------

Co-authored-by: wadealexc <pragma-services@proton.me>
ypatil12 pushed a commit that referenced this pull request Feb 19, 2025
* fix: overflow bug for pendingDiff input

* test: add check to regression test

---------

Co-authored-by: wadealexc <pragma-services@proton.me>
ypatil12 pushed a commit that referenced this pull request Feb 20, 2025
* fix: overflow bug for pendingDiff input

* test: add check to regression test

---------

Co-authored-by: wadealexc <pragma-services@proton.me>
ypatil12 pushed a commit that referenced this pull request Feb 20, 2025
* fix: overflow bug for pendingDiff input

* test: add check to regression test

---------

Co-authored-by: wadealexc <pragma-services@proton.me>
ypatil12 pushed a commit that referenced this pull request Feb 20, 2025
* fix: overflow bug for pendingDiff input

* test: add check to regression test

---------

Co-authored-by: wadealexc <pragma-services@proton.me>
ypatil12 pushed a commit that referenced this pull request Feb 20, 2025
* fix: overflow bug for pendingDiff input

* test: add check to regression test

---------

Co-authored-by: wadealexc <pragma-services@proton.me>
ypatil12 pushed a commit that referenced this pull request Feb 20, 2025
* fix: overflow bug for pendingDiff input

* test: add check to regression test

---------

Co-authored-by: wadealexc <pragma-services@proton.me>
ypatil12 pushed a commit that referenced this pull request Feb 20, 2025
* fix: overflow bug for pendingDiff input

* test: add check to regression test

---------

Co-authored-by: wadealexc <pragma-services@proton.me>
ypatil12 pushed a commit that referenced this pull request Feb 20, 2025
* fix: overflow bug for pendingDiff input

* test: add check to regression test

---------

Co-authored-by: wadealexc <pragma-services@proton.me>
ypatil12 pushed a commit that referenced this pull request Feb 20, 2025
* fix: overflow bug for pendingDiff input

* test: add check to regression test

---------

Co-authored-by: wadealexc <pragma-services@proton.me>
ypatil12 pushed a commit that referenced this pull request Feb 20, 2025
* fix: overflow bug for pendingDiff input

* test: add check to regression test

---------

Co-authored-by: wadealexc <pragma-services@proton.me>
ypatil12 pushed a commit that referenced this pull request Feb 20, 2025
* fix: overflow bug for pendingDiff input

* test: add check to regression test

---------

Co-authored-by: wadealexc <pragma-services@proton.me>
ypatil12 pushed a commit that referenced this pull request Feb 20, 2025
* fix: overflow bug for pendingDiff input

* test: add check to regression test

---------

Co-authored-by: wadealexc <pragma-services@proton.me>
ypatil12 pushed a commit that referenced this pull request Feb 20, 2025
* fix: overflow bug for pendingDiff input

* test: add check to regression test

---------

Co-authored-by: wadealexc <pragma-services@proton.me>
ypatil12 pushed a commit that referenced this pull request Feb 20, 2025
* fix: overflow bug for pendingDiff input

* test: add check to regression test

---------

Co-authored-by: wadealexc <pragma-services@proton.me>
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.

4 participants