BriVault

First Flight #52
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: low
Likelihood: high
Invalid

Unused State Variables (totalAssetsShares, notRegistered) Increase Code Complexity and Gas Overhead

Unused State Variables (totalAssetsShares, notRegistered) Increase Code Complexity and Gas Overhead

Description

In the BriVault contract, the following state variables are declared but never used anywhere in the contract’s logic or event flow:

uint256 public totalAssetsShares;
error notRegistered();

Risk

Likelihood:

  • This issue always occurs on every contract deployment since the variables are permanently stored on-chain.

  • The cost is deterministic: ~20,000 gas per unused storage slot and an increased bytecode size.

Impact:

  • Increased gas cost during contract deployment due to additional storage layout.

Proof of Concept

You can verify the absence of references using Foundry’s static analysis:

forge inspect src/briVault.sol:BriVault storage-layout | grep totalAssetsShares
forge inspect src/briVault.sol:BriVault storage-layout | grep notRegistered

And by running a quick grep across the codebase:

grep -rnw 'src/' -e 'totalAssetsShares'
grep -rnw 'src/' -e 'notRegistered'

These commands show only the declaration line, confirming they are not read or written anywhere in the project.

Recommended Mitigation

Remove the variables entirely:

- uint256 public totalAssetsShares;
- error notRegistered();
Updates

Appeal created

bube Lead Judge 19 days ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Gas optimizations

Gas optimizations are invalid according to the CodeHawks documentation.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!