Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CCIP-3552 refactor OP oracle to accept generic DA oracle config #14599

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feedback
  • Loading branch information
ogtownsend committed Oct 10, 2024
commit 9b2f749614203c1a5dc1956813e441362f80675d
14 changes: 0 additions & 14 deletions core/chains/evm/config/toml/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,20 +779,6 @@ func (d *DAOracle) setFrom(f *DAOracle) {
d.CustomGasPriceAPICalldata = f.CustomGasPriceAPICalldata
}

func (d *DAOracle) ValidateConfig() (err error) {
// TODO: do we want this strict of a validation from the get-go? If so we'll need to update several integration test
// TOML files
//if d.OracleType == "" {
// err = multierr.Append(err, commonconfig.ErrMissing{Name: "OracleType", Msg: "must be set"})
//}
//// Ensure OracleType is set to one of the known and supported oracle types
//if d.OracleType != OPOracle && d.OracleType != ArbitrumOracle && d.OracleType != ZKSyncOracle {
// err = multierr.Append(err, commonconfig.ErrInvalid{Name: "OracleType", Value: d.OracleType,
// Msg: "must be a supported oracle type"})
//}
return
}

type KeySpecificConfig []KeySpecific

func (ks KeySpecificConfig) ValidateConfig() (err error) {
Expand Down
10 changes: 8 additions & 2 deletions core/chains/evm/gas/rollups/l1_oracle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas/rollups/mocks"
)

const (
OPGasOracleAddress = "0x420000000000000000000000000000000000000F"
ogtownsend marked this conversation as resolved.
Show resolved Hide resolved
KromaGasOracleAddress = "0x4200000000000000000000000000000000000005"
ScrollGasOracleAddress = "0x5300000000000000000000000000000000000002"
)

func TestL1Oracle(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -95,7 +101,7 @@ func TestL1Oracle_GasPrice(t *testing.T) {
assert.Nil(t, blockNumber)
}).Return(common.BigToHash(l1BaseFee).Bytes(), nil)

daOracle := CreateTestDAOracle(t, toml.OPOracle, "0x4200000000000000000000000000000000000005", "")
daOracle := CreateTestDAOracle(t, toml.OPOracle, KromaGasOracleAddress, "")
oracle, err := NewL1GasOracle(logger.Test(t), ethClient, chaintype.ChainKroma, daOracle)
require.NoError(t, err)
servicetest.RunHealthy(t, oracle)
Expand Down Expand Up @@ -152,7 +158,7 @@ func TestL1Oracle_GasPrice(t *testing.T) {
assert.Nil(t, blockNumber)
}).Return(common.BigToHash(l1BaseFee).Bytes(), nil)

daOracle := CreateTestDAOracle(t, toml.OPOracle, "0x5300000000000000000000000000000000000002", "")
daOracle := CreateTestDAOracle(t, toml.OPOracle, ScrollGasOracleAddress, "")
oracle, err := NewL1GasOracle(logger.Test(t), ethClient, chaintype.ChainScroll, daOracle)
require.NoError(t, err)
servicetest.RunHealthy(t, oracle)
Expand Down
8 changes: 1 addition & 7 deletions core/chains/evm/gas/rollups/op_l1_oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,6 @@ const (
// decimals is a hex encoded call to:
// `function decimals() public pure returns (uint256);`
decimalsMethod = "decimals"
// OPGasOracleAddress is the address of the precompiled contract that exists on Optimism, Base and Mantle.
OPGasOracleAddress = "0x420000000000000000000000000000000000000F"
// KromaGasOracleAddress is the address of the precompiled contract that exists on Kroma.
KromaGasOracleAddress = "0x4200000000000000000000000000000000000005"
// ScrollGasOracleAddress is the address of the precompiled contract that exists on Scroll.
ScrollGasOracleAddress = "0x5300000000000000000000000000000000000002"
)

func NewOpStackL1GasOracle(lggr logger.Logger, ethClient l1OracleClient, chainType chaintype.ChainType, daOracle evmconfig.DAOracle) (*optimismL1Oracle, error) {
Expand Down Expand Up @@ -533,7 +527,7 @@ func encodeCalldata(abiString, methodName string) ([]byte, abi.ABI, error) {
}
calldata, err := methodAbi.Pack(methodName)
if err != nil {
return nil, abi.ABI{}, fmt.Errorf("failed to pack calldata: %w", err)
return nil, abi.ABI{}, fmt.Errorf("failed to pack calldata for %s: %w", methodName, err)
}
return calldata, methodAbi, nil
}
2 changes: 1 addition & 1 deletion core/config/docs/chains-evm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ TipCapMin = '1 wei' # Default

[EVM.GasEstimator.DAOracle]
# OracleType refers to the oracle family this config belongs to (OP, Arbitrum, etc).
OracleType = 'OP' # Example
OracleType = 'OPOracle' # Example
# OracleAddress is the address of the oracle contract.
OracleAddress = '0x420000000000000000000000000000000000000F' # Example
# CustomGasPriceAPICalldata is optional and can be set to call a custom gas price API at the given OracleAddress.
Expand Down