Thank you, Matej, for submitting this RFC. I see some incredible work in arranging this proposal, and I think that the technical design behind it is solid. I’ve also reviewed the insightful follow-up discussions, though I joined them quite late in the process.
I have a few questions regarding the technical implementation details of this design. These are relatively low-level concerns that I’m curious about, but they may ultimately affect our assessment of whether a hard fork is truly not required for this project.
I want to highlight that I’m by no means the most knowledgeable person when it comes to writing zkApps, so if my questions seem naive, I apologize for potentially diverting the discussion. However, it would still be helpful for me to understand a few design details you’re considering.
Staking Ledger Access and Voting Mechanics
As I understand it, a key component in this zkApp design is the ability to reference the staking ledger that corresponds to a specific historical state. I have a few questions about this:
-
Ledger Snapshot Timing: Could you specify more precisely which ledger we will be using for voting?
-
Will it always be the staking ledger at the time the vote is cast, or will it be the staking ledger at the time the proposal was submitted?
-
Assuming that voting for a proposal may take at least a few days, and considering that in the future we might reduce slot times leading to shorter epochs, we could have situations where the staking ledger changes during the voting period. If in this design code looks to the ledger state that was captured at the time of proposal submission, this isn’t a concern, of course.
-
Programmatic Ledger Access: How do you plan to programmatically access that ledger from the zkApp? If you could share some zkApp code snippets that demonstrate the ability to, for example, assert that the staking ledger root hash equals a specific value within the zkApp code, that would be extremely useful for understanding how this will work in practice.
Stake Delegation Computation Feasibility
Regarding the section that states:
“Mina Protocol’s ledger is a Merkle tree of accounts, where each account has a balance and a delegate. There’s no ‘total delegated stake’ per BP, since it’s not necessary for the consensus protocol (due to how VRF is implemented). This means that in order to determine the voting weight of an account, we need to iterate over all accounts delegated to the BP (or any valid voter) and sum up the delegated balance of each account.”
If I understand correctly, you’re saying that we will need to run computation over the entire ledger, and as a result, we’ll have some sort of tree-like structure containing information that maps each block producer to their total delegated stake — unless this information will be provided somehow by the protocol itself.
Do you think it’s actually feasible to create such a mapping using existing zkApp mechanisms, and would it be practical to perform this computation in practice? I mean, if it’s a very intensive computation that runs once and then the result can be posted to a zkApp, I think it’s perfectly viable unless it takes an impractical amount of time to compute. My intuition is that it’s probably possible, but I wanted to double-check because if the answer is that it’s not practical, then we would need to introduce a protocol-level feature, which would most definitely require a hard fork.
Looking forward to your insights on these technical details.