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.forkPreState()
/ph.forkPostState()
: Compare implementation address before and after transactiongetStateChangesAddress()
: Track all changes to the implementation slot during transaction executionregisterStorageChangeTrigger()
: Trigger when implementation address changes
Code Example
Note: Full examples with tests available in the Phylax Assertion Examples Repository.