Skip to content
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a1f2153
Add BloatNet tests
gballet Aug 14, 2025
02d65b4
try building the contract
gballet Aug 14, 2025
e721cc6
fix: SSTORE 0 -> 1 match all values in the state
gballet Aug 14, 2025
d1cad25
add the tx for 0 -> 1 and 1 -> 2
gballet Aug 14, 2025
16f6d30
fix: linter issues
gballet Aug 14, 2025
374e08a
remove more whitespaces
gballet Aug 14, 2025
333c876
fix formatting
gballet Aug 15, 2025
79a95b8
move to benchmarks
gballet Aug 21, 2025
8131e98
fix linter value
gballet Aug 22, 2025
5f805fd
use the gas limit from the environment
gballet Aug 22, 2025
090a400
parameterize the written value in SSTORE
gballet Aug 26, 2025
cd02a02
fix linter issues
gballet Aug 26, 2025
1f3c381
update CHANGELOG.md
gballet Aug 26, 2025
f6def7e
fix format
gballet Aug 26, 2025
7e20a50
simplify syntax
gballet Aug 26, 2025
c24ad35
fix: start with an empty contract storage
gballet Aug 26, 2025
fc27e53
more fixes, but the result is still incorrect
gballet Aug 26, 2025
7d87262
fix: finally fix the tests
gballet Aug 26, 2025
8556014
linter fix
gballet Aug 27, 2025
326915e
add SLOAD tests
gballet Aug 27, 2025
bc7ee84
Merge branch 'main' into bloatnet-test-SSTORE
gballet Aug 28, 2025
4164f3c
review feedback
gballet Aug 28, 2025
6d12da6
more review feedback
gballet Aug 29, 2025
b3aa527
refactor(tests): Proposed patch for bloatnet SSTORE tests (#1)
fselmo Sep 2, 2025
add1a36
mandatory linter issue fix
gballet Sep 2, 2025
134dc8c
fix SLOAD test
gballet Sep 2, 2025
20c47b7
fix linter issue
gballet Sep 2, 2025
f668f86
break sload tests in multiple txs
gballet Sep 2, 2025
edfc381
fix doc issue in CI
gballet Sep 3, 2025
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/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Users can select any of the artifacts depending on their testing needs for their

### πŸ§ͺ Test Cases

- ✨ [BloatNet](bloatnet.info)/Multidimensional Metering: Add benchmarks to be used as part of the BloatNet project and also for Multidimensional Metering.
- ✨ [EIP-7951](https://eips.ethereum.org/EIPS/eip-7951): Add additional test cases for modular comparison.
- πŸ”€ Refactored `BLOBHASH` opcode context tests to use the `pre_alloc` plugin in order to avoid contract and EOA address collisions ([#1637](https://github.com/ethereum/execution-spec-tests/pull/1637)).
- πŸ”€ Refactored `SELFDESTRUCT` opcode collision tests to use the `pre_alloc` plugin in order to avoid contract and EOA address collisions ([#1643](https://github.com/ethereum/execution-spec-tests/pull/1643)).
Expand Down
80 changes: 80 additions & 0 deletions tests/benchmark/test_bloatnet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
"""
abstract: Tests [EIP-8047 BloatNet](https://eips.ethereum.org/EIPS/eip-8047)
Test cases for [EIP-8047 BloatNet](https://eips.ethereum.org/EIPS/eip-8047)].
"""

import pytest

from ethereum_test_forks import Fork
from ethereum_test_tools import (
Account,
Alloc,
Block,
BlockchainTestFiller,
Environment,
Storage,
Transaction,
)
from ethereum_test_tools.vm.opcode import Opcodes as Op

REFERENCE_SPEC_GIT_PATH = "DUMMY/eip-DUMMY.md"
REFERENCE_SPEC_VERSION = "0.1"


@pytest.mark.valid_from("Prague")
@pytest.mark.parametrize("final_storage_value", [0x02 << 248, 0x02])
def test_bloatnet(
blockchain_test: BlockchainTestFiller, pre: Alloc, fork: Fork, final_storage_value: int
):
"""
A test that calls a contract with many SSTOREs.

The first block will have many SSTORES that go from 0 -> 1
and the 2nd block will have many SSTORES that go from 1 -> 2
"""
# Get gas costs for the current fork
gas_costs = fork.gas_costs()

# this is only used for computing the intinsic gas
data = final_storage_value.to_bytes(32, "big").rstrip(b"\x00")

storage = Storage()

totalgas = gas_costs.G_BASE * 2 + gas_costs.G_VERY_LOW # Initial gas for PUSH0 + CALLDATALOAD + POP (at the end)
totalgas = totalgas + fork.transaction_intrinsic_cost_calculator()(calldata=data);
gas_increment = gas_costs.G_VERY_LOW * 2 + gas_costs.G_STORAGE_SET + gas_costs.G_COLD_SLOAD
sstore_code = Op.PUSH0 + Op.CALLDATALOAD
storage_slot: int = 0
while totalgas + gas_increment < Environment().gas_limit:
totalgas += gas_increment
sstore_code = sstore_code + Op.SSTORE(storage_slot, Op.DUP1)
storage[storage_slot] = final_storage_value
storage_slot += 1

sstore_code = sstore_code + Op.POP # Drop last value on the stack

sender = pre.fund_eoa()
print(sender)
contract_address = pre.deploy_contract(
code=sstore_code,
storage=Storage(),
)

tx_0_1 = Transaction(
to=contract_address,
gas_limit=Environment().gas_limit,
data=(final_storage_value // 2).to_bytes(32, "big").rstrip(b"\x00"),
value=0,
sender=sender,
)
tx_1_2 = Transaction(
to=contract_address,
gas_limit=Environment().gas_limit,
data=final_storage_value.to_bytes(32, "big").rstrip(b"\x00"),
value=0,
sender=sender,
)

post = {contract_address: Account(storage=storage)}

blockchain_test(pre=pre, blocks=[Block(txs=[tx_0_1, tx_1_2])], post=post)