The LevelTwo
contract manually redefines the storage
structure without preserving the layout of LevelOne
. It removes important storage
variables such as schoolFees
, reviewTime
, reviewCount
, and lastReviewTime
, as well as other intermediate fields.
This collision causes the bursary value, which should retain 60% of the school funds as per the specified invariant, to be corrupted and replaced by other values like sessionEnd
. Consequently, the contract does not correctly reflect the remaining resources after the upgrade, violating a critical functional requirement of the system.
This misalignment causes severe collisions with persistent proxy data as well.
The bursary is corrupted and no longer contains the expected value.
Stored data is read incorrectly.
Values in utilized slots are overwritten.
The contract may operate with incorrect roles, scores, or balances.
The resulting behavior is erratic and difficult to detect.
No visible errors occur, even though the state is corrupted.
It is very difficult to recover or fix the state once deployed.
The following demonstrates a storage
collision between LevelOne
and LevelTwo
, showing how the bursary
and sessionEnd
values are corrupted after the upgrade:
Capture the values of bursary
(slot 5) and sessionEnd
(slot 4) before performing the upgrade:
Perform the upgrade to LevelTwo:
Query the value of bursary again from LevelTwo:
Result:
This demonstrates that the expected value of bursary
has been overwritten by the value of sessionEnd
, confirming a storage
collision caused by the incorrect redefinition of the layout in LevelTwo.
Manual Review, Foundry
To ensure compatibility with the state stored in the proxy, none of the existing storage
variables should be removed in the new implementation (LevelTwo
). All variables from LevelOne
must be preserved in the same order.
If new variables need to be added, they should only be appended at the end of the layout, after the last existing variable. This practice ensures that previous values are not overwritten and the contract's state remains intact.
Constants (constant
) are not part of the storage
and do not affect slot layout.
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.