Submitted by 0x52, also found by berndartmueller, IllIllI, kenzo, and rotcivegaf
VoteEscrowCore.sol#L1226-L1236
Burn NFTs remained delegated causing bloat and wasting gas.
VoteEscrowDelegation.sol doesnt change the withdraw or _burn functions inherited from VoteEscrowCore.sol. These functions are ignorant of the delegation system and dont properly remove the delegation when burning an NFT. The votes for the burned NFT will be removed but the reference will still be stored in the delegation list where it was last delegated. This creates a few issues. 1) It adds bloat to both getVotes and getPriorVotes because it adds a useless element that must be looped through. 2) The max number of users that can delegate to another NFT is 500 and the burned NFT takes up one of those spots reducing the number of real users that can delegate. 3) Adds gas cost when calling removeDelegation which adds gas cost to _transferFrom because removeElement has to cycle through a larger number of elements.
Override _burn in VoteEscrowDelegation and add this.removeDelegation(_tokenId), similar to how it was done in _transferFrom.
zeroexdead (Golom) confirmed
zeroexdead (Golom) commented:
0xsaruman (Golom) resolved
LSDan (judge) commented:
