Section 4 Puppy Raffle - Refund does not reduce the players.length making fees calc incorrect #221
Closed
0xstormblessed
started this conversation in
General
Replies: 1 comment 2 replies
-
Hello @0xstormblessed, Thanks for pointing this out, and it is expected that we may find more bugs in the codebase than what was touched on in the course. Patrick can't go over every single bug that the codebase may contain. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey all,
not sure if this is the best place to post a possible issue, lmk if this is a known issue, i could not find it on the search.
So i found this issue while doing a quick review on PuppyRaffle following the video, not sure is expected that the PuppyRaffle may have further issues after the section, but this one looked like it was worth noticing.
PuppyRaffle:refund
overwrites the player position to address(0) so in solidity the array length will remain the same and will not be reduced.This may affect who wins the actual raffle since it could be an address 0 of a previously ocuppied slot in the array potentially and also definitely makes the fees calculation incorrect.
POC
Note: added a helper view function puppyRaffle.getPlayersLength() to assert the players.length from test.
Beta Was this translation helpful? Give feedback.
All reactions