Handling reference block on transaction execution
- 主要语言
- Rust
- 星标
- 78
- 派生
- 129
- 平均合并
- 4 天 14 小时
- 30 天内合并 PR
- 52
描述
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.
贡献指南
调研方向
查看 `Client::execute_transaction` 方法及其如何将当前同步高度用作 `ref_block`。通过数据存储检查执行器的 MMR 构建逻辑。审查 `blockchain_checkpoint` 存储以了解峰值是如何被跟踪的。目标是确保在并发状态同步期间 MMR 与 `ref_block` 的一致性。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- rust
- 领域
- backend, blockchain
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100