Closed 0xRizwan closed 5 months ago
Thanks for the thorough research on this.
However we already have setters to address this type of issue. This is because blocks may not consistently be 12 seconds forever (as you note before and after the merge.)
I'm not sure exactly how issue severity is ranked, but given that we have setters to handle situations like this, I would consider this a valid, but very low severity issue.
Hi @pavlovcik,
Thanks for the comment.
The issue was identified as Medium severity since it's breaking the protocol intended design. Since the information is known to protocol team and this can be adjusted periodically as Ethereum changes the block formation period in future.
Thank you for confirming the issue and I think, the issue can be considered as low severity as there is setter function as referenced by you and it can be used to adjust number of blocks over time.
# Issue was not closed as completed. Skipping.
Issue Title
Wrong consideration of number of blocks in
blockCountInAWeek
Issue severity
Medium
Vulnerability details
DiamondInit.init()
contract is used to initializes a diamond with user defined state variables. The issue is the number of blocks considered inblockCountInAWeek
is incorrect which will break the core intended design of contracts functionalities.Affected code location: check here
The number of seconds in one week is
6,04,800
seconds and while calculating theblockCountInAWeek
, the blocks formation period is considered to be13.3
seconds. It is to be noted that Ethereum Proof of Work is deprecated and merged with Proof of stake which has different block formation period. It is explained as below,1) During of Ethereum, Proof of work 13 to 16 seconds was an average block formation time before Ethereum merge i.e before september, 2022 and
13.3
seconds is considered in current implementation.**BEFORE merge Ethereum block time reference with chart:![before merge](https://github.com/0xRizwan/Audit-snippets/assets/112799398/38f8b5b6-c62e-4dc7-8353-0c5a0154f231)
However, Ethereum block formation happens on every 12 seconds and it is confirmed from below sources, Ethereum official Reference-01 chainstack Reference-02 ycharts Reference-03
**AFTER merge Ethereum block time reference with chart:
To see the actual difference,
With current implementation:
With Ethereum Proof of stake,
The difference = 50400 - 45361 = 5039 = 17 hours approx.
This much time difference will affect wherever
blockCountInAWeek
variable used in contracts which will cause unexpected design failure.In
LibStaking.sol
, Indeposit()
function, To calculate the_endBlock
,blockCountInAWeek
variable is used,Similarly, in functions like
addLiquidity()
,The end block calculation is getting delayed by 17 hours approx. which is loss of time of users in both of these functions due to incorrect calculations.
Recommended Mitigation Steps
Consider 12 seconds block formation period.
cc- @rndquu , @pavlovcik , @molecula451 , @gitcoindev