code-423n4 / 2022-05-factorydao-findings

1 stars 1 forks source link

Gas Optimizations #281

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Gas

I. Cache numTrees in a local variable and use in LoC mentioned below:

MerkleDropFactory.sol

https://github.com/code-423n4/2022-05-factorydao/blob/db415804c06143d8af6880bc4cda7222e5463c0e/contracts/MerkleDropFactory.sol#L51

https://github.com/code-423n4/2022-05-factorydao/blob/db415804c06143d8af6880bc4cda7222e5463c0e/contracts/MerkleDropFactory.sol#L59

https://github.com/code-423n4/2022-05-factorydao/blob/db415804c06143d8af6880bc4cda7222e5463c0e/contracts/MerkleDropFactory.sol#L61

MerkleVesting.sol

https://github.com/code-423n4/2022-05-factorydao/blob/db415804c06143d8af6880bc4cda7222e5463c0e/contracts/MerkleVesting.sol#L64

https://github.com/code-423n4/2022-05-factorydao/blob/main/contracts/MerkleVesting.sol#L71-L72

https://github.com/code-423n4/2022-05-factorydao/blob/db415804c06143d8af6880bc4cda7222e5463c0e/contracts/MerkleResistor.sol#L86

https://github.com/code-423n4/2022-05-factorydao/blob/main/contracts/MerkleResistor.sol#L99-L100

II. Cache in a local variable and use ++

https://github.com/code-423n4/2022-05-factorydao/blob/db415804c06143d8af6880bc4cda7222e5463c0e/contracts/VoterID.sol#L130

https://github.com/code-423n4/2022-05-factorydao/blob/db415804c06143d8af6880bc4cda7222e5463c0e/contracts/MerkleEligibility.sol#L47

https://github.com/code-423n4/2022-05-factorydao/blob/db415804c06143d8af6880bc4cda7222e5463c0e/contracts/MerkleEligibility.sol#L91

illuzen commented 2 years ago

all duplicates