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: introduce block.prevrandao as alias for block.difficulty #3085

Merged
merged 10 commits into from
Sep 8, 2022
Merged

feat: introduce block.prevrandao as alias for block.difficulty #3085

merged 10 commits into from
Sep 8, 2022

Conversation

pcaversaccio
Copy link
Collaborator

@pcaversaccio pcaversaccio commented Sep 6, 2022

What I did

EIP-4399 renames the DIFFICULTY (0x44) opcode to PREVRANDAO (0x44). The return value of the DIFFICULTY (0x44) instruction after this change is the output of the randomness beacon provided by the beacon chain.

How I did it

With my brain.

How to verify it

Ask Vitalik's masternode.

Commit message

feat: add `block.prevrandao` as alias for `block.difficulty`

per paris merge, EIP-4399 renames the `DIFFICULTY (0x44)` opcode to
`PREVRANDAO (0x44)`. the return value of the `DIFFICULTY (0x44)`
instruction after this change is the output of the randomness beacon
provided by the beacon chain.

Description for the changelog

Add block.prevrandao as alias for block.difficulty.

Cute Animal Picture

image

Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
docs/constants-and-vars.rst Outdated Show resolved Hide resolved
docs/constants-and-vars.rst Show resolved Hide resolved
vyper/codegen/expr.py Outdated Show resolved Hide resolved
vyper/evm/opcodes.py Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Sep 6, 2022

Codecov Report

Merging #3085 (7423bd1) into master (915d430) will decrease coverage by 0.02%.
The diff coverage is 60.00%.

@@            Coverage Diff             @@
##           master    #3085      +/-   ##
==========================================
- Coverage   88.36%   88.33%   -0.03%     
==========================================
  Files          98       98              
  Lines       11020    11028       +8     
  Branches     2605     2608       +3     
==========================================
+ Hits         9738     9742       +4     
- Misses        832      834       +2     
- Partials      450      452       +2     
Impacted Files Coverage Δ
vyper/semantics/environment.py 100.00% <ø> (ø)
vyper/codegen/expr.py 84.56% <50.00%> (-0.67%) ⬇️
vyper/evm/opcodes.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

pcaversaccio and others added 4 commits September 7, 2022 10:06
Co-authored-by: El De-dog-lo <3859395+fubuloubu@users.noreply.github.com>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
@pcaversaccio
Copy link
Collaborator Author

@fubuloubu since all conversations are resolved, I think it's time to trigger the CI.

Copy link
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Copy link
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pcaversaccio could you add a warning then depending on the EVM version? if the user tries to use block.difficulty in >= paris, warn. if the user tries to use block.prevrandao in pre-paris, warn. the fact that the two usages compile to the same opcode is handy for backwards compatibility reasons, but ultimately we do not want users to be thinking of them as the same thing as they have (very) different semantics.

@pcaversaccio
Copy link
Collaborator Author

@charles-cooper thanks for implementing the warning!

@charles-cooper
Copy link
Member

@fubuloubu implemented a warning depending on usage in 7107788. could you please sign off if it makes sense to you? and then i can merge

@fubuloubu fubuloubu changed the title feat: Introduce block.prevrandao as alias for block.difficulty feat: introduce block.prevrandao as alias for block.difficulty Sep 8, 2022
@charles-cooper charles-cooper enabled auto-merge (squash) September 8, 2022 21:59
Copy link
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i resolved my last bit of feedback

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.

4 participants