0xMiden / 0xMiden/protocol

Allow accounts to read and write to memory region in kernel

Abierto
#1,338 3 comentarios 0 reacciones 0 asignados Ver en GitHub
kernels
Lenguaje dominante
Rust
Estrellas
132
Forks
167
Merge medio
1 d 23 h
PR fusionados (30 d)
110

Descripción

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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.