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

Conversation

ogtownsend
Copy link
Collaborator

@ogtownsend ogtownsend commented Sep 27, 2024

This PR:

  • adds a DAOracle config to the GasEstimator interface to be set by the chain TOML
  • refactors the OP oracle to accept this generic DA oracle config

See the CCIP-3551 epic for more details

@ogtownsend ogtownsend force-pushed the CCIP-3552-refactor-op-stack-oracle-to-accept-generic-op-l-2-config branch 6 times, most recently from 4fc823a to f158de6 Compare October 2, 2024 17:36
@ogtownsend ogtownsend changed the title wip CCIP-3552 add DA oracle config to gas estimator Oct 2, 2024
@ogtownsend ogtownsend changed the title CCIP-3552 add DA oracle config to gas estimator CCIP-3552 refactor OP oracle to accept generic DA oracle config Oct 2, 2024
@ogtownsend ogtownsend force-pushed the CCIP-3552-refactor-op-stack-oracle-to-accept-generic-op-l-2-config branch 2 times, most recently from 948d154 to 2c95e64 Compare October 3, 2024 00:52
@ogtownsend ogtownsend marked this pull request as ready for review October 3, 2024 03:39
@ogtownsend ogtownsend requested review from a team as code owners October 3, 2024 03:39
@ogtownsend ogtownsend force-pushed the CCIP-3552-refactor-op-stack-oracle-to-accept-generic-op-l-2-config branch from b298388 to 7968c5b Compare October 4, 2024 17:56
Comment on lines 56 to 66
switch chainType {
case chaintype.ChainOptimismBedrock, chaintype.ChainKroma, chaintype.ChainScroll, chaintype.ChainMantle, chaintype.ChainZircuit:
l1Oracle, err = NewOpStackL1GasOracle(lggr, ethClient, chainType)
case chaintype.ChainArbitrum:
switch daOracle.OracleType() {
case toml.OPOracle:
l1Oracle, err = NewOpStackL1GasOracle(lggr, ethClient, chainType, daOracle)
case toml.ArbitrumOracle:
l1Oracle, err = NewArbitrumL1GasOracle(lggr, ethClient)
case chaintype.ChainZkSync:
case toml.ZKSyncOracle:
l1Oracle = NewZkSyncL1GasOracle(lggr, ethClient)
default:
return nil, fmt.Errorf("received unsupported chaintype %s", chainType)
return nil, fmt.Errorf("unsupported DA oracle type %s", daOracle.OracleType())
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was made per @matYang 's suggestion here: #14599 (comment)

The one "gotcha" with this is that now we need to make sure the DAOracle config is correctly set and non-nil for each of these chains.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see how this simplifies this switch but I'm worried about introducing another config for this when ChainType is already used to group behavior for different chains. Don't think this saves us from making changes either. If we introduce a new ChainType for a new chain, we have to make code changes like this for it anyways.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the idea is that chaintype can deviate from oracle type, e.g if we have the heuristic oracle, many chain types may be able to share the same oracle type

Copy link
Contributor

github-actions bot commented Oct 4, 2024

WF: CI Core#8f50535

No errors found in this run. 🎉

@amit-momin
Copy link
Contributor

Think we'll also need to update the default tomls for chains that use the the OP oracle. Should be the ones with the ChainType's: optimismBedrock, mantle, zircuit, kroma, scroll

@ogtownsend ogtownsend force-pushed the CCIP-3552-refactor-op-stack-oracle-to-accept-generic-op-l-2-config branch from 7968c5b to 3c74ccc Compare October 7, 2024 13:46
docs/CONFIG.md Outdated Show resolved Hide resolved
@@ -47,21 +49,21 @@ func IsRollupWithL1Support(chainType chaintype.ChainType) bool {
return slices.Contains(supportedChainTypes, chainType)
}

func NewL1GasOracle(lggr logger.Logger, ethClient l1OracleClient, chainType chaintype.ChainType) (L1Oracle, error) {
func NewL1GasOracle(lggr logger.Logger, ethClient l1OracleClient, chainType chaintype.ChainType, daOracle evmconfig.DAOracle) (L1Oracle, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed, we can keep the hardcoded switch statement when daOracle does not exist for backwards-compatibility

@matYang matYang requested a review from simsonraj October 7, 2024 20:27
@ogtownsend ogtownsend force-pushed the CCIP-3552-refactor-op-stack-oracle-to-accept-generic-op-l-2-config branch from 3c74ccc to 4c7d92b Compare October 7, 2024 20:49
@ogtownsend ogtownsend force-pushed the CCIP-3552-refactor-op-stack-oracle-to-accept-generic-op-l-2-config branch from e33bf1e to 6ab6540 Compare October 10, 2024 20:36
Comment on lines +602 to +608
func (d *TestDAOracleConfig) OracleAddress() *types.EIP55Address {
a, err := types.NewEIP55Address("0x420000000000000000000000000000000000000F")
if err != nil {
panic(err)
}
return &a
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks eth specific but the capability generally tries to keep all the chain specific things separated. Might be worth discussing /w @asoliman92 at some point

@ogtownsend ogtownsend added this pull request to the merge queue Oct 11, 2024
Merged via the queue into develop with commit 4ac405a Oct 11, 2024
149 checks passed
@ogtownsend ogtownsend deleted the CCIP-3552-refactor-op-stack-oracle-to-accept-generic-op-l-2-config branch October 11, 2024 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants