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: Support blob basefee opcode #3878

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions docs/constants-and-vars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Block and Transaction Properties
Name Type Value
==================== ================ =========================================================
``block.coinbase`` ``address`` Current block miner's address
``block.blobbasefee`` ``bytes32`` Current value of the blob base fee
``block.difficulty`` ``uint256`` Current block difficulty
``block.prevrandao`` ``uint256`` Current randomness beacon provided by the beacon chain
``block.number`` ``uint256`` Current block number
Expand Down
8 changes: 8 additions & 0 deletions vyper/codegen/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,14 @@ def parse_Attribute(self):
return IRnode.from_list(["callvalue"], typ=UINT256_T)
elif key == "msg.gas":
return IRnode.from_list(["gas"], typ=UINT256_T)
elif key == "block.blobbasefee":
if not version_check(begin="cancun"):
Copy link
Member

Choose a reason for hiding this comment

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

this should throw an exception, not warn

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is the proper way to do that? It seems like everything else just warns on wrong version?

warning = VyperException(
"tried to use block.blobbasefee in pre-cancun",
self.expr,
)
vyper_warn(str(warning))
return IRnode.from_list(["blobbasefee"], typ=UINT256_T)
elif key == "block.prevrandao":
if not version_check(begin="paris"):
warning = "tried to use block.prevrandao in pre-Paris "
Expand Down
1 change: 1 addition & 0 deletions vyper/evm/opcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"CHAINID": (0x46, 0, 1, 2),
"SELFBALANCE": (0x47, 0, 1, 5),
"BASEFEE": (0x48, 0, 1, 2),
"BLOBBASEFEE": (0x4a, 0, 1, 2),
"POP": (0x50, 1, 0, 2),
"MLOAD": (0x51, 1, 1, 3),
"MSTORE": (0x52, 2, 0, 3),
Expand Down
1 change: 1 addition & 0 deletions vyper/semantics/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class _Block(_EnvType):
"number": UINT256_T,
"gaslimit": UINT256_T,
"basefee": UINT256_T,
"blobbasefee": UINT256_T,
"prevhash": BYTES32_T,
"timestamp": UINT256_T,
}
Expand Down
1 change: 1 addition & 0 deletions vyper/venom/ir_node_to_venom.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"chainid",
"basefee",
"timestamp",
"blobbasefee",
"blockhash",
"caller",
"selfbalance",
Expand Down
1 change: 1 addition & 0 deletions vyper/venom/venom_to_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"calldatasize",
"calldatacopy",
"calldataload",
"blobbasefee",
"gas",
"gasprice",
"gaslimit",
Expand Down
Loading