Replies: 2 comments 4 replies
-
Interesting experiment here i must say. |
Beta Was this translation helpful? Give feedback.
-
Yes, Then, yes when Also, when So, the reason your test is passing is because of |
Beta Was this translation helpful? Give feedback.
-
Hello everyone,
I'm currently working through the lesson 14 about Foundry Upgrades and decided to do some experiments with the
SmallProxy
contract. Below is the code for theSmallProxy
andImplementationA
contracts (it was modified!):Here is the unit test I wrote for these contracts:
First, I'm assuming that
ImplementationA
andSmallProxyContract
are two independent contracts, each one with its own storage layout. I'm puzzled by the behavior of:Changing the Admin Address
SmallProxy::setSomeAddress
is supposed to set a new address for the admin variable in slot 0 ofSmallProxy
.implementationA.owner
is also changed to the attacker’s address, despite nodelegatecall
being present inSmallProxy::setSomeAddress
.SmallProxy.admin
to change, but both are being updated. Why is this happening?Changing the Owner Address
implementationA.setOwner()
, bothadmin
andowner
are updated to the owner's address.delegatecall
in this function, so why are both variables being updated?Now this contract utilizes
Proxy
from OpenZeppelin, so my guess is that something is happening behind the scenes with thefallback
anddelegatecall
function that I'm not able to understand.Thank you in advance!
Beta Was this translation helpful? Give feedback.
All reactions