0xMiden / 0xMiden/protocol

`Account::apply_patch` rejects full-state patches

オープン
#3,292 コメント 7 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
Rust
スター
132
フォーク
167
平均マージ
1日 23時間
マージ済み PR(30日)
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 を短くまとめたダイジェスト。