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

feat: VVM injection, internal functions and variables #294

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
63910a4
WIP: VVM internal variables
DanielSchiavini Sep 2, 2024
99bf860
VVM internal functions via vyper wrapper
DanielSchiavini Sep 2, 2024
bae493b
VVM eval
DanielSchiavini Sep 2, 2024
2fd09c0
Self-review
DanielSchiavini Sep 2, 2024
1114804
Inline method
DanielSchiavini Sep 3, 2024
7418116
Use the new vvm version
DanielSchiavini Sep 6, 2024
2ce4436
Merge branch 'master' of github.com:vyperlang/titanoboa into vvm-storage
DanielSchiavini Sep 11, 2024
9a0cd05
Recursion, review comments
DanielSchiavini Sep 11, 2024
37cf4eb
Merge branch 'master' of github.com:vyperlang/titanoboa into vvm-storage
DanielSchiavini Sep 18, 2024
b375574
Use vvm from https://github.com/vyperlang/vvm/pull/26
DanielSchiavini Sep 18, 2024
99cb8e1
Merge branch 'master' of github.com:vyperlang/titanoboa into vvm-storage
DanielSchiavini Sep 23, 2024
8b778dd
Update vvm
DanielSchiavini Sep 23, 2024
eb4518f
Extract regex
DanielSchiavini Sep 23, 2024
8de1b7f
Review comments
DanielSchiavini Sep 26, 2024
4e0876f
Merge branch 'master' of github.com:vyperlang/titanoboa into vvm-storage
DanielSchiavini Sep 26, 2024
28e97cd
Merge branch 'master' of github.com:vyperlang/titanoboa into vvm-storage
DanielSchiavini Oct 1, 2024
7837fdb
Merge branch 'master' of github.com:vyperlang/titanoboa into vvm-storage
DanielSchiavini Oct 3, 2024
e101d0b
refactor: extract function
DanielSchiavini Oct 4, 2024
dcfe941
feat: cache all vvm compile calls
DanielSchiavini Oct 4, 2024
23ed6ec
fix: revert search path changes
DanielSchiavini Oct 7, 2024
f99a667
Merge branch 'master' of github.com:vyperlang/titanoboa into vvm-storage
DanielSchiavini Oct 9, 2024
a96aeb4
Merge branch 'master' into vvm-storage
DanielSchiavini Oct 15, 2024
42eca98
feat: implement function injection instead of eval
DanielSchiavini Oct 18, 2024
3f302ed
some refactor
charles-cooper Oct 19, 2024
da7467e
fix bytecode override
charles-cooper Oct 19, 2024
d6dad63
fix API regression
charles-cooper Oct 19, 2024
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
30 changes: 14 additions & 16 deletions boa/contracts/vvm/vvm_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,33 +162,31 @@ def internal(self):
def internal():
return None

result = self._compile_metadata_fn_info()
result = self._compile_function_metadata()
for fn_name, meta in result.items():
if meta["visibility"] == "internal":
function = VVMInternalFunction(meta, self)
setattr(internal, function.name, function)
return internal

def _compile_metadata_fn_info(self) -> dict:
"""Compiles the metadata for the contract"""
def _compile_function_metadata(self) -> dict:
"""Compiles the contract and returns the function metadata"""

# todo: move this to vvm?
DanielSchiavini marked this conversation as resolved.
Show resolved Hide resolved
def run_vyper(filename: str) -> dict:
stdoutdata, stderrdata, command, proc = vyper_wrapper(
vyper_binary=get_executable(self.vyper_version),
f="metadata",
source_files=[filename],
)
return json.loads(stdoutdata)["function_info"]

if self.filename is not None:
return self._get_metadata_from_vyper_executable(self.filename)
return run_vyper(self.filename)
with NamedTemporaryFile(suffix=".vy") as f:
f.write(self.source_code.encode())
f.flush()
return self._get_metadata_from_vyper_executable(f.name)

def _get_metadata_from_vyper_executable(self, filename: str) -> dict:
"""
Calls the vvm to get the metadata for the contract.
"""
stdoutdata, stderrdata, command, proc = vyper_wrapper(
vyper_binary=get_executable(self.vyper_version),
f="metadata",
source_files=[filename],
)
return json.loads(stdoutdata)["function_info"]
return run_vyper(f.name)


class _VVMInternal(ABIFunction):
Expand Down
Loading