Skip to content
Business logic Audit finding Beginner

DAY_IN_BLOCKS is incorrect

The contract used a constant for the number of blocks per day based on a 13.3-second block time, but after Ethereum's move to proof of stake, block times are fixed at 12 seconds. This caused lock and voting durations to expire earlier than intended, by about 7 and 11.7 hours respectively.

Anirruth Follow with DadeKuma, bart1e and 5 others

Originally disclosed on Code4rena

Submitted by Anirruth, also found by DadeKuma, bart1e, ladboy233, Matin, giovannidisiena, rvierdiiev, and MohammedRizwan

The day in blocks is calculated with the block time as 13.3 seconds in CoreVoting.sol.: uint256 public constant DAY_IN_BLOCKS = 6496;, but since moving to proof of stake, block times are fixed to 12 seconds per block. Reference.

This results in an incorrect calculation of the lockDuration and extraVoteTime, which is used in setting the total duration of a proposal should be active and also the max vote time.

The time difference can be calculated:

3*24*60*60 / 13.3 = 19488.721804511 (lockDuration with 13.3 seconds). 3*24*60*60 / 12 = 21600 (lockDuration with 12 seconds). 21600 - 19488.7 = 2111.3 2111.3*12 / (60*60) = 7.03 (difference in hours for lockDuration).

5*24*60*60 / 13.3 = 32481.203007519 (extraVoteTime with 13.3 seconds). 5*24*60*60 / 12 = 36000 (extraVoteTime with 12 seconds). 36000 - 32481.2 = 3518.8 3518.8*12 / (60*60) = 11.72 (difference in hours extraVoteTime).

By using block time as 13.3 seconds, the lockDuration expires 7 hours earlier and the extraVoteTime expires 11.72 hours earlier. Since it is a significant time and affects the proposal and voting duration, I consider medium severity to be fair.

Tools Used

VS code

Recommended Mitigation Steps

86400 / 12 = 7200 Change the DAY_IN_BLOCKS to 7200: uint256 public constant DAY_IN_BLOCKS = 7200;

Assessed type

Error

PowVT (Arcade.xyz) disagreed with severity, confirmed and commented via duplicate issue #56:

QA - Having a shorter staleBlockLag doesn’t affect the contract’s behavior at all really. Just makes things a bit more confusing for those reading the code. We will accept this since it is a very straightforward change and helps the readability of the contract.

0xean (judge) decreased severity to QA via duplicate issue #56

MohammedRizwan (warden) commented via duplicate issue #56:

@0xean @PowVT - With due respect to the sponsor and judge, I would like to add below additional context:

This should be considered a valid Medium. It’s not about the readability of the code, but about the design consideration which is currently deviating. 13.3 seconds was for proof of work and the proposed 12 seconds is for the proof of stake which happened after the Ethereum merge. The overall impact has been described in the report and it’s duplicate.

Let’s consider a case related to voting and the number of blocks considered in the current implementation:

    uint256 public constant DAY_IN_BLOCKS = 6496;

The lock duration is 3 days by default:

    uint256 public lockDuration = DAY_IN_BLOCKS * 3;

Lock duration in number of blocks = 19_488.

Now, as I said, Ethereum produces blocks at 12 seconds. Ethereum official reference and chart.

Therefore, the lock duration will expire in 2.7 days instead of 3 days.

How? Let’s see below:

Lock duration in number of blocks = 19_488 blocks Block formation period = 12 seconds Lock duration will expire in = 19_488 X 12 = 2,33,856 seconds ~ 2.7 days

Such blockduration issues have been judged as Medium/High in past Code4rena audits. I am putting below the reference report link from backstage as the report is not public yet. This reference report was judged by Trust.

The in-scope Issue 2 about staleBlockLag is to be considered as between 1 and 2 months (equivalent in blocks) per sponsor response in a discord chat.

Let’s consider 1 month for staleBlockLag:

With current implementation: staleBlockLag with 1 month(equivilent in blocks) = 1_94_887.

With proposed recommendation: staleBlockLag with 1 month(equivilent in blocks) = 2_16_000.

Total difference = 21_113 blocks.

It means staleBlockLag will expire before 2.93 days i.e. ~ 27 days instead of 30 days (1 month as designed for).

This is a major change in arcade protocol design reducing the block duration time to 12 seconds instead of 13.3 seconds. This will affect not only contracts in scope but it will also the out-of-scope contracts relating to voting calculations.

I believe this should be considered a Medium.

0xean (judge) increased severity to Medium and commented via duplicate issue #56:

2 — Med: Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements

After reviewing this all further, and re-reading the C4 documentation I think this does qualify as Medium. While there are setters for some of these variables that could be modified to end up with the correct values, this issue does impact the functionality of the protocol.

I will go ahead and upgrade all of these to Medium.


The original report as published on Code4rena, by Anirruth. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The constant DAY_IN_BLOCKS was calculated using a 13.3-second block time, which is outdated after Ethereum's transition to proof of stake with 12-second blocks.

What the attacker needed

None

The fix

The constant should be updated to 7200 to reflect 12-second blocks.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A smart contract used an old estimate for how many blocks are mined per day. After Ethereum changed how blocks are produced, blocks come faster, so the contract's time windows ended sooner than planned. This could affect how long votes and locks last.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by Anirruth

View all

6 more disclosed reports, best first.

More from Arcade.xyz

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.