Skip to content

MilosMicun/solidity-proxy-patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 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.

About

Delegatecall, storage layout, and proxy patterns in Solidity with tests and exploits.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors