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

chore: generic change to reduce the number of compilation warnings #2696

Merged
merged 7 commits into from
May 16, 2024

Conversation

Ivansete-status
Copy link
Collaborator

Description

Simple but long (sorry for that) PR that aims to reduce the number of compilation warnings.

  • Compilation warnings related to "imported module but not used".
  • Changes around async: (raises:[..]) pragma
  • re is deprecated
  • Make proc's not to raise exceptions. This is a little bit beyond the original purpose of the PR. I can submit it in a separate one if you consider appropriate.

Copy link

github-actions bot commented May 13, 2024

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:2696-rln-v1

Built from dc59888

Copy link

github-actions bot commented May 13, 2024

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:2696-rln-v2

Built from dc59888

@Ivansete-status Ivansete-status force-pushed the avoid-compilation-warnings branch 3 times, most recently from 0735440 to c2a6bb3 Compare May 15, 2024 10:37
@Ivansete-status Ivansete-status marked this pull request as ready for review May 15, 2024 11:20
@darshankabariya darshankabariya self-requested a review May 15, 2024 11:23
Copy link
Contributor

@gabrielmer gabrielmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's reaally nice! Thanks so much!

Just added a couple questions

@@ -312,13 +311,13 @@ proc startMaintainingSubscriptions(wf: WakuFilter, interval: Duration) =

wf.maintenanceTask = setTimer(Moment.fromNow(interval), maintainSubs)

method start*(wf: WakuFilter) {.async.} =
method start*(wf: WakuFilter) {.async, base.} =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to understand, why do we need the base pragma?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For proper inheritance I think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comments @gabrielmer , @SionoiS !
This change actually comes from a compiler warning, where it stated that it was deprecated to use non-base methods (I can't remember the precise message.)

Comment on lines 48 to 65
try:
await connection.writeLP(filterSubscribeRequest.encode().buffer)

let respBuf = await connection.readLp(DefaultMaxSubscribeResponseSize)
let respDecodeRes = FilterSubscribeResponse.decode(respBuf)
if respDecodeRes.isErr():
trace "Failed to decode filter subscribe response", servicePeer
waku_filter_errors.inc(labelValues = [decodeRpcFailure])
return err(FilterSubscribeError.badResponse(decodeRpcFailure))

let response = respDecodeRes.get()

if response.requestId != filterSubscribeRequest.requestId:
trace "Filter subscribe response requestId mismatch", servicePeer, response
waku_filter_errors.inc(labelValues = [requestIdMismatch])
return err(FilterSubscribeError.badResponse(requestIdMismatch))

if response.statusCode != 200:
trace "Filter subscribe error response", servicePeer, response
waku_filter_errors.inc(labelValues = [errorResponse])
let cause =
if response.statusDesc.isSome():
response.statusDesc.get()
else:
"filter subscribe error"
return err(FilterSubscribeError.parse(response.statusCode, cause = cause))
except CatchableError:
let errMsg = "exception in waku_filter_v2 client: " & getCurrentExceptionMsg()
trace "exception in waku_filter_v2 client", error = getCurrentExceptionMsg()
waku_filter_errors.inc(labelValues = [errMsg])
return err(FilterSubscribeError.badResponse(errMsg))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it be better for the try block to be more scoped?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it be better for the try block to be more scoped?

Yes, you are absolutely right! I tried to apply that in 06546bb

Copy link
Contributor

@SionoiS SionoiS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such a good clean-up. Amazing!

@@ -31,7 +31,7 @@ import
../testlib/wakucore,
../testlib/wakunode

procSuite "WakuNode - Store":
procSuite "WakuNode - Store Legacy":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah thanks I totally forgot about renaming tests!

Comment on lines +446 to +449
try:
await node.wakuFilter.start()
except CatchableError:
error "failed to start wakuFilter", error = getCurrentExceptionMsg()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't like the catch: macro?

Suggested change
try:
await node.wakuFilter.start()
except CatchableError:
error "failed to start wakuFilter", error = getCurrentExceptionMsg()
let catchable = catch: await node.wakuFilter.start()
if catchable.isErr():
error "failed to start wakuFilter", error = catchable.error.msg

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SionoiS We would need better a valueOrCatch macro... hm, due I don't think catch works together with valueOr template.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SionoiS We would need better a valueOrCatch macro... hm, due I don't think catch works together with valueOr template.

Yes it's unfortunate, otherwise this would be possible

(catch: await node.wakuFilter.start()).isOkOr:
   error "failed to start wakuFilter", error = error.msg

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SionoiS We would need better a valueOrCatch macro... hm, due I don't think catch works together with valueOr template.

Yes it's unfortunate, otherwise this would be possible

(catch: await node.wakuFilter.start()).isOkOr:
   error "failed to start wakuFilter", error = error.msg

Well we can add! I may do it somewhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't like the catch: macro?

Well, I "don't like" maybe because I don't fully understand it xD
To me, it sounds a bit more verbose the traditional approach but I'll give it another glance ;P

@@ -312,13 +311,13 @@ proc startMaintainingSubscriptions(wf: WakuFilter, interval: Duration) =

wf.maintenanceTask = setTimer(Moment.fromNow(interval), maintainSubs)

method start*(wf: WakuFilter) {.async.} =
method start*(wf: WakuFilter) {.async, base.} =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For proper inheritance I think?

Copy link
Contributor

@NagyZoltanPeter NagyZoltanPeter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Spartaaa!!!! ... I would say so after our greek tour, but I better say: It is amazing and very needed PR. Special thank for the depricate net lib warning elimination!

Comment on lines +446 to +449
try:
await node.wakuFilter.start()
except CatchableError:
error "failed to start wakuFilter", error = getCurrentExceptionMsg()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SionoiS We would need better a valueOrCatch macro... hm, due I don't think catch works together with valueOr template.

@Ivansete-status Ivansete-status force-pushed the avoid-compilation-warnings branch from 06546bb to 13921f1 Compare May 16, 2024 16:21
@Ivansete-status Ivansete-status merged commit 78132dc into master May 16, 2024
14 of 15 checks passed
@Ivansete-status Ivansete-status deleted the avoid-compilation-warnings branch May 16, 2024 20:29
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