-
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
Closed
jmank88
wants to merge
1
commit into
smartcontractkit:main
from
jmank88:BCF-2887-context-propagation
Closed
add context #33
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
go 1.20 | ||
go 1.21 | ||
|
||
toolchain go1.21.7 | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
module github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin | ||
|
||
go 1.20 | ||
go 1.21 | ||
|
||
toolchain go1.21.7 | ||
|
||
replace github.com/smartcontractkit/libocr => github.com/jmank88/libocr v0.0.0-20240425103000-0eed0c09969e | ||
|
||
require ( | ||
github.com/google/go-cmp v0.5.9 | ||
github.com/smartcontractkit/libocr v0.0.0-20230503222226-29f534b2de1a | ||
github.com/smartcontractkit/tdh2/go/tdh2 v0.0.0-20230616062456-5c32c95fc166 | ||
github.com/stretchr/testify v1.3.0 | ||
google.golang.org/protobuf v1.30.0 | ||
github.com/stretchr/testify v1.7.0 | ||
google.golang.org/protobuf v1.31.0 | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect | ||
github.com/mr-tron/base58 v1.2.0 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/sirupsen/logrus v1.6.0 // indirect | ||
github.com/sirupsen/logrus v1.9.3 // indirect | ||
github.com/stretchr/objx v0.1.0 // indirect | ||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect | ||
golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912 // indirect | ||
golang.org/x/crypto v0.17.0 // indirect | ||
golang.org/x/sys v0.15.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 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.
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
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
Am I reading this correctly that you are unhappy with the docs? But then why ask to merge the original PR?
But many of these will not have a deadline!? They only expire once
offchainreporting2plus.Oracle.Close()
is called or there is asetConfig
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.
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.
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.
Adding a good deadline for these is tricky for a few reasons, here are some of them:
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.