Skip to main content

Use Case & Applications

Prevents unauthorized changes to proxy implementation addresses, which could allow attackers to replace contract logic with malicious code. Critical for proxy-based upgradeable contracts in DeFi protocols (lending pools, yield aggregators), governance systems with timelocks, and cross-chain bridges. For example, it’s possible to define a whitelist of allowed implementations - any other implementation would be considered an invalid state.

Explanation

Monitors changes to the implementation address storage slot in proxy contracts using:
  • ph.forkPreTx() / ph.forkPostTx(): Compare implementation address before and after transaction
  • getStateChangesAddress(): Track all changes to the implementation slot during transaction execution
  • registerStorageChangeTrigger(): Trigger when implementation address changes
The assertion performs both direct pre/post comparison and verification of all intermediate state changes to detect unauthorized modifications. For more information about cheatcodes, see the Cheatcodes Documentation.

Code Example

Full examples with tests available in the Phylax Assertion Examples Repository.