Skip to content

feat: swap AccountDelta for AccountPatch in executed and proven transaction#3089

Open
PhilippGackstatter wants to merge 7 commits into
pgackst-patch-mergefrom
pgackst-account-kernel-patch
Open

feat: swap AccountDelta for AccountPatch in executed and proven transaction#3089
PhilippGackstatter wants to merge 7 commits into
pgackst-patch-mergefrom
pgackst-account-kernel-patch

Conversation

@PhilippGackstatter

@PhilippGackstatter PhilippGackstatter commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Stacks on top of #3082 and replaces the account delta with the account patch in the transaction account update path: the kernel-emitted commitment, TxAccountUpdate, AccountUpdateDetails, the batch and block account update flows, and the prover.

Changes

  • AccountUpdateDetails::Delta(AccountDelta) becomes AccountUpdateDetails::Public(AccountPatch).
  • TxAccountUpdate::account_delta_commitment becomes account_patch_commitment, and its validator checks the carried AccountPatch against that commitment directly.
  • The transaction kernel epilogue now calls the new account_delta::compute_patch_commitment (module to be renamed) and hashes it together with the final account commitment to produce ACCOUNT_UPDATE_COMMITMENT.
  • The host's AccountUpdateTracker::into_patch is now wired in: TransactionBaseHost::into_parts returns both the delta and the patch, the executor reconciles account_patch.to_commitment() against tx_outputs.account_patch_commitment(), and the prover uses the patch when building the ProvenTransaction.
  • ExecutedTransaction gains an account_patch field, so consumers can inspect the absolute post-transaction state. Delta is kept for this PR.
  • Moves the TxAccountUpdate::account_id == AccountPatch::account_id so it always runs for public accounts, not just for new public accounts.

Temporary pre-fee / post-fee handling

Under the old delta flow the kernel committed to the pre-fee delta, while the host carried the post-fee delta in AccountUpdateDetails::Delta (the fee asset had been removed). The verifier worked around this by re-adding the fee asset to the carried delta before checking it against the committed pre-fee commitment, then removing it again.

This PR makes the assumption that the automatic fee removal in the tx kernel will go away and be replaced with a fee note, which will no longer have this pre-post-fee split. So, this PR treats the pre-fee patch as the patch of the entire transaction. This is not correct under the current fee model (the fee removal is not reflected in the patch), but it would be correct under the planned note-based fee model. This PR disables one test that fails because of this mismatch (prove_account_creation_with_fees) that should be re-enabled (or removed if no longer useful) once we have refactored fees.

Follow-Ups

  • Remove AccountDelta from ExecutedTransaction. For now kept because it's still used in many tests and those will be refactored separately.
    • With this change, we can remove the temporary account_delta::compute_commitment call in the epilogue. It still calls account_delta::compute_commitment (and drops the result) right after compute_patch_commitment, because the host's delta event hooks fire from that procedure and downstream code still observes the delta.
  • Rename $kernel::account_delta module to account_update since it contains both delta and patch logic.
  • Rename $kernel::account_delta::compute_commitment to compute_delta_commitment.
  • Rename update* procedures in account_delta.masm to commit* for clarity.
  • Refactor test_account_delta to a different approach since the tests previously relied on the executor checking the delta commitment match, but this is no longer the case. As part of this, integrate patch testing into this test module.

@PhilippGackstatter PhilippGackstatter added the pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority label Jun 12, 2026
@PhilippGackstatter PhilippGackstatter force-pushed the pgackst-account-kernel-patch branch 2 times, most recently from 20ddffe to decf3cc Compare June 12, 2026 11:40
@PhilippGackstatter PhilippGackstatter marked this pull request as ready for review June 12, 2026 12:16
@PhilippGackstatter PhilippGackstatter force-pushed the pgackst-account-kernel-patch branch from 3869ea8 to 553a27a Compare June 12, 2026 12:38

@bobbinth bobbinth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you! I left just a couple of small comments inline.

Comment on lines 37 to +38
/// The commitment to the delta computed by the transaction kernel.
account_delta_commitment: Word,
account_patch_commitment: Word,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment here needs to be updated.

Comment on lines +321 to +325
/// The commitment to the [`AccountPatch`](crate::account::AccountPatch) resulting from the
/// execution of the transaction, as computed by the transaction kernel in the epilogue. It
/// must equal the commitment of the patch carried in [`AccountUpdateDetails::Public`] when
/// present.
account_patch_commitment: Word,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last sentence is a bit unclear: if AccountUpdateDetails is Private is account_patch_commitment set to anything (or is it an empty word)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants