Skip to content

Commit

Permalink
use chain Id as opposed to chain type to identify Mantle (#1489) (#1494)
Browse files Browse the repository at this point in the history
## 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.
  • Loading branch information
matYang authored Oct 11, 2024
1 parent 2d5ff29 commit 918ccf6
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions core/services/relay/evm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 918ccf6

Please sign in to comment.