Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ogtownsend committed Oct 10, 2024
1 parent 3ce1436 commit e33bf1e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 24 deletions.
4 changes: 0 additions & 4 deletions core/chains/evm/config/chain_scoped_gas_estimator.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ func (g *gasEstimatorConfig) EstimateLimit() bool {
return *g.c.EstimateLimit
}

// ====== DAOracle ======
type daOracleConfig struct {
c toml.DAOracle
}
Expand All @@ -143,7 +142,6 @@ func (d *daOracleConfig) CustomGasPriceCalldata() string {
return ""
}

// ====== LimitJobType ======
type limitJobTypeConfig struct {
c toml.GasLimitJobType
}
Expand Down Expand Up @@ -172,7 +170,6 @@ func (l *limitJobTypeConfig) VRF() *uint32 {
return l.c.VRF
}

// ====== BlockHistory ======
type blockHistoryConfig struct {
c toml.BlockHistoryEstimator
blockDelay *uint16
Expand Down Expand Up @@ -210,7 +207,6 @@ func (b *blockHistoryConfig) BlockDelay() uint16 {
return *b.blockDelay
}

// ====== FeeHistory ======
type feeHistoryConfig struct {
c toml.FeeHistoryEstimator
}
Expand Down
6 changes: 2 additions & 4 deletions core/chains/evm/gas/rollups/l1_oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,12 @@ func NewL1GasOracle(lggr logger.Logger, ethClient l1OracleClient, chainType chai
case toml.ZKSync:
l1Oracle = NewZkSyncL1GasOracle(lggr, ethClient)
default:
lggr.Warnf("Unsupported DA oracle type %s. Going forward all chain configs should specify an oracle type", daOracle.OracleType())
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)
}
if l1Oracle != nil {
return l1Oracle, nil
}
return l1Oracle, nil
}

// Going forward all configs should specify a DAOracle config. This is a fall back to maintain backwards compat.
Expand Down
26 changes: 12 additions & 14 deletions core/chains/evm/gas/rollups/l1_oracle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/chaintype"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas/rollups/mocks"
)

const (
OPGasOracleAddress = "0x420000000000000000000000000000000000000F"
KromaGasOracleAddress = "0x4200000000000000000000000000000000000005"
ScrollGasOracleAddress = "0x5300000000000000000000000000000000000002"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils"
)

func TestL1Oracle(t *testing.T) {
Expand All @@ -35,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, OPGasOracleAddress, "")
daOracle := CreateTestDAOracle(t, toml.OPStack, utils.RandomAddress().String(), "")
oracle, err := NewL1GasOracle(logger.Test(t), ethClient, chaintype.ChainCelo, daOracle)
require.NoError(t, err)
assert.Nil(t, oracle)
Expand All @@ -48,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, OPGasOracleAddress, "")
daOracle := CreateTestDAOracle(t, toml.OPStack, utils.RandomAddress().String(), "")
oracle, err := NewL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle)
require.NoError(t, err)

Expand Down Expand Up @@ -89,7 +84,8 @@ func TestL1Oracle_GasPrice(t *testing.T) {
l1GasPriceMethodAbi, err := abi.JSON(strings.NewReader(L1BaseFeeAbiString))
require.NoError(t, err)

ethClient := setupUpgradeCheck(t, KromaGasOracleAddress, false, false) // Ecotone, Fjord disabled
oracleAddress := utils.RandomAddress().String()
ethClient := setupUpgradeCheck(t, oracleAddress, false, false) // Ecotone, Fjord disabled

ethClient.On("CallContract", mock.Anything, mock.IsType(ethereum.CallMsg{}), mock.IsType(&big.Int{})).Run(func(args mock.Arguments) {
callMsg := args.Get(1).(ethereum.CallMsg)
Expand All @@ -101,7 +97,7 @@ func TestL1Oracle_GasPrice(t *testing.T) {
assert.Nil(t, blockNumber)
}).Return(common.BigToHash(l1BaseFee).Bytes(), nil)

daOracle := CreateTestDAOracle(t, toml.OPStack, KromaGasOracleAddress, "")
daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "")
oracle, err := NewL1GasOracle(logger.Test(t), ethClient, chaintype.ChainKroma, daOracle)
require.NoError(t, err)
servicetest.RunHealthy(t, oracle)
Expand All @@ -118,7 +114,8 @@ func TestL1Oracle_GasPrice(t *testing.T) {
l1GasPriceMethodAbi, err := abi.JSON(strings.NewReader(L1BaseFeeAbiString))
require.NoError(t, err)

ethClient := setupUpgradeCheck(t, OPGasOracleAddress, false, false) // Ecotone, Fjord disabled
oracleAddress := utils.RandomAddress().String()
ethClient := setupUpgradeCheck(t, oracleAddress, false, false) // Ecotone, Fjord disabled

ethClient.On("CallContract", mock.Anything, mock.IsType(ethereum.CallMsg{}), mock.IsType(&big.Int{})).Run(func(args mock.Arguments) {
callMsg := args.Get(1).(ethereum.CallMsg)
Expand All @@ -130,7 +127,7 @@ func TestL1Oracle_GasPrice(t *testing.T) {
assert.Nil(t, blockNumber)
}).Return(common.BigToHash(l1BaseFee).Bytes(), nil)

daOracle := CreateTestDAOracle(t, toml.OPStack, OPGasOracleAddress, "")
daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "")
oracle, err := NewL1GasOracle(logger.Test(t), ethClient, chaintype.ChainOptimismBedrock, daOracle)
require.NoError(t, err)
servicetest.RunHealthy(t, oracle)
Expand All @@ -146,7 +143,8 @@ func TestL1Oracle_GasPrice(t *testing.T) {
l1GasPriceMethodAbi, err := abi.JSON(strings.NewReader(L1BaseFeeAbiString))
require.NoError(t, err)

ethClient := setupUpgradeCheck(t, ScrollGasOracleAddress, false, false) // Ecotone, Fjord disabled
oracleAddress := utils.RandomAddress().String()
ethClient := setupUpgradeCheck(t, oracleAddress, false, false) // Ecotone, Fjord disabled

ethClient.On("CallContract", mock.Anything, mock.IsType(ethereum.CallMsg{}), mock.IsType(&big.Int{})).Run(func(args mock.Arguments) {
callMsg := args.Get(1).(ethereum.CallMsg)
Expand All @@ -158,7 +156,7 @@ func TestL1Oracle_GasPrice(t *testing.T) {
assert.Nil(t, blockNumber)
}).Return(common.BigToHash(l1BaseFee).Bytes(), nil)

daOracle := CreateTestDAOracle(t, toml.OPStack, ScrollGasOracleAddress, "")
daOracle := CreateTestDAOracle(t, toml.OPStack, oracleAddress, "")
oracle, err := NewL1GasOracle(logger.Test(t), ethClient, chaintype.ChainScroll, daOracle)
require.NoError(t, err)
servicetest.RunHealthy(t, oracle)
Expand Down
2 changes: 1 addition & 1 deletion core/config/docs/chains-evm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ TipCapMin = '1 wei' # Default
OracleType = 'opstack' # Example
# OracleAddress is the address of the oracle contract.
OracleAddress = '0x420000000000000000000000000000000000000F' # Example
# CustomGasPriceCalldata is optional and can be set to call a custom gas price API at the given OracleAddress.
# CustomGasPriceCalldata is optional and can be set to call a custom gas price function at the given OracleAddress.
CustomGasPriceCalldata = '' # Default

[EVM.GasEstimator.LimitJobType]
Expand Down
2 changes: 1 addition & 1 deletion docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9333,7 +9333,7 @@ OracleAddress is the address of the oracle contract.
```toml
CustomGasPriceCalldata = '' # Default
```
CustomGasPriceCalldata is optional and can be set to call a custom gas price API at the given OracleAddress.
CustomGasPriceCalldata is optional and can be set to call a custom gas price function at the given OracleAddress.

## EVM.GasEstimator.LimitJobType
```toml
Expand Down

0 comments on commit e33bf1e

Please sign in to comment.