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

0 stars 0 forks source link

Gas: `SignatureValidatorV2.recoverAddrImpl` should use `else if` #42

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

cmichel

Vulnerability details

The SignatureValidatorV2.recoverAddrImpl function currently uses three if (mode == *) checks but the modes are all distinct enum values and therefore an else if can be used. This is more efficient because if the first branch is already matched, there's no need to check the mode against the remaining values anymore.

Ivshti commented 2 years ago

resolved in https://github.com/AmbireTech/adex-protocol-eth/commit/0200e3639f0b9558b0c2ee9e04e1a231b2f9c3c0

GalloDaSballo commented 2 years ago

Using else if allows in the best case to avoid the other ifs

The sponsor has applied the improvement