code-423n4 / 2022-01-elasticswap-findings

1 stars 0 forks source link

Making the MathLib internal #141

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

UncleGrandpa925

Vulnerability details

Impact

Saving gas-cost for all transactions interacting with the pools.

Currently the bytecode size of the Exchange is 10.99KB. Making the entire MathLib internal (therefore embedding it into the Exchange) will only make the bytecode size grows to 14.45KB, which is well below the limit of 24576 bytes. Doing this will save at least 2300 gas for every transaction since that the cost for cold-load the bytecode of the library, and also saving the gas cost of doing delegate call to the library instead of doing internal call.

Recommended Mitigation Steps

Converting all public properties in the MathLib to internal.

Note

Normally I'm not into farming gas-optimization issues, but I think this is worth doing.

0xean commented 2 years ago

interesting, will look into this.

GalloDaSballo commented 2 years ago

Would have preferred some more details from the warden, to show their work. That said, because the sponsor confirmed, we'll mark as valid

0xean commented 2 years ago

Opting to not go with this optimization as it does increase the gas costs to deploy the exchange significantly and requires a fair bit of restructuring of code, sdk.