The getOrderDetailsString
function is designed as a view function that only reads order data to format and return order details without modifying any state.
The function uses a storage
reference to access order data instead of copying it to memory
, resulting in higher gas costs for each field access and potential risks if the function is later modified to be non-view.
Likelihood:
This inefficiency occurs every time getOrderDetailsString
is called, affecting all users querying order details
The gas overhead accumulates with each field access throughout the function execution
Impact:
Unnecessary gas consumption due to repeated storage reads instead of single memory copy
Potential security risk if the view
modifier is accidentally removed in future modifications
Performance degradation from inefficient memory access patterns
Higher transaction costs for users calling the function
This analysis shows how using storage reference creates unnecessary gas overhead for read-only operations:
Change the storage reference to memory to optimize gas usage for read-only operations:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.