From 2d064071b97c02c7c9d757ac48c3eec38735db75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedemann=20F=C3=BCrst?= Date: Tue, 9 Apr 2024 00:33:44 +0200 Subject: [PATCH 1/7] Add X Layer --- .changeset/sixty-readers-mix.md | 5 + .../config/toml/defaults/XLayer_Mainnet.toml | 19 ++ .../config/toml/defaults/XLayer_Sepolia.toml | 19 ++ docs/CONFIG.md | 168 ++++++++++++++++++ integration-tests/go.mod | 2 +- integration-tests/go.sum | 2 + integration-tests/load/go.mod | 2 +- integration-tests/load/go.sum | 1 + 8 files changed, 216 insertions(+), 2 deletions(-) create mode 100644 .changeset/sixty-readers-mix.md create mode 100644 core/chains/evm/config/toml/defaults/XLayer_Mainnet.toml create mode 100644 core/chains/evm/config/toml/defaults/XLayer_Sepolia.toml diff --git a/.changeset/sixty-readers-mix.md b/.changeset/sixty-readers-mix.md new file mode 100644 index 00000000000..c85894e202a --- /dev/null +++ b/.changeset/sixty-readers-mix.md @@ -0,0 +1,5 @@ +--- +"chainlink": patch +--- + +Add support for X Layer (X1) diff --git a/core/chains/evm/config/toml/defaults/XLayer_Mainnet.toml b/core/chains/evm/config/toml/defaults/XLayer_Mainnet.toml new file mode 100644 index 00000000000..840a4a0cf2f --- /dev/null +++ b/core/chains/evm/config/toml/defaults/XLayer_Mainnet.toml @@ -0,0 +1,19 @@ +ChainID = '196' +FinalityDepth = 500 +NoNewHeadsThreshold = '6m' +MinIncomingConfirmations = 1 +LogPollInterval = '30s' +RPCBlockQueryDelay = 15 +RPCDefaultBatchSize = 100 + +[OCR] +ContractConfirmations = 1 + +[Transactions] +ResendAfterThreshold = '3m' + +[GasEstimator.BlockHistory] +BlockHistorySize = 12 + +[HeadTracker] +HistoryDepth = 2000 diff --git a/core/chains/evm/config/toml/defaults/XLayer_Sepolia.toml b/core/chains/evm/config/toml/defaults/XLayer_Sepolia.toml new file mode 100644 index 00000000000..c8503f09bc7 --- /dev/null +++ b/core/chains/evm/config/toml/defaults/XLayer_Sepolia.toml @@ -0,0 +1,19 @@ +ChainID = '195' +FinalityDepth = 500 +NoNewHeadsThreshold = '6m' +MinIncomingConfirmations = 1 +LogPollInterval = '30s' +RPCBlockQueryDelay = 15 +RPCDefaultBatchSize = 100 + +[OCR] +ContractConfirmations = 1 + +[Transactions] +ResendAfterThreshold = '3m' + +[GasEstimator.BlockHistory] +BlockHistorySize = 12 + +[HeadTracker] +HistoryDepth = 2000 diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 2e4ccfa1196..9debdfd51c6 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -2978,6 +2978,174 @@ GasLimit = 5400000

+
XLayer Sepolia (195)

+ +```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 = '6m0s' +RPCDefaultBatchSize = 100 +RPCBlockQueryDelay = 15 + +[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 = '1 gwei' +LimitDefault = 500000 +LimitMax = 500000 +LimitMultiplier = '1' +LimitTransfer = 21000 +BumpMin = '5 gwei' +BumpPercent = 20 +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 +FinalizedBlockPollInterval = '5s' + +[OCR] +ContractConfirmations = 1 +ContractTransmitterTransmitTimeout = '10s' +DatabaseTimeout = '10s' +DeltaCOverride = '168h0m0s' +DeltaCJitterOverride = '1h0m0s' +ObservationGracePeriod = '1s' + +[OCR2] +[OCR2.Automation] +GasLimit = 5400000 +``` + +

+ +
XLayer Mainnet (196)

+ +```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 = '6m0s' +RPCDefaultBatchSize = 100 +RPCBlockQueryDelay = 15 + +[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 = '1 gwei' +LimitDefault = 500000 +LimitMax = 500000 +LimitMultiplier = '1' +LimitTransfer = 21000 +BumpMin = '5 gwei' +BumpPercent = 20 +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 +FinalizedBlockPollInterval = '5s' + +[OCR] +ContractConfirmations = 1 +ContractTransmitterTransmitTimeout = '10s' +DatabaseTimeout = '10s' +DeltaCOverride = '168h0m0s' +DeltaCJitterOverride = '1h0m0s' +ObservationGracePeriod = '1s' + +[OCR2] +[OCR2.Automation] +GasLimit = 5400000 +``` + +

+
Fantom Mainnet (250)

```toml diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 2bc01df21f7..8f9adde7533 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -25,7 +25,7 @@ require ( github.com/slack-go/slack v0.12.2 github.com/smartcontractkit/chainlink-automation v1.0.2 github.com/smartcontractkit/chainlink-common v0.1.7-0.20240404141006-77085a02ce25 - github.com/smartcontractkit/chainlink-testing-framework v1.28.1 + github.com/smartcontractkit/chainlink-testing-framework v1.28.2-0.20240408220248-fe7896288bfe github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 github.com/smartcontractkit/libocr v0.0.0-20240326191951-2bbe9382d052 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 658a77c4f04..9181be4e7b5 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1539,6 +1539,8 @@ github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.202403 github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240325075535-0f7eb05ee595/go.mod h1:vV6WfnVIbK5Q1JsIru4YcTG0T1uRpLJm6t2BgCnCSsg= github.com/smartcontractkit/chainlink-testing-framework v1.28.1 h1:B0YEbaKjAGTPa9rkSfXS+RkH1phzBFjeV6ejPVGM/Jg= github.com/smartcontractkit/chainlink-testing-framework v1.28.1/go.mod h1:jN+HgXbriq6fKRlIqLw9F3I81aYImV6kBJkIfz0mdIA= +github.com/smartcontractkit/chainlink-testing-framework v1.28.2-0.20240408220248-fe7896288bfe h1:pkIsbasU6nQve172f4DVak7B+UkFWDniu2NvaOm1ICc= +github.com/smartcontractkit/chainlink-testing-framework v1.28.2-0.20240408220248-fe7896288bfe/go.mod h1:jN+HgXbriq6fKRlIqLw9F3I81aYImV6kBJkIfz0mdIA= github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 h1:FFdvEzlYwcuVHkdZ8YnZR/XomeMGbz5E2F2HZI3I3w8= github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868/go.mod h1:Kn1Hape05UzFZ7bOUnm3GVsHzP0TNrVmpfXYNHdqGGs= github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16 h1:TFe+FvzxClblt6qRfqEhUfa4kFQx5UobuoFGO2W4mMo= diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index e08143040be..b8c16c54435 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -17,7 +17,7 @@ require ( github.com/slack-go/slack v0.12.2 github.com/smartcontractkit/chainlink-automation v1.0.2 github.com/smartcontractkit/chainlink-common v0.1.7-0.20240404141006-77085a02ce25 - github.com/smartcontractkit/chainlink-testing-framework v1.28.1 + github.com/smartcontractkit/chainlink-testing-framework v1.28.2-0.20240408220248-fe7896288bfe github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20240214231432-4ad5eb95178c github.com/smartcontractkit/chainlink/v2 v2.9.0-beta0.0.20240216210048-da02459ddad8 github.com/smartcontractkit/libocr v0.0.0-20240326191951-2bbe9382d052 diff --git a/integration-tests/load/go.sum b/integration-tests/load/go.sum index a5c62d390e1..0f502c8e38d 100644 --- a/integration-tests/load/go.sum +++ b/integration-tests/load/go.sum @@ -1522,6 +1522,7 @@ github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.202403 github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240325075535-0f7eb05ee595/go.mod h1:vV6WfnVIbK5Q1JsIru4YcTG0T1uRpLJm6t2BgCnCSsg= github.com/smartcontractkit/chainlink-testing-framework v1.28.1 h1:B0YEbaKjAGTPa9rkSfXS+RkH1phzBFjeV6ejPVGM/Jg= github.com/smartcontractkit/chainlink-testing-framework v1.28.1/go.mod h1:jN+HgXbriq6fKRlIqLw9F3I81aYImV6kBJkIfz0mdIA= +github.com/smartcontractkit/chainlink-testing-framework v1.28.2-0.20240408220248-fe7896288bfe/go.mod h1:jN+HgXbriq6fKRlIqLw9F3I81aYImV6kBJkIfz0mdIA= github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240227164431-18a7065e23ea h1:ZdLmNAfKRjH8AYUvjiiDGUgiWQfq/7iNpxyTkvjx/ko= github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240227164431-18a7065e23ea/go.mod h1:gCKC9w6XpNk6jm+XIk2psrkkfxhi421N9NSiFceXW88= github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 h1:FFdvEzlYwcuVHkdZ8YnZR/XomeMGbz5E2F2HZI3I3w8= From a45a6ec2532c3b0af7393561cb541b866b46a2c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedemann=20F=C3=BCrst?= Date: Tue, 9 Apr 2024 00:38:11 +0200 Subject: [PATCH 2/7] go mod tidy --- integration-tests/go.sum | 2 -- integration-tests/load/go.sum | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 9181be4e7b5..25027fd263c 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1537,8 +1537,6 @@ github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240216142700-c5869534c19 github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240216142700-c5869534c19e/go.mod h1:JiykN+8W5TA4UD2ClrzQCVvcH3NcyLEVv7RwY0busrw= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240325075535-0f7eb05ee595 h1:y6ks0HsSOhPUueOmTcoxDQ50RCS1XINlRDTemZyHjFw= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240325075535-0f7eb05ee595/go.mod h1:vV6WfnVIbK5Q1JsIru4YcTG0T1uRpLJm6t2BgCnCSsg= -github.com/smartcontractkit/chainlink-testing-framework v1.28.1 h1:B0YEbaKjAGTPa9rkSfXS+RkH1phzBFjeV6ejPVGM/Jg= -github.com/smartcontractkit/chainlink-testing-framework v1.28.1/go.mod h1:jN+HgXbriq6fKRlIqLw9F3I81aYImV6kBJkIfz0mdIA= github.com/smartcontractkit/chainlink-testing-framework v1.28.2-0.20240408220248-fe7896288bfe h1:pkIsbasU6nQve172f4DVak7B+UkFWDniu2NvaOm1ICc= github.com/smartcontractkit/chainlink-testing-framework v1.28.2-0.20240408220248-fe7896288bfe/go.mod h1:jN+HgXbriq6fKRlIqLw9F3I81aYImV6kBJkIfz0mdIA= github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 h1:FFdvEzlYwcuVHkdZ8YnZR/XomeMGbz5E2F2HZI3I3w8= diff --git a/integration-tests/load/go.sum b/integration-tests/load/go.sum index 0f502c8e38d..2ffac5ba737 100644 --- a/integration-tests/load/go.sum +++ b/integration-tests/load/go.sum @@ -1520,8 +1520,7 @@ github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240216142700-c5869534c19 github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240216142700-c5869534c19e/go.mod h1:JiykN+8W5TA4UD2ClrzQCVvcH3NcyLEVv7RwY0busrw= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240325075535-0f7eb05ee595 h1:y6ks0HsSOhPUueOmTcoxDQ50RCS1XINlRDTemZyHjFw= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240325075535-0f7eb05ee595/go.mod h1:vV6WfnVIbK5Q1JsIru4YcTG0T1uRpLJm6t2BgCnCSsg= -github.com/smartcontractkit/chainlink-testing-framework v1.28.1 h1:B0YEbaKjAGTPa9rkSfXS+RkH1phzBFjeV6ejPVGM/Jg= -github.com/smartcontractkit/chainlink-testing-framework v1.28.1/go.mod h1:jN+HgXbriq6fKRlIqLw9F3I81aYImV6kBJkIfz0mdIA= +github.com/smartcontractkit/chainlink-testing-framework v1.28.2-0.20240408220248-fe7896288bfe h1:pkIsbasU6nQve172f4DVak7B+UkFWDniu2NvaOm1ICc= github.com/smartcontractkit/chainlink-testing-framework v1.28.2-0.20240408220248-fe7896288bfe/go.mod h1:jN+HgXbriq6fKRlIqLw9F3I81aYImV6kBJkIfz0mdIA= github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240227164431-18a7065e23ea h1:ZdLmNAfKRjH8AYUvjiiDGUgiWQfq/7iNpxyTkvjx/ko= github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240227164431-18a7065e23ea/go.mod h1:gCKC9w6XpNk6jm+XIk2psrkkfxhi421N9NSiFceXW88= From 275df5f528fc3f706f8be15345f3bf825a09355d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedemann=20F=C3=BCrst?= Date: Fri, 26 Apr 2024 14:39:53 +0200 Subject: [PATCH 3/7] Add ChainType for XLayer to ignore transactions with 0 gasPrice --- common/config/chaintype.go | 4 +++- .../config/toml/defaults/XLayer_Mainnet.toml | 6 ++++++ .../config/toml/defaults/XLayer_Sepolia.toml | 8 +++++++- core/chains/evm/gas/chain_specific.go | 17 +++++++---------- core/config/docs/chains-evm.toml | 2 +- core/services/ocr/contract_tracker.go | 2 +- core/services/ocrcommon/block_translator.go | 2 +- docs/CONFIG.md | 18 ++++++++++-------- 8 files changed, 36 insertions(+), 23 deletions(-) diff --git a/common/config/chaintype.go b/common/config/chaintype.go index 29bab2a91e2..73c48960a13 100644 --- a/common/config/chaintype.go +++ b/common/config/chaintype.go @@ -19,6 +19,7 @@ const ( ChainScroll ChainType = "scroll" ChainWeMix ChainType = "wemix" ChainXDai ChainType = "xdai" // Deprecated: use ChainGnosis instead + ChainXLayer ChainType = "xlayer" ChainZkSync ChainType = "zksync" ) @@ -31,13 +32,14 @@ var ErrInvalidChainType = fmt.Errorf("must be one of %s or omitted", strings.Joi string(ChainOptimismBedrock), string(ChainScroll), string(ChainWeMix), + string(ChainXLayer), string(ChainZkSync), }, ", ")) // IsValid returns true if the ChainType value is known or empty. func (c ChainType) IsValid() bool { switch c { - case "", ChainArbitrum, ChainCelo, ChainGnosis, ChainKroma, ChainMetis, ChainOptimismBedrock, ChainScroll, ChainWeMix, ChainXDai, ChainZkSync: + case "", ChainArbitrum, ChainCelo, ChainGnosis, ChainKroma, ChainMetis, ChainOptimismBedrock, ChainScroll, ChainWeMix, ChainXDai, ChainXLayer, ChainZkSync: return true } return false diff --git a/core/chains/evm/config/toml/defaults/XLayer_Mainnet.toml b/core/chains/evm/config/toml/defaults/XLayer_Mainnet.toml index 840a4a0cf2f..4096a4db244 100644 --- a/core/chains/evm/config/toml/defaults/XLayer_Mainnet.toml +++ b/core/chains/evm/config/toml/defaults/XLayer_Mainnet.toml @@ -1,4 +1,5 @@ ChainID = '196' +ChainType = 'xlayer' FinalityDepth = 500 NoNewHeadsThreshold = '6m' MinIncomingConfirmations = 1 @@ -12,6 +13,11 @@ ContractConfirmations = 1 [Transactions] ResendAfterThreshold = '3m' +[GasEstimator] +PriceMin = '100 mwei' +BumpPercent = 40 +BumpMin = '100 mwei' + [GasEstimator.BlockHistory] BlockHistorySize = 12 diff --git a/core/chains/evm/config/toml/defaults/XLayer_Sepolia.toml b/core/chains/evm/config/toml/defaults/XLayer_Sepolia.toml index c8503f09bc7..62e2c1e8ad0 100644 --- a/core/chains/evm/config/toml/defaults/XLayer_Sepolia.toml +++ b/core/chains/evm/config/toml/defaults/XLayer_Sepolia.toml @@ -1,6 +1,7 @@ ChainID = '195' +ChainType = 'xlayer' FinalityDepth = 500 -NoNewHeadsThreshold = '6m' +NoNewHeadsThreshold = '12m' MinIncomingConfirmations = 1 LogPollInterval = '30s' RPCBlockQueryDelay = 15 @@ -12,6 +13,11 @@ ContractConfirmations = 1 [Transactions] ResendAfterThreshold = '3m' +[GasEstimator] +PriceMin = '1 mwei' +BumpPercent = 40 +BumpMin = '20 mwei' + [GasEstimator.BlockHistory] BlockHistorySize = 12 diff --git a/core/chains/evm/gas/chain_specific.go b/core/chains/evm/gas/chain_specific.go index c64441cc142..a5de7c4c4fe 100644 --- a/core/chains/evm/gas/chain_specific.go +++ b/core/chains/evm/gas/chain_specific.go @@ -9,17 +9,17 @@ import ( // chainSpecificIsUsable allows for additional logic specific to a particular // Config that determines whether a transaction should be used for gas estimation func chainSpecificIsUsable(tx evmtypes.Transaction, baseFee *assets.Wei, chainType config.ChainType, minGasPriceWei *assets.Wei) bool { - if chainType == config.ChainGnosis || chainType == config.ChainXDai { + switch chainType { + case config.ChainGnosis, config.ChainXDai, config.ChainXLayer: // GasPrice 0 on most chains is great since it indicates cheap/free transactions. - // However, Gnosis reserves a special type of "bridge" transaction with 0 gas + // However, Gnosis and XLayer reserve a special type of "bridge" transaction with 0 gas // price that is always processed at top priority. Ordinary transactions // must be priced at least 1GWei, so we have to discard anything priced // below that (unless the contract is whitelisted). if tx.GasPrice != nil && tx.GasPrice.Cmp(minGasPriceWei) < 0 { return false } - } - if chainType == config.ChainOptimismBedrock || chainType == config.ChainKroma { + case config.ChainOptimismBedrock, config.ChainKroma: // This is a special deposit transaction type introduced in Bedrock upgrade. // This is a system transaction that it will occur at least one time per block. // We should discard this type before even processing it to avoid flooding the @@ -28,8 +28,7 @@ func chainSpecificIsUsable(tx evmtypes.Transaction, baseFee *assets.Wei, chainTy if tx.Type == 0x7e { return false } - } - if chainType == config.ChainCelo { + case config.ChainCelo: // Celo specific transaction types that utilize the feeCurrency field. if tx.Type == 0x7c || tx.Type == 0x7b { return false @@ -41,15 +40,13 @@ func chainSpecificIsUsable(tx evmtypes.Transaction, baseFee *assets.Wei, chainTy if baseFee != nil && tx.GasPrice.Cmp(baseFee) < 0 { return false } - } - if chainType == config.ChainWeMix { + case config.ChainWeMix: // WeMix specific transaction types that enables fee delegation. // https://docs.wemix.com/v/en/design/fee-delegation if tx.Type == 0x16 { return false } - } - if chainType == config.ChainZkSync { + case config.ChainZkSync: // zKSync specific type for contract deployment & priority transactions // https://era.zksync.io/docs/reference/concepts/transactions.html#eip-712-0x71 if tx.Type == 0x71 || tx.Type == 0xff { diff --git a/core/config/docs/chains-evm.toml b/core/config/docs/chains-evm.toml index dd63edaf694..2fe212d4549 100644 --- a/core/config/docs/chains-evm.toml +++ b/core/config/docs/chains-evm.toml @@ -14,7 +14,7 @@ BlockBackfillDepth = 10 # Default # BlockBackfillSkip enables skipping of very long backfills. BlockBackfillSkip = false # Default # ChainType is automatically detected from chain ID. Set this to force a certain chain type regardless of chain ID. -# Available types: `arbitrum`, `celo`, `gnosis`, `kroma`, `metis`, `optimismBedrock`, `scroll`, `wemix`, `zksync` +# Available types: `arbitrum`, `celo`, `gnosis`, `kroma`, `metis`, `optimismBedrock`, `scroll`, `wemix`, `xlayer`, `zksync` # # `xdai` has been deprecated and will be removed in v2.13.0, use `gnosis` instead. ChainType = 'arbitrum' # Example diff --git a/core/services/ocr/contract_tracker.go b/core/services/ocr/contract_tracker.go index e4845ee3bc2..2254912dc1c 100644 --- a/core/services/ocr/contract_tracker.go +++ b/core/services/ocr/contract_tracker.go @@ -405,7 +405,7 @@ func (t *OCRContractTracker) LatestBlockHeight(ctx context.Context) (blockheight // care about the block height; we have no way of getting the L1 block // height anyway return 0, nil - case "", config.ChainArbitrum, config.ChainCelo, config.ChainGnosis, config.ChainKroma, config.ChainOptimismBedrock, config.ChainScroll, config.ChainWeMix, config.ChainXDai, config.ChainZkSync: + case "", config.ChainArbitrum, config.ChainCelo, config.ChainGnosis, config.ChainKroma, config.ChainOptimismBedrock, config.ChainScroll, config.ChainWeMix, config.ChainXDai, config.ChainXLayer, config.ChainZkSync: // continue } latestBlockHeight := t.getLatestBlockHeight() diff --git a/core/services/ocrcommon/block_translator.go b/core/services/ocrcommon/block_translator.go index bc7242a6019..6ef64499fa9 100644 --- a/core/services/ocrcommon/block_translator.go +++ b/core/services/ocrcommon/block_translator.go @@ -21,7 +21,7 @@ func NewBlockTranslator(cfg Config, client evmclient.Client, lggr logger.Logger) switch cfg.ChainType() { case config.ChainArbitrum: return NewArbitrumBlockTranslator(client, lggr) - case "", config.ChainCelo, config.ChainGnosis, config.ChainKroma, config.ChainMetis, config.ChainOptimismBedrock, config.ChainScroll, config.ChainWeMix, config.ChainXDai, config.ChainZkSync: + case "", config.ChainCelo, config.ChainGnosis, config.ChainKroma, config.ChainMetis, config.ChainOptimismBedrock, config.ChainScroll, config.ChainWeMix, config.ChainXDai, config.ChainXLayer, config.ChainZkSync: fallthrough default: return &l1BlockTranslator{} diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 9debdfd51c6..b40f7dc50c2 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -2984,6 +2984,7 @@ GasLimit = 5400000 AutoCreateKey = true BlockBackfillDepth = 10 BlockBackfillSkip = false +ChainType = 'xlayer' FinalityDepth = 500 FinalityTagEnabled = false LogBackfillBatchSize = 1000 @@ -2994,7 +2995,7 @@ BackupLogPollerBlockDelay = 100 MinIncomingConfirmations = 1 MinContractPayment = '0.00001 link' NonceAutoSync = true -NoNewHeadsThreshold = '6m0s' +NoNewHeadsThreshold = '12m0s' RPCDefaultBatchSize = 100 RPCBlockQueryDelay = 15 @@ -3013,13 +3014,13 @@ Enabled = true Mode = 'BlockHistory' PriceDefault = '20 gwei' PriceMax = '115792089237316195423570985008687907853269984665.640564039457584007913129639935 tether' -PriceMin = '1 gwei' +PriceMin = '1 mwei' LimitDefault = 500000 LimitMax = 500000 LimitMultiplier = '1' LimitTransfer = 21000 -BumpMin = '5 gwei' -BumpPercent = 20 +BumpMin = '20 mwei' +BumpPercent = 40 BumpThreshold = 3 EIP1559DynamicFees = false FeeCapDefault = '100 gwei' @@ -3068,6 +3069,7 @@ GasLimit = 5400000 AutoCreateKey = true BlockBackfillDepth = 10 BlockBackfillSkip = false +ChainType = 'xlayer' FinalityDepth = 500 FinalityTagEnabled = false LogBackfillBatchSize = 1000 @@ -3097,13 +3099,13 @@ Enabled = true Mode = 'BlockHistory' PriceDefault = '20 gwei' PriceMax = '115792089237316195423570985008687907853269984665.640564039457584007913129639935 tether' -PriceMin = '1 gwei' +PriceMin = '100 mwei' LimitDefault = 500000 LimitMax = 500000 LimitMultiplier = '1' LimitTransfer = 21000 -BumpMin = '5 gwei' -BumpPercent = 20 +BumpMin = '100 mwei' +BumpPercent = 40 BumpThreshold = 3 EIP1559DynamicFees = false FeeCapDefault = '100 gwei' @@ -6494,7 +6496,7 @@ BlockBackfillSkip enables skipping of very long backfills. ChainType = 'arbitrum' # Example ``` ChainType is automatically detected from chain ID. Set this to force a certain chain type regardless of chain ID. -Available types: `arbitrum`, `celo`, `gnosis`, `kroma`, `metis`, `optimismBedrock`, `scroll`, `wemix`, `zksync` +Available types: `arbitrum`, `celo`, `gnosis`, `kroma`, `metis`, `optimismBedrock`, `scroll`, `wemix`, `xlayer`, `zksync` `xdai` has been deprecated and will be removed in v2.13.0, use `gnosis` instead. From ec16434267dd1c7ddb33918ca35b8cf37f2ae49f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedemann=20F=C3=BCrst?= Date: Fri, 26 Apr 2024 14:57:08 +0200 Subject: [PATCH 4/7] revert switch stmt --- core/chains/evm/gas/chain_specific.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/core/chains/evm/gas/chain_specific.go b/core/chains/evm/gas/chain_specific.go index a5de7c4c4fe..694411f164b 100644 --- a/core/chains/evm/gas/chain_specific.go +++ b/core/chains/evm/gas/chain_specific.go @@ -9,8 +9,7 @@ import ( // chainSpecificIsUsable allows for additional logic specific to a particular // Config that determines whether a transaction should be used for gas estimation func chainSpecificIsUsable(tx evmtypes.Transaction, baseFee *assets.Wei, chainType config.ChainType, minGasPriceWei *assets.Wei) bool { - switch chainType { - case config.ChainGnosis, config.ChainXDai, config.ChainXLayer: + if chainType == config.ChainGnosis || chainType == config.ChainXDai || chainType == config.ChainXLayer { // GasPrice 0 on most chains is great since it indicates cheap/free transactions. // However, Gnosis and XLayer reserve a special type of "bridge" transaction with 0 gas // price that is always processed at top priority. Ordinary transactions @@ -19,7 +18,8 @@ func chainSpecificIsUsable(tx evmtypes.Transaction, baseFee *assets.Wei, chainTy if tx.GasPrice != nil && tx.GasPrice.Cmp(minGasPriceWei) < 0 { return false } - case config.ChainOptimismBedrock, config.ChainKroma: + } + if chainType == config.ChainOptimismBedrock || chainType == config.ChainKroma { // This is a special deposit transaction type introduced in Bedrock upgrade. // This is a system transaction that it will occur at least one time per block. // We should discard this type before even processing it to avoid flooding the @@ -28,7 +28,8 @@ func chainSpecificIsUsable(tx evmtypes.Transaction, baseFee *assets.Wei, chainTy if tx.Type == 0x7e { return false } - case config.ChainCelo: + } + if chainType == config.ChainCelo { // Celo specific transaction types that utilize the feeCurrency field. if tx.Type == 0x7c || tx.Type == 0x7b { return false @@ -40,13 +41,15 @@ func chainSpecificIsUsable(tx evmtypes.Transaction, baseFee *assets.Wei, chainTy if baseFee != nil && tx.GasPrice.Cmp(baseFee) < 0 { return false } - case config.ChainWeMix: + } + if chainType == config.ChainWeMix { // WeMix specific transaction types that enables fee delegation. // https://docs.wemix.com/v/en/design/fee-delegation if tx.Type == 0x16 { return false } - case config.ChainZkSync: + } + if chainType == config.ChainZkSync { // zKSync specific type for contract deployment & priority transactions // https://era.zksync.io/docs/reference/concepts/transactions.html#eip-712-0x71 if tx.Type == 0x71 || tx.Type == 0xff { From 321d8863aa315457055df5498361572e8794035b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedemann=20F=C3=BCrst?= Date: Fri, 26 Apr 2024 14:59:46 +0200 Subject: [PATCH 5/7] update changeset --- .changeset/sixty-readers-mix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/sixty-readers-mix.md b/.changeset/sixty-readers-mix.md index c85894e202a..a6782a5b276 100644 --- a/.changeset/sixty-readers-mix.md +++ b/.changeset/sixty-readers-mix.md @@ -2,4 +2,4 @@ "chainlink": patch --- -Add support for X Layer (X1) +Add support for X Layer (X1) #added From 0ff127502422e67bb9e9f1135e97e8014b5a774b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedemann=20F=C3=BCrst?= Date: Fri, 26 Apr 2024 17:13:34 +0200 Subject: [PATCH 6/7] fix test --- core/services/chainlink/config_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/services/chainlink/config_test.go b/core/services/chainlink/config_test.go index d02948fd07b..9e5fc913113 100644 --- a/core/services/chainlink/config_test.go +++ b/core/services/chainlink/config_test.go @@ -1256,7 +1256,7 @@ func TestConfig_Validate(t *testing.T) { - 1: 6 errors: - ChainType: invalid value (Foo): must not be set with this chain id - Nodes: missing: must have at least one node - - ChainType: invalid value (Foo): must be one of arbitrum, celo, gnosis, kroma, metis, optimismBedrock, scroll, wemix, zksync or omitted + - ChainType: invalid value (Foo): must be one of arbitrum, celo, gnosis, kroma, metis, optimismBedrock, scroll, wemix, xlayer, zksync or omitted - HeadTracker.HistoryDepth: invalid value (30): must be equal to or greater than FinalityDepth - GasEstimator: 2 errors: - FeeCapDefault: invalid value (101 wei): must be equal to PriceMax (99 wei) since you are using FixedPrice estimation with gas bumping disabled in EIP1559 mode - PriceMax will be used as the FeeCap for transactions instead of FeeCapDefault @@ -1265,7 +1265,7 @@ func TestConfig_Validate(t *testing.T) { - 2: 5 errors: - ChainType: invalid value (Arbitrum): only "optimismBedrock" can be used with this chain id - Nodes: missing: must have at least one node - - ChainType: invalid value (Arbitrum): must be one of arbitrum, celo, gnosis, kroma, metis, optimismBedrock, scroll, wemix, zksync or omitted + - ChainType: invalid value (Arbitrum): must be one of arbitrum, celo, gnosis, kroma, metis, optimismBedrock, scroll, wemix, xlayer, zksync or omitted - FinalityDepth: invalid value (0): must be greater than or equal to 1 - MinIncomingConfirmations: invalid value (0): must be greater than or equal to 1 - 3.Nodes: 5 errors: From 9680c47dba0ccad1eea16b80edad5ae5d948fc65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedemann=20F=C3=BCrst?= Date: Tue, 30 Apr 2024 11:05:42 +0200 Subject: [PATCH 7/7] add BlockHistoryEstimator test for XLayer --- core/chains/evm/gas/block_history_estimator_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/chains/evm/gas/block_history_estimator_test.go b/core/chains/evm/gas/block_history_estimator_test.go index 941b60545ba..43f42c69203 100644 --- a/core/chains/evm/gas/block_history_estimator_test.go +++ b/core/chains/evm/gas/block_history_estimator_test.go @@ -997,6 +997,11 @@ func TestBlockHistoryEstimator_Recalculate_NoEIP1559(t *testing.T) { cfg.ChainTypeF = string(config.ChainXDai) bhe.Recalculate(cltest.Head(0)) require.Equal(t, assets.NewWeiI(80), gas.GetGasPrice(bhe)) + + // And for X Layer + cfg.ChainTypeF = string(config.ChainXLayer) + bhe.Recalculate(cltest.Head(0)) + require.Equal(t, assets.NewWeiI(80), gas.GetGasPrice(bhe)) }) t.Run("handles unreasonably large gas prices (larger than a 64 bit int can hold)", func(t *testing.T) {