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

Contract bytecode size is extremely large with hashmaps of struct with large array members #2330

Closed
skellet0r opened this issue Mar 13, 2021 · 4 comments
Labels
bug Bug that shouldn't change language semantics when fixed.

Comments

@skellet0r
Copy link
Contributor

skellet0r commented Mar 13, 2021

Version Information

  • vyper Version: 0.2.11
  • OS: linux
  • Python Version : 3.8.6

What's your issue about?

Example Bytecode Issue

The issue is contracts that use a struct (with a large size array member) in a hashmap see their bytecode size increase dramatically. Using brownie compile -s one can see the bytecode size of compiled contracts.

@fubuloubu fubuloubu added the bug Bug that shouldn't change language semantics when fixed. label Mar 13, 2021
@fubuloubu
Copy link
Member

Probably something to do with a missing optimization of return data pointers for statically sized structs

@charles-cooper
Copy link
Member

The issue is that the two contracts have different semantics. The former contract takes a single argument (an address) generates a return statement which writes the entire struct at the location data[arg0:address] to the returndata. The latter takes two arguments (an address and an index into the array) and returns the item at the location data[arg0:address,arg1:uint256] to the returndata.

I don't think this is a performance bug per se, but rather the bug is that the semantics are inconsistent or at least unclear. So we need to figure out which one we want.

(for reference, I'm pasting the two contracts here:

# repros/2330.1.vy 
struct Foo:
  value: uint256
  value2: uint256
  value3: uint256
  value4: uint256[256]
data: public(HashMap[address, Foo])
# repros/2330.2.vy 
values: public(HashMap[address, uint256])
values2: public(HashMap[address, uint256])
values3: public(HashMap[address, uint256])
values4: public(HashMap[address, uint256[256]])

@charles-cooper
Copy link
Member

charles-cooper commented Apr 4, 2022

tracking note: the codesize blowup would be solved in #2738

@charles-cooper
Copy link
Member

re. the differing semantics of the getters, i'm declaring as "wontfix".

the codesize blowup is solved as of 5dc3ac7 (#3483).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug that shouldn't change language semantics when fixed.
Projects
None yet
Development

No branches or pull requests

3 participants