From ae45e1230eed351bb93ee375e5689d57e106c013 Mon Sep 17 00:00:00 2001 From: Jonas Theis <4181434+jonastheis@users.noreply.github.com> Date: Wed, 10 Jul 2024 12:31:52 +0800 Subject: [PATCH] fix(GPO): min suggested tip cap if there's congestion to avoid filtering through `DefaultIgnorePrice` (#883) --- eth/gasprice/gasprice.go | 11 +++++++---- params/version.go | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/eth/gasprice/gasprice.go b/eth/gasprice/gasprice.go index 29ffcc6051..ae31407602 100644 --- a/eth/gasprice/gasprice.go +++ b/eth/gasprice/gasprice.go @@ -38,7 +38,7 @@ const sampleNumber = 3 // Number of transactions sampled in a block var ( DefaultMaxPrice = big.NewInt(500 * params.GWei) - DefaultIgnorePrice = big.NewInt(2 * params.Wei) + DefaultIgnorePrice = big.NewInt(1 * params.Wei) DefaultBasePrice = big.NewInt(0) ) @@ -194,10 +194,13 @@ func (oracle *Oracle) SuggestTipCap(ctx context.Context) (*big.Int, error) { // high-priced txs are causing the suggested tip cap to be high. pendingTxCount, _ := oracle.backend.Stats() if pendingTxCount < oracle.congestedThreshold { - // Before Curie (EIP-1559), we need to return the total suggested gas price. After Curie we return 1 wei as the tip cap, + // Before Curie (EIP-1559), we need to return the total suggested gas price. After Curie we return 2 wei as the tip cap, // as the base fee is set separately or added manually for legacy transactions. - // Set price to 1 as otherwise tx with a 0 tip might be filtered out by the default mempool config. - price := big.NewInt(1) + // 1. Set price to at least 1 as otherwise tx with a 0 tip might be filtered out by the default mempool config. + // 2. Since oracle.ignoreprice was set to 2 (DefaultIgnorePrice) before by default, we need to set the price + // to 2 to avoid filtering in oracle.getBlockValues() by nodes that did not yet update to this version. + // In the future we can set the price to 1 wei. + price := big.NewInt(2) if !oracle.backend.ChainConfig().IsCurie(head.Number) { price = oracle.defaultBasePrice } diff --git a/params/version.go b/params/version.go index d3bbaea785..bdd5573ebe 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 5 // Major version component of the current release VersionMinor = 5 // Minor version component of the current release - VersionPatch = 6 // Patch version component of the current release + VersionPatch = 7 // Patch version component of the current release VersionMeta = "mainnet" // Version metadata to append to the version string )