0xPolygonMiden / miden-client

Client library that facilitates interaction with the Miden rollup
MIT License
25 stars 22 forks source link

Catch invalid `AccountDelta`s before applying a transaction's result #389

Open igamigo opened 1 week ago

igamigo commented 1 week ago

What should be done?

When a transaction is executed and its results are applied in the store, it's possible that the account is not modified at all. This means that the nonce remains unchanged, as do the storage slots and the vault assets. If an account was new (nonce=0), and such a transaction is executed, when the transaction results are applied, the account gets saved with the same nonce and no seed which is rejected by the account. We should catch this before applying the result to more gracefully surface the error.

How should it be done?

Before transaction results get applied, check that there is no account state with the same nonce and error otherwise.

When is this task done?

When we error before applying transaction results with an account's existing nonce.

Additional context

An example of this happening is running cargo run --release init -p 1 1 1 1 on this repo/branch