From f33cd1915c03bef9bfe110481eb13094c36ce454 Mon Sep 17 00:00:00 2001 From: Nick Corin Date: Fri, 28 Jun 2024 19:23:07 +0200 Subject: [PATCH] [BCI-3438] Add the chainwriter to the EVM relayer impl (#13718) * evm: Add chain writer constructor onto the evm relayer impl * changeset: Add changeset --- .changeset/five-apes-fold.md | 5 +++++ core/services/relay/evm/evm.go | 9 +++++++++ core/services/relay/evm/write_target.go | 9 +++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 .changeset/five-apes-fold.md diff --git a/.changeset/five-apes-fold.md b/.changeset/five-apes-fold.md new file mode 100644 index 00000000000..b9f33cbfa18 --- /dev/null +++ b/.changeset/five-apes-fold.md @@ -0,0 +1,5 @@ +--- +"chainlink": minor +--- + +#internal Added a chain writer constructor onto the evm relayer. diff --git a/core/services/relay/evm/evm.go b/core/services/relay/evm/evm.go index bda99d3cb1c..0a6dea6588b 100644 --- a/core/services/relay/evm/evm.go +++ b/core/services/relay/evm/evm.go @@ -626,6 +626,15 @@ func newOnChainContractTransmitter(ctx context.Context, lggr logger.Logger, rarg ) } +func (r *Relayer) NewChainWriter(_ context.Context, config []byte) (commontypes.ChainWriter, error) { + var cfg types.ChainWriterConfig + if err := json.Unmarshal(config, &cfg); err != nil { + return nil, fmt.Errorf("failed to unmarshall chain writer config err: %s", err) + } + + return NewChainWriterService(r.lggr, r.chain.Client(), r.chain.TxManager(), r.chain.GasEstimator(), cfg) +} + func (r *Relayer) NewContractReader(chainReaderConfig []byte) (commontypes.ContractReader, error) { ctx := context.Background() cfg := &types.ChainReaderConfig{} diff --git a/core/services/relay/evm/write_target.go b/core/services/relay/evm/write_target.go index 46f4f83b05b..dc1a3635330 100644 --- a/core/services/relay/evm/write_target.go +++ b/core/services/relay/evm/write_target.go @@ -69,9 +69,14 @@ func NewWriteTarget(ctx context.Context, relayer *Relayer, chain legacyevm.Chain }, }, } - chainWriterConfig.MaxGasPrice = chain.Config().EVM().GasEstimator().PriceMax() - cw, err := NewChainWriterService(lggr.Named("ChainWriter"), chain.Client(), chain.TxManager(), chain.GasEstimator(), chainWriterConfig) + + encodedWriterConfig, err := json.Marshal(chainWriterConfig) + if err != nil { + return nil, fmt.Errorf("failed to marshal chainwriter config: %w", err) + } + + cw, err := relayer.NewChainWriter(ctx, encodedWriterConfig) if err != nil { return nil, err }