Skip to content

fix!: more missing boolean constraints in calldata, calldata hashing, sha256 mem PILs#19367

Merged
dbanks12 merged 1 commit into
merge-train/avmfrom
db/more-bools
Jan 7, 2026
Merged

fix!: more missing boolean constraints in calldata, calldata hashing, sha256 mem PILs#19367
dbanks12 merged 1 commit into
merge-train/avmfrom
db/more-bools

Conversation

@dbanks12

@dbanks12 dbanks12 commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

Found by claude

@dbanks12 dbanks12 marked this pull request as ready for review January 6, 2026 20:37

dbanks12 commented Jan 6, 2026

Copy link
Copy Markdown
Contributor Author

Comment on lines 108 to 111
////////////////////////////////////////////////
pol commit start;
pol commit start; // @boolean
start * (1 - start) = 0;
start * (1 - sel) = 0;

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 couldn't convince myself that this was secure without the explicit boolean constraint. For this instance and others, I think we should consider... is it really worth omitting explicit boolean constraints? If it makes it easier to reason about, what is the real cost?

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.

Actually it is not necessary but I would add the following explanations:
start * (1 - sel) = 0; means that start != 0 ==> sel == 1 or equivalently sel == 0 ==> start == 0
And from #[START_AFTER_LAST], we have sel == 1 ==> start is boolean.
Together, we have the guarantee that start is boolean.

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 wonder if it's really worth leaving such things "implicitly" constrained. What might be the cost of constraining EVERY boolean explicitly? These things are quite hard to read about and we're going to have comments all over like "this is implicitly constrained to be boolean because of X, Y, Z" that will probably add time to audits

@MirandaWood MirandaWood 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.

Nice! I think for calldata we assumed some of these weren't necessary (calldata.pil is essentially just hints, and is looked up into by a usually constrained local sel, and calldata_hashing looks up the posiedon trace via sel for every active row). But as you say it's much easier to reason about when we're explicit! 🚀

@dbanks12 dbanks12 merged commit fb000f6 into merge-train/avm Jan 7, 2026
9 checks passed
@dbanks12 dbanks12 deleted the db/more-bools branch January 7, 2026 18:42
@AztecBot AztecBot mentioned this pull request Jan 7, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Jan 8, 2026
BEGIN_COMMIT_OVERRIDE
feat(avm)!: optionally use TS logger in C++ simulation (#19305)
chore(avm): bytecode caching comments
chore(avm): disable VK hash checking in tests
fix(avm)!: instr_fetching soundness bug (#19381)
fix(avm): dont catch wide exceptions (#19388)
refactor(avm): Refactor get contract instance fuzzer backfill (#19387)
feat(avm): mutate enqueued calls (#19315)
chore(avm): migrate to BB asserts (#19395)
fix!: more missing boolean constraints in calldata, calldata hashing,
sha256 mem PILs (#19367)
feat(avm): defensively assert cd hashes (#19346)
chore: annotate booleans in PIL, and add some missing boolean
constraints (#19371)
fix!: missing boolean constraints on zero checks targets (#19401)
fix!: context did not constrain returndata size to 0 at start, and had a
misnamed relation (#19404)
END_COMMIT_OVERRIDE
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.

3 participants