Appendix A Simulation Code Example
The following is the code written in Python to generate the simulations used in the document above.
Simulated Transactions Per Second (TPS) Over 24 Hours
```python
import numpy as np
import matplotlib . pyplot as plt
base_tps_phronzero = 100000
base_tps_phronlayer1 = 50000
time_hours = np. arange (0, 24, 1)
network_load_factor_phronzero = 0.5 * np. sin (np .pi * time_hours / 12 - np.pi /2) + 1
network_load_factor_phronlayer1 = 0.5 * np.sin(np .pi * time_hours / 12 - np .pi /2) + 1.5
effective_tps_phronzero = base_tps_phronzero * network_load_factor_phronzero
effective_tps_phronlayer1 = base_tps_phronlayer1 * network_load_factor_phronlayer1
plt.figure ( figsize =(14 , 7))
plt.plot ( time_hours , effective_tps_phronzero , label ='PhronZero TPS', marker ='o')
plt.plot ( time_hours , effective_tps_phronlayer1 , label ='Phron Layer 1 TPS', marker ='x')
plt.title ('Simulated Transactions Per Second ( TPS) Over 24 Hours ')
plt.xlabel ('Time ( Hours )')
plt.ylabel (' Transactions Per Second ( TPS )')
plt.legend ()
plt.grid ( True )
plt.xticks ( time_hours )
plt.ylim (0, max ( effective_tps_phronzero ) + 50000)
plt.show ()
# \ end { verbatim *}
# \ subsection { Simulated Dynamic Gas Fee }
# \ begin { verbatim *}
def calculate_dynamic_gas_fee ( base_fee , tip , epsilon , p_target , p_current , delta_c ,
delta_n ):
"""
Calculate the dynamic gas fee for a transaction based on the provided parameters .
: param base_fee : Base fee of the transaction
: param tip : Optional tip to miners / validators
: param epsilon : Sensitivity parameter for token price stabilization
: param p_target : Target token price
: param p_current : Current token price
: param delta_c : Rate of change in transaction complexity
: param delta_n : Rate of change in network congestion
: return : Calculated dynamic gas fee
"""
price_adjustment = epsilon * ( p_target - p_current ) / p_current
gas_fee = ( base_fee + tip + price_adjustment ) * ( delta_c + delta_n )
return gas_fee
base_fee = 10
tip = 1
epsilon = 0.1
p_target = 1
p_current = 0.65
delta_c = 1
delta_n = 1
```