By making the event topic indexed
for string
type inside the SystemConfig
contract, it would lead for wrong variables to be emitted.
when the indexed
keyword is used for reference type variables such as dynamic arrays or strings, it will return the hash of the mentioned variables.
Thus, the event which is supposed to inform all of the applications subscribed to its emitting transaction (e.g. front-end of the DApp, or the backend listeners to that event), would get a meaningless and obscure 32 bytes that correspond to keccak256 of an encoded dynamic array. This may cause some problems on the DApp side and even lead to data loss.
For more information about the indexed events, check here:
(https://docs.soliditylang.org/en/v0.8.17/abi-spec.html?highlight=indexed#events)
The problem exists inside the SystemConfig
contract. The events CreateMarketPlaceInfo
and UpdateMarket
are defined in such a way that the string
variable of marketPlaceName
in both is indexed
.
The functions createMarketPlace()
and updateMarket()
are intended to create a new marketplace and update a market with the provided data respectively. However, with the current design, the expected parameter (marketPlaceName
) wouldn't be emitted properly and front-end would get a meaningless one-way hash.
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/interfaces/ISystemConfig.sol#L55
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/interfaces/ISystemConfig.sol#L62
Wrong and meaningless event variables would be emitted in the front-end
Consider this scenario as an example:
The function createMarketPlace()
or updateMarket()
is called
Inside the mentioned functions we expect to see the the string
of marketPlaceName
from calldata be emitted
But as the event topic is defined as indexed
we'll get an obscure 32-byte hash and listeners will not be notified properly. Thus, the marketPlaceName
would be lost in the DApp.
For test purposes, one can run this test file:
Outputs of test:
event CreateMarketPlaceInfo
:
event CreateMarketPlaceInfo1
:
Manual
Invalid, known issue [Low-24](https://github.com/Cyfrin/2024-08-tadle/issues/1)
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.