Skip to content

Upstream symbolic bytes lookup, List membership lemmas #2702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 1, 2025

Conversation

palinatolmach
Copy link
Contributor

@palinatolmach palinatolmach commented Feb 6, 2025

Closes #2476.

This PR adds lemmas for lookups in partially symbolic bytes arrays; specifically, in runtime bytecode of contracts that contain immutable variables that are initialized in a constructor with a symbolic value. It also adds List membership lemmas that facilitate checking if a performed call is allowed in Kontrol when the allowCalls cheatcode is used.

Once this PR is merged, the relevant lemmas should be removed from KONTROL-AUX-LEMMAS and https://github.com/runtimeverification/kontrol/blob/master/src/tests/integration/test-data/symbolic-bytes-lemmas.k.

@palinatolmach palinatolmach changed the title Add bytes lookup lemmas for symbolic immutables Upstream symbolic bytes lookup, List membership lemmas Jul 29, 2025
@palinatolmach palinatolmach marked this pull request as ready for review July 31, 2025 14:03

rule [lookup-as-asWord]:
B:Bytes [ I:Int ] => #asWord ( #range ( B, I, 1 ) )
requires 0 <=Int I andBool I <=Int lengthBytes(B)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be I <Int lengthBytes(B) instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, it should be, thank you @lucasmt! It is I <Int lengthBytes(B) in the rule we're using in Kontrol, I'll update it here. I guess I should also make sure Kontrol tests are passing with this version of KEVM, I'll open a PR in Kontrol checking that and will merge it — with the <Int change — if they're passing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in d38bec6.

Copy link
Contributor

@lucasmt lucasmt left a comment

Choose a reason for hiding this comment

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

I'm approving the PR, just have one comment above that I think needs to be addressed before it's merged

@palinatolmach
Copy link
Contributor Author

I opened a PR in Kontrol to test if upstreamed lemmas don't negatively affect the tests and are applied if I take out the same lemmas from Kontrol aux files. The tests are passing: runtimeverification/kontrol#1059 (there's a minor expected output diff in some end-to-end tests that don't seem relevant). I updated the bytes lookup lemma according to @lucasmt's suggestion too. @anvacaru I'd merge it tomorrow if it looks good to you too.

Copy link
Contributor

@anvacaru anvacaru left a comment

Choose a reason for hiding this comment

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

LGTM!

@automergerpr-permission-manager automergerpr-permission-manager bot merged commit 0f07bcd into master Aug 1, 2025
12 checks passed
@automergerpr-permission-manager automergerpr-permission-manager bot deleted the add-bytes-lookup-lemmas branch August 1, 2025 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upstream symbolic bytes lemmas for CSE
3 participants