Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The default permission setup might make it impossible to ever upgrade the token contract #112

Closed
Comdex opened this issue Nov 28, 2024 · 12 comments

Comments

@Comdex
Copy link

Comdex commented Nov 28, 2024

The default permission settings of the current token standard contract are configured this way:

this.account.permissions.set({
...Permissions.default(),
setVerificationKey: Permissions.VerificationKey.impossibleDuringCurrentVersion(),
setPermissions: Permissions.impossible(),
access: Permissions.proof(),

The access permission is set to Proof, and if I am not mistaken, this requires the corresponding AccountUpdate of the token contract to include a proof in order to be accepted by the network. However, the permission for setVerificationKey will change to Signature after the protocol upgrade. This means that updating the VerificationKey will require signature authorization. Since an AccountUpdate cannot simultaneously include both proof and signature authorization, and with updates to permissions being disallowed, this would likely result in the token contract being permanently unupgradable.

The access permission has the highest priority, which means that when it is set to Proof, other permissions set to Signature will become invalid

@L-as
Copy link

L-as commented Nov 30, 2024

This is a very good point.

@L-as
Copy link

L-as commented Nov 30, 2024

Unless I’m missing something this isn’t fixable and is a limitation of Mina.

Linked pre-MIP is relevant.

access permission needs to be ignored in some cases or you could split it into two permissions

@Comdex
Copy link
Author

Comdex commented Nov 30, 2024

Unless I’m missing something this isn’t fixable and is a limitation of Mina.

I think that makes sense. We’ll probably need to make some changes at the protocol level to fix this.

@mitschabaude
Copy link
Collaborator

mitschabaude commented Dec 5, 2024

DAMN that's a great find @Comdex. I agree it needs a protocol-level fix.

@mrmr1993 @nholland94 hope you saw this -- once there is a vk-breaking hard fork, all contracts with access=proof are broken, because the verification key update (using a signature) can't go through, and neither can any proof for the outdated vk

@andrewferrone
Copy link

Is a short-term workaround to change the access permission to Signature? @kantp

@kantp
Copy link
Collaborator

kantp commented Dec 5, 2024

With access set to signature, other things would stop working, so unfortunately we can't do that. I think what we need to do is have a method that changes the verification key, using a proper access control (like what @dfstio is working on for the NFT standard). Then, we need to change the permissions to change the verification key to proof, instead of impossibleDuringCurrentVersion.

@kantp
Copy link
Collaborator

kantp commented Dec 5, 2024

Unfortunately, we can't set the permissions to change the verification key to proof with the contract as it is right now, because the updateVerificationKey() method does not control who calls it. So we need to change that, and only then change the permissions.

@kantp
Copy link
Collaborator

kantp commented Dec 6, 2024

For anyone following this: there is also a discussion on Discord, see https://discord.com/channels/484437221055922177/1311633212769960009/1311633212769960009.

At the moment, we're trying to get a short term solution to this for the fungible tokens, while also looking at the necessary protocol changes to fix the root cause. I'll update as we progress.

@mrmr1993
Copy link

mrmr1993 commented Dec 8, 2024

We've been tracking this issue for a while on the O(1) side. There's an easy fix, and it's part of the plan for the next hard fork.
Feel free to use the access permission however you need, the upgrade mechanism will handle it in a coherent way.

@kantp
Copy link
Collaborator

kantp commented Dec 9, 2024

Thanks @mrmr1993, that's good news!

What I still want to change is adding access management to the updateVerificationKey method, in order to enable making the contract upgradable before a breaking change to the protocol. That way, people can upgrade to keep up to date with fixes and improvements in o1js.

@kantp
Copy link
Collaborator

kantp commented Dec 10, 2024

What I still want to change is adding access management to the updateVerificationKey method, in order to enable making the contract upgradable before a breaking change to the protocol. That way, people can upgrade to keep up to date with fixes and improvements in o1js.

See #113.

@kantp
Copy link
Collaborator

kantp commented Dec 18, 2024

With #113, deploy() now has a flag allowUpdates to switch between upgradable and not upgradable (during the current protocol version). The documentation recommends allowing updates during the current protocol version. Updating the verification key requires a permission from the admin contract, so that is customisable (the example contract uses a signature from the admin).

Together with @mrmr1993's message above that the access permission issue will be fixed with the next protocol update, I think we can close this issue.

@kantp kantp closed this as completed Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants