diff options
author | Aaron Buchwald <[email protected]> | 2020-12-17 13:58:14 -0500 |
---|---|---|
committer | Aaron Buchwald <[email protected]> | 2020-12-17 13:58:14 -0500 |
commit | 3960b690bf8c67afe706bb469b0ff2798424a26e (patch) | |
tree | 77b60c080f63df21af115406e6b78a7862a68ad9 /params | |
parent | ea099f5811574d3dae79a31053d21b523d008d75 (diff) |
Decrease minimum gas price at apricot upgrade
Diffstat (limited to 'params')
-rw-r--r-- | params/protocol_params.go | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/params/protocol_params.go b/params/protocol_params.go index fdfb9a5..fe6e6c2 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -152,8 +152,42 @@ var ( GenesisDifficulty = big.NewInt(131072) // Difficulty of the Genesis block. MinimumDifficulty = big.NewInt(131072) // The minimum that the difficulty may ever be. DurationLimit = big.NewInt(13) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. +) +// Minimum Gas Price +var ( // MinGasPrice is the number of nAVAX required per gas unit for a transaction // to be valid, measured in wei - MinGasPrice = big.NewInt(470 * GWei) + MinGasPrice = big.NewInt(470 * GWei) + LaunchMinGasPrice = big.NewInt(470 * GWei) + ApricotMinGasPrice = big.NewInt(100 * GWei) ) + +// GasPrice provides an interface to get the minimum +// gas price +type GasPrice interface { + GetMin(blockTimestamp *big.Int) *big.Int +} + +// NewGasPrice returns a getter for the GasPrice based on a block timestamp +func NewGasPrice(apricotTimestamp *big.Int) GasPrice { + return &minGasPriceFetcher{ + launchPrice: LaunchMinGasPrice, + apricotPrice: ApricotMinGasPrice, + apricotTimestamp: apricotTimestamp, + } +} + +type minGasPriceFetcher struct { + apricotTimestamp *big.Int + launchPrice, apricotPrice *big.Int +} + +// GetMin returns the minimum gas price for a block with the given timestamp +func (m *minGasPriceFetcher) GetMin(blockTimestamp *big.Int) *big.Int { + if m.apricotTimestamp == nil || blockTimestamp.Cmp(m.apricotTimestamp) >= 0 { + return m.apricotPrice + } + + return m.launchPrice +} |