From 79547eb01b34a50dd6cccd934b0e6eb14e77cb83 Mon Sep 17 00:00:00 2001 From: iamsofonias Date: Mon, 22 Apr 2024 14:24:49 -0400 Subject: [PATCH] Add Default Prefix to New Fee Estimation Constant Names --- lib/blockchain.go | 32 ++++++++++++++++---------------- lib/constants.go | 34 ++++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/lib/blockchain.go b/lib/blockchain.go index 01772668b..373440f71 100644 --- a/lib/blockchain.go +++ b/lib/blockchain.go @@ -5014,10 +5014,10 @@ func (bc *Blockchain) CreateMaxSpend( txn, minFeeRateNanosPerKB, // TODO: Make these flags or GlobalParams - bc.params.MempoolCongestionFactorBasisPoints, - bc.params.MempoolPriorityPercentileBasisPoints, - bc.params.PastBlocksCongestionFactorBasisPoints, - bc.params.PastBlocksPriorityPercentileBasisPoints, + bc.params.DefaultMempoolCongestionFactorBasisPoints, + bc.params.DefaultMempoolPriorityPercentileBasisPoints, + bc.params.DefaultPastBlocksCongestionFactorBasisPoints, + bc.params.DefaultPastBlocksPriorityPercentileBasisPoints, maxBlockSizeBytes) if err != nil { return nil, 0, 0, 0, errors.Wrapf(err, "CreateMaxSpend: Problem estimating fee: ") @@ -5157,10 +5157,10 @@ func (bc *Blockchain) AddInputsAndChangeToTransactionWithSubsidy( txArg, minFeeRateNanosPerKB, // TODO: Make these flags or GlobalParams - bc.params.MempoolCongestionFactorBasisPoints, - bc.params.MempoolPriorityPercentileBasisPoints, - bc.params.PastBlocksCongestionFactorBasisPoints, - bc.params.PastBlocksPriorityPercentileBasisPoints, + bc.params.DefaultMempoolCongestionFactorBasisPoints, + bc.params.DefaultMempoolPriorityPercentileBasisPoints, + bc.params.DefaultPastBlocksCongestionFactorBasisPoints, + bc.params.DefaultPastBlocksPriorityPercentileBasisPoints, maxBlockSizeBytes) UpdateTxnFee(txArg, newTxFee) if err != nil { @@ -5879,10 +5879,10 @@ func (bc *Blockchain) CreateAtomicTxnsWrapper( // TODO: Allow the caller to specify minFeeRateNanosPerKB 0, // TODO: Make these flags or GlobalParams - bc.params.MempoolCongestionFactorBasisPoints, - bc.params.MempoolPriorityPercentileBasisPoints, - bc.params.PastBlocksCongestionFactorBasisPoints, - bc.params.PastBlocksPriorityPercentileBasisPoints, + bc.params.DefaultMempoolCongestionFactorBasisPoints, + bc.params.DefaultMempoolPriorityPercentileBasisPoints, + bc.params.DefaultPastBlocksCongestionFactorBasisPoints, + bc.params.DefaultPastBlocksPriorityPercentileBasisPoints, maxBlockSizeBytes) if err != nil { return nil, 0, errors.Wrapf(err, "CreateAtomicTxnsWrapper: failed to recompute fee estimate") @@ -5972,10 +5972,10 @@ func (bc *Blockchain) CreateAtomicTxnsWrapper( atomicTxn, 0, // TODO: Make these flags or GlobalParams - bc.params.MempoolCongestionFactorBasisPoints, - bc.params.MempoolPriorityPercentileBasisPoints, - bc.params.PastBlocksCongestionFactorBasisPoints, - bc.params.PastBlocksPriorityPercentileBasisPoints, + bc.params.DefaultMempoolCongestionFactorBasisPoints, + bc.params.DefaultMempoolPriorityPercentileBasisPoints, + bc.params.DefaultPastBlocksCongestionFactorBasisPoints, + bc.params.DefaultPastBlocksPriorityPercentileBasisPoints, maxBlockSizeBytes) if err != nil { return nil, 0, errors.Wrapf(err, "CreateAtomicTxnsWrapper: failed to compute "+ diff --git a/lib/constants.go b/lib/constants.go index b6db7de56..cff8ebf01 100644 --- a/lib/constants.go +++ b/lib/constants.go @@ -794,6 +794,18 @@ type DeSoParams struct { // this setting. DefaultMempoolFeeEstimatorNumPastBlocks uint64 + // DefaultMempoolCongestionFactorBasisPoints and DefaultPastBlocksCongestionFactorBasisPoints are the default values + // for GlobalParams.MempoolCongestionFactorBasisPoints and GlobalParams.DefaultPastBlocksCongestionFactorBasisPoints. + /// See comments in GlobalParamsEntry for a description of their usage. + DefaultMempoolCongestionFactorBasisPoints uint64 + DefaultPastBlocksCongestionFactorBasisPoints uint64 + + // DefaultMempoolPriorityPercentileBasisPoints and DefaultPastBlocksPriorityPercentileBasisPoints are the default values + // for GlobalParams.DefaultMempoolPriorityPercentileBasisPoints and GlobalParams.DefaultPastBlocksPriorityPercentileBasisPoints. + // See comments in GlobalParamsEntry for a description of their usage. + DefaultMempoolPriorityPercentileBasisPoints uint64 + DefaultPastBlocksPriorityPercentileBasisPoints uint64 + // DefaultMaxBlockSizeBytesPoS is the default value for GlobalParamsEntry.MaxBlockSizeBytesPoS. // This is the initial value for the maximum block size in bytes that we allow for PoS blocks. DefaultMaxBlockSizeBytesPoS uint64 @@ -823,12 +835,6 @@ type DeSoParams struct { ForkHeights ForkHeights - // See comment on the DeSoMainnetParams settings of these values - MempoolCongestionFactorBasisPoints uint64 - MempoolPriorityPercentileBasisPoints uint64 - PastBlocksCongestionFactorBasisPoints uint64 - PastBlocksPriorityPercentileBasisPoints uint64 - EncoderMigrationHeights *EncoderMigrationHeights EncoderMigrationHeightsList []*MigrationHeight } @@ -1362,8 +1368,8 @@ var DeSoMainnetParams = DeSoParams{ // Using the 90th percentile allows the fee market to be aggressive, but it's better than using // 100% because that can have some rounding issues. For example, if you use 100% and blocks are // 99% full, the fee market won't adapt. So it's better to have a little slack. - MempoolCongestionFactorBasisPoints: uint64(9000), - PastBlocksCongestionFactorBasisPoints: uint64(9000), + DefaultMempoolCongestionFactorBasisPoints: uint64(9000), + DefaultPastBlocksCongestionFactorBasisPoints: uint64(9000), // The priority percentile determines what benchmark we use to increase the fee we're paying. For // past blocks, we set a percentile of 90%, which means we'll take the fee paid by the 90th percentile // txn in the past N blocks and increase it by one fee bucket. This works nicely with N=50 blocks @@ -1372,8 +1378,8 @@ var DeSoMainnetParams = DeSoParams{ // the highest 1 block's worth of txns in the mempool. We use a lower percentile here because the mempool // has a much tighter window of a single block, and so by outbidding *anybody* in that block, you're // already highly likely to get in. - MempoolPriorityPercentileBasisPoints: uint64(1000), - PastBlocksPriorityPercentileBasisPoints: uint64(9000), + DefaultMempoolPriorityPercentileBasisPoints: uint64(1000), + DefaultPastBlocksPriorityPercentileBasisPoints: uint64(9000), ForkHeights: MainnetForkHeights, EncoderMigrationHeights: GetEncoderMigrationHeights(&MainnetForkHeights), @@ -1684,10 +1690,10 @@ var DeSoTestnetParams = DeSoParams{ DisableNetworkManagerRoutines: false, // See comment on DeSoMainnetParams - MempoolCongestionFactorBasisPoints: uint64(9000), - PastBlocksCongestionFactorBasisPoints: uint64(9000), - MempoolPriorityPercentileBasisPoints: uint64(1000), - PastBlocksPriorityPercentileBasisPoints: uint64(9000), + DefaultMempoolCongestionFactorBasisPoints: uint64(9000), + DefaultPastBlocksCongestionFactorBasisPoints: uint64(9000), + DefaultMempoolPriorityPercentileBasisPoints: uint64(1000), + DefaultPastBlocksPriorityPercentileBasisPoints: uint64(9000), ForkHeights: TestnetForkHeights, EncoderMigrationHeights: GetEncoderMigrationHeights(&TestnetForkHeights),