From 468fc4cd352b5be8cfd0e65f7da370fdf544be46 Mon Sep 17 00:00:00 2001 From: Oliver Townsend <133903322+ogtownsend@users.noreply.github.com> Date: Thu, 17 Oct 2024 14:20:08 -0700 Subject: [PATCH] Add explicit DA oracle type to arbitrum and zksync chaintype configs (#14835) * Add explicit DA oracle type to arbitrum and zksync chaintype configs * changeset * remove default case in da oracle switch * add more test cases for fallback scenario --- .changeset/gorgeous-wolves-collect.md | 5 +++ ccip/config/evm/Arbitrum_Mainnet.toml | 3 ++ ccip/config/evm/Arbitrum_Sepolia.toml | 3 ++ ccip/config/evm/L3X_Mainnet.toml | 3 ++ ccip/config/evm/L3X_Sepolia.toml | 3 ++ ccip/config/evm/zkSync_Mainnet.toml | 3 ++ ccip/config/evm/zkSync_Sepolia.toml | 3 ++ .../config/toml/defaults/Arbitrum_Goerli.toml | 3 ++ .../toml/defaults/Arbitrum_Mainnet.toml | 3 ++ .../toml/defaults/Arbitrum_Rinkeby.toml | 3 ++ .../toml/defaults/Arbitrum_Sepolia.toml | 3 ++ .../evm/config/toml/defaults/L3X_Mainnet.toml | 3 ++ .../evm/config/toml/defaults/L3X_Sepolia.toml | 3 ++ .../config/toml/defaults/zkSync_Goerli.toml | 3 ++ .../config/toml/defaults/zkSync_Mainnet.toml | 3 ++ .../config/toml/defaults/zkSync_Sepolia.toml | 3 ++ core/chains/evm/gas/rollups/l1_oracle.go | 6 ++-- core/chains/evm/gas/rollups/l1_oracle_test.go | 28 +++++++++++++++ docs/CONFIG.md | 36 +++++++++++++++++++ 19 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 .changeset/gorgeous-wolves-collect.md diff --git a/.changeset/gorgeous-wolves-collect.md b/.changeset/gorgeous-wolves-collect.md new file mode 100644 index 00000000000..62b11100151 --- /dev/null +++ b/.changeset/gorgeous-wolves-collect.md @@ -0,0 +1,5 @@ +--- +"chainlink": patch +--- + +Add DA oracle type to arbitrum and zksync configs #bugfix diff --git a/ccip/config/evm/Arbitrum_Mainnet.toml b/ccip/config/evm/Arbitrum_Mainnet.toml index e3dcafd56fb..b81d53731fb 100644 --- a/ccip/config/evm/Arbitrum_Mainnet.toml +++ b/ccip/config/evm/Arbitrum_Mainnet.toml @@ -22,6 +22,9 @@ BumpThreshold = 5 # Force an error if someone set GAS_UPDATER_ENABLED=true by accident; we never want to run the block history estimator on arbitrum BlockHistorySize = 0 +[GasEstimator.DAOracle] +OracleType = 'arbitrum' + [NodePool] SyncThreshold = 10 diff --git a/ccip/config/evm/Arbitrum_Sepolia.toml b/ccip/config/evm/Arbitrum_Sepolia.toml index ea994cf7c78..2599456c6c0 100644 --- a/ccip/config/evm/Arbitrum_Sepolia.toml +++ b/ccip/config/evm/Arbitrum_Sepolia.toml @@ -20,6 +20,9 @@ BumpThreshold = 5 # Force an error if someone set GAS_UPDATER_ENABLED=true by accident; we never want to run the block history estimator on arbitrum BlockHistorySize = 0 +[GasEstimator.DAOracle] +OracleType = 'arbitrum' + [NodePool] SyncThreshold = 10 diff --git a/ccip/config/evm/L3X_Mainnet.toml b/ccip/config/evm/L3X_Mainnet.toml index 1fbda42fd2a..9dd33c9e15d 100644 --- a/ccip/config/evm/L3X_Mainnet.toml +++ b/ccip/config/evm/L3X_Mainnet.toml @@ -16,3 +16,6 @@ PriceMin = '0' PriceDefault = '0.1 gwei' FeeCapDefault = '1000 gwei' BumpThreshold = 5 + +[GasEstimator.DAOracle] +OracleType = 'arbitrum' diff --git a/ccip/config/evm/L3X_Sepolia.toml b/ccip/config/evm/L3X_Sepolia.toml index ee515bb72ba..c0f6a60e943 100644 --- a/ccip/config/evm/L3X_Sepolia.toml +++ b/ccip/config/evm/L3X_Sepolia.toml @@ -16,3 +16,6 @@ PriceMin = '0' PriceDefault = '0.1 gwei' FeeCapDefault = '1000 gwei' BumpThreshold = 5 + +[GasEstimator.DAOracle] +OracleType = 'arbitrum' diff --git a/ccip/config/evm/zkSync_Mainnet.toml b/ccip/config/evm/zkSync_Mainnet.toml index a434cd38153..a8910a37e4a 100644 --- a/ccip/config/evm/zkSync_Mainnet.toml +++ b/ccip/config/evm/zkSync_Mainnet.toml @@ -23,6 +23,9 @@ PriceMin = '25 mwei' # increasing this to smooth out gas estimation BlockHistorySize = 200 +[GasEstimator.DAOracle] +OracleType = 'zksync' + [HeadTracker] # tracks top N blocks to keep in heads database table. Should store atleast the same # of blocks as finalityDepth HistoryDepth = 1500 \ No newline at end of file diff --git a/ccip/config/evm/zkSync_Sepolia.toml b/ccip/config/evm/zkSync_Sepolia.toml index f3bc594886a..6eb4ba4137e 100644 --- a/ccip/config/evm/zkSync_Sepolia.toml +++ b/ccip/config/evm/zkSync_Sepolia.toml @@ -23,6 +23,9 @@ PriceMin = '25 mwei' # increasing this to smooth out gas estimation BlockHistorySize = 200 +[GasEstimator.DAOracle] +OracleType = 'zksync' + [HeadTracker] # tracks top N blocks to keep in heads database table. Should store atleast the same # of blocks as finalityDepth HistoryDepth = 250 \ No newline at end of file diff --git a/core/chains/evm/config/toml/defaults/Arbitrum_Goerli.toml b/core/chains/evm/config/toml/defaults/Arbitrum_Goerli.toml index 42de6beb9ba..3d4b71347c4 100644 --- a/core/chains/evm/config/toml/defaults/Arbitrum_Goerli.toml +++ b/core/chains/evm/config/toml/defaults/Arbitrum_Goerli.toml @@ -19,6 +19,9 @@ BumpThreshold = 5 # Force an error if someone set GAS_UPDATER_ENABLED=true by accident; we never want to run the block history estimator on arbitrum BlockHistorySize = 0 +[GasEstimator.DAOracle] +OracleType = 'arbitrum' + [NodePool] SyncThreshold = 10 diff --git a/core/chains/evm/config/toml/defaults/Arbitrum_Mainnet.toml b/core/chains/evm/config/toml/defaults/Arbitrum_Mainnet.toml index e3dcafd56fb..b81d53731fb 100644 --- a/core/chains/evm/config/toml/defaults/Arbitrum_Mainnet.toml +++ b/core/chains/evm/config/toml/defaults/Arbitrum_Mainnet.toml @@ -22,6 +22,9 @@ BumpThreshold = 5 # Force an error if someone set GAS_UPDATER_ENABLED=true by accident; we never want to run the block history estimator on arbitrum BlockHistorySize = 0 +[GasEstimator.DAOracle] +OracleType = 'arbitrum' + [NodePool] SyncThreshold = 10 diff --git a/core/chains/evm/config/toml/defaults/Arbitrum_Rinkeby.toml b/core/chains/evm/config/toml/defaults/Arbitrum_Rinkeby.toml index f9296adcb76..68e28e7c5bc 100644 --- a/core/chains/evm/config/toml/defaults/Arbitrum_Rinkeby.toml +++ b/core/chains/evm/config/toml/defaults/Arbitrum_Rinkeby.toml @@ -19,5 +19,8 @@ BumpThreshold = 5 # Force an error if someone set GAS_UPDATER_ENABLED=true by accident; we never want to run the block history estimator on arbitrum BlockHistorySize = 0 +[GasEstimator.DAOracle] +OracleType = 'arbitrum' + [NodePool] SyncThreshold = 10 diff --git a/core/chains/evm/config/toml/defaults/Arbitrum_Sepolia.toml b/core/chains/evm/config/toml/defaults/Arbitrum_Sepolia.toml index 2af70d04d35..ab5351b9a74 100644 --- a/core/chains/evm/config/toml/defaults/Arbitrum_Sepolia.toml +++ b/core/chains/evm/config/toml/defaults/Arbitrum_Sepolia.toml @@ -19,6 +19,9 @@ BumpThreshold = 5 # Force an error if someone set GAS_UPDATER_ENABLED=true by accident; we never want to run the block history estimator on arbitrum BlockHistorySize = 0 +[GasEstimator.DAOracle] +OracleType = 'arbitrum' + [NodePool] SyncThreshold = 10 diff --git a/core/chains/evm/config/toml/defaults/L3X_Mainnet.toml b/core/chains/evm/config/toml/defaults/L3X_Mainnet.toml index 1fbda42fd2a..9dd33c9e15d 100644 --- a/core/chains/evm/config/toml/defaults/L3X_Mainnet.toml +++ b/core/chains/evm/config/toml/defaults/L3X_Mainnet.toml @@ -16,3 +16,6 @@ PriceMin = '0' PriceDefault = '0.1 gwei' FeeCapDefault = '1000 gwei' BumpThreshold = 5 + +[GasEstimator.DAOracle] +OracleType = 'arbitrum' diff --git a/core/chains/evm/config/toml/defaults/L3X_Sepolia.toml b/core/chains/evm/config/toml/defaults/L3X_Sepolia.toml index ee515bb72ba..c0f6a60e943 100644 --- a/core/chains/evm/config/toml/defaults/L3X_Sepolia.toml +++ b/core/chains/evm/config/toml/defaults/L3X_Sepolia.toml @@ -16,3 +16,6 @@ PriceMin = '0' PriceDefault = '0.1 gwei' FeeCapDefault = '1000 gwei' BumpThreshold = 5 + +[GasEstimator.DAOracle] +OracleType = 'arbitrum' diff --git a/core/chains/evm/config/toml/defaults/zkSync_Goerli.toml b/core/chains/evm/config/toml/defaults/zkSync_Goerli.toml index 05d85cfe248..035eec62d49 100644 --- a/core/chains/evm/config/toml/defaults/zkSync_Goerli.toml +++ b/core/chains/evm/config/toml/defaults/zkSync_Goerli.toml @@ -10,5 +10,8 @@ LimitDefault = 100_000_000 PriceMax = 18446744073709551615 PriceMin = 0 +[GasEstimator.DAOracle] +OracleType = 'zksync' + [HeadTracker] HistoryDepth = 50 diff --git a/core/chains/evm/config/toml/defaults/zkSync_Mainnet.toml b/core/chains/evm/config/toml/defaults/zkSync_Mainnet.toml index 02ce2b0f18c..d4602a85479 100644 --- a/core/chains/evm/config/toml/defaults/zkSync_Mainnet.toml +++ b/core/chains/evm/config/toml/defaults/zkSync_Mainnet.toml @@ -10,5 +10,8 @@ LimitDefault = 100_000_000 PriceMax = 18446744073709551615 PriceMin = 0 +[GasEstimator.DAOracle] +OracleType = 'zksync' + [HeadTracker] HistoryDepth = 50 diff --git a/core/chains/evm/config/toml/defaults/zkSync_Sepolia.toml b/core/chains/evm/config/toml/defaults/zkSync_Sepolia.toml index b4e957a6c99..4ea175bfdb8 100644 --- a/core/chains/evm/config/toml/defaults/zkSync_Sepolia.toml +++ b/core/chains/evm/config/toml/defaults/zkSync_Sepolia.toml @@ -10,5 +10,8 @@ LimitDefault = 100_000_000 PriceMax = 18446744073709551615 PriceMin = 0 +[GasEstimator.DAOracle] +OracleType = 'zksync' + [HeadTracker] HistoryDepth = 50 diff --git a/core/chains/evm/gas/rollups/l1_oracle.go b/core/chains/evm/gas/rollups/l1_oracle.go index 826210ab9bf..28172051fb7 100644 --- a/core/chains/evm/gas/rollups/l1_oracle.go +++ b/core/chains/evm/gas/rollups/l1_oracle.go @@ -63,13 +63,13 @@ func NewL1GasOracle(lggr logger.Logger, ethClient l1OracleClient, chainType chai l1Oracle, err = NewArbitrumL1GasOracle(lggr, ethClient) case toml.DAOracleZKSync: l1Oracle = NewZkSyncL1GasOracle(lggr, ethClient) - default: - err = fmt.Errorf("unsupported DA oracle type %s. Going forward all chain configs should specify an oracle type", daOracle.OracleType()) } if err != nil { return nil, fmt.Errorf("failed to initialize L1 oracle for chaintype %s: %w", chainType, err) } - return l1Oracle, nil + if l1Oracle != nil { + return l1Oracle, nil + } } // Going forward all configs should specify a DAOracle config. This is a fall back to maintain backwards compat. diff --git a/core/chains/evm/gas/rollups/l1_oracle_test.go b/core/chains/evm/gas/rollups/l1_oracle_test.go index fc3cd68d821..05e3e7c193d 100644 --- a/core/chains/evm/gas/rollups/l1_oracle_test.go +++ b/core/chains/evm/gas/rollups/l1_oracle_test.go @@ -35,6 +35,34 @@ func TestL1Oracle(t *testing.T) { require.NoError(t, err) assert.Nil(t, oracle) }) + + t.Run("DAOracle config is nil, falls back to using chainType", func(t *testing.T) { + ethClient := mocks.NewL1OracleClient(t) + + oracle, err := NewL1GasOracle(logger.Test(t), ethClient, chaintype.ChainArbitrum, nil) + require.NoError(t, err) + assert.NotNil(t, oracle) + }) + + t.Run("DAOracle config is not nil, but OracleType is empty, falls back to using chainType arbitrum", func(t *testing.T) { + ethClient := mocks.NewL1OracleClient(t) + + daOracle := CreateTestDAOracle(t, "", utils.RandomAddress().String(), "") + oracle, err := NewL1GasOracle(logger.Test(t), ethClient, chaintype.ChainArbitrum, daOracle) + require.NoError(t, err) + assert.NotNil(t, oracle) + assert.Equal(t, oracle.Name(), "L1GasOracle(arbitrum)") + }) + + t.Run("DAOracle config is not nil, but OracleType is empty, falls back to using chainType ZKSync", func(t *testing.T) { + ethClient := mocks.NewL1OracleClient(t) + + daOracle := CreateTestDAOracle(t, "", utils.RandomAddress().String(), "") + oracle, err := NewL1GasOracle(logger.Test(t), ethClient, chaintype.ChainZkSync, daOracle) + require.NoError(t, err) + assert.NotNil(t, oracle) + assert.Equal(t, oracle.Name(), "L1GasOracle(zkSync)") + }) } func TestL1Oracle_GasPrice(t *testing.T) { diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 67818325b37..010d1aa03d9 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -4012,6 +4012,10 @@ TransactionPercentile = 60 [GasEstimator.FeeHistory] CacheTimeout = '10s' +[GasEstimator.DAOracle] +OracleType = 'zksync' +CustomGasPriceCalldata = '' + [HeadTracker] HistoryDepth = 50 MaxBufferSize = 3 @@ -4324,6 +4328,10 @@ TransactionPercentile = 60 [GasEstimator.FeeHistory] CacheTimeout = '10s' +[GasEstimator.DAOracle] +OracleType = 'zksync' +CustomGasPriceCalldata = '' + [HeadTracker] HistoryDepth = 50 MaxBufferSize = 3 @@ -4428,6 +4436,10 @@ TransactionPercentile = 60 [GasEstimator.FeeHistory] CacheTimeout = '10s' +[GasEstimator.DAOracle] +OracleType = 'zksync' +CustomGasPriceCalldata = '' + [HeadTracker] HistoryDepth = 50 MaxBufferSize = 3 @@ -6112,6 +6124,10 @@ TransactionPercentile = 60 [GasEstimator.FeeHistory] CacheTimeout = '10s' +[GasEstimator.DAOracle] +OracleType = 'arbitrum' +CustomGasPriceCalldata = '' + [HeadTracker] HistoryDepth = 100 MaxBufferSize = 3 @@ -6217,6 +6233,10 @@ TransactionPercentile = 60 [GasEstimator.FeeHistory] CacheTimeout = '10s' +[GasEstimator.DAOracle] +OracleType = 'arbitrum' +CustomGasPriceCalldata = '' + [HeadTracker] HistoryDepth = 100 MaxBufferSize = 3 @@ -6322,6 +6342,10 @@ TransactionPercentile = 60 [GasEstimator.FeeHistory] CacheTimeout = '10s' +[GasEstimator.DAOracle] +OracleType = 'arbitrum' +CustomGasPriceCalldata = '' + [HeadTracker] HistoryDepth = 100 MaxBufferSize = 3 @@ -7905,6 +7929,10 @@ TransactionPercentile = 60 [GasEstimator.FeeHistory] CacheTimeout = '10s' +[GasEstimator.DAOracle] +OracleType = 'arbitrum' +CustomGasPriceCalldata = '' + [HeadTracker] HistoryDepth = 100 MaxBufferSize = 3 @@ -8010,6 +8038,10 @@ TransactionPercentile = 60 [GasEstimator.FeeHistory] CacheTimeout = '10s' +[GasEstimator.DAOracle] +OracleType = 'arbitrum' +CustomGasPriceCalldata = '' + [HeadTracker] HistoryDepth = 100 MaxBufferSize = 3 @@ -8114,6 +8146,10 @@ TransactionPercentile = 60 [GasEstimator.FeeHistory] CacheTimeout = '10s' +[GasEstimator.DAOracle] +OracleType = 'arbitrum' +CustomGasPriceCalldata = '' + [HeadTracker] HistoryDepth = 100 MaxBufferSize = 3