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

Permission preconditions #15982

Open
Trivo25 opened this issue Aug 26, 2024 · 1 comment · May be fixed by #16211
Open

Permission preconditions #15982

Trivo25 opened this issue Aug 26, 2024 · 1 comment · May be fixed by #16211
Assignees

Comments

@Trivo25
Copy link
Member

Trivo25 commented Aug 26, 2024

in o1js, and the zkApps protocol, we can set preconditions on certain network or account state in transactions/account updates (smart contracts) that only succeed if the preconditions are fulfilled.

There are two types of preconditions that we have access to:

  • network - anything network related (slot, timestamp, ..)
  • account - anything account related (balance, app state, nonce, ..)

However, account preconditions can not be set on account permissions. We want to enable zkApp developers to set preconditions on permissions. For example, we want a transaction only to succeed if another account has their permissions set to something specific.

In a zkApp, this would look like this:

class SimpleZkapp extends SmartContract {
  @method
  async doSmth() {
    // do something

    // assert that the balance is greater than 10
    let balance = this.account.balance.getAndRequireEquals();
    balance.assertGreaterThanOrEqual(UInt64.from(10));

    // assert that the nonce to equal to 1
    let nonce = this.account.nonce.getAndRequireEquals();
    nonce.assertEquals(UInt32.from(1));


   // ideally, setting preconditions on permissions would work the same way!
  }
}

In order to add preconditions on permissions, we have to adjust the protocol (and any resulting transaction structures, checks and o1js) accordingly.

For example, the body of an account update has a preconditions field that looks like this currently (this is auto generated from ocaml)

https://github.com/o1-labs/o1js-bindings/blob/ff3588199eaf8f423c4474862f049bf1d8ed4c77/mina-transaction/gen/transaction.ts#L268-L373?plain=1

Goal: Change the zkApps protocol (OCaml, transaction structure, txn snark checks, and eventually o1js) accordingly to support preconditions on accounts

@Geometer1729 Geometer1729 self-assigned this Aug 28, 2024
@Geometer1729
Copy link
Member

o1-labs/o1js#1862

@Geometer1729 Geometer1729 linked a pull request Oct 10, 2024 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants