0xMiden / 0xMiden/rust-sdk

Handling reference block on transaction execution

Abierto
#2,139 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Rust
Estrellas
78
Forks
129
Merge medio
4 d 14 h
PR fusionados (30 d)
52

Descripción

After https://github.com/0xMiden/miden-client/pull/2100, the client only tracks the MMR peaks for the current sync height.

As mentioned [here](https://github.com/0xMiden/miden-client/pull/2100#discussion_r3157271113), I think there could be a problem with how we handle the `ref_block` on transaction execution.

`Client::execute_transaction` uses the current sync height as `ref_block` and passes it to the executor. The executor then builds the partial MMR through the data store. Since the client only stores peaks at the latest sync height, the MMR could not be consistent with the `ref_block`. If a concurrent `sync_state` advanced the chain between the caller capturing `ref_block` and the data store reading the peaks, the execution would fail.

I think there are two options here:

1. Assume a sync never runs during transaction execution. This would allow us to simplify the existing code by assuming the sync height is always the same during execution. It need to be documented (and ideally enforced).

2. Track historical peaks on the store. Allow `blockchain_checkpoint` to hold one row per chain tip we've seen, and look up peaks by `ref_block`. Since the client only accesses sync heigh, we only need to store the peaks for blocks that were added as chain tip, not for all intermediate blocks.

I think option 2 makes more sense and is probably the safest.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Look at the `Client::execute_transaction` method and how it uses the current sync height as `ref_block`. Examine the executor's MMR building logic via the data store. Review the `blockchain_checkpoint` storage to understand how peaks are tracked. The goal is to ensure MMR consistency with the `ref_block` during concurrent state syncs.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
rust
Área
backend, blockchain
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.