From 918ccf656b2663ab5f8f7a4fb039605adb542add Mon Sep 17 00:00:00 2001 From: Chunkai Yang Date: Fri, 11 Oct 2024 17:00:25 -0400 Subject: [PATCH] use chain Id as opposed to chain type to identify Mantle (#1489) (#1494) ## Motivation Mantle chaintype is no longer used by the BIX team, Mantle's chaintype has been changed to optimism in chain toml ## Solution In order to match for Mantle and apply custom gas price interceptor, we can check for evm ChainId. Not going for a more generic solution given OCR2 plugins will be sunset soon, and Mantle should be the only chain that requires such custom logic before that. This is already included in 1.5.4 release and verified to work. Back-porting here to dev branch. --- core/services/relay/evm/evm.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/core/services/relay/evm/evm.go b/core/services/relay/evm/evm.go index ae5244f5f0..f2143ceded 100644 --- a/core/services/relay/evm/evm.go +++ b/core/services/relay/evm/evm.go @@ -12,7 +12,7 @@ import ( "sync" cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" - "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/chaintype" + "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/estimatorconfig/interceptors/mantle" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip" @@ -413,12 +413,14 @@ func (r *Relayer) NewCCIPCommitProvider(rargs commontypes.RelayArgs, pargs commo // CCIPCommit reads only when source chain is Mantle, then reports to dest chain // to minimize misconfigure risk, might make sense to wire Mantle only when Commit + Mantle + IsSourceProvider - if r.chain.Config().EVM().ChainType() == chaintype.ChainMantle && commitPluginConfig.IsSourceProvider { - mantleInterceptor, iErr := mantle.NewInterceptor(ctx, r.chain.Client()) - if iErr != nil { - return nil, iErr + if r.chain.Config().EVM().ChainID().Uint64() == 5003 || r.chain.Config().EVM().ChainID().Uint64() == 5000 { + if commitPluginConfig.IsSourceProvider { + mantleInterceptor, iErr := mantle.NewInterceptor(ctx, r.chain.Client()) + if iErr != nil { + return nil, iErr + } + feeEstimatorConfig.AddGasPriceInterceptor(mantleInterceptor) } - feeEstimatorConfig.AddGasPriceInterceptor(mantleInterceptor) } // The src chain implementation of this provider does not need a configWatcher or contractTransmitter; @@ -494,12 +496,14 @@ func (r *Relayer) NewCCIPExecProvider(rargs commontypes.RelayArgs, pargs commont // CCIPExec reads when dest chain is mantle, and uses it to calc boosting in batching // to minimize misconfigure risk, make sense to wire Mantle only when Exec + Mantle + !IsSourceProvider - if r.chain.Config().EVM().ChainType() == chaintype.ChainMantle && !execPluginConfig.IsSourceProvider { - mantleInterceptor, iErr := mantle.NewInterceptor(ctx, r.chain.Client()) - if iErr != nil { - return nil, iErr + if r.chain.Config().EVM().ChainID().Uint64() == 5003 || r.chain.Config().EVM().ChainID().Uint64() == 5000 { + if !execPluginConfig.IsSourceProvider { + mantleInterceptor, iErr := mantle.NewInterceptor(ctx, r.chain.Client()) + if iErr != nil { + return nil, iErr + } + feeEstimatorConfig.AddGasPriceInterceptor(mantleInterceptor) } - feeEstimatorConfig.AddGasPriceInterceptor(mantleInterceptor) } // The src chain implementation of this provider does not need a configWatcher or contractTransmitter;