Gas Limit after EIP-7623 (pectra) with the pre-EIP-7623 values in brackets:
| Gas Limit | All zeros (MiB) | All nonzeros (MiB) | Mixed (29% zeros, 71% nonzeros) (MiB) | Comp All zeros (MiB) | Comp All nonzeros (MiB) | Comp Mixed (MiB) |
|------------:|:------------------|:---------------------|:----------------------------------------|:-----------------------|:--------------------------|:-------------------|
| 30m | 2.86 (7.15) | 0.72 (1.79) | 1.34 (3.34) | 0.13 (0.34) | 0.72 (1.79) | 1.07 (2.67) |
| 40m | 3.81 (9.54) | 0.95 (2.38) | 1.78 (4.46) | 0.18 (0.45) | 0.95 (2.38) | 1.42 (3.56) |
| 50m | 4.77 (11.92) | 1.19 (2.98) | 2.23 (5.57) | 0.22 (0.56) | 1.19 (2.98) | 1.78 (4.45) |
| 60m | 5.72 (14.31) | 1.43 (3.58) | 2.68 (6.69) | 0.27 (0.67) | 1.43 (3.58) | 2.14 (5.34) |
| 80m | 7.63 (19.07) | 1.91 (4.77) | 3.57 (8.92) | 0.36 (0.89) | 1.91 (4.77) | 2.85 (7.12) |
| 100m | 9.54 (23.84) | 2.38 (5.96) | 4.46 (11.15) | 0.45 (1.12) | 2.38 (5.96) | 3.56 (8.90) |
| 200m | 19.07 (47.68) | 4.77 (11.92) | 8.92 (22.29) | 0.89 (2.24) | 4.77 (11.92) | 7.11 (17.79) |
| 500m | 47.68 (119.21) | 11.92 (29.80) | 22.29 (55.73) | 2.24 (5.59) | 11.92 (29.80) | 17.79 (44.48) |
| 1b | 95.37 (238.42) | 23.84 (59.60) | 44.58 (111.46) | 4.47 (11.18) | 23.84 (59.61) | 35.58 (88.95) |
Created using this code:
```python
import math
import random
import pandas as pd
try:
import snappy # requires: pip install python-snappy
except ImportError:
raise ImportError("Please install the python-snappy package (pip install python-snappy)")
def compute_block_sizes(gas_limit, cost_zero, cost_nonzero):
"""
Compute block sizes given a gas limit and per-byte costs.
Returns a dictionary with:
- 'all_zeros': uncompressed block size (bytes) using only zero bytes
- 'all_nonzeros': uncompressed block size (bytes) using only non-zero bytes (random)
- 'mixed': uncompressed block size (bytes) with 29% gas used for zeros and 71% for non-zeros (random)
- 'comp_all_zeros': Snappy compressed size (bytes) of the all-zero data
- 'comp_all_nonzeros': Snappy compressed size (bytes) of the all non-zero data (random)
- 'comp_mixed': Snappy compressed size (bytes) of the mixed (randomly shuffled) data
"""
# Uncompressed sizes:
size_all_zeros = gas_limit // cost_zero
size_all_nonzeros = gas_limit // cost_nonzero
# For mixed block, allocate 29% of gas for zeros and 71% for non-zeros.
gas_for_zeros = int(gas_limit * 0.29)
gas_for_nonzeros = gas_limit - gas_for_zeros
num_zero_bytes = gas_for_zeros // cost_zero
num_nonzero_bytes = gas_for_nonzeros // cost_nonzero
size_mixed = num_zero_bytes + num_nonzero_bytes
# Generate data for compression:
data_zeros = b'\x00' * size_all_zeros
# For nonzero bytes, generate random bytes in the range 1-255.
data_nonzeros = bytes(random.choices(range(1, 256), k=size_all_nonzeros))
# Create mixed data: zeros and random nonzero bytes, then shuffle.
zero_part = b'\x00' * num_zero_bytes
nonzero_part = bytes(random.choices(range(1, 256), k=num_nonzero_bytes))
mixed_data = bytearray(zero_part + nonzero_part)
mixed_data_list = list(mixed_data)
random.shuffle(mixed_data_list)
mixed_data_shuffled = bytes(mixed_data_list)
# Compress using snappy:
comp_zeros = snappy.compress(data_zeros)
comp_nonzeros = snappy.compress(data_nonzeros)
comp_mixed = snappy.compress(mixed_data_shuffled)
return {
'all_zeros': size_all_zeros,
'all_nonzeros': size_all_nonzeros,
'mixed': size_mixed,
'comp_all_zeros': len(comp_zeros),
'comp_all_nonzeros': len(comp_nonzeros),
'comp_mixed': len(comp_mixed)
}
def bytes_to_mib(byte_value):
"""Convert bytes to mebibytes (MiB)."""
return byte_value / (1024 * 1024)
def main():
# Define gas limits from 30M to 1B.
gas_limits = [30_000_000, 40_000_000, 50_000_000, 60_000_000, 80_000_000, 100_000_000, 200_000_000, 500_000_000, 1_000_000_000]
# Define calldata cost parameters:
# New/current costs as per EIP-7623.
new_costs = {'zero': 10, 'nonzero': 40}
# Old costs before the increase.
old_costs = {'zero': 4, 'nonzero': 16}
# Prepare the data to be stored in the DataFrame.
data = {
"Gas Limit": [],
"All zeros (MiB)": [],
"All nonzeros (MiB)": [],
"Mixed (29% zeros, 71% nonzeros) (MiB)": [],
"Comp All zeros (MiB)": [],
"Comp All nonzeros (MiB)": [],
"Comp Mixed (MiB)": []
}
for gas in gas_limits:
print(gas)
# Compute values with new (current) costs.
new_vals = compute_block_sizes(gas, new_costs['zero'], new_costs['nonzero'])
# Compute values with old costs.
old_vals = compute_block_sizes(gas, old_costs['zero'], old_costs['nonzero'])
data["Gas Limit"].append(gas)
data["All zeros (MiB)"].append(f"{bytes_to_mib(new_vals['all_zeros']):.2f} ({bytes_to_mib(old_vals['all_zeros']):.2f})")
data["All nonzeros (MiB)"].append(f"{bytes_to_mib(new_vals['all_nonzeros']):.2f} ({bytes_to_mib(old_vals['all_nonzeros']):.2f})")
data["Mixed (29% zeros, 71% nonzeros) (MiB)"].append(f"{bytes_to_mib(new_vals['mixed']):.2f} ({bytes_to_mib(old_vals['mixed']):.2f})")
data["Comp All zeros (MiB)"].append(f"{bytes_to_mib(new_vals['comp_all_zeros']):.2f} ({bytes_to_mib(old_vals['comp_all_zeros']):.2f})")
data["Comp All nonzeros (MiB)"].append(f"{bytes_to_mib(new_vals['comp_all_nonzeros']):.2f} ({bytes_to_mib(old_vals['comp_all_nonzeros']):.2f})")
data["Comp Mixed (MiB)"].append(f"{bytes_to_mib(new_vals['comp_mixed']):.2f} ({bytes_to_mib(old_vals['comp_mixed']):.2f})")
df = pd.DataFrame(data)
# Print the DataFrame as a markdown table.
print(df.to_markdown(index=False))
if __name__ == '__main__':
main()
```