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

Update zkapp-development-frameworks.mdx #1072

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JanSlobodnik
Copy link

update the doc with protokit and explanation for devs to know which one to select
This update is without the decision tree image, i need push access to add images.

update without decision tree image
@JanSlobodnik JanSlobodnik requested a review from a team as a code owner November 13, 2024 12:55
Copy link

vercel bot commented Nov 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs2 ❌ Failed (Inspect) Nov 21, 2024 5:33am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
07-oracles ⬜️ Ignored (Inspect) Visit Preview Nov 21, 2024 5:33am

Copy link

vercel bot commented Nov 13, 2024

@JanSlobodnik is attempting to deploy a commit to the o1labs Team on Vercel.

A member of the Team first needs to authorize it.


:::
Applications on Mina are called zkApps, and they come in a wide range of forms, including DeFi, games, state bridges, and more. However, due to Mina’s client execution model, the developer experience differs somewhat from that of other blockchain networks, such as Ethereum.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "client side execution model"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

</tr>
<tr>
<td>Please note that **Protokit is in alpha**, and settlement support with reorgs is still in progress.
<p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no closing tag for

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

<tr>
<td>For developers coming from the Ethereum ecosystem, think of zkApps like smart contracts that can be verified off-chain.
<p>
This enables Mina to employ a client execution model, which gives Mina its scalability and privacy properties, but it can make it difficult to develop applications with concurrent users requiring a shared state. Protokit builds on top of o1js to solve these concurrency challenges.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: client side

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

- [Developer documentation](/zkapps/o1js)
- [o1js repository](https://github.com/o1-labs/o1js)
- [Discord](https://discord.gg/minaprotocol)
[o1js](https://docs.minaprotocol.com/zkapps/o1js) is the best way to author **highly-optimized ZK circuits and primitives**, but it does not provide an easy-to-use solution for managing a shared global state.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OffchainState provides an out-of-the box solution to this. It's worth mentioning here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

o1js is also the only way to interfact directly with the protocol, its "not just" a tool for primitives

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should highlight offchain state as a serious way to handle app state until it's out of the experimental namespace. I don't think we should make casual references to things in the docs until we're ready to stand behind them 100%.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we consider this closed? Jan has address Florian's comment and we're not going to include mention of OffchainState.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not true that OffchainState is a solution to race conditions on "shared global state" as suggested above. It only solves this for user-specific state. The thing is that you can't concurrently compute over shared global state without any form of on-chain execution. That is why we built protokit, to add that possibility to the features already existing in o1js.
If you wanted to do the same with vanilla-o1js features and then polish the DX, solve other limitations in the process and then make the system efficient, you'd pretty much end up with protokit in based sequencing mode (which is the first mode we will ship)

1. Are you willing to trade off L1 censorship resistance and liveness guarantees for high throughput and low latency?*
1. Yes - Hybrid mode
2. No - Based mode
2. No - o1js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existence of OffchainState makes this tree a bit complicated than this. It's true that OffchainState is not scalable as base mode Protokit since it doesn't keep a db thus recreates the offchain state Merkle tree on-the-fly which creates an overhead. But, It's ready to use now (not production-ready) and worth mentioning in the tree.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering this closed.


# zkApp Development Frameworks
Developers build zkApps with **o1js**. Developers can either use o1js directly or use o1js with **Protokit**, a framework built on top of o1js. Both options offer the full benefits of Mina’s verifiable, privacy-preserving zero knowledge proofs, but offer different tradeoffs between developer experience, performance, and decentralization.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both options offer the full benefits of Mina’s verifiable, privacy-preserving zero knowledge proofs

Do they actually? Natively, afaik Protokit executes business logic on a server/"on-chain" - away from the client - this would render privacy-preserving not true in the default case

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An example from the protokit docs:

@runtimeModule()
export class Balances extends RuntimeModule<Record<string, never>> {
  @state() public balances = StateMap.from(PublicKey, UInt64);
 
  @runtimeMethod()
  public mint(canMintProof: CanMintProof, amount: UInt64) {
    canMintProof.verify();
    this.balances.set(address, amount);
  }
}

Seems like using a proof input would be a valid way of preserving privacy on protokit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not the default tho whereas with o1js it is, because everything happens locally on the clients machine

Copy link
Member

@Trivo25 Trivo25 Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a difference between opt-in and opt-out so this needs to be highlighted

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a Protokit runtime you can accomplish the same architecture patterns as with account updates, but you'll have an easier time customizing the on-chain protocol part, something that is not possible with a general purpose smart contract L1. So privacy is indeed optional, but that's actually a feature you can leverage, which mitigates the concurrency issues of current smart contracts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So privacy is indeed optional, but that's actually a feature you can leverage, which mitigates the concurrency issues of current smart contracts.

I am not saying it isn't a feature! But a big difference that users should be made aware of, especially since the default is on-chain execution.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is everyone ok to leave this as is? The statement is still correct - both frameworks allow for privacy. The details of how to implement for privacy can be left for deeper level docs. The key point to land here is that you can build a privacy-preserving app using either framework.


Protokit is built on top of o1js and simplifies the development of **zkApps with concurrent users requiring a shared state**, such as DEXes or games. Protokit is recommended for most developers.

O1js is the best way to write **custom zero knowledge circuits** and construct low-level primitives on Mina, such as an NFT standard or a zkML library.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

o1js not O1js

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


Developers can build zkApps either directly with **o1js**, or with **o1js** + **Protokit**.

Protokit is built on top of o1js and simplifies the development of **zkApps with concurrent users requiring a shared state**, such as DEXes or games. Protokit is recommended for most developers.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protokit is recommended for most developers.
is it? What's some examples when this is the case and when it isn't? If we recommend something we should clearly lay out the motivations

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll remove "Protokit is recommended for most developers."

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed (removed sentence)

</td>
</tr>
<tr>
<td>For developers coming from the Ethereum ecosystem, think of zkApps like smart contracts that can be verified off-chain.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zkApps aren't verified off-chain, they are proven off-chain and verified on-chain

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed




## Protokit[​](https://docs.minaprotocol.com/zkapps/zkapp-development-frameworks#protokit)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this link is broken

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

- [Developer documentation](/zkapps/o1js)
- [o1js repository](https://github.com/o1-labs/o1js)
- [Discord](https://discord.gg/minaprotocol)
[o1js](https://docs.minaprotocol.com/zkapps/o1js) is the best way to author **highly-optimized ZK circuits and primitives**, but it does not provide an easy-to-use solution for managing a shared global state.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

o1js is also the only way to interfact directly with the protocol, its "not just" a tool for primitives


## [Protokit](https://protokit.dev/)
o1js can be used directly on the Mina L1, and is thus limited by the L1’s throughput and latency, but maintains strong decentralization guarantees.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a good way to phrase this. o1js is a tool that lets you build whatever on top of Mina, you can build your own app-specific rollups that would not be limited by the L1s throughput.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @Trivo25, we should be clear in distinguishing the terminology between "general o1js" and "smart contracts / account updates"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Trivo25 @maht0rz how would you recommend changing this sentence? We're trying to make the point here that o1js has to use L1 sequencing and therefore is constrained by L1's throughput and latency but with strong decentralization guarantees.


**Still can’t decide between Protokit and o1js?**

This section provides a simple decision tree x`and comparison table to help zkApp developers choose which framework to use.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tree x`and

typo?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


![Decision Tree for zkApp devs](/img/decision-tree.png)

Are you developing a zkApp with concurrent users requiring a shared state?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a fan of this decision tree. It ignores many details and will, imo in most cases, point developers to the wrong tools. We should educate devs on the benefits of both options, instead of assuming their use cases will just fit into one of two buckets

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll remove the decision tree and leave the table

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed decision tree, only table remains

Copy link
Contributor

@45930 45930 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JanSlobodnik

Will the protokit documentation be moving to the mina protocol docs? The part about based vs. hybrid sequencing seems like it could be its own article in the protokit docs.

Overall, what message is this change intended to deliver? I think as-written it's in quite a confusing state where it pretty explicitly recommends protokit, but still makes references to o1js to be polite. If the goal is simply to say "protokit is the app development platform for Mina", this halfway approach seems too weak. If the goal is to say "o1js and protokit are two app development platforms for Mina", then I think we should remove recommendations for one or the other, and stick to the facts. I also think a factual approach will scale better when other frameworks are added.

Also, should we expect more similar PRs for docs pages as part of an effort to clean up the marketing, or is this a one-off?

@andrewferrone
Copy link

@45930 yes the idea is to move the Protokit documentation to the Mina Protocol docs in the future.

This update is intended to address one of the most common questions we've heard from devs when confronted with o1js and Protokit - which should I use?

The intent was to land a few core messages:

  1. It's not o1js or Protokit, but rather o1js directly or Protokit on top of o1js.
  2. Protokit provides an "out-of-the-box" solution for developing apps across shared state. What types of apps are those? DEXes, lending protocols, games, most apps.
  3. Protokit has tradeoffs though (decentralization vs. throughput and latency) and can be configured in two ways - Based and Hybrid modes - depending on the dev's requirements for decentralizations vs. throughput and latency.

The goal is to help devs choose whether to develop on o1js directly or Protokit on top of o1js. If you see specific areas that are confusing let's definitely clear them up.

@45930
Copy link
Contributor

45930 commented Nov 18, 2024

@andrewferrone Thanks for the reply!

one of the most common questions we've heard from devs when confronted with o1js and Protokit - which should I use?

I see! Yeah, it makes sense that people are confused by this, but I don't think there is a simple answer.

It's not o1js or Protokit, but rather o1js directly or Protokit on top of o1js.

I love this message, no issues with this from my side

Protokit provides an "out-of-the-box" solution for developing apps across shared state. What types of apps are those? DEXes, lending protocols, games, most apps.

This seems overly prescriptive to me and it also puts a narrow view on the potential use cases for Mina. What if this message was re-written more as a comparison table that explains the properties of each option? I suppose the difference between this format and a decision tree is that it's more ambiguous and doesn't lead to a specific recommendation, but it gives devs a lot more direction about how to start making their decision.

Maybe this is too many columns, but something like this, e.g.

o1js circuits only o1js on Mina Protokit on Mina (Based) Protokit on Mina (Hybrid)
Throughput
Latency
Centralization
Infrastructure Requirements
...

@andrewferrone
Copy link

@45930 did you see the comparison table at the bottom of the page?

We can remove the decision tree.

What if this message was re-written more as a comparison table that explains the properties of each option? I suppose the difference between this format and a decision tree is that it's more ambiguous and doesn't lead to a specific recommendation, but it gives devs a lot more direction about how to start making their decision.

Maybe this is too many columns, but something like this, e.g.

o1js circuits only o1js on Mina Protokit on Mina (Based) Protokit on Mina (Hybrid)
Throughput
Latency
Centralization
Infrastructure Requirements
...

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

Successfully merging this pull request may close these issues.

7 participants