forked from vyperlang/vyper
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat[lang]: support
block.blobbasefee
(vyperlang#3945)
This commit adds access to the `BLOBBASEFEE` opcode via the environment variable `block.blobbasefee`. The opcode was introduced in EIP-4844. --------- Co-authored-by: sudo rm -rf --no-preserve-root / <pcaversaccio@users.noreply.github.com>
- Loading branch information
1 parent
80708e6
commit f6c0c89
Showing
9 changed files
with
113 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
tests/functional/codegen/environment_variables/test_blobbasefee.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import pytest | ||
from eth.vm.forks.cancun.constants import BLOB_BASE_FEE_UPDATE_FRACTION, MIN_BLOB_BASE_FEE | ||
from eth.vm.forks.cancun.state import fake_exponential | ||
|
||
|
||
@pytest.mark.requires_evm_version("cancun") | ||
def test_blobbasefee(get_contract_with_gas_estimation, w3): | ||
code = """ | ||
@external | ||
@view | ||
def get_blobbasefee() -> uint256: | ||
return block.blobbasefee | ||
""" | ||
c = get_contract_with_gas_estimation(code) | ||
|
||
assert c.get_blobbasefee() == MIN_BLOB_BASE_FEE | ||
|
||
a0 = w3.eth.account.from_key(f"0x{'00' * 31}01") | ||
|
||
text = b"Vyper is the language of the sneks" | ||
# Blobs contain 4096 32-byte field elements. | ||
blob_data = text.rjust(32 * 4096) | ||
|
||
for _i in range(10): | ||
tx = { | ||
"type": 3, | ||
"chainId": 1337, | ||
"from": a0.address, | ||
"to": "0xb45BEc6eeCA2a09f4689Dd308F550Ad7855051B5", # random address | ||
"value": 0, | ||
"gas": 21000, | ||
"maxFeePerGas": 10**10, | ||
"maxPriorityFeePerGas": 10**10, | ||
"maxFeePerBlobGas": 10**10, | ||
"nonce": w3.eth.get_transaction_count(a0.address), | ||
} | ||
|
||
signed = a0.sign_transaction(tx, blobs=[blob_data] * 6) | ||
w3.eth.send_raw_transaction(signed.rawTransaction) | ||
|
||
block = w3.eth.get_block("latest") | ||
excess_blob_gas = block["excessBlobGas"] | ||
expected_blobbasefee = fake_exponential( | ||
MIN_BLOB_BASE_FEE, excess_blob_gas, BLOB_BASE_FEE_UPDATE_FRACTION | ||
) | ||
|
||
assert c.get_blobbasefee() == expected_blobbasefee | ||
|
||
# sanity check that blobbasefee has increased above the minimum | ||
assert c.get_blobbasefee() > MIN_BLOB_BASE_FEE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,7 @@ | |
"delegatecall", | ||
"codesize", | ||
"basefee", | ||
"blobbasefee", | ||
"prevrandao", | ||
"difficulty", | ||
"invalid", | ||
|