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

chore: update vyper imports #46

Merged
merged 22 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions boa/vyper/compiler_utils.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import textwrap

import vyper.ast as vy_ast
import vyper.semantics.validation as validation
import vyper.semantics.analysis as analysis
from vyper.ast.signatures.function_signature import FunctionSignature
from vyper.ast.utils import parse_to_ast
from vyper.codegen.function_definitions import generate_ir_for_function
from vyper.codegen.ir_node import IRnode
from vyper.exceptions import InvalidType
from vyper.ir import compile_ir as compile_ir
from vyper.semantics.validation.utils import get_exact_type_from_node
from vyper.utils import abi_method_id
from vyper.semantics.analysis.utils import get_exact_type_from_node
from vyper.utils import method_id_int

from boa.vyper import _METHOD_ID_VAR

Expand All @@ -28,8 +28,8 @@ def _compile_vyper_function(vyper_function, contract):

# override namespace and add wrapper code at the top
with contract.override_vyper_namespace():
validation.add_module_namespace(ast, ifaces)
validation.validate_functions(ast)
analysis.add_module_namespace(ast, ifaces)
analysis.validate_functions(ast)

ast = ast.body[0]
sig = FunctionSignature.from_definition(ast, global_ctx)
Expand All @@ -39,7 +39,7 @@ def _compile_vyper_function(vyper_function, contract):
ir = generate_ir_for_function(ast, sigs, global_ctx, False)

ir = IRnode.from_list(
["with", _METHOD_ID_VAR, abi_method_id(sig.base_signature), ir]
["with", _METHOD_ID_VAR, method_id_int(sig.base_signature), ir]
)
assembly = compile_ir.compile_to_assembly(ir, no_optimize=True)

Expand Down
16 changes: 8 additions & 8 deletions boa/vyper/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import vyper
import vyper.ast as vy_ast
import vyper.ir.compile_ir as compile_ir
import vyper.semantics.analysis as analysis
import vyper.semantics.namespace as vy_ns
import vyper.semantics.validation as validation
from eth.exceptions import VMError
from eth_typing import Address
from eth_utils import to_canonical_address, to_checksum_address
Expand All @@ -25,8 +25,8 @@
from vyper.compiler import output as compiler_output
from vyper.exceptions import VyperException
from vyper.ir.optimizer import optimize
from vyper.semantics.validation.data_positions import set_data_positions
from vyper.utils import abi_method_id, cached_property
from vyper.semantics.analysis.data_positions import set_data_positions
from vyper.utils import cached_property, method_id_int

from boa.environment import AddressT, Env, to_int
from boa.profiling import LineProfile
Expand Down Expand Up @@ -643,8 +643,8 @@ def _ast_module(self):
# do the same thing as vyper_module_folded but skip getter expansion
vy_ast.folding.fold(module)
with vy_ns.get_namespace().enter_scope():
validation.add_module_namespace(module, self.compiler_data.interface_codes)
validation.validate_functions(module)
analysis.add_module_namespace(module, self.compiler_data.interface_codes)
analysis.validate_functions(module)
# we need to cache the namespace right here(!).
# set_data_positions will modify the type definitions in place.
self._cache_namespace(vy_ns.get_namespace())
Expand Down Expand Up @@ -674,7 +674,7 @@ def override_vyper_namespace(self):
with vy_ns.override_global_namespace(self._vyper_namespace):
yield
finally:
self._vyper_namespace["self"].members.pop("__boa_debug__", None)
self._vyper_namespace["self"].typ.members.pop("__boa_debug__", None)

# for eval(), we need unoptimized assembly, since the dead code
# eliminator might prune a dead function (which we want to eval)
Expand Down Expand Up @@ -752,7 +752,7 @@ def inject_function(self, fn_source_code, force=False):

# ensure self._vyper_namespace is computed
m = self._ast_module # noqa: F841
self._vyper_namespace["self"].members.pop(fn_ast.name, None)
self._vyper_namespace["self"].typ.members.pop(fn_ast.name, None)
f = _InjectVyperFunction(self, fn_source_code)
setattr(self.inject, fn_ast.name, f)

Expand Down Expand Up @@ -825,7 +825,7 @@ def args_abi_type(self, num_kwargs):
args_abi_type = (
"(" + ",".join(arg.typ.abi_type.selector_name() for arg in sig_args) + ")"
)
method_id = abi_method_id(self.fn_signature.name + args_abi_type).to_bytes(
method_id = method_id_int(self.fn_signature.name + args_abi_type).to_bytes(
4, "big"
)
self._signature_cache[num_kwargs] = (method_id, args_abi_type)
Expand Down
2 changes: 1 addition & 1 deletion boa/vyper/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Event:
log_id: int # internal py-evm log id, for ordering purposes
address: str # checksum address
event_type: Any # vyper.semantics.types.user.Event
event_type: Any # vyper.semantics.types.user.EventT
topics: List[Any] # list of decoded topics
args: List[Any] # list of decoded args

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ classifiers = ["Topic :: Software Development"]

# Requirements
dependencies = [
"vyper >= 0.3.7",
"vyper @ git+https://github.com/vyperlang/vyper.git@master",
tserg marked this conversation as resolved.
Show resolved Hide resolved
"eth-abi",
"py-evm",
"eth-typing",
Expand Down