starknet-hardhat-plugin icon indicating copy to clipboard operation
starknet-hardhat-plugin copied to clipboard

Make OpenZeppelin account contracts deployed by hardhat Upgradable

Open zeapherine opened this issue 2 years ago • 6 comments

Since to migrating to cairo v1 after the starknet regenesis, we will need the account contract to be upgradable.

zeapherine avatar Feb 27 '23 08:02 zeapherine

I'd love to fix this issue😊

TsBauer avatar Mar 03 '23 15:03 TsBauer

We've implemented a Cairo v0.11 proxy which uses replace_class to make the proxy itself upgradable to Cairo 1.0. We're unsure how to proceed and have a couple of questions:

  • How should we implement tests? Right now, this seems impossible because v0.11 is not live yet.
  • Should the proxy implementation reside in an MIT licensed repo at our organization such that only the compilation artifacts are kept in this repo?
  • The currently used OZ account contract version is 0.5.1. Should this be upgraded to v0.6.1 at this opportunity?

Actually, anything which helps to pinpoint the scope of this issue is much appreciated😊

TsBauer avatar Mar 08 '23 18:03 TsBauer

@TsBauer

We've implemented a Cairo v0.11 proxy which uses replace_class to make the proxy itself upgradable to Cairo 1.0.

When you say you've implemented it, do you mean that you've written a smart contract yourself? Or reused something from the OpenZeppelin repo?

  • How should we implement tests? Right now, this seems impossible because v0.11 is not live yet.

I'm ok with you creating a complete PR only when starknet 0.11 becomes live. Perhaps for now it can be a draft PR which instead of testing on starknet-devnet or testing on alpha-goerli (https://alpha4.starknet.io/) tests on the integration network (https://external.integration.starknet.io/). But I'm also ok with temporarily pausing this issue.

  • Should the proxy implementation reside in an MIT licensed repo at our organization such that only the compilation artifacts are kept in this repo?

I'm ok with this approach if you don't think there is a better way.

  • The currently used OZ account contract version is 0.5.1. Should this be upgraded to v0.6.1 at this opportunity?

Yes, you can upgrade to OZ v0.6.1

FabijanC avatar Mar 09 '23 08:03 FabijanC

@FabijanC

When you say you've implemented it, do you mean that you've written a smart contract yourself? Or reused something from the OpenZeppelin repo?

We reused the OpenZeppelin proxy and merely added an upgrade function which allows to upgrade the proxy itself with the replace_class syscall.

TsBauer avatar Mar 09 '23 14:03 TsBauer

@TsBauer

We reused the OpenZeppelin proxy and merely added an upgrade function which allows to upgrade the proxy itself with the replace_class syscall.

Surely OpenZeppelin isn't already working on this functionality? Maybe this: https://github.com/OpenZeppelin/cairo-contracts/pull/583

A problem with writing our own account classes is that we (or someone) will have to declare them on all testnets and mainnets.

FabijanC avatar Mar 10 '23 08:03 FabijanC

@FabijanC

We reused the OpenZeppelin proxy and merely added an upgrade function which allows to upgrade the proxy itself with the replace_class syscall.

Surely OpenZeppelin isn't already working on this functionality? Maybe this: OpenZeppelin/cairo-contracts#583

A problem with writing our own account classes is that we (or someone) will have to declare them on all testnets and mainnets.

I overlooked this PR when doing my research. Thanks for making me aware of this. You're certainly right. That's the way to go.

I'll use the integration network for testing and open a draft PR in the upcoming days.

TsBauer avatar Mar 11 '23 15:03 TsBauer