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

contract with only internal functions is executable #3446

Closed
tserg opened this issue May 23, 2023 · 2 comments
Closed

contract with only internal functions is executable #3446

tserg opened this issue May 23, 2023 · 2 comments

Comments

@tserg
Copy link
Collaborator

tserg commented May 23, 2023

Version Information

  • vyper Version (output of vyper --version): 95bf73f
  • OS: linux
  • Python Version (output of python --version): 3.10.8

What's your issue about?

A contract that only has internal functions besides the constructor may still compile to executable code. Internals are not pruned, and execution of the internal functions section is not guarded. Upon calling the contract, execution will start at the first internal function. However, execution will generally fail when POPping the RETURN_PC from the stack, which should be empty upon function exit.

h/t @trocher @ptrcarta

How can it be fixed?

Fill this in if you know how to fix it.

@charles-cooper charles-cooper changed the title bug: contract with only internal functions is executable contract with only internal functions is executable May 23, 2023
@charles-cooper
Copy link
Member

this was resolved in #3496

@charles-cooper
Copy link
Member

repro:

$ vyc -f ir_runtime /dev/stdin <<EOF
@internal
def foo():
  pass

EOF
[seq,
  [goto, fallback],
  [label, fallback, var_list, /* Default function */ [revert, 0, 0]],
  [seq,
    [label,
      internal_foo____runtime,
      [var_list, return_pc],
      [seq, [exit_to, internal_foo____cleanup, return_pc], pass]],
    [label, internal_foo____cleanup, [var_list, return_pc], [exit_to, return_pc]]]]

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

No branches or pull requests

2 participants