Skip to content

Optimize nonpayable assertion#2307

Merged
iamdefinitelyahuman merged 3 commits into
vyperlang:masterfrom
iamdefinitelyahuman:feat-payable-check
Feb 16, 2021
Merged

Optimize nonpayable assertion#2307
iamdefinitelyahuman merged 3 commits into
vyperlang:masterfrom
iamdefinitelyahuman:feat-payable-check

Conversation

@iamdefinitelyahuman

Copy link
Copy Markdown
Contributor

What I did

Optimize how the nonpayable check is applied within the bytecode

How I did it

Where possible, external functions are now organized by [payable], [nonpayable] and a single assertion that msg.value == 0 is placed in between the two sections.

When a contract contains a payable default function, and nonpayable functions, this optimization is not possible and the check is still applied per-function.

How to verify it

Run the tests. I expanded the testing around the @payable decorator to handle all the different possible permutations based on this optimization.

Cute Animal Picture

image

@fubuloubu fubuloubu self-requested a review February 16, 2021 18:57
@lgtm-com

lgtm-com Bot commented Feb 16, 2021

Copy link
Copy Markdown
Contributor

This pull request introduces 1 alert when merging 980dd35 into b378bfd - view on LGTM.com

new alerts:

  • 1 for Unused local variable

Comment thread vyper/parser/function_definitions/parse_external_function.py
Comment thread vyper/parser/parser.py
Comment thread vyper/parser/parser.py
@iamdefinitelyahuman iamdefinitelyahuman merged commit fb9381e into vyperlang:master Feb 16, 2021
@iamdefinitelyahuman iamdefinitelyahuman deleted the feat-payable-check branch February 16, 2021 22:19
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.

2 participants