Skip to content

fix: prevent stack overflow and double vote in on_prepare#2019

Open
Sertug17 wants to merge 2 commits into
hyli-org:mainfrom
Sertug17:fix/double-vote-check
Open

fix: prevent stack overflow and double vote in on_prepare#2019
Sertug17 wants to merge 2 commits into
hyli-org:mainfrom
Sertug17:fix/double-vote-check

Conversation

@Sertug17

Copy link
Copy Markdown

Closes #2017
Closes #2018

Changes:
- Convert recursive fast forward to iterative loop to prevent stack
  overflow with many chained prepares
- Clone values before pushing to buffer so originals remain available
  for the loop
- Add double vote check: skip PrepareVote if the same proposal hash
  and slot/view was already processed

Sertug17 added 2 commits June 23, 2026 20:55
replace raw -= and += with checked_sub and checked_add in transfer
and transfer_from to prevent silent overflow/underflow wrapping.
also fix the same issue in the allowance deduction.

defense-in-depth: the balance checks already prevent underflow but
checked arithmetic ensures no silent wrapping if the guards ever
get out of sync with the actual mutations.
- convert recursive fast-forward to iterative loop to prevent stack
  overflow with many chained prepares (closes hyli-org#2017)
- add double-vote check: skip PrepareVote if the same proposal hash
  and slot/view was already processed (closes hyli-org#2018)
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.

missing double vote check before sending PrepareVote stack overflow risk in on_prepare fast forward recursion

1 participant