-
Notifications
You must be signed in to change notification settings - Fork 2
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
add context #33
add context #33
Conversation
782e854
to
bf6e034
Compare
c55f1c7
to
cf396d1
Compare
4645944
to
0704599
Compare
@@ -33,7 +33,7 @@ type decryptionPlugin struct { | |||
} | |||
|
|||
// NewReportingPlugin complies with ReportingPluginFactory. | |||
func (f DecryptionReportingPluginFactory) NewReportingPlugin(rpConfig types.ReportingPluginConfig) (types.ReportingPlugin, types.ReportingPluginInfo, error) { | |||
func (f DecryptionReportingPluginFactory) NewReportingPlugin(ctx context.Context, rpConfig types.ReportingPluginConfig) (types.ReportingPlugin, types.ReportingPluginInfo, error) { |
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.
Shouldn't this be looppcontext types.LOOPPContext
? Otherwise I worry about a future maintainer of this code doing long-running work with one of these contexts.
The same concern would apply across all other repos and functions that take a types.LOOPPContext
.
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.
I only settled for this pattern under the impression that it would not leak out of libocr. I would like to re-emphasize that I think LOOPPContext
is the wrong name. I think we need to take two steps back and re-evaluate the purpose of this type.
- There is nothing about a regular context that implies doing something "long-running" is allowed or not.
- An implementer assuming that the presence of a context argument means that they can make a web request and block for 30 seconds is making a mistake.
- A method that has timing expectations needs to be clear about those expectations, regardless of whether or not a context is included in the argument set.
Context type, which carries deadlines, cancellation signals, and other request-scoped values across API boundaries and between processes.
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.
would like to re-emphasize that I think LOOPPContext is the wrong name
Thanks for re-iterating that you don't like the name, I'm happy to consider alternatives.
For now, I would suggest that we leave the naming aside and focus on the conceptual aspects.
I agree with your three points.
My concern is about misuse resistance. The intention behind types.LOOPPContext
is to make people read the docs.
Expanding on that (apologies if I am being repetitive): Contexts are frequently used for "long-running" interactions e.g. with remote servers. I worry that someone will (incorrectly as you point out, and without having read the docs on the interface) take the context and stuff it into whatever HTTP/Ethereum RPC call they want to perform, because they just assume that the presence of the context means that they're in "long-running" land. However, the context that's passed here effectively never expires (only when the underlying OCR configuration changes or the offchainreporting2plus.Oracle
is shutdown). This is particularly concerning for the ReportingPlugin functions.
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.
(Lmk if you'd prefer to take this discussion back to the original PR or elsewhere. Not sure whether this is the best place for it, since it goes beyond tdh2.)
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.
There is no "long-running land" and "short-running land". There are methods and collections of methods with specific timing expectations, and those expectations fall on a sliding scale.
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.
Rephrasing the tradeoff as I understand it for my understanding:
What amount of standard tooling breakage and type conversion boiler plate are we willing to introduce to signal to LibOCR consumers that they need to be careful with their usage of context?
So, it seems like the best case scenario is one where we
- Don't break standard tooling
- Don't introduce unnecessary type conversion boiler plate
- Do signal to consumers that they need to be careful with their usage of context
Can we accomplish that best case scenario with standard Godoc comments?
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.
@jmank88 you wrote above
and then after reading the docs possibly confused more when they realize it is just a context with ambiguously short runtime expectations of some kind.
Am I reading this correctly that you are unhappy with the docs? But then why ask to merge the original PR?
The correct thing to do is still just to meet the deadline
But many of these will not have a deadline!? They only expire once offchainreporting2plus.Oracle.Close()
is called or there is a setConfig
on the contract.
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.
Am I reading this correctly that you are unhappy with the docs? But then why ask to merge the original PR?
The whole approach has diverged from my proposal and feedback. I have tried to be maximally receptive to this alternative in the interest of time and with the understanding that it would not have cascading effects across other repos.
But many of these will not have a deadline!? They only expire once offchainreporting2plus.Oracle.Close() is called or there is a setConfig on the contract.
Should they have a deadline? It seems in conflict to claim they should not have a deadline, but also that the implementations "need to be fast". Why can't/shouldn't "fast" be quantified as specific deadlines?
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.
Should they have a deadline? It seems in conflict to claim they should not have a deadline, but also that the implementations "need to be fast". Why can't/shouldn't "fast" be quantified as specific deadlines?
Adding a good deadline for these is tricky for a few reasons, here are some of them:
- it would force reporting plugin implementers to think about more timing parameters. setting the params wrong risks breaking things.
- timing parameters for the other reportingplugin functions are set via setConfig, adding more parameters there is a far reaching change!
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.
I think we need to be precise about the problem being solved.
If the author of the interface and caller of the method are not equipped to handle this, then how is an
implementer supposed to be any better equipped to solve the problem?
I am not proposing adding a bunch of new fine tuned configuration. I would propose that we start by doing the obvious naive thing, which is to not block forever. e.g. If the upstream caller knows a round has ended, then it should cancel all associated contexts, not block on an unbounded one forever. Only after we have exhausted the standard patterns for context usage should we start trying to invent new complexities. It has not been stated clearly where the idiomatic approaches fall short.
0704599
to
9b8b97a
Compare
https://smartcontract-it.atlassian.net/browse/BCF-2887
Bump libocr and react to context.Context signature changes.
Requires:
Supports: