0xMiden / 0xMiden/protocol

Allow accounts to read and write to memory region in kernel

Đang mở
#1,338 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
kernels
Ngôn ngữ chính
Rust
Star
132
Fork
167
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
110

Mô tả

## 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).

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.