From efead72965fec7e822a16f4d50cc0e5a27dd4640 Mon Sep 17 00:00:00 2001
From: Domino Valdano
Date: Fri, 8 Mar 2024 10:11:59 -0800
Subject: [PATCH] Increase FinalityDepth & HistoryDepth defaults to match
Polygon mainnet (#12348)
* Increase FinalityDepth & HistoryDepth defaults to match Polygon mainnet
We have verified that finality tags on zkevm polygon are just as far
behind latest as they are on other polygon chains (often 300-500
blocks). HistoryDepth needs to be larger for the same reason, and allow
room for uncles.
* Add Cardona defaults based on Goerli
and increase FinalityDepth & BlockHistoryDepth for both chains
* make config-docs
* pnpm changeset
* Re-run "make config-docs"
---
.changeset/dull-pugs-wonder.md | 5 +
.../toml/defaults/Polygon_Zkevm_Cardona.toml | 23 +++++
.../toml/defaults/Polygon_Zkevm_Goerli.toml | 4 +-
.../toml/defaults/Polygon_Zkevm_Mainnet.toml | 5 +-
docs/CONFIG.md | 91 ++++++++++++++++++-
5 files changed, 120 insertions(+), 8 deletions(-)
create mode 100644 .changeset/dull-pugs-wonder.md
create mode 100644 core/chains/evm/config/toml/defaults/Polygon_Zkevm_Cardona.toml
diff --git a/.changeset/dull-pugs-wonder.md b/.changeset/dull-pugs-wonder.md
new file mode 100644
index 00000000000..f750db9f62c
--- /dev/null
+++ b/.changeset/dull-pugs-wonder.md
@@ -0,0 +1,5 @@
+---
+"chainlink": minor
+---
+
+Update config for zkevm polygon chains
diff --git a/core/chains/evm/config/toml/defaults/Polygon_Zkevm_Cardona.toml b/core/chains/evm/config/toml/defaults/Polygon_Zkevm_Cardona.toml
new file mode 100644
index 00000000000..02cc322f19e
--- /dev/null
+++ b/core/chains/evm/config/toml/defaults/Polygon_Zkevm_Cardona.toml
@@ -0,0 +1,23 @@
+ChainID = '2442'
+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_Goerli.toml b/core/chains/evm/config/toml/defaults/Polygon_Zkevm_Goerli.toml
index 58451679558..a259e4766f8 100644
--- a/core/chains/evm/config/toml/defaults/Polygon_Zkevm_Goerli.toml
+++ b/core/chains/evm/config/toml/defaults/Polygon_Zkevm_Goerli.toml
@@ -1,5 +1,5 @@
ChainID = '1442'
-FinalityDepth = 1
+FinalityDepth = 500
NoNewHeadsThreshold = '12m'
MinIncomingConfirmations = 1
LogPollInterval = '30s'
@@ -20,4 +20,4 @@ BumpMin = '20 mwei'
BlockHistorySize = 12
[HeadTracker]
-HistoryDepth = 50
+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 6be91b0e2cc..e8833bc7312 100644
--- a/core/chains/evm/config/toml/defaults/Polygon_Zkevm_Mainnet.toml
+++ b/core/chains/evm/config/toml/defaults/Polygon_Zkevm_Mainnet.toml
@@ -1,5 +1,5 @@
ChainID = '1101'
-FinalityDepth = 1
+FinalityDepth = 500
NoNewHeadsThreshold = '6m'
MinIncomingConfirmations = 1
LogPollInterval = '30s'
@@ -21,4 +21,5 @@ BumpMin = '100 mwei'
BlockHistorySize = 12
[HeadTracker]
-HistoryDepth = 50
+# Polygon suffers from a tremendous number of re-orgs, we need to set this to something very large to be conservative enough
+HistoryDepth = 2000
diff --git a/docs/CONFIG.md b/docs/CONFIG.md
index c91f7d0e23c..eee414f461f 100644
--- a/docs/CONFIG.md
+++ b/docs/CONFIG.md
@@ -3615,7 +3615,7 @@ GasLimit = 5400000
AutoCreateKey = true
BlockBackfillDepth = 10
BlockBackfillSkip = false
-FinalityDepth = 1
+FinalityDepth = 500
FinalityTagEnabled = false
LogBackfillBatchSize = 1000
LogPollInterval = '30s'
@@ -3665,7 +3665,7 @@ CheckInclusionPercentile = 90
TransactionPercentile = 60
[HeadTracker]
-HistoryDepth = 50
+HistoryDepth = 2000
MaxBufferSize = 3
SamplingInterval = '1s'
@@ -3949,7 +3949,7 @@ GasLimit = 5400000
AutoCreateKey = true
BlockBackfillDepth = 10
BlockBackfillSkip = false
-FinalityDepth = 1
+FinalityDepth = 500
FinalityTagEnabled = false
LogBackfillBatchSize = 1000
LogPollInterval = '30s'
@@ -3999,7 +3999,7 @@ CheckInclusionPercentile = 90
TransactionPercentile = 60
[HeadTracker]
-HistoryDepth = 50
+HistoryDepth = 2000
MaxBufferSize = 3
SamplingInterval = '1s'
@@ -4110,6 +4110,89 @@ GasLimit = 5400000
+Polygon Zkevm Cardona (2442)
+
+```toml
+AutoCreateKey = true
+BlockBackfillDepth = 10
+BlockBackfillSkip = false
+FinalityDepth = 500
+FinalityTagEnabled = false
+LogBackfillBatchSize = 1000
+LogPollInterval = '30s'
+LogKeepBlocksDepth = 100000
+LogPrunePageSize = 0
+BackupLogPollerBlockDelay = 100
+MinIncomingConfirmations = 1
+MinContractPayment = '0.00001 link'
+NonceAutoSync = true
+NoNewHeadsThreshold = '12m0s'
+RPCDefaultBatchSize = 100
+RPCBlockQueryDelay = 1
+
+[Transactions]
+ForwardersEnabled = false
+MaxInFlight = 16
+MaxQueued = 250
+ReaperInterval = '1h0m0s'
+ReaperThreshold = '168h0m0s'
+ResendAfterThreshold = '3m0s'
+
+[BalanceMonitor]
+Enabled = true
+
+[GasEstimator]
+Mode = 'BlockHistory'
+PriceDefault = '20 gwei'
+PriceMax = '115792089237316195423570985008687907853269984665.640564039457584007913129639935 tether'
+PriceMin = '50 mwei'
+LimitDefault = 500000
+LimitMax = 500000
+LimitMultiplier = '1'
+LimitTransfer = 21000
+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
+
+[HeadTracker]
+HistoryDepth = 2000
+MaxBufferSize = 3
+SamplingInterval = '1s'
+
+[NodePool]
+PollFailureThreshold = 5
+PollInterval = '10s'
+SelectionMode = 'HighestHead'
+SyncThreshold = 5
+LeaseDuration = '0s'
+NodeIsSyncingEnabled = false
+
+[OCR]
+ContractConfirmations = 1
+ContractTransmitterTransmitTimeout = '10s'
+DatabaseTimeout = '10s'
+DeltaCOverride = '168h0m0s'
+DeltaCJitterOverride = '1h0m0s'
+ObservationGracePeriod = '1s'
+
+[OCR2]
+[OCR2.Automation]
+GasLimit = 5400000
+```
+
+
+
Fantom Testnet (4002)
```toml