From 3960b690bf8c67afe706bb469b0ff2798424a26e Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Thu, 17 Dec 2020 13:58:14 -0500 Subject: Decrease minimum gas price at apricot upgrade --- params/protocol_params.go | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'params/protocol_params.go') 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 +} -- cgit v1.2.3