-
Notifications
You must be signed in to change notification settings - Fork 1
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
median: prefer adapting ChainReader to MedianContract #7
Conversation
dbf489a
to
67a411c
Compare
@vyzaldysanchez the linter is broken again. Didn't we resolve this already or was that in another repo? <checkstyle version="5.0">
<file name="../../../../../opt/hostedtoolcache/go/1.21.3/x64/src/slices/sort.go">
<error column="7" line="67" message="undefined: min" severity="error" source="typecheck"></error>
<error column="7" line="97" message="undefined: max" severity="error" source="typecheck"></error>
</file> |
67a411c
to
de42285
Compare
Nevermind - it just need a bump from 1.53 to 1.55. Passing now. |
@jmank88 We have two places where we create median plugins now (here and in the medianpoc package), so I think we need a place where we can add common code like this (this adaptor should apply to both plugins really) that isn't client-specific. My idea was to create a constructor function for NumericalMedianFactory and add these changes to that. What do you think? |
Should medianpoc be moved to this repo? But regardless, a |
@jmank88 and I synced offline: we are going to move medianpoc to this package and expose the two different server interfaces via different methods on the plugin type. I'm happy to go with the adaptation listed here and will circle back with a PR to combine median and medianpoc. |
This change will also need to be made in |
} | ||
|
||
return resp.ConfigDigest, resp.Epoch, resp.Round, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, come to think of it, if we're going to do it this way then the definition of medianContract
along with its methods needs to go in chainlink-commons
rather than here. Otherwise there is no way for chainlink-commons
to import it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would chainlink-common need to import this? We only want to use it at the outermost client layer. If we used it on the server side, then we would still be using the GRPC services over the wire, and could not phase them out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, nevermind I think I was confused about the interconnection of all of this. I was thinking the NewMedianFactory
method in chainlink-common
was calling NumericalMedianFactory
directly but I guess the call it's making must end up getting back to this function (in chainlink-feeds
at some point, where the actual call gets made... right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of yeah. I think it's more about the GRPC layer being a separate concern from chain reader being available or not.
I don't think that needs to change, because we only pass a provider ID. |
de42285
to
cdbec5d
Compare
Updated to remove TODO and renamed to avoid |
func (c *chainReaderContract) LatestRoundRequested(ctx context.Context, lookback time.Duration) (configDigest ocrtypes.ConfigDigest, epoch uint32, round uint8, err error) { | ||
var resp latestRoundRequested | ||
|
||
err = c.chainReader.GetLatestValue(ctx, c.contract, "LatestRoundReported", map[string]any{"lookback": lookback}, &resp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lookback is an obsolete parameter unused anywhere at Chainlink. We can't support it with GetLatestValue()
without changing the meaning of the method and breaking the chain agnostic nature of it in an awkward way. Only contract method params (or equivalently, log topics) should be passed in params field to GetLatestValue()
This PR moves
type medianContract
from core, which is the adapter for implementing theMedianContract
interface withChainReader
. By using it here in the plugin, at the outermost client layer, instead of from the core host, in the middle of proxying the provider, we ensure that the newChainReader
is used end-to-end underneath, so that the oldMedianContract
grpc support can safely be phased out.There are a few differences with
medianContract
from core:package json
can access themPending: false
- this matches existing behavior forLatestTransmissionDetails
here: https://github.com/smartcontractkit/chainlink/blob/bd7e233d3a489e8dacae0a8c8539802b3ae10832/core/services/relay/evm/median.go#L73lookback
argument is passed along as an arg toGetLatestValue