0xMiden / 0xMiden/protocol

Allow accounts to read and write to memory region in kernel

未关闭
#1,338 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
kernels
主要语言
Rust
星标
132
派生
167
平均合并
1 天 23 小时
30 天内合并 PR
110

描述

## Motivation

Coming out of https://github.com/0xMiden/miden-base/issues/1331#issuecomment-2859942082, it could be useful in a variety of contexts for accounts to have access to a stable memory location. Because the VM does not assign the same memory context across `call`s, an account currently cannot persist anything in memory for the duration of the transaction. The only stable memory context is the kernel itself. So adding a `mem_{storew,loadw}`-like TX kernel API would enable this functionality.

From the above issue, one potential use case could be to keep track of the operations that were invoked on the account. The authentication code could then check if an operation was executed that requires authentication (such as minting assets) and if so, run signature verification. If not (e.g. if assets were burned), then the transaction could pass without requiring a signature verification.

There could be other uses cases for this, such as "cross-note communication" by going through account interfaces.

## Design

For this, we would need:
- A memory region in the kernel of some tbd size, that the native account is allowed to write to and read from arbitrarily.
- Two new kernel APIs, for writing and reading memory with equivalent "signatures" as `mem_{storew,loadw}`.
- `tx_mem_loadw` reads a single felt from the stack (the pointer) and returns the word at that location.
- `tx_mem_storew` reads 5 felts from the stack (the pointer and the word to be stored).
- These validate that the provided pointer points inside the allowed region.

One open question is how large the memory region should be. This depends on the use cases we can come up with for this. A safe bet would be to keep it small initially and increase if the need arises, mainly because increasing is a non-breaking change (API-wise).

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。