You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: rfcs/0050-verification-key-permissions.md
+19-29Lines changed: 19 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -18,52 +18,41 @@ We wish for zkApps developers to be able to make their contract immutable withou
18
18
19
19
NB: This RFC relies on the [protocol versioning RFC](TODO).
20
20
21
-
In order to prevent a zkApp from breaking upon a future incompatible upgrade of the protocol, we will not allow users to set the `Impossible`or`Proof` permissions on the verification key. Instead, we will add 2 new permissions, `Impossible_during_hard_fork` and `Proof_during_hard_fork`, each of which will carry a specific transaction logic version to represent the hard fork they in which they are valid. Thus, the total set of permissions allowed to be set on verification keys would be:
21
+
In order to prevent a zkApp from breaking upon a future incompatible upgrade of the protocol, we will put special rules in place for the `Impossible`and`Proof` permissions on the verification key. The verification key permission will be represented as a tuple `(Control.t * txn_version)`, and `Proof`/`Impossible` controllers will be reinterpreted as `Signature` if the specified `txn_version` differs from the current protocol's transaction version. User interfaces may provide a less-detailed representation for `None` and `Either`, but the snark and over-the-wire protocol must accept a tuple for all variants.
22
22
23
-
*`None`
24
-
*`Either`
25
-
*`Signature`
26
-
*`Proof_during_hard_fork of txn_version`
27
-
*`Impossible_during_hard_fork of txn_version`
23
+
To ensure that contracts do not become soft-locked, both the transaction logic and the snark must only accept transactions with verification key permission `txn_version`s equal to the current version. Any other versions must be rejected by the transaction pool, block validation logic, and by the snark. We will accomplish this by adding a `txn_version` check to the set of well-formedness checks we do against transactions.
28
24
29
-
There is a restriction enforced in the transaction snark when a user attempts to set the permission to either `Proof_during_hard_fork` or `Impossible_during_hard_fork`. For any hard fork version, the transaction snark will only accept attempts to set one of these permissions to the current hard fork version. Any attempt to set one of these permissions to a hard fork version other than the current one will result in a failure. This failure should be implemented as a well formed transaction error rather than failing on chain, since it is something that can be checked statically before accepting transactions into the transaction pool. Thus, the transaction snark will fail to prove any such transactions, rather than failing on-chain.
25
+
Because setting the verification key permission requires specifying the `txn_version`, the `txn_version`will be included in the transactions hash, ensuring that the update cannot be replayed to 're-lock' the account to a newer, incompatible version.
30
26
31
-
When the `txn_version`referenced by either of these new permissions matches the current hard fork version of the protocol, the permissions act exactly like their normal counterparts (`Proof` fields can only be updated with a valid proof, `Impossible` fields can never be updated). When the `txn_version` is older than (less than) the current hard fork version, then both of these permissions fallback to the `Signature` case, so that the now broken zkApps can be updated for the new hard fork.
27
+
When the `txn_version`stored in the account's verification key permission matches the current hard fork version of the protocol, the `Impossible` and `Proof`permissions act exactly like their normal counterparts (`Proof` fields can only be updated with a valid proof, `Impossible` fields can never be updated). When the `txn_version` stored within an account's verification key permission is older than (less than) the current hard fork version, then both of these permissions fallback to the `Signature` case, so that the now broken zkApps can be updated for the new hard fork.
32
28
33
-
An account permission that is set to either of these new permissions can be updated when the `txn_version` referenced is older than the current hard fork version. This scenario ignores restrictions by `set_permission`, and operates as if `set_permission` were `Signature`.
34
-
35
-
The transaction snark asserts that any `txn_version` referenced by any account permission cannot be newer than the current protocol version.
29
+
The details for updating an old version account to a new version account are elided in this proposal and will be determined on a per upgrade basis. As such, we will keep the existing `zkapp_version` on accounts, storing both the `zkapp_version` of an account and the verificatin key permission `txn_version` separately. This separation means that the migration of an account's format happens separately from the account's smart contract migration. The migration of the account format can flexibly be done either on-chain, upon first interaction with an account, or off-chain, during the hard fork package generation step (but the decision of which route to take is left until we know what we are upgrading to).
36
30
37
31
## Test plan and functional requirements
38
32
39
-
Unit tests will be written to test these new permissions, and a new test case will be added to the hard fork integration test.
33
+
Unit tests will be written to test these new permission rules, and a new test case will be added to the hard fork integration test.
40
34
41
35
The unit tests are to be written against the transaction snark, testing various account updates as inputs. The tests are broken into categories by the expected result: that the statement is unprovable, that the statement was proven to be failed, or that the statement was proven to be successful.
42
36
43
37
* Unprovable account updates
44
-
* updates operating on an account in the ledger where the `verification_key` permission is set to `Proof` or `Impossible`
45
-
* updates operating on an account in the ledger where the `verification_key` permission is set to `Proof_during_hard_fork` or `Impossible_during_hard_fork` that references a `txn_version` that is greater than the current hard fork version
46
-
* updates which set the `verification_key` permission to `Proof` or `Impossible`
47
-
* updates which set the `verification_key` permission to `Proof_during_hard_fork` or `Impossible_during_hard_fork` that references a `txn_version` other than the current hard fork version
38
+
* updates which set the `verification_key` permission to `Proof` or `Impossible` with a `txn_version` other than the current hard fork version
48
39
* Failed account updates
49
-
* updates which set the `verification_key` permission to `Proof_during_hard_fork` or `Impossible_during_hard_fork` that references a `txn_version` equal t the current hard fork version if `set_permission` does not allow it.
50
-
* updates that modify the `verification_key` using a `Signature` authorization when the `verification_key` permission is set to `Proof_during_hard_fork` or `Impossible_during_hard_fork`.
51
-
* updates that modify the `verification_key` when the `verification_key` permission is set to `Impossible_during_hard_fork` set to the current hard fork version.
52
-
* updates that modify `verification_key` using a `Signature` authorization when the `verification_key` permission is set to `Proof_during_hard_fork` or `Impossible_during_hard_fork` set to the current hard fork version
53
-
* updates that modify the `verification_key` permission using a `Signature` authorization whenever the `verification_key` permission is set to `Proof_during_hard_fork` or `Impossible_during_hard_fork` set to the current hard fork version when the `set_permission` is not `None`, `Either`, or `Signature`
40
+
* updates which modify the `verification_key` permission in a way that violates the `set_permission` setting while the account's verification key permission's `txn_version` is equal to the current hard fork version
41
+
* updates which modify the `verification_key` using `Signature` or `None` authorizations when the `verification_key` permission is set to `Proof` or `Impossible` while the account's verification key permission's `txn_version` is equal to the current hard fork version
42
+
* updates which modify the `verification_key` using a `Proof` authorization when the `verification_key` permission is set to `Impossible` while the account's verification key permission's `txn_version` is equal to the current hard fork version
54
43
* Successful account updates
55
-
* updates which set the `verification_key` permission to `Proof_during_hard_fork` or `Impossible_during_hard_fork` that references a `txn_version` equal t the current hard fork version, given `set_permission` allows it.
56
-
* updates that modify the `verification_key` using a `Proof` authorization when the `verification_key` permission is set to `Proof_during_hard_fork` set to the current hard fork version.
57
-
* updates that modify the `verification_key` using a `Signature` authorization when the `verification_key` permission is set to `Proof_during_hard_fork` or `Impossible_during_hard_fork` set to an older hard fork version
58
-
* updates that modify the `verification_key` permission using a `Signature` authorization whenever the `verification_key` permission is set to `Proof_during_hard_fork` or `Impossible_during_hard_fork` set to an older hard fork version (even if `set_permission` disagrees)
44
+
* updates which set the `verification_key` permission to `Proof` or `Impossible` with a `txn_version` equal to the current hard fork version, given `set_permission` allows it
45
+
* updates that modify the `verification_key` using a `Proof` authorization when the `verification_key` permission is set to `Proof` while the account's verification key permission's `txn_version` is equal to the current hard fork version
46
+
* updates that modify the `verification_key` using a `Signature` authorization when the `verification_key` permission is set to `Proof` or `Impossible` while the account's verification key permission's `txn_version` is less than the current hard fork version
47
+
* updates that modify the `verification_key` permission using a `Signature` authorization whenever the `verification_key` permission is set to `Proof` or `Impossible` while the account's verification key permission's `txn_version` is less than the current hard fork version (even if `set_permission` disagrees)
59
48
60
49
The new test cases in the hard fork integration tests will utilize 2 accounts in the ledger which we will name A and B. The new test cases are as follows:
61
50
62
51
* Before the hard fork
63
-
* Attempt to set any account's `verification_key` permission to `Proof_during_hard_fork` for the wrong hard fork
64
-
* Attempt to set any account's `verification_key` permission to `Impossible_during_hard_fork` for the wrong hard fork
65
-
* Set A's `verification_key` permission to `Proof_during_hard_fork` for the current hard fork
66
-
* Set B's `verification_key` permission to `Impossible_during_hard_fork` for the current hard fork
52
+
* Attempt to set any account's `verification_key` permission to `Proof` for the wrong hard fork
53
+
* Attempt to set any account's `verification_key` permission to `Impossible` for the wrong hard fork
54
+
* Set A's `verification_key` permission to `Proof` for the current hard fork
55
+
* Set B's `verification_key` permission to `Impossible` for the current hard fork
67
56
* Check that you can still update A's `verification_key` using the `Proof` authorization
68
57
* Check that neither A nor B can have their `verification_key` updated using the `Signature` authorization
69
58
* After the hard fork
@@ -79,3 +68,4 @@ The new test cases in the hard fork integration tests will utilize 2 accounts in
79
68
80
69
* Should we require that any outdated permissions must be reset by the first account update sent to it?
81
70
* At a glance, this seems to make sense, but it also seems unnecessarily restrictive.
71
+
* DECISION: it is unnecessary to enforce this, especially given we are tracking the verification key permission's `txn_version` separately from the `zkapp_version` of the underlying account
0 commit comments