Skip to content
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

Fixes fillNodeRoleSlots() to not remove from array while it is being accessed #448

Merged
merged 2 commits into from
Sep 25, 2024

Conversation

joshuahannan
Copy link
Member

@joshuahannan joshuahannan commented Sep 11, 2024

Closes #443

Fixes a bug that was causing the system chunk to fail when the end staking auction was executing.

The code is in the loop in fillNodeRoleSlots() function that refunds candidate nodes who didn't get chosen for staking. The loop was removing items from the candidateNodesForRole dictionary in the same loop as the dictionary being accessed. The index that was being accessed was randomly generated, so it would sometimes cause an out of bounds error. This likelihood of the error increases as the number of candidate nodes increases.

The fix moves the code to remove from the candidate node list to after the loop has completed

Still working on a test for the change

@janezpodhostnik
Copy link
Collaborator

@joshuahannan should this be merged now?

@joshuahannan
Copy link
Member Author

yes, I'll merge

@joshuahannan joshuahannan merged commit 028f5a6 into master Sep 25, 2024
2 checks passed
@joshuahannan joshuahannan deleted the fill-slots-error branch September 25, 2024 13:00
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.

Fix bug in fillNodeRoleSlots() that removes nodes from the same list it is indexing into
4 participants