Estimate gas consumption for a year
rach-id opened this issue · 1 comments
We should analyze the gas cost of deploying the QGB smart contract and relaying to it for a year.
I created the following plot for estimating the cost of running a relayer per data commitment window:
import numpy as np
import matplotlib.pyplot as plt
# Parameters
eth_price = 1500 # Current Ether price in USD
gas_price = 0.000000011 # Current Ethereum gas price in Ether
windows = [10, 50, 100, 200, 400, 800, 1000, 2000, 5000, 10000, 20000] # Data commitment windows
block_time = 15 # Celestia block time in seconds
gas_per_transaction = 560000 # Gas required per batch submission
# Calculate the monthly cost for each window
monthly_costs = []
for window in windows:
blocks_per_day = 24 * 60 * 60 / block_time
windows_per_day = blocks_per_day / window
daily_cost = windows_per_day * gas_per_transaction * gas_price * eth_price
monthly_cost = daily_cost * 30 # Assuming 30 days in a month
monthly_costs.append(monthly_cost)
# Plot the results
plt.figure(figsize=(8, 6))
plt.bar([str(window) for window in windows], monthly_costs, color='skyblue')
plt.xlabel('Data Commitment Window')
plt.ylabel('Monthly Cost (USD)')
plt.title('Monthly Cost of Batches Submission')
plt.show()
link for the plot online: http://tpcg.io/_7DE5M5
The estimation of the gas consumption is taken from the testground deployment of QGB:
https://sepolia.etherscan.io/address/0xe202870169Fbf440124203b5Fde4352cEeC58e77
And the BSR one:
https://sepolia.etherscan.io/address/0x8fCd4B41702386d646190C5E751c1c8841CD1137
Gas consumption is just a randomly chosen mean value over the calls we did when we deployed on Sepolia. It highly depends on the number of validators and their stake in the network.
For the above deployments, they both had a validator set that doesn't change much, and mostly the same stake for all validators (especially the testground one). The BSR one was a bit variable.
So, the testground deployment can be seen as almost a worst case scenario where you need 67 signature to relay (because all validators have the same stake).
The worst case would be to use the testground validator set, and only send 67 signatures. Then, place the signatures at the end of the call data instead of the beginning. That would be the most expensive
Also, the above estimation doesn't take into consideration validator set changes.
The price of Ether used is $1500 and the gas cost is 11GWei, which is the current value used at the moment.