Let say that LogicContract is deployed is the implementation of a proxy. Is it still possible to call through via proxy and get latest updated_Supply ? Does it affect the storage slot assuming that it can be called? Will _Supply be incremented?
contract LogicContract {
uint256 public _Supply;
uint256 public _Supply;
constructor() {
uint256 _Supply = 0;
}
function add() public{
_Supply += 1;
}
}
Both the proxy and implementation addresses have their own storage. Functions called through the proxy would affect the proxy's storage. But the constructor only affects the implementation's storage.
Typically, only the proxy's storage is relevant, while storage at the implementation is not used (and the recommendation is to disable initializers for the implementation, to prevent it from being used directly).
For your questions, the answer is yes to all of those. This is because your example's constructor sets _Supply to 0, which is the same as the default.
But if you constructor had something like:
constructor() {
uint256 _Supply = 10;
}
then calling add()
would result in _Supply to be 1 according to the proxy, not 11! This is because from the proxy's perspective, the _Supply variable was not initialized.
1 Like