Skip to content
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

Check real stack changes inside function vs its definition #302

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

igorline
Copy link

@igorline igorline commented Oct 3, 2023

This PR introduces compiler error on incorrect takes/returns specification for huff functions as this produces broken bytecode.
Related research https://twitter.com/igorlineee/status/1699206608994078949

Missing tests yet, but would like to know opinions on my implementation.

Opcode::Push30 => (0, 1),
Opcode::Push31 => (0, 1),
Opcode::Push32 => (0, 1),
Opcode::Dup1 => (1, 2),
Copy link
Contributor

Choose a reason for hiding this comment

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

these dup and swap look wrong

Copy link
Author

@igorline igorline Oct 3, 2023

Choose a reason for hiding this comment

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

agree, followed blindlly evm.codes :/ here different context

Copy link
Author

Choose a reason for hiding this comment

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

force-pushed the fix

Copy link
Author

Choose a reason for hiding this comment

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

@devtooligan was testing it against elohim contract and indeed we need those numbers
if inside macro I would first do swap1 then, I need to be sure that stack is having at least 2 elements

@igorline igorline force-pushed the compiler-error-incorrect-fn-returns branch from 61241ef to 28020a4 Compare October 3, 2023 19:45
@igorline igorline force-pushed the compiler-error-incorrect-fn-returns branch from 28020a4 to c562b98 Compare October 3, 2023 20:12
@igorline igorline marked this pull request as ready for review October 3, 2023 21:54
@igorline igorline force-pushed the compiler-error-incorrect-fn-returns branch 2 times, most recently from ab98df2 to 43d3f4c Compare October 9, 2023 20:40
@igorline igorline force-pushed the compiler-error-incorrect-fn-returns branch from 43d3f4c to 6c32e66 Compare October 10, 2023 10:06
@igorline
Copy link
Author

This is ready to review. Hoping to get this merged and make my huff friends safe with outlined macros
cc @Maddiaa0 @clabby

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.

None yet

2 participants