0xMiden / 0xMiden/protocol

`Account::apply_patch` rejects full-state patches

Ouverte
#3,292 7 commentaires 1 réaction 0 personnes assignées Voir sur GitHub
Langage dominant
Rust
Étoiles
132
Forks
167
Merge moyen
1 j 23 h
PR mergées (30 j)
110

Description

`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?

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.