Skip to content

chore(avm)!: Bytecode Decomposition pre-audit docs - WIP#20120

Draft
MirandaWood wants to merge 3 commits intomerge-train/avmfrom
mw/avm-bc-decomp-pre-audit-docs
Draft

chore(avm)!: Bytecode Decomposition pre-audit docs - WIP#20120
MirandaWood wants to merge 3 commits intomerge-train/avmfrom
mw/avm-bc-decomp-pre-audit-docs

Conversation

@MirandaWood
Copy link
Contributor

WIP!

This branch is only low priority changes (no bug fixes or big logic changes) including:

  • New comments/documentation
  • Rearranging code
  • Renaming variables/relations

Applies to AVM-51

TODOs/Notes: See comments!

Comment on lines 141 to +143
// Remark: Depending on how bytecode hashing constraints work, we might remove this relation.
#[BC_DEC_SEL_BYTES_REM_NON_ZERO]
// MW note: We do NOT constrain this in bytecode hashing, but we could move it there. One downside of doing that is there are no lookups
// into this trace at /each row/ (all conditional e.g. sel_not_start) so we would need something gated by sel.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If everyone agrees, I could remove this Remark and keep #[BYTES_REM_NON_ZERO] in this trace?

Comment on lines 358 to +364
// NOTE: The bytecode hashing trace constrains that every 31st pc is packed, however
// we must duplicate this check here as we do not constrain uniqueness of bytecode ids:
// MW note: Is this true now that we use a permutation into this trace? The perm. looks up pc (constrained to be a multiple of 31),
// bytecode id (as above, not constrained to be unique, but is constrained to be consistent), and packed_field.
// We should ensure that packed_field is non zero when we have bytes to pack. IIUC this is enforced by hashing trace:
// hashing permutations are on as long as we have not finished the bytecode => sel_packed_read[i] must be on =>
// sel_packed must be on every 31st byte => #[BC_DECOMPOSITION_REPACKING] must be satisfied.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we could remove this check - would appreciate a logic check on this comment!
Since the hashing trace is the 'source', if it is 'off' then decomp could easily just skip any packing. But this may be ok since a) we seem to assume a decomp event is always accompanied by a hashing event and b) currently only the hashing trace makes use of packed_field and its correctness.

Comment on lines 379 to +380
// TODO: Once we manually optimize the generated files, this subrelation can benefit from short-circuit multiplication.
// MW note: Can we do this ^ now?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As above - I'm not sure what this old comment was referring to!

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.

1 participant