code-423n4 / 2021-10-slingshot-findings

0 stars 0 forks source link

No need to save old slingshot variable in ModuleRegistry.setSlingshot() #33

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

0x0x0x

Vulnerability details

Impact

Gas optimization

Proof of Concept

Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.

At ModuleRegistry.setSlingshot(), old slingshot adress is saved to variable oldAdress. oldAdress is only used to emit the change of slingshot adress. It is not required to save the oldAdress to a variable. L71-73:

        address oldAddress = slingshot;
        slingshot = _slingshot;
        emit NewSlingshot(oldAddress, _slingshot);

Recommended Mitigation Steps

Replace with:

        emit NewSlingshot(slingshot, _slingshot);
        slingshot = _slingshot;

Tools Used

Manual analysis

tommyz7 commented 2 years ago

Duplicate of #69