Skip to content

Commit

Permalink
[BCI-3438] Add the chainwriter to the EVM relayer impl (#13718)
Browse files Browse the repository at this point in the history
* evm: Add chain writer constructor onto the evm relayer impl

* changeset: Add changeset
  • Loading branch information
nickcorin authored Jun 28, 2024
1 parent 39e4442 commit f33cd19
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/five-apes-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

#internal Added a chain writer constructor onto the evm relayer.
9 changes: 9 additions & 0 deletions core/services/relay/evm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
9 changes: 7 additions & 2 deletions core/services/relay/evm/write_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit f33cd19

Please sign in to comment.