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[lang]!: change the signature of block.prevrandao #3879

Merged
merged 4 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
4 changes: 2 additions & 2 deletions docs/constants-and-vars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Name Type Value
==================== ================ =========================================================
``block.coinbase`` ``address`` Current block miner's address
``block.difficulty`` ``uint256`` Current block difficulty
``block.prevrandao`` ``uint256`` Current randomness beacon provided by the beacon chain
``block.prevrandao`` ``bytes32`` Current randomness beacon provided by the beacon chain
``block.number`` ``uint256`` Current block number
``block.prevhash`` ``bytes32`` Equivalent to ``blockhash(block.number - 1)``
``block.timestamp`` ``uint256`` Current block epoch timestamp
Expand All @@ -31,7 +31,7 @@ Name Type Value

.. note::

``block.prevrandao`` is an alias for ``block.difficulty``. Since ``block.difficulty`` is considered deprecated according to `EIP-4399 <https://eips.ethereum.org/EIPS/eip-4399>`_ after "The Merge" (Paris hard fork), we recommend using ``block.prevrandao``.
``block.prevrandao`` is an alias for the ``block.difficulty`` opcode. Since ``block.difficulty`` is considered deprecated according to `EIP-4399 <https://eips.ethereum.org/EIPS/eip-4399>`_ after "The Merge" (Paris hard fork), we recommend using ``block.prevrandao``.

.. note::

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/syntax/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def foo():
"""
@external
def foo():
x: uint256 = block.prevrandao + 185
x: bytes32 = block.prevrandao
if tx.origin == self:
y: Bytes[35] = concat(block.prevhash, b"dog")
""",
Expand Down
2 changes: 1 addition & 1 deletion vyper/codegen/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def parse_Attribute(self):
warning = "tried to use block.prevrandao in pre-Paris "
warning += "environment! Suggest using block.difficulty instead."
vyper_warn(warning, self.expr)
return IRnode.from_list(["prevrandao"], typ=UINT256_T)
return IRnode.from_list(["prevrandao"], typ=BYTES32_T)
elif key == "block.difficulty":
if version_check(begin="paris"):
warning = "tried to use block.difficulty in post-Paris "
Expand Down
2 changes: 1 addition & 1 deletion vyper/semantics/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class _Block(_EnvType):
_type_members = {
"coinbase": AddressT(),
"difficulty": UINT256_T,
"prevrandao": UINT256_T,
"prevrandao": BYTES32_T,
"number": UINT256_T,
"gaslimit": UINT256_T,
"basefee": UINT256_T,
Expand Down
Loading