Skip to content

Commit

Permalink
move fallback in a level of nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Feb 17, 2022
1 parent cdbb155 commit eca642f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion vyper/codegen/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,16 @@ def parse_regular_functions(
external_seq.append(["assert", ["iszero", "callvalue"]])
external_seq += nonpayable_funcs

# place fallback in same block as other external functions
# (consistency for external tools which parse our IR)
external_seq.append(["label", "fallback", ["var_list"], fallback_lll])

# bytecode is organized by: external functions, fallback fn, internal functions
# this way we save gas and reduce bytecode by not jumping over internal functions
runtime = [
"seq",
func_init_lll(),
["with", "_calldata_method_id", ["mload", 0], external_seq],
["label", "fallback", ["var_list"], fallback_lll],
]
runtime.extend(internal_funcs)

Expand Down

0 comments on commit eca642f

Please sign in to comment.