Open code423n4 opened 1 year ago
gzeon-c4 marked the issue as grade-b
Hello @gzeon-c4 ,
I would like to encourage you to revisit this issue. I believe it should receive a grade A and I will explain why down below. If you still decide to maintain the current grade after reading this, I would very much appreciate some advice on how I can improve my submisions and provide more value in the future.
bot-like
findings in an attempt to provide more value, and out of respect for the sponor's time.In the spirit of fairness (as well as maintaining and encouraging high quality reports) I have provided a detailed comparison of the other reports which received a grade A. Some of these reports contain false findings/false positives, but a majority of the reports contain low impact findings akin to the kind in bot races. I believe reports such as these should be discouraged from being submitted as a regular gas report and instead be encouraged to participate in the bot races. Regular gas reports, in my opinion, should be held to a higher standard compared to bot races
.
In addition, seeing as we are receiving compensation for our time and effort, I wanted to be fair to myself as it is difficult for me to observe the reports below and understand what I am 'missing' that resulted in my report being graded lower.
bot-like
/low impactstorage
keyword would result in a compiler error.bot-like
/low impactstorage
keyword would result in a compiler error.bot-like
/low impactbot-like
/low impactproof
of optimizationbot-like
bot-race
reports. Therefore, I will only comment on the high impact findings presented in this report.address
state variable above the isFixedLengthApprovalPeriod
state variable and therefore the refactoring suggested will not save 1 slot. The refactoring will result in 3 slots, similarly the original code also results in 3 slotsConfig
struct is not used in storage. It is used to instantiate a memory struct.calldata
LlamaAbsoluteStrategyBase
, which is upgradeable and thus the policy
state variable is set in a separate initialize
function instead of the constructor
. Therefore, none of the state variables in LlamaAbsoluteStrategyBase
, policy
included, can be set as immutable.LlamaAbsoluteStrategyBase
is upgradeable and thus the policy
state variable is set in a separate initialize
function instead of the constructor
. Therefore, none of the state variables in LlamaAbsoluteStrategyBase
, policy
included, can be set as immutable.proof
for the validity of the optimization.proof
for the validity of the optimization.block.timestamp
uses the NUMBER
opcode, which costs 2 Gas. Caching the timestamp in a variable will be more expensive because you have the perform stack manipulation (at least DUP
(3 gas)) to use the variable.proof
for the validity of the optimization.immutable
. The suggested refactoring will result in a compiler error.calldata
, not storage
, as suggested in the explanation of the optimization.safeTransfer
and safeTransferFrom
does not explicitly check for a zero address. Checking for the zero address early and reverting early before any further calls or changes to state are made will save gas.proof
for the validity of the optimizationpure
function, which do not cost gas.pure
function, which do not cost gas.Thanks for flagging, will do another pass of gas report review.
gzeon-c4 marked the issue as grade-a
Hi @gzeon-c4 ,
Thank you for taking the time to review my comment. I have one more clarifying question I'd like to ask you. I was wondering if you could offer some insight as to how this report could've been improved so that it qualified for "selected for report"? I'd appreciate any feedback so I can do better in the future and provide more value to the sponsor.
Thank you.
Hi @gzeon-c4 ,
Thank you for taking the time to review my comment. I have one more clarifying question I'd like to ask you. I was wondering if you could offer some insight as to how this report could've been improved so that it qualified for "selected for report"? I'd appreciate any feedback so I can do better in the future and provide more value to the sponsor.
Thank you.
I actually got interrupted yesterday and will finish the review in the next few hours I think.
Apologize again for the delay, I am going to mark this report as best because out of all the gas reports, this provided the most unique insight and the least inaccuracy. Judging qa and gas reports are tricky, since they are assigned a very small % of the overall prize pool it does not make a lot of sense to spend more time on it than HM issues. I usually quickly sort them into A B C bucket and reviewing only a few of them in more detail. That said, there are still ways to improve my process here as in retrospect I have been tricked by some warden to believe certain gas optimization is legit, when they are providing invalid or out-of-context examples.
Regarding this report, I think it looks good and it is impressive that everything is with actual coded poc and gas metering. It would be nicer if you can show the function you metered in the summary table (for example, a gas saving in a hot path is much better than in say init function which is only called once). Nit-picking but e.g. this finding:
Use already cached actionId to save 1 SLOAD
This seems to have this risk of making actionCount off due to possible reentrancy, it seems to be possible that an action is created during the external call to the strategy or the guard so if you use the cached action count you will only increment it by 1 even if many action is created. I am unsure this is an actual issue tho because the mapping will be overwritten anyway.
gzeon-c4 marked the issue as selected for report
Apologize again for the delay, I am going to mark this report as best because out of all the gas reports, this provided the most unique insight and the least inaccuracy. Judging qa and gas reports are tricky, since they are assigned a very small % of the overall prize pool it does not make a lot of sense to spend more time on it than HM issues. I usually quickly sort them into A B C bucket and reviewing only a few of them in more detail. That said, there are still ways to improve my process here as in retrospect I have been tricked by some warden to believe certain gas optimization is legit, when they are providing invalid or out-of-context examples.
Regarding this report, I think it looks good and it is impressive that everything is with actual coded poc and gas metering. It would be nicer if you can show the function you metered in the summary table (for example, a gas saving in a hot path is much better than in say init function which is only called once). Nit-picking but e.g. this finding:
Use already cached actionId to save 1 SLOAD
This seems to have this risk of making actionCount off due to possible reentrancy, it seems to be possible that an action is created during the external call to the strategy or the guard so if you use the cached action count you will only increment it by 1 even if many action is created. I am unsure this is an actual issue tho because the mapping will be overwritten anyway.
Thank you for your detailed response. In future contests I will be sure to exclude init
functions as I agree that they hold less value compared to functions that are expected to be called again and again. I will also be much more specific with the exact functions that I am metering. The action information seems to be stored into the mapping using the correct actionId. Th tests passed with this optimization, as I always make sure no obvious issues with the test suite occur, but I understand the observation.
I also understand that as a judge your time is rightfully spent evaluating HM for the majority of the judging process. As someone who primarily participates in Gas Optimization, I recognize this and therefore believe it is beneficial for me to share additional insight regarding some reports that seem to have inaccuracies, so we can provide more value to the sponsors. That being said I would like to provide some additional remarks regarding Issue 120 that I believe is important for the assessment of the report:
Gcoldsload (2100 gas)
will incur when the fields are accessed. The first instance (lines 106) will not save any gas when using the storage
keyword. This is due to the fact that on line 107 all of the struct fields are read regardless. This means the same amount of SLOADs will take place regardless whether or not the struct is copied into memory. The second instance will not save any gas due to the fact that the timestamp
field is read twice (once on line 135 and once on line 138). This means that the Gwarmaccess (100 gas)
that would be saved by using the storage
keyword (this comes from not reading the quantity
field) is is ultimately spent when the timestamp
field is read for a second time.ERC1155Data
struct is not used in storage. It is used in calldata.
See the markdown file with the details of this report here.