DatingDapp

AI First Flight #6
Beginner FriendlyFoundrySolidityNFT
EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

[L-03] Unused `Like` struct declared in LikeRegistry is dead code

Description

LikeRegistry declares a Like struct that is never instantiated, stored, or referenced anywhere in the contract. It inflates the source code and ABI with no functional purpose.

Vulnerability Details

// src/LikeRegistry.sol, line 9-13
struct Like {
address liker; // @> never used
address liked; // @> never used
uint256 timestamp; // @> never used
}

The contract tracks likes through mapping(address => mapping(address => bool)) public likes on line 20, a simple boolean mapping. No function creates a Like instance, and no storage variable uses the Like type. The struct's timestamp field suggests the developer planned to track like history with timestamps but implemented a simpler boolean approach instead.

A search of the entire codebase confirms zero usage beyond the declaration:

$ grep -n "Like" src/LikeRegistry.sol
9: struct Like {
20: mapping(address => mapping(address => bool)) public likes;
24: event Liked(address indexed liker, address indexed liked);
// struct Like is only in the declaration — never instantiated

Risk

Likelihood:

  • The dead struct is present in every deployment. It exists in the source code regardless of how the contract is used.

Impact:

  • No functional impact. The struct appears in the ABI, potentially confusing developers or integrators who expect it to be used for querying like history (including timestamps). It suggests incomplete feature implementation.

PoC

The struct exists only in the type system — no runtime state uses it. Likes are tracked purely via the boolean mapping. The test confirms the mapping is the actual storage mechanism:

function testLikeStructUnused() public {
// Likes are tracked via: mapping(address => mapping(address => bool)) public likes
// No Like[] array, no Like storage variable, no function returns Like.
vm.prank(alice);
likeRegistry.likeUser{value: 1 ether}(bob);
assertTrue(likeRegistry.likes(alice, bob)); // boolean mapping, not Like struct
}

Recommendations

Remove the unused struct to clean up the codebase. If like timestamps are a desired feature, the struct should be integrated into the storage and populated in likeUser().

contract LikeRegistry is Ownable {
- struct Like {
- address liker;
- address liked;
- uint256 timestamp;
- }
-
SoulboundProfileNFT public profileNFT;
Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge about 16 hours ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!