Skip to content

Commit

Permalink
fix(GPO): min suggested tip cap if there's congestion to avoid filter…
Browse files Browse the repository at this point in the history
…ing through `DefaultIgnorePrice` (scroll-tech#883)
  • Loading branch information
jonastheis authored and lwedge99 committed Aug 27, 2024
1 parent 9a5399d commit dd0fea1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions eth/gasprice/gasprice.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down

0 comments on commit dd0fea1

Please sign in to comment.