From 94ab7f217ff83326aaf005f3da570a2d7814330f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Friedemann=20F=C3=BCrst?=
<59653747+friedemannf@users.noreply.github.com>
Date: Mon, 23 Sep 2024 19:39:16 +0200
Subject: [PATCH] Change Polygon zkEVM to use FeeHistory estimator (#14161)
* Change Polygon zkEVM to use SuggestedPriceEstimator
(SHIP-2885)
* Set PriceMin to 1mwei for Polygon zkEVM
* Remove Polygon zkEVM Goerli
* Enable FeeHistory estimator for Polygon zkEVM
* Update PriceMin
* apply suggestions
* Set CacheTimeout to 2 seconds
* Revert back to 5s cachetimeout
* Change timeout to 4 seconds
---------
Co-authored-by: joaoluisam
# Conflicts:
# docs/CONFIG.md
---
.changeset/tender-lemons-obey.md | 5 +
.../toml/defaults/Polygon_Zkevm_Cardona.toml | 10 +-
.../toml/defaults/Polygon_Zkevm_Goerli.toml | 24 ----
.../toml/defaults/Polygon_Zkevm_Mainnet.toml | 10 +-
docs/CONFIG.md | 118 ++----------------
5 files changed, 27 insertions(+), 140 deletions(-)
create mode 100644 .changeset/tender-lemons-obey.md
delete mode 100644 core/chains/evm/config/toml/defaults/Polygon_Zkevm_Goerli.toml
diff --git a/.changeset/tender-lemons-obey.md b/.changeset/tender-lemons-obey.md
new file mode 100644
index 0000000000..2d6cb774b0
--- /dev/null
+++ b/.changeset/tender-lemons-obey.md
@@ -0,0 +1,5 @@
+---
+"chainlink": patch
+---
+
+Enable FeeHistory estimator for Polygon zkEVM #nops
diff --git a/core/chains/evm/config/toml/defaults/Polygon_Zkevm_Cardona.toml b/core/chains/evm/config/toml/defaults/Polygon_Zkevm_Cardona.toml
index cd91465dae..46ce80e29f 100644
--- a/core/chains/evm/config/toml/defaults/Polygon_Zkevm_Cardona.toml
+++ b/core/chains/evm/config/toml/defaults/Polygon_Zkevm_Cardona.toml
@@ -13,12 +13,14 @@ ContractConfirmations = 1
ResendAfterThreshold = '3m'
[GasEstimator]
-PriceMin = '1 mwei'
+Mode = 'FeeHistory'
+# The FeeHistory estimator does not enforce PriceMin, setting it to 0 to not place any limits on the price
+PriceMin = '0'
BumpPercent = 40
-BumpMin = '20 mwei'
-[GasEstimator.BlockHistory]
-BlockHistorySize = 12
+[GasEstimator.FeeHistory]
+# Refresh the suggested price every 4 seconds, to stay slightly below their polling rate of 5s
+CacheTimeout = '4s'
[HeadTracker]
HistoryDepth = 2000
diff --git a/core/chains/evm/config/toml/defaults/Polygon_Zkevm_Goerli.toml b/core/chains/evm/config/toml/defaults/Polygon_Zkevm_Goerli.toml
deleted file mode 100644
index 6a9b47190f..0000000000
--- a/core/chains/evm/config/toml/defaults/Polygon_Zkevm_Goerli.toml
+++ /dev/null
@@ -1,24 +0,0 @@
-ChainID = '1442'
-ChainType = 'zkevm'
-FinalityDepth = 500
-NoNewHeadsThreshold = '12m'
-MinIncomingConfirmations = 1
-LogPollInterval = '30s'
-RPCDefaultBatchSize = 100
-
-[OCR]
-ContractConfirmations = 1
-
-[Transactions]
-ResendAfterThreshold = '3m'
-
-[GasEstimator]
-PriceMin = '50 mwei'
-BumpPercent = 40
-BumpMin = '20 mwei'
-
-[GasEstimator.BlockHistory]
-BlockHistorySize = 12
-
-[HeadTracker]
-HistoryDepth = 2000
diff --git a/core/chains/evm/config/toml/defaults/Polygon_Zkevm_Mainnet.toml b/core/chains/evm/config/toml/defaults/Polygon_Zkevm_Mainnet.toml
index 79e0cb0fce..2fef7874d1 100644
--- a/core/chains/evm/config/toml/defaults/Polygon_Zkevm_Mainnet.toml
+++ b/core/chains/evm/config/toml/defaults/Polygon_Zkevm_Mainnet.toml
@@ -14,12 +14,14 @@ ContractConfirmations = 1
ResendAfterThreshold = '3m'
[GasEstimator]
-PriceMin = '100 mwei'
+Mode = 'FeeHistory'
+# The FeeHistory estimator does not enforce PriceMin, setting it to 0 to not place any limits on the price
+PriceMin = '0'
BumpPercent = 40
-BumpMin = '100 mwei'
-[GasEstimator.BlockHistory]
-BlockHistorySize = 12
+[GasEstimator.FeeHistory]
+# Refresh the suggested price every 4 seconds, to stay slightly below their polling rate of 5s
+CacheTimeout = '4s'
[HeadTracker]
# Polygon suffers from a tremendous number of re-orgs, we need to set this to something very large to be conservative enough
diff --git a/docs/CONFIG.md b/docs/CONFIG.md
index 95743363ab..980635a9fe 100644
--- a/docs/CONFIG.md
+++ b/docs/CONFIG.md
@@ -4652,16 +4652,16 @@ Enabled = false
Enabled = true
[GasEstimator]
-Mode = 'BlockHistory'
+Mode = 'FeeHistory'
PriceDefault = '20 gwei'
PriceMax = '115792089237316195423570985008687907853269984665.640564039457584007913129639935 tether'
-PriceMin = '100 mwei'
+PriceMin = '0'
LimitDefault = 8000000
LimitMax = 8000000
LimitMultiplier = '1'
LimitTransfer = 21000
EstimateLimit = false
-BumpMin = '100 mwei'
+BumpMin = '5 gwei'
BumpPercent = 40
BumpThreshold = 3
EIP1559DynamicFees = false
@@ -4671,13 +4671,13 @@ TipCapMin = '1 wei'
[GasEstimator.BlockHistory]
BatchSize = 25
-BlockHistorySize = 12
+BlockHistorySize = 8
CheckInclusionBlocks = 12
CheckInclusionPercentile = 90
TransactionPercentile = 60
[GasEstimator.FeeHistory]
-CacheTimeout = '10s'
+CacheTimeout = '4s'
[HeadTracker]
HistoryDepth = 2000
@@ -5005,104 +5005,6 @@ GasLimit = 5400000
-Polygon Zkevm Goerli (1442)
-
-```toml
-AutoCreateKey = true
-BlockBackfillDepth = 10
-BlockBackfillSkip = false
-ChainType = 'zkevm'
-FinalityDepth = 500
-FinalityTagEnabled = false
-LogBackfillBatchSize = 1000
-LogPollInterval = '30s'
-LogKeepBlocksDepth = 100000
-LogPrunePageSize = 10000
-BackupLogPollerBlockDelay = 100
-MinIncomingConfirmations = 1
-MinContractPayment = '0.00001 link'
-NonceAutoSync = true
-NoNewHeadsThreshold = '12m0s'
-RPCDefaultBatchSize = 100
-RPCBlockQueryDelay = 1
-FinalizedBlockOffset = 0
-NoNewFinalizedHeadsThreshold = '0s'
-
-[Transactions]
-ForwardersEnabled = false
-MaxInFlight = 16
-MaxQueued = 250
-ReaperInterval = '1h0m0s'
-ReaperThreshold = '168h0m0s'
-ResendAfterThreshold = '3m0s'
-
-[Transactions.AutoPurge]
-Enabled = false
-
-[BalanceMonitor]
-Enabled = true
-
-[GasEstimator]
-Mode = 'BlockHistory'
-PriceDefault = '20 gwei'
-PriceMax = '115792089237316195423570985008687907853269984665.640564039457584007913129639935 tether'
-PriceMin = '50 mwei'
-LimitDefault = 8000000
-LimitMax = 8000000
-LimitMultiplier = '1'
-LimitTransfer = 21000
-EstimateLimit = false
-BumpMin = '20 mwei'
-BumpPercent = 40
-BumpThreshold = 3
-EIP1559DynamicFees = false
-FeeCapDefault = '100 gwei'
-TipCapDefault = '1 wei'
-TipCapMin = '1 wei'
-
-[GasEstimator.BlockHistory]
-BatchSize = 25
-BlockHistorySize = 12
-CheckInclusionBlocks = 12
-CheckInclusionPercentile = 90
-TransactionPercentile = 60
-
-[GasEstimator.FeeHistory]
-CacheTimeout = '10s'
-
-[HeadTracker]
-HistoryDepth = 2000
-MaxBufferSize = 3
-SamplingInterval = '1s'
-MaxAllowedFinalityDepth = 10000
-FinalityTagBypass = true
-
-[NodePool]
-PollFailureThreshold = 5
-PollInterval = '10s'
-SelectionMode = 'HighestHead'
-SyncThreshold = 5
-LeaseDuration = '0s'
-NodeIsSyncingEnabled = false
-FinalizedBlockPollInterval = '5s'
-EnforceRepeatableRead = false
-DeathDeclarationDelay = '10s'
-
-[OCR]
-ContractConfirmations = 1
-ContractTransmitterTransmitTimeout = '10s'
-DatabaseTimeout = '10s'
-DeltaCOverride = '168h0m0s'
-DeltaCJitterOverride = '1h0m0s'
-ObservationGracePeriod = '1s'
-
-[OCR2]
-[OCR2.Automation]
-GasLimit = 5400000
-```
-
-
-
Kroma Sepolia (2358)
```toml
@@ -5239,16 +5141,16 @@ Enabled = false
Enabled = true
[GasEstimator]
-Mode = 'BlockHistory'
+Mode = 'FeeHistory'
PriceDefault = '20 gwei'
PriceMax = '115792089237316195423570985008687907853269984665.640564039457584007913129639935 tether'
-PriceMin = '1 mwei'
+PriceMin = '0'
LimitDefault = 8000000
LimitMax = 8000000
LimitMultiplier = '1'
LimitTransfer = 21000
EstimateLimit = false
-BumpMin = '20 mwei'
+BumpMin = '5 gwei'
BumpPercent = 40
BumpThreshold = 3
EIP1559DynamicFees = false
@@ -5258,13 +5160,13 @@ TipCapMin = '1 wei'
[GasEstimator.BlockHistory]
BatchSize = 25
-BlockHistorySize = 12
+BlockHistorySize = 8
CheckInclusionBlocks = 12
CheckInclusionPercentile = 90
TransactionPercentile = 60
[GasEstimator.FeeHistory]
-CacheTimeout = '10s'
+CacheTimeout = '4s'
[HeadTracker]
HistoryDepth = 2000