Skip to content

feat[lang]: add ABIBuffer type #4561

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

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Apr 6, 2025

What I did

bypasses abi encoding of return types

How I did it

How to verify it

check the following code

def foo() -> ABIBuffer[32]:
    return x"abcdef"  # raw abi encoded data

@external
def bar() -> ABIBuffer[32]:
    return x"abcdef01"

@external
def baz() -> ABIBuffer[128]:
    res: Bytes[128] = raw_call(self, method_id("bar()"), is_delegate_call=True, max_outsize=128)
    return convert(res, ABIBuffer[128])

Commit message

Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@@ -23,7 +23,7 @@
from vyper.semantics.analysis.levenshtein_utils import get_levenshtein_error_suggestions
from vyper.semantics.namespace import get_namespace
from vyper.semantics.types.base import TYPE_T, VyperType
from vyper.semantics.types.bytestrings import BytesT, StringT
from vyper.semantics.types.bytestrings import _BytestringT

Check notice

Code scanning / CodeQL

Cyclic import Note

Import of module
vyper.semantics.types.bytestrings
begins an import cycle.
Copy link

codecov bot commented Apr 6, 2025

Codecov Report

Attention: Patch coverage is 97.72727% with 1 line in your changes missing coverage. Please review.

Project coverage is 92.65%. Comparing base (2d515d3) to head (a10e7e6).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
vyper/builtins/_convert.py 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4561      +/-   ##
==========================================
- Coverage   92.70%   92.65%   -0.06%     
==========================================
  Files         123      122       -1     
  Lines       17526    17565      +39     
  Branches     2971     2984      +13     
==========================================
+ Hits        16248    16275      +27     
- Misses        879      892      +13     
+ Partials      399      398       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -31,6 +31,7 @@
)
from vyper.semantics.data_locations import DataLocation
from vyper.semantics.types.base import KwargSettings, VyperType
from vyper.semantics.types.bytestrings import ReturnBufferT

Check notice

Code scanning / CodeQL

Cyclic import Note

Import of module
vyper.semantics.types.bytestrings
begins an import cycle.
@cyberthirst
Copy link
Collaborator

event FooEvent:
    a: ReturnBuffer[100]

interface Foo:
    def foo() -> ReturnBuffer[100]: view

@external
def foo(target: Foo):
    log FooEvent(a=staticcall target.foo())

yields

vyper.exceptions.StructureException: not a valid tuple member: ReturnBuffer[100]

  contract "tests/custom/test.vy:10", function "foo", line 10:4 
        9 def foo(target: Foo):
  ---> 10     log FooEvent(a=staticcall target.foo())
  ------------^

i don't think that "not a valid tuple member" is a very clear ex

@cyberthirst cyberthirst added this to the v0.4.2 milestone Apr 14, 2025
@cyberthirst
Copy link
Collaborator

note that the fact, that we don't allow conversion into Bytes severely limits how the type can be used

the type doesn't support slice, concat, len, or abi_decode, it can be converted to Bytes but can't be converted back

thus it's basically impossible to do post-processing on it

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