Pieces Protocol

First Flight #32
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

Missing Indexed Fields in Events

Description

The OrderSelled event in the TokenDivider contract does not have the price field indexed, making it difficult to search and filter orders by price off-chain.

Code Location:

event OrderSelled(address indexed buyer, uint256 price);

Impact

Severity: Low

The lack of indexing of the price field has the following impacts:

  • Inability to effectively filter events by price

  • Reduced performance for off-chain applications that need to analyze order prices

  • Degraded user experience for interfaces that require price filtering

Proof of Concept

To find all orders with a specific price, an off-chain application would need to:

  1. Retrieve all OrderSelled events

  2. Decode each event to access the price field

  3. Manually filter the results

With an indexed field, this search would be much more efficient as it could directly use the event index.

Tools Used

  • Manual code analysis

  • Foundry tests

  • Aderyn (static analysis tool)

Recommendations

Index the price field in the OrderSelled event:

event OrderSelled(address indexed buyer, uint256 indexed price);

Note: Although indexing numerical values consumes more gas, the benefit in terms of ease of use and off-chain performance generally justifies this additional cost for important events like order sales.

Updates

Lead Judging Commences

fishy Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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