code-423n4 / 2021-08-gravitybridge-findings

1 stars 0 forks source link

Smart Contract Gas Optimization #3

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

ElliotFriedman

Vulnerability details

Impact

Currently, submitBatch, updateValset, deployERC20 and submitLogicCall all have arguments that are in memory. This causes calls to these functions to be more expensive than they need to be. By moving to external functions and upgrading the compiler version, there will be gas savings. The larger the amount of data being submitted to the contracts, the greater the savings as the cost of memory in the EVM goes up quadratically with the amount of data stored.

Tools Used

Hardhat

Recommended Mitigation Steps

Make all functions that you can external instead of public, especially the ones mentioned above that will see large transaction volumes, and change the data types from memory to external. This may involve changing compiler versions to 0.8.0 or greater to support using structs as external types.

jkilpatr commented 3 years ago

duplicate of #50

loudoguno commented 3 years ago

reopening as per judges assessment as "primary issue" on findings sheet