From bf9b08c33119d14a34c4914a3a7cc94ea6cb5481 Mon Sep 17 00:00:00 2001 From: Joe Huang Date: Wed, 6 Nov 2024 16:44:38 -0600 Subject: [PATCH] Nonevm 825/remove evm config dependency from plugin (#15126) * remove dependency of evmConfig in plugin oracle creator function * fix make * add changeset * update test --- .changeset/brave-frogs-greet.md | 5 +++ .../ccip/configs/evm/chain_writer.go | 9 ----- .../ccip/configs/evm/chain_writer_test.go | 35 +------------------ core/capabilities/ccip/delegate.go | 1 - .../capabilities/ccip/oraclecreator/plugin.go | 11 ------ core/services/relay/evm/evm.go | 1 + 6 files changed, 7 insertions(+), 55 deletions(-) create mode 100644 .changeset/brave-frogs-greet.md diff --git a/.changeset/brave-frogs-greet.md b/.changeset/brave-frogs-greet.md new file mode 100644 index 00000000000..907e8f1ee75 --- /dev/null +++ b/.changeset/brave-frogs-greet.md @@ -0,0 +1,5 @@ +--- +"chainlink": minor +--- + +update plugin and evm chainwriter to remove evmConfig dependency #updated diff --git a/core/capabilities/ccip/configs/evm/chain_writer.go b/core/capabilities/ccip/configs/evm/chain_writer.go index f88bfce937b..ada135aecd8 100644 --- a/core/capabilities/ccip/configs/evm/chain_writer.go +++ b/core/capabilities/ccip/configs/evm/chain_writer.go @@ -8,7 +8,6 @@ import ( "github.com/smartcontractkit/chainlink-ccip/pkg/consts" - "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/offramp" evmrelaytypes "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/types" @@ -21,19 +20,12 @@ var ( // ChainWriterConfigRaw returns a ChainWriterConfig that can be used to transmit commit and execute reports. func ChainWriterConfigRaw( fromAddress common.Address, - maxGasPrice *assets.Wei, commitGasLimit, execBatchGasLimit uint64, ) (evmrelaytypes.ChainWriterConfig, error) { if fromAddress == common.HexToAddress("0x0") { return evmrelaytypes.ChainWriterConfig{}, fmt.Errorf("fromAddress cannot be zero") } - if maxGasPrice == nil { - return evmrelaytypes.ChainWriterConfig{}, fmt.Errorf("maxGasPrice cannot be nil") - } - if maxGasPrice.Cmp(assets.NewWeiI(0)) <= 0 { - return evmrelaytypes.ChainWriterConfig{}, fmt.Errorf("maxGasPrice must be greater than zero") - } if commitGasLimit == 0 { return evmrelaytypes.ChainWriterConfig{}, fmt.Errorf("commitGasLimit must be greater than zero") } @@ -59,7 +51,6 @@ func ChainWriterConfigRaw( }, }, }, - MaxGasPrice: maxGasPrice, }, nil } diff --git a/core/capabilities/ccip/configs/evm/chain_writer_test.go b/core/capabilities/ccip/configs/evm/chain_writer_test.go index e24863866cc..a8851ab6e48 100644 --- a/core/capabilities/ccip/configs/evm/chain_writer_test.go +++ b/core/capabilities/ccip/configs/evm/chain_writer_test.go @@ -8,14 +8,12 @@ import ( "github.com/smartcontractkit/chainlink-ccip/pkg/consts" "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/configs/evm" - "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" ) func TestChainWriterConfigRaw(t *testing.T) { tests := []struct { name string fromAddress common.Address - maxGasPrice *assets.Wei commitGasLimit uint64 execBatchGasLimit uint64 expectedError string @@ -23,7 +21,6 @@ func TestChainWriterConfigRaw(t *testing.T) { { name: "valid input", fromAddress: common.HexToAddress("0x1234567890abcdef1234567890abcdef12345678"), - maxGasPrice: assets.NewWeiI(1000000000), commitGasLimit: 21000, execBatchGasLimit: 42000, expectedError: "", @@ -31,39 +28,13 @@ func TestChainWriterConfigRaw(t *testing.T) { { name: "zero fromAddress", fromAddress: common.HexToAddress("0x0"), - maxGasPrice: assets.NewWeiI(1000000000), commitGasLimit: 21000, execBatchGasLimit: 42000, expectedError: "fromAddress cannot be zero", }, - { - name: "nil maxGasPrice", - fromAddress: common.HexToAddress("0x1234567890abcdef1234567890abcdef12345678"), - maxGasPrice: nil, - commitGasLimit: 21000, - execBatchGasLimit: 42000, - expectedError: "maxGasPrice cannot be nil", - }, - { - name: "zero maxGasPrice", - fromAddress: common.HexToAddress("0x1234567890abcdef1234567890abcdef12345678"), - maxGasPrice: assets.NewWeiI(0), - commitGasLimit: 21000, - execBatchGasLimit: 42000, - expectedError: "maxGasPrice must be greater than zero", - }, - { - name: "negative maxGasPrice", - fromAddress: common.HexToAddress("0x1234567890abcdef1234567890abcdef12345678"), - maxGasPrice: assets.NewWeiI(-1), - commitGasLimit: 21000, - execBatchGasLimit: 42000, - expectedError: "maxGasPrice must be greater than zero", - }, { name: "zero commitGasLimit", fromAddress: common.HexToAddress("0x1234567890abcdef1234567890abcdef12345678"), - maxGasPrice: assets.NewWeiI(1000000000), commitGasLimit: 0, execBatchGasLimit: 42000, expectedError: "commitGasLimit must be greater than zero", @@ -71,7 +42,6 @@ func TestChainWriterConfigRaw(t *testing.T) { { name: "zero execBatchGasLimit", fromAddress: common.HexToAddress("0x1234567890abcdef1234567890abcdef12345678"), - maxGasPrice: assets.NewWeiI(1000000000), commitGasLimit: 21000, execBatchGasLimit: 0, expectedError: "execBatchGasLimit must be greater than zero", @@ -80,7 +50,7 @@ func TestChainWriterConfigRaw(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - config, err := evm.ChainWriterConfigRaw(tt.fromAddress, tt.maxGasPrice, tt.commitGasLimit, tt.execBatchGasLimit) + config, err := evm.ChainWriterConfigRaw(tt.fromAddress, tt.commitGasLimit, tt.execBatchGasLimit) if tt.expectedError != "" { assert.EqualError(t, err, tt.expectedError) } else { @@ -94,9 +64,6 @@ func TestChainWriterConfigRaw(t *testing.T) { assert.Equal(t, tt.execBatchGasLimit, config.Contracts[consts.ContractNameOffRamp].Configs[consts.MethodExecute].GasLimit) - assert.Equal(t, - tt.maxGasPrice, - config.MaxGasPrice) } }) } diff --git a/core/capabilities/ccip/delegate.go b/core/capabilities/ccip/delegate.go index 7e5401ad5e6..09e3769627e 100644 --- a/core/capabilities/ccip/delegate.go +++ b/core/capabilities/ccip/delegate.go @@ -205,7 +205,6 @@ func (d *Delegate) ServicesForSpec(ctx context.Context, spec job.Job) (services bootstrapperLocators, hcr, cciptypes.ChainSelector(homeChainChainSelector), - d.evmConfigs, ) } else { oracleCreator = oraclecreator.NewBootstrapOracleCreator( diff --git a/core/capabilities/ccip/oraclecreator/plugin.go b/core/capabilities/ccip/oraclecreator/plugin.go index 5df0b1135d7..573d1dd0cac 100644 --- a/core/capabilities/ccip/oraclecreator/plugin.go +++ b/core/capabilities/ccip/oraclecreator/plugin.go @@ -73,7 +73,6 @@ type pluginOracleCreator struct { homeChainReader ccipreaderpkg.HomeChain homeChainSelector cciptypes.ChainSelector relayers map[types.RelayID]loop.Relayer - evmConfigs toml.EVMConfigs } func NewPluginOracleCreator( @@ -91,7 +90,6 @@ func NewPluginOracleCreator( bootstrapperLocators []commontypes.BootstrapperLocator, homeChainReader ccipreaderpkg.HomeChain, homeChainSelector cciptypes.ChainSelector, - evmConfigs toml.EVMConfigs, ) cctypes.OracleCreator { return &pluginOracleCreator{ ocrKeyBundles: ocrKeyBundles, @@ -108,7 +106,6 @@ func NewPluginOracleCreator( bootstrapperLocators: bootstrapperLocators, homeChainReader: homeChainReader, homeChainSelector: homeChainSelector, - evmConfigs: evmConfigs, } } @@ -367,7 +364,6 @@ func (i *pluginOracleCreator) createReadersAndWriters( cw, err1 := createChainWriter( ctx, chainID, - i.evmConfigs, relayer, i.transmitters, execBatchGasLimit) @@ -480,7 +476,6 @@ func isUSDCEnabled(ofc offChainConfig) bool { func createChainWriter( ctx context.Context, chainID *big.Int, - evmConfigs toml.EVMConfigs, relayer loop.Relayer, transmitters map[types.RelayID][]string, execBatchGasLimit uint64, @@ -492,14 +487,8 @@ func createChainWriter( fromAddress = common.HexToAddress(transmitter[0]) } - maxGasPrice := getKeySpecificMaxGasPrice(evmConfigs, chainID, fromAddress) - if maxGasPrice == nil { - return nil, fmt.Errorf("failed to find max gas price for chain %s", chainID.String()) - } - chainWriterRawConfig, err := evmconfig.ChainWriterConfigRaw( fromAddress, - maxGasPrice, defaultCommitGasLimit, execBatchGasLimit, ) diff --git a/core/services/relay/evm/evm.go b/core/services/relay/evm/evm.go index 7c380211ea0..8e63a26a9d7 100644 --- a/core/services/relay/evm/evm.go +++ b/core/services/relay/evm/evm.go @@ -838,6 +838,7 @@ func (r *Relayer) NewChainWriter(_ context.Context, config []byte) (commontypes. return nil, fmt.Errorf("failed to unmarshall chain writer config err: %s", err) } + cfg.MaxGasPrice = r.chain.Config().EVM().GasEstimator().PriceMax() return NewChainWriterService(r.lggr, r.chain.Client(), r.chain.TxManager(), r.chain.GasEstimator(), cfg) }