Skip to content

Latest commit

 

History

History
84 lines (51 loc) · 1.43 KB

File metadata and controls

84 lines (51 loc) · 1.43 KB

🧠 Solidity Proxy & Delegatecall Patterns

Low-level exploration of EVM execution context, storage behavior, and proxy architectures.


📚 Topics Covered

  • Delegatecall vs Call
  • Execution context and msg.sender
  • Storage layout and slot behavior
  • Storage collision vulnerabilities
  • Proxy pattern (fallback + delegatecall)
  • Minimal proxy (EIP-1167 clones)

🧪 Experiments

Delegatecall vs Call

Same function call.
Different execution context.
Different storage outcome.

  • call → modifies target contract storage
  • delegatecall → modifies caller contract storage

Storage Collision

Mismatched storage layouts:

  • same slot
  • different meaning

Result:

  • critical state overwrite (owner)

Proxy Pattern

User interacts with proxy.

  • proxy forwards calldata
  • implementation executes logic
  • state is stored in proxy

Minimal Proxy (EIP-1167)

Factory deploys lightweight proxy instances.

  • shared implementation
  • isolated storage per instance
  • cheap deployment

⚠️ Key Insight

Delegatecall executes external code using the caller’s storage.

Storage layout must be consistent across contracts.


🧠 Core Mental Model

  • Code lives in implementation
  • State lives in proxy
  • Execution context defines where state changes

📌 Summary

Same code.
Different storage.
Completely different system behavior.