Hi Team,
I am using OZ's UpgradableProxies.. UUPS one..
proxy => logic
and logic contains initialize
function that when proxy gets deployed, it immediatelly calls initialize
! as for the security measures, initialize
function on the logic is protected by initializer
that comes from OZ's Initializable
Now, let's say I want to update the contract. It at first glance, seems so easy. one writes another logic contract(v2), deploys it and then calls proxy
's upgradeTo and passes this. But Imagine that v2 also needs initialization. There're 2 choices.
- v2 logic's creator writes
initialize2
function in it and when it's time to upgrade, he callsupgradeToAndCall
on the proxy with the new logic address andinitialize2
's calldata. Question 1: If I addinitializer
modifier to thisinitialize2
function,upgradeToAndCall
won't still be able to call it as v1's initialize already set that boolean as true. Any ideas ? - Or user updates v1's
initialize
function's body in the v2(possibly changing arguments as well). Now, Problem I am looking at is thisinitialize
won't be able to be called, because it's protected byinitializer
and when proxy first called it for v1, it set the boolean as true ! Question 2: how can the sameinitialize
function be called while upgrading contracts only ? i understand that other than upgrading, it should be protected to not be called, but question relies only for upgrading.
I'd appreciate both cases/scenarios explanation as this is very critical to be solved.
Thank you.