-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
refactor: use go context instead of sdk.Context #14050
Conversation
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.
LGTM
[Cosmos SDK] Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
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.
going to merge this now so I can continue on another pr but would like @AmauryM or someone to confirm there is no need to unwrap the context like we do in other places
maybe do a wrap on the caller side, on the callee side the ctx is not used at all. |
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.
LGTM like this.
Where do you want to unwrap? It seems the ctx
arg is not used in the File streaming service (though still good to keep it on the interface for other implementations maybe)
would the caller need to unwrap before using it? since we are passing context.Context I was think we may need to unwrap before passing it to avoid unwrapping in the caller. |
Ah I see. Yeah, as @yihuang suggested, maybe let's do a wrap on the caller side, e.g. here: Line 204 in 721b174
(and all other instances in baseapp). I think it's a terrible idea that sdk.Context implements context.Context, we don't catch these statically. Maybe it will work as-is, but I would prefer a |
dfb4c8a
to
a2cb92f
Compare
@@ -201,7 +201,10 @@ | |||
|
|||
// call the hooks with the BeginBlock messages | |||
for _, streamingListener := range app.abciListeners { | |||
if err := streamingListener.ListenBeginBlock(app.deliverState.ctx, req, res); err != nil { | |||
|
|||
goCtx := sdk.WrapSDKContext(app.deliverState.ctx) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
@@ -226,7 +229,9 @@ | |||
|
|||
// call the streaming service hooks with the EndBlock messages | |||
for _, streamingListener := range app.abciListeners { | |||
if err := streamingListener.ListenEndBlock(app.deliverState.ctx, req, res); err != nil { | |||
goCtx := sdk.WrapSDKContext(app.deliverState.ctx) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
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 @tac0turtle!
Why is this a problem @AmauryM? What is the issue it's causing? |
In this issue, it was confusing whether a2cb92f was needed or not. If sdk.Context didn't implement context.Context, then we would catch this with the compiler. I think I prefer the explicitness of wrapping and unwrapping between sdk.Context and context.Context. |
Calling |
Ah okay, so @tac0turtle my bad about asking you to add it, it was confusing to me too. |
sweet, it didnt error on me, but was super unclear. Ill undo it and then mark wrapsdkContext as deprecated? |
That would be great. Sorry I forgot to mark it as deprecated when I did this refactor. |
all good #14072 modified here |
Description
Use go context on abcilistener instead of sdk native context.
Im not sure if I need to unwrap the context before?
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change