Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose ContractReader and ChainWriter of relayer in relayerSet #749

Merged
merged 7 commits into from
Sep 5, 2024

Conversation

kidambisrinivas
Copy link
Contributor

@kidambisrinivas kidambisrinivas commented Sep 4, 2024

Updates

  • Implement ContractReader and ChainWriter in relayerset
    • Relayerset does not start gRPC service for relayer and mount it on-demand
    • So we had to expose ContractReader and ChainWriter of relayer from relayerset client itself

Testing

$ go test -count=1 -v ./pkg/loop/internal/relayerset
=== RUN   Test_RelayerSet
2024-09-04T16:02:42.491+0100 [DEBUG] accepting initial connection: addr=/var/folders/1b/byq7w64n1x7gmp5cp9__vp_r0000gn/T/plugin2829362114
2024-09-04T16:02:42.492+0100 [DEBUG] stdio EOF, exiting copy loop
2024-09-04T16:02:42.492+0100 [DEBUG] stdio EOF, exiting copy loop
2024-09-04T16:02:42.493+0100 [DEBUG] making new client mux initial connection: addr=/var/folders/1b/byq7w64n1x7gmp5cp9__vp_r0000gn/T/plugin2829362114
2024-09-04T16:02:42.493+0100 [DEBUG] initial server connection accepted: addr=/var/folders/1b/byq7w64n1x7gmp5cp9__vp_r0000gn/T/plugin2829362114
2024-09-04T16:02:42.494+0100 [DEBUG] client muxer connected: addr=/var/folders/1b/byq7w64n1x7gmp5cp9__vp_r0000gn/T/plugin2829362114
2024-09-04T16:02:42.494+0100 [DEBUG] sending conn to default listener
2024-09-04T16:02:42.497+0100 [DEBUG] sending conn to default listener
2024-09-04T16:02:42.497+0100 [DEBUG] stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
--- PASS: Test_RelayerSet (0.01s)
PASS
ok      github.com/smartcontractkit/chainlink-common/pkg/loop/internal/relayerset       0.408s

@kidambisrinivas kidambisrinivas requested a review from a team as a code owner September 4, 2024 10:24
@kidambisrinivas kidambisrinivas requested review from bolekk and removed request for a team September 4, 2024 10:24
@jmank88
Copy link
Collaborator

jmank88 commented Sep 4, 2024

Is this PR part of a set? If so, please link them together from the descriptions.

@kidambisrinivas kidambisrinivas changed the title Embed relayer::relayer in relayerset::relayer to expose chainReader Expose ContractReader and ChainWriter of relayer in relayerSet Sep 4, 2024
@patrickhuie19
Copy link
Contributor

I don't follow - relayerset is supposed to serve relayers, which then hold a Chain Reader and Chain Writer. What does defining a Chain Reader and Chain Writer on a relayerset mean?

@cedric-cordenier
Copy link
Contributor

cedric-cordenier commented Sep 4, 2024

I don't follow - relayerset is supposed to serve relayers, which then hold a Chain Reader and Chain Writer. What does defining a Chain Reader and Chain Writer on a relayerset mean?

@patrickhuie19 This is just a way to save us from instantiating an extra server for the relayer.

The calls we would make normally are:
RelayerSet.Get -> Relayer
and then
Relayer.NewChainReader -> ChainReader

We could translate this to the GRPC world by having each call to RelayerSet.Get wrap the returned relayer in a server and register that to the GRPC server. However this is actually pretty inefficient since a relayer object on its own is useless; users will always want to use the relayer to instantiate eg. a chainreader or chainwriter.

So we can avoid the intermediate server for the relayer by just storing a reference to the relayerSet client and the relayer we want to fetch.

I.e. the calls described above instead would become:

RelayerSet.Get -> RelayerClient (i.e. a RelayerSetClient + relayerID) -- effectively this call just acts as a check that the relayer exists
RelayerClient.NewChainReader -> this is a call to RelayerSet.NewChainReader with (relayerID, []chainReaderConfig); the implementation will then fetch the relayer and call NewChainReader on it

pkg/types/core/relayerset.go Outdated Show resolved Hide resolved
@patrickhuie19
Copy link
Contributor

I don't follow - relayerset is supposed to serve relayers, which then hold a Chain Reader and Chain Writer. What does defining a Chain Reader and Chain Writer on a relayerset mean?

@patrickhuie19 This is just a way to save us from instantiating an extra server for the relayer.

The calls we would make normally are: RelayerSet.Get -> Relayer and then Relayer.NewChainReader -> ChainReader

We could translate this to the GRPC world by having each call to RelayerSet.Get wrap the returned relayer in a server and register that to the GRPC server. However this is actually pretty inefficient since a relayer object on its own is useless; users will always want to use the relayer to instantiate eg. a chainreader or chainwriter.

So we can avoid the intermediate server for the relayer by just storing a reference to the relayerSet client and the relayer we want to fetch.

I.e. the calls described above instead would become:

RelayerSet.Get -> RelayerClient (i.e. a RelayerSetClient + relayerID) -- effectively this call just acts as a check that the relayer exists RelayerClient.NewChainReader -> this is a call to RelayerSet.NewChainReader with (relayerID, []chainReaderConfig); the implementation will then fetch the relayer and call NewChainReader on it

That makes sense to me. Can we document that @kidambisrinivas ?

@kidambisrinivas
Copy link
Contributor Author

@patrickhuie19 Documented this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants