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: publish immutables layout #2768

Merged
merged 9 commits into from
Apr 30, 2022

Conversation

charles-cooper
Copy link
Member

What I did

publish immutables layout. since the output is a single dict of variable names (see below for ex.), I was a bit concerned about collisions between immutables and storage variables, so I went ahead and blocked those.

{"foo": {"type": "uint256", "location": "code", "offset": 0, "length": 32}, "x": {"type": "uint256", "location": "storage", "slot": 0}}

How I did it

add code offsets dict to the -f layout output

How to verify it

try

vyper -f layout /dev/stdin <<EOF
x: uint256
y: immutable(uint256)
@external
def __init__():
    y = 1
EOF

Commit message

Description for the changelog

Cute Animal Picture

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

immutables can have the same name as storage variables, depending on the
order they occur in. for instance, this is allowed
```
x: uint256
x: immutable(uint256)
```

but, this is is not:
```
x: immutable(uint256)
x: uint256
```

this commit ensures both cases are blocked.
@codecov-commenter
Copy link

codecov-commenter commented Apr 8, 2022

Codecov Report

Merging #2768 (33074bc) into master (df29609) will decrease coverage by 0.01%.
The diff coverage is 84.61%.

@@            Coverage Diff             @@
##           master    #2768      +/-   ##
==========================================
- Coverage   87.33%   87.32%   -0.02%     
==========================================
  Files          94       94              
  Lines       10046    10053       +7     
  Branches     2489     2490       +1     
==========================================
+ Hits         8774     8779       +5     
- Misses        804      805       +1     
- Partials      468      469       +1     
Impacted Files Coverage Δ
vyper/semantics/validation/module.py 85.71% <0.00%> (-0.89%) ⬇️
vyper/semantics/validation/data_positions.py 91.39% <100.00%> (+0.48%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update df29609...33074bc. Read the comment docs.

@charles-cooper
Copy link
Member Author

charles-cooper commented Apr 10, 2022

kind of wonder if we should publish as two separate dicts. e.g.

{
  "storage": [{"x": ...}, {"y": ...}],
  "code": [{"a": ...}, {"b": ...}],
}

@fubuloubu thoughts?

@fubuloubu
Copy link
Member

fubuloubu commented Apr 11, 2022

kind of wonder if we should publish as two separatel dicts. e.g.

{
  "storage": [{"x": ...}, {"y": ...}],
  "code": [{"a": ...}, {"b": ...}],
}

@fubuloubu thoughts?

Are collisions even allowed?

@charles-cooper
Copy link
Member Author

charles-cooper commented Apr 11, 2022

Are collisions even allowed?

there was a case where they were allowed, but I blocked that case in this PR. but we might not always block.

@fubuloubu
Copy link
Member

Are collisions even allowed?

there was a case where they were allowed, but I blocked that case in this PR. but we might not always block.

I think collisions should not be allowed here. It's sort of like a global var

@charles-cooper charles-cooper mentioned this pull request Apr 12, 2022
5 tasks
@charles-cooper
Copy link
Member Author

meeting notes: separate into two dicts

@charles-cooper charles-cooper enabled auto-merge (squash) April 30, 2022 10:55
@charles-cooper charles-cooper merged commit d366899 into vyperlang:master Apr 30, 2022
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.

3 participants