diff --git a/.changeset/red-jobs-marry.md b/.changeset/red-jobs-marry.md new file mode 100644 index 00000000000..d66ad019027 --- /dev/null +++ b/.changeset/red-jobs-marry.md @@ -0,0 +1,5 @@ +--- +"chainlink": patch +--- + +Rename DA oracle consts to be more descriptive #wip diff --git a/core/capabilities/ccip/ocrimpls/contract_transmitter_test.go b/core/capabilities/ccip/ocrimpls/contract_transmitter_test.go index 7cfb48901ef..64a504e8842 100644 --- a/core/capabilities/ccip/ocrimpls/contract_transmitter_test.go +++ b/core/capabilities/ccip/ocrimpls/contract_transmitter_test.go @@ -8,6 +8,7 @@ import ( "time" "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ocrimpls" cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" @@ -600,7 +601,7 @@ type TestDAOracleConfig struct { evmconfig.DAOracle } -func (d *TestDAOracleConfig) OracleType() toml.OracleType { return toml.OPStack } +func (d *TestDAOracleConfig) OracleType() toml.DAOracleType { return toml.DAOracleOPStack } func (d *TestDAOracleConfig) OracleAddress() *types.EIP55Address { a, err := types.NewEIP55Address("0x420000000000000000000000000000000000000F") if err != nil { diff --git a/core/chains/evm/config/chain_scoped_gas_estimator.go b/core/chains/evm/config/chain_scoped_gas_estimator.go index 49e438fc67c..1e04690b12f 100644 --- a/core/chains/evm/config/chain_scoped_gas_estimator.go +++ b/core/chains/evm/config/chain_scoped_gas_estimator.go @@ -127,7 +127,7 @@ type daOracleConfig struct { c toml.DAOracle } -func (d *daOracleConfig) OracleType() toml.OracleType { +func (d *daOracleConfig) OracleType() toml.DAOracleType { return d.c.OracleType } diff --git a/core/chains/evm/config/config.go b/core/chains/evm/config/config.go index db08512a146..6d4bcf159b5 100644 --- a/core/chains/evm/config/config.go +++ b/core/chains/evm/config/config.go @@ -165,7 +165,7 @@ type BlockHistory interface { } type DAOracle interface { - OracleType() toml.OracleType + OracleType() toml.DAOracleType OracleAddress() *types.EIP55Address CustomGasPriceCalldata() string } diff --git a/core/chains/evm/config/toml/config.go b/core/chains/evm/config/toml/config.go index dff73cacb47..4655a9798c3 100644 --- a/core/chains/evm/config/toml/config.go +++ b/core/chains/evm/config/toml/config.go @@ -759,19 +759,27 @@ func (u *FeeHistoryEstimator) setFrom(f *FeeHistoryEstimator) { } type DAOracle struct { - OracleType OracleType + OracleType DAOracleType OracleAddress *types.EIP55Address CustomGasPriceCalldata string } -type OracleType string +type DAOracleType string const ( - OPStack = OracleType("opstack") - Arbitrum = OracleType("arbitrum") - ZKSync = OracleType("zksync") + DAOracleOPStack = DAOracleType("opstack") + DAOracleArbitrum = DAOracleType("arbitrum") + DAOracleZKSync = DAOracleType("zksync") ) +func (o DAOracleType) IsValid() bool { + switch o { + case "", DAOracleOPStack, DAOracleArbitrum, DAOracleZKSync: + return true + } + return false +} + func (d *DAOracle) setFrom(f *DAOracle) { d.OracleType = f.OracleType if v := f.OracleAddress; v != nil { diff --git a/core/chains/evm/gas/models_test.go b/core/chains/evm/gas/models_test.go index 28ad5260d8a..936a4810569 100644 --- a/core/chains/evm/gas/models_test.go +++ b/core/chains/evm/gas/models_test.go @@ -72,7 +72,7 @@ func TestWrappedEvmEstimator(t *testing.T) { assert.Nil(t, l1Oracle) // expect l1Oracle - daOracle := rollups.CreateTestDAOracle(t, toml.OPStack, "0x420000000000000000000000000000000000000F", "") + daOracle := rollups.CreateTestDAOracle(t, toml.DAOracleOPStack, "0x420000000000000000000000000000000000000F", "") oracle, err := rollups.NewL1GasOracle(lggr, nil, chaintype.ChainOptimismBedrock, daOracle) require.NoError(t, err) // cast oracle to L1Oracle interface diff --git a/core/chains/evm/gas/rollups/da_oracle_test_helper.go b/core/chains/evm/gas/rollups/da_oracle_test_helper.go index 57c81c007c0..6dfa96d3118 100644 --- a/core/chains/evm/gas/rollups/da_oracle_test_helper.go +++ b/core/chains/evm/gas/rollups/da_oracle_test_helper.go @@ -13,7 +13,7 @@ type TestDAOracle struct { toml.DAOracle } -func (d *TestDAOracle) OracleType() toml.OracleType { +func (d *TestDAOracle) OracleType() toml.DAOracleType { return d.DAOracle.OracleType } @@ -25,7 +25,7 @@ func (d *TestDAOracle) CustomGasPriceCalldata() string { return d.DAOracle.CustomGasPriceCalldata } -func CreateTestDAOracle(t *testing.T, oracleType toml.OracleType, oracleAddress string, customGasPriceCalldata string) *TestDAOracle { +func CreateTestDAOracle(t *testing.T, oracleType toml.DAOracleType, oracleAddress string, customGasPriceCalldata string) *TestDAOracle { oracleAddr, err := types.NewEIP55Address(oracleAddress) require.NoError(t, err) diff --git a/core/chains/evm/gas/rollups/l1_oracle.go b/core/chains/evm/gas/rollups/l1_oracle.go index e03b27b3176..826210ab9bf 100644 --- a/core/chains/evm/gas/rollups/l1_oracle.go +++ b/core/chains/evm/gas/rollups/l1_oracle.go @@ -57,11 +57,11 @@ func NewL1GasOracle(lggr logger.Logger, ethClient l1OracleClient, chainType chai var err error if daOracle != nil { switch daOracle.OracleType() { - case toml.OPStack: + case toml.DAOracleOPStack: l1Oracle, err = NewOpStackL1GasOracle(lggr, ethClient, chainType, daOracle) - case toml.Arbitrum: + case toml.DAOracleArbitrum: l1Oracle, err = NewArbitrumL1GasOracle(lggr, ethClient) - case toml.ZKSync: + 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()) diff --git a/core/chains/evm/gas/rollups/l1_oracle_test.go b/core/chains/evm/gas/rollups/l1_oracle_test.go index 82dc7925293..fc3cd68d821 100644 --- a/core/chains/evm/gas/rollups/l1_oracle_test.go +++ b/core/chains/evm/gas/rollups/l1_oracle_test.go @@ -30,7 +30,7 @@ func TestL1Oracle(t *testing.T) { t.Run("Unsupported ChainType returns nil", func(t *testing.T) { ethClient := mocks.NewL1OracleClient(t) - daOracle := CreateTestDAOracle(t, toml.OPStack, utils.RandomAddress().String(), "") + daOracle := CreateTestDAOracle(t, toml.DAOracleOPStack, utils.RandomAddress().String(), "") oracle, err := NewL1GasOracle(logger.Test(t), ethClient, chaintype.ChainCelo, daOracle) require.NoError(t, err) assert.Nil(t, oracle) @@ -43,7 +43,7 @@ func TestL1Oracle_GasPrice(t *testing.T) { t.Run("Calling GasPrice on unstarted L1Oracle returns error", func(t *testing.T) { ethClient := mocks.NewL1OracleClient(t) - daOracle := CreateTestDAOracle(t, toml.OPStack, utils.RandomAddress().String(), "") + daOracle := CreateTestDAOracle(t, toml.DAOracleOPStack, utils.RandomAddress().String(), "") oracle, err := NewL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle) require.NoError(t, err) @@ -67,7 +67,7 @@ func TestL1Oracle_GasPrice(t *testing.T) { assert.Nil(t, blockNumber) }).Return(common.BigToHash(l1BaseFee).Bytes(), nil) - daOracle := CreateTestDAOracle(t, toml.Arbitrum, "0x0000000000000000000000000000000000000000", "") + daOracle := CreateTestDAOracle(t, toml.DAOracleArbitrum, "0x0000000000000000000000000000000000000000", "") oracle, err := NewL1GasOracle(logger.Test(t), ethClient, chaintype.ChainArbitrum, daOracle) require.NoError(t, err) servicetest.RunHealthy(t, oracle) @@ -97,7 +97,7 @@ func TestL1Oracle_GasPrice(t *testing.T) { assert.Nil(t, blockNumber) }).Return(common.BigToHash(l1BaseFee).Bytes(), nil) - daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "") + daOracle := CreateTestDAOracle(t, toml.DAOracleOPStack, oracleAddress, "") oracle, err := NewL1GasOracle(logger.Test(t), ethClient, chaintype.ChainKroma, daOracle) require.NoError(t, err) servicetest.RunHealthy(t, oracle) @@ -127,7 +127,7 @@ func TestL1Oracle_GasPrice(t *testing.T) { assert.Nil(t, blockNumber) }).Return(common.BigToHash(l1BaseFee).Bytes(), nil) - daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "") + daOracle := CreateTestDAOracle(t, toml.DAOracleOPStack, oracleAddress, "") oracle, err := NewL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle) require.NoError(t, err) servicetest.RunHealthy(t, oracle) @@ -156,7 +156,7 @@ func TestL1Oracle_GasPrice(t *testing.T) { assert.Nil(t, blockNumber) }).Return(common.BigToHash(l1BaseFee).Bytes(), nil) - daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "") + daOracle := CreateTestDAOracle(t, toml.DAOracleOPStack, oracleAddress, "") oracle, err := NewL1GasOracle(logger.Test(t), ethClient, chaintype.ChainScroll, daOracle) require.NoError(t, err) servicetest.RunHealthy(t, oracle) @@ -194,7 +194,7 @@ func TestL1Oracle_GasPrice(t *testing.T) { assert.Nil(t, blockNumber) }).Return(common.BigToHash(gasPerPubByteL2).Bytes(), nil) - daOracle := CreateTestDAOracle(t, toml.ZKSync, "0x0000000000000000000000000000000000000000", "") + daOracle := CreateTestDAOracle(t, toml.DAOracleZKSync, "0x0000000000000000000000000000000000000000", "") oracle, err := NewL1GasOracle(logger.Test(t), ethClient, chaintype.ChainZkSync, daOracle) require.NoError(t, err) servicetest.RunHealthy(t, oracle) diff --git a/core/chains/evm/gas/rollups/op_l1_oracle_test.go b/core/chains/evm/gas/rollups/op_l1_oracle_test.go index 8d5fd357baf..0b67cc7178d 100644 --- a/core/chains/evm/gas/rollups/op_l1_oracle_test.go +++ b/core/chains/evm/gas/rollups/op_l1_oracle_test.go @@ -103,7 +103,7 @@ func TestOPL1Oracle_ReadV1GasPrice(t *testing.T) { assert.Nil(t, blockNumber) }).Return(common.BigToHash(l1BaseFee).Bytes(), nil).Once() - daOracle := CreateTestDAOracle(t, toml.OPStack, "0x0000000000000000000000000000000000001234", "") + daOracle := CreateTestDAOracle(t, toml.DAOracleOPStack, "0x0000000000000000000000000000000000001234", "") oracle, err := NewOpStackL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle) require.NoError(t, err) gasPrice, err := oracle.GetDAGasPrice(tests.Context(t)) @@ -226,7 +226,7 @@ func TestOPL1Oracle_CalculateEcotoneGasPrice(t *testing.T) { ethClient := setupUpgradeCheck(t, oracleAddress, false, true) mockBatchContractCall(t, ethClient, oracleAddress, baseFee, baseFeeScalar, blobBaseFee, blobBaseFeeScalar, decimals) - daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "") + daOracle := CreateTestDAOracle(t, toml.DAOracleOPStack, oracleAddress, "") oracle, err := NewOpStackL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle) require.NoError(t, err) gasPrice, err := oracle.GetDAGasPrice(tests.Context(t)) @@ -246,7 +246,7 @@ func TestOPL1Oracle_CalculateEcotoneGasPrice(t *testing.T) { rpcElements[1].Result = &badData }).Return(nil).Once() - daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "") + daOracle := CreateTestDAOracle(t, toml.DAOracleOPStack, oracleAddress, "") oracle, err := NewOpStackL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle) require.NoError(t, err) _, err = oracle.GetDAGasPrice(tests.Context(t)) @@ -257,7 +257,7 @@ func TestOPL1Oracle_CalculateEcotoneGasPrice(t *testing.T) { ethClient := setupUpgradeCheck(t, oracleAddress, false, true) ethClient.On("BatchCallContext", mock.Anything, mock.IsType([]rpc.BatchElem{})).Return(fmt.Errorf("revert")).Once() - daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "") + daOracle := CreateTestDAOracle(t, toml.DAOracleOPStack, oracleAddress, "") oracle, err := NewOpStackL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle) require.NoError(t, err) _, err = oracle.GetDAGasPrice(tests.Context(t)) @@ -273,7 +273,7 @@ func TestOPL1Oracle_CalculateEcotoneGasPrice(t *testing.T) { rpcElements[1].Error = fmt.Errorf("revert") }).Return(nil).Once() - daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "") + daOracle := CreateTestDAOracle(t, toml.DAOracleOPStack, oracleAddress, "") oracle, err := NewOpStackL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle) require.NoError(t, err) _, err = oracle.GetDAGasPrice(tests.Context(t)) @@ -295,7 +295,7 @@ func TestOPL1Oracle_CalculateFjordGasPrice(t *testing.T) { ethClient := setupUpgradeCheck(t, oracleAddress, true, true) mockBatchContractCall(t, ethClient, oracleAddress, baseFee, baseFeeScalar, blobBaseFee, blobBaseFeeScalar, decimals) - daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "") + daOracle := CreateTestDAOracle(t, toml.DAOracleOPStack, oracleAddress, "") oracle, err := NewOpStackL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle) require.NoError(t, err) gasPrice, err := oracle.GetDAGasPrice(tests.Context(t)) @@ -315,7 +315,7 @@ func TestOPL1Oracle_CalculateFjordGasPrice(t *testing.T) { rpcElements[1].Result = &badData }).Return(nil).Once() - daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "") + daOracle := CreateTestDAOracle(t, toml.DAOracleOPStack, oracleAddress, "") oracle, err := NewOpStackL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle) require.NoError(t, err) _, err = oracle.GetDAGasPrice(tests.Context(t)) @@ -326,7 +326,7 @@ func TestOPL1Oracle_CalculateFjordGasPrice(t *testing.T) { ethClient := setupUpgradeCheck(t, oracleAddress, true, true) ethClient.On("BatchCallContext", mock.Anything, mock.IsType([]rpc.BatchElem{})).Return(fmt.Errorf("revert")).Once() - daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "") + daOracle := CreateTestDAOracle(t, toml.DAOracleOPStack, oracleAddress, "") oracle, err := NewOpStackL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle) require.NoError(t, err) _, err = oracle.GetDAGasPrice(tests.Context(t)) @@ -342,7 +342,7 @@ func TestOPL1Oracle_CalculateFjordGasPrice(t *testing.T) { rpcElements[1].Error = fmt.Errorf("revert") }).Return(nil).Once() - daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "") + daOracle := CreateTestDAOracle(t, toml.DAOracleOPStack, oracleAddress, "") oracle, err := NewOpStackL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle) require.NoError(t, err) _, err = oracle.GetDAGasPrice(tests.Context(t)) diff --git a/core/chains/evm/txmgr/test_helpers.go b/core/chains/evm/txmgr/test_helpers.go index 5b5295432da..960d921e879 100644 --- a/core/chains/evm/txmgr/test_helpers.go +++ b/core/chains/evm/txmgr/test_helpers.go @@ -82,7 +82,7 @@ type TestDAOracleConfig struct { evmconfig.DAOracle } -func (d *TestDAOracleConfig) OracleType() toml.OracleType { return toml.OPStack } +func (d *TestDAOracleConfig) OracleType() toml.DAOracleType { return toml.DAOracleOPStack } func (d *TestDAOracleConfig) OracleAddress() *types.EIP55Address { a, err := types.NewEIP55Address("0x420000000000000000000000000000000000000F") if err != nil {