Skip to content

Instantly share code, notes, and snippets.

@protolambda
Created October 10, 2022 05:43
Show Gist options
  • Save protolambda/a9bc82e6170cdeb9a3c4b66eabb2b2a1 to your computer and use it in GitHub Desktop.
Save protolambda/a9bc82e6170cdeb9a3c4b66eabb2b2a1 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
MIN_DATA_GASPRICE = 10**8
DATA_GASPRICE_UPDATE_FRACTION = 8902606
DATA_GAS_PER_BLOB = 2**17
def fake_exponential(factor: int, numerator: int, denominator: int) -> int:
i = 1
output = 0
numerator_accum = factor * denominator
while numerator_accum > 0:
output += numerator_accum
numerator_accum = (numerator_accum * numerator) // (denominator * i)
i += 1
return output // denominator
def get_data_gasprice(excess_data_gas: int) -> int:
return fake_exponential(
MIN_DATA_GASPRICE,
excess_data_gas,
DATA_GASPRICE_UPDATE_FRACTION
)
data = []
for i in range(5000):
excess_data_gas = DATA_GAS_PER_BLOB * i
# wei to gwei, and per blob
y = get_data_gasprice(excess_data_gas) / 1e9 / DATA_GAS_PER_BLOB
data.append(y)
fig, ax = plt.subplots()
plt.plot(data)
fig.suptitle('blob fee curve', fontsize=20)
plt.xlabel('excess blobs', fontsize=18)
plt.ylabel('gwei per blob', fontsize=16)
ax.set_yscale('log', base=10)
# use the plot function
plt.plot(data)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment