0xMiden / 0xMiden/protocol

`Account::apply_patch` rejects full-state patches

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

描述

`Account::apply_patch` rejects a full-state `AccountPatch` (the kind produced by an account creating transaction), forcing callers to branch on `AccountPatch::is_full_state()` and reconstruct the account via `Account::try_from(&patch)` instead of applying the patch uniformly. This is a DX rough edge: consumers that maintain an in-memory account by applying successive patches need two code paths where one would be natural.

In the node's `network-monitor`, the monitor wallet is created in-memory and never separately deployed, so its *first* increment transaction doubles as the account-creation transaction. That transaction's patch is full-state (it carries the account code + full initial state), so `apply_patch` cannot be used and we must special-case it:

```rust
if account_patch.is_full_state() {
self.wallet_account = Account::try_from(account_patch)
.expect("full-state patch should convert to a valid account");
} else {
self.wallet_account
.apply_patch(account_patch)
.expect("successful tx should apply patch correctly");
}

Can the `is_full_state()` be absorbed into `apply_patch`?
Is there a reason a full-state patch can't be applied onto a nonce-0 empty account?

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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