Submitted by Arabadzhiev, also found by said
GaugeController::remove_gauge will always revert when it is called for gauges with weight that is != 0.
The current implementation of the GaugeController::remove_gauge function has a major flaw within it. Because it erases the gauge type of the gauge being removed prior to calling _remove_gauge_weight, it will always revert whenever it is called for gauges that have a weight value different from 0. This is due to the fact that in _remove_gauge_weight there are subtractions being made to gauge type mappings (where the gauge type key being used will be -1, since the gauge type for the gauge has already been erased) using values from gauge mappings.
Although an argument can be made that this issue can be avoided by calling GaugeController::remove_gauge_weight prior to calling GaugeController::remove_gauge, it can still prove to be quite problematic in an event where an urgent removal of a given gauge is required. The initial remove_gauge call for doing so gets reverted, since the governance didnt know about the issue and the proper way of bypass it up until that point. In that case, a separate new governance proposal will have to be executed in order to remove the gauge, which will take a significant amount of time.
The following short coded PoC demonstrates the issue:
Call _remove_gauge_weight prior to erasing the gauge type of the gauge:
Under/Overflow
zjesko (Neobase) confirmed
