Skip to content

fix!: misc avm - fixes constraints, ts sim, cpp sim, tracegen#16664

Merged
dbanks12 merged 1 commit intonextfrom
db/misc-fixes-sideeffects
Sep 1, 2025
Merged

fix!: misc avm - fixes constraints, ts sim, cpp sim, tracegen#16664
dbanks12 merged 1 commit intonextfrom
db/misc-fixes-sideeffects

Conversation

@dbanks12
Copy link
Copy Markdown
Contributor

@dbanks12 dbanks12 commented Aug 29, 2025

Fixes to alu, context, execution, tx pil. Fixes to tx execution and tx tracegen. Trace side-effect operations before they fail in TS state manager. Always perform nullifier non-membership check on non-existence in AVM TS. Side-effects rollbacks in tx execution.

  1. ALU PIL should disable C's tag check on sel_err (any error) rather than sel_tag_err. It at least needs to be disabled on div-by-0 as well.
  2. sel_instruction_fetching_success should be forced to 0 on bytecode retrieval faliure.
  3. TX's dispatch "end" interaction to execution's should use execution's sel_failure to capture "error or revert opcode".
  4. Bytecode retrieval failures should emit an event that includes tree roots so that non-membership can be performed.
  5. When bytecode is not found for a contract call, the execution trace's empty row should have opcode 0.
  6. TX trace should snapshot and restore end-setup's side effect states.
  7. Execution tracegen should handle "exit call scenarios" in a separate if-statement to individual opcodes, because if an opcode errors, we need to set all of the selectors for "exit", but also need to tracegen the failing opcode.
  8. In the TS avm simulator, contract instance retrieval should perform the nullifier [non]membership check even if the instance does not exist.

@dbanks12 dbanks12 changed the title fix!: avm fixes to alu, context, execution, tx pil. Fixes to tx execution and tx tracegen. Trace side-effect operations before they fail in TS state manager. Always perform nullifier non-membership check on non-existence in AVM TS. fix!: misc avm fixes constraints, ts sim, cpp sim, tracegen Aug 29, 2025
@dbanks12 dbanks12 changed the title fix!: misc avm fixes constraints, ts sim, cpp sim, tracegen fix!: misc avm - fixes constraints, ts sim, cpp sim, tracegen Aug 29, 2025
@dbanks12 dbanks12 force-pushed the db/misc-fixes-sideeffects branch from 78f4786 to 3c874e4 Compare August 29, 2025 17:49
@dbanks12 dbanks12 marked this pull request as ready for review August 29, 2025 17:50
Comment thread barretenberg/cpp/pil/vm2/alu.pil
Copy link
Copy Markdown
Contributor

@IlyasRidhuan IlyasRidhuan left a comment

Choose a reason for hiding this comment

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

LGTM! The comments are minor and more nit-ty

Comment thread barretenberg/cpp/pil/vm2/execution.pil Outdated
`Contract instance for address ${contractAddress} in DB: ${exists} != nullifier tree: ${nullifierExistsInTree}. This is a bug!`,
);
}

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.

Feels like instead of this coud be re-organised to use the early return instead of this extra if statement. Is the order of checks the following?

  1. isCanonical ? return instance
  2. Nullifier (non)member check
  3. Return instance (already checked to undefined if !exists)

We probably don't even need the if(exists) branch (the log can be made more generic)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it can be simplified to this, but we need an if exists or if !exists somewhere, at least to gate the update check.
image

Comment thread barretenberg/cpp/src/barretenberg/vm2/simulation/execution.cpp Outdated
…tion and tx tracegen. Trace side-effect operations before they fail in TS state manager. Always perform nullifier non-membership check on non-existence in AVM TS.
@dbanks12 dbanks12 force-pushed the db/misc-fixes-sideeffects branch from 3c874e4 to 953f475 Compare September 1, 2025 17:53
@dbanks12 dbanks12 enabled auto-merge September 1, 2025 18:00
@dbanks12 dbanks12 added this pull request to the merge queue Sep 1, 2025
Merged via the queue into next with commit 331ad6c Sep 1, 2025
15 checks passed
@dbanks12 dbanks12 deleted the db/misc-fixes-sideeffects branch September 1, 2025 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants