fix(GPO): min suggested tip cap if there's congestion to avoid filtering through DefaultIgnorePrice (#883)

This commit is contained in:
Jonas Theis 2024-07-10 12:31:52 +08:00 committed by GitHub
parent f56dbb7c43
commit ae45e1230e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View file

@ -38,7 +38,7 @@ const sampleNumber = 3 // Number of transactions sampled in a block
var ( var (
DefaultMaxPrice = big.NewInt(500 * params.GWei) DefaultMaxPrice = big.NewInt(500 * params.GWei)
DefaultIgnorePrice = big.NewInt(2 * params.Wei) DefaultIgnorePrice = big.NewInt(1 * params.Wei)
DefaultBasePrice = big.NewInt(0) 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. // high-priced txs are causing the suggested tip cap to be high.
pendingTxCount, _ := oracle.backend.Stats() pendingTxCount, _ := oracle.backend.Stats()
if pendingTxCount < oracle.congestedThreshold { 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. // 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. // 1. Set price to at least 1 as otherwise tx with a 0 tip might be filtered out by the default mempool config.
price := big.NewInt(1) // 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) { if !oracle.backend.ChainConfig().IsCurie(head.Number) {
price = oracle.defaultBasePrice price = oracle.defaultBasePrice
} }

View file

@ -24,7 +24,7 @@ import (
const ( const (
VersionMajor = 5 // Major version component of the current release VersionMajor = 5 // Major version component of the current release
VersionMinor = 5 // Minor 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 VersionMeta = "mainnet" // Version metadata to append to the version string
) )