chore: replace Option with Opt#4035
Conversation
* change all usage of std.options.Option[T] to results.Opt[T] * fix broken apps and examples (to validate refactor) * removed all std/options code added for libp2p v2 migration * add broker Opt codec to persistency/backend_comm.nim * add a readValue overload for Opt[T] in tools/confutils/cli_args.nim * keep Option where required (Presto, confutils' config_file.nim)
|
This PR may contain changes to configuration options of one of the apps. If you are introducing a breaking change (i.e. the set of options in latest release would no longer be applicable) make sure the original option is preserved with a deprecation note for 2 following releases before it is actually removed. Please also make sure the label |
|
This PR may contain changes to database schema of one of the drivers. If you are introducing any changes to the schema, make sure the upgrade from the latest release to this change passes without any errors/issues. Please make sure the label |
|
You can find the image built from this PR at Built from 1092b96 |
Ivansete-status
left a comment
There was a problem hiding this comment.
LGTM! Thanks for it! 💯
It sounds interesting to submit a separate PR to adjust the REST/presto part.
Cheers.
| waitFor c.node.rln.generateRLNProof(message.toRLNSignal(), float64(time)) | ||
| try: | ||
| waitFor c.node.rln.generateRLNProof(message.toRLNSignal(), float64(time)) | ||
| except CatchableError: |
There was a problem hiding this comment.
I wonder if we could instead handle the possible exception inside generateRLNProof so that we have better granularity of where it occurred. And therefore we can annotate that proc with .async: (raises: []).
| if args.ethRpcEndpoint == "": | ||
| # Create a basic configuration for the Waku node | ||
| # No RLN as we don't have an ETH RPC Endpoint | ||
| conf.mode = Core |
There was a problem hiding this comment.
These changes seems aside from PR's purpose.
There was a problem hiding this comment.
Yes I explained above, the examples don't compile.
| const discv5Port = 9000 | ||
|
|
||
| proc setupAndPublish(rng: ref HmacDrbgContext) {.async.} = | ||
| proc setupAndPublish(rng: crypto.Rng) {.async.} = |
There was a problem hiding this comment.
I'm fine with that but seems unrelated?
There was a problem hiding this comment.
Yes, the examples are broken. I'm fixing them here.
| import logos_delivery/waku/compat/option_valueor | ||
| import std/[atomics, options, macros] | ||
| import chronicles, chronos, chronos/threadsync, ffi | ||
| import std/[atomics, macros], chronicles, chronos, chronos/threadsync, ffi |
There was a problem hiding this comment.
nit, even though we not always do, we traditionally separated imports in three categories:
- std
- explicit nimbledeps (former vendor deps.)
- internal modules
| import std/[atomics, macros], chronicles, chronos, chronos/threadsync, ffi | |
| import std/[atomics, macros] | |
| import chronicles, chronos, chronos/threadsync, ffi |
| import | ||
| std/sets, | ||
| chronos, | ||
| web3, | ||
| stew/byteutils, | ||
| stint, | ||
| results, | ||
| chronicles, | ||
| logos_delivery/waku/incentivization/rpc, | ||
| tests/waku_rln_relay/utils_onchain |
There was a problem hiding this comment.
| import | |
| std/sets, | |
| chronos, | |
| web3, | |
| stew/byteutils, | |
| stint, | |
| results, | |
| chronicles, | |
| logos_delivery/waku/incentivization/rpc, | |
| tests/waku_rln_relay/utils_onchain | |
| import | |
| std/sets, | |
| chronos, | |
| web3, | |
| stew/byteutils, | |
| stint, | |
| results | |
| import | |
| chronicles | |
| import | |
| logos_delivery/waku/incentivization/rpc, | |
| tests/waku_rln_relay/utils_onchain |
| mixin mtMarshalSizeValue | ||
| result = sizeof(uint8) | ||
| if value.isSome(): | ||
| result += mtMarshalSizeValue(value.get()) |
There was a problem hiding this comment.
Let's avoid the use of implicit result value.
There was a problem hiding this comment.
Ugh, classic Claude.
There was a problem hiding this comment.
Besides the point, but I still want resurrect the Styler project sometime in the future. We've been using GenAI for a few months now, and I guess now I have better ideas about how to automate these recurrent style checks.
| std/options, | ||
| std/[strformat, sugar], | ||
| results, | ||
| chronicles, | ||
| uri, | ||
| json_serialization, | ||
| presto/route |
There was a problem hiding this comment.
| std/options, | |
| std/[strformat, sugar], | |
| results, | |
| chronicles, | |
| uri, | |
| json_serialization, | |
| presto/route | |
| std/options, | |
| std/[strformat, sugar], | |
| results | |
| import | |
| chronicles, | |
| uri, | |
| json_serialization, | |
| presto/route |
| chronicles, | ||
| chronos, | ||
| chronos/apps/http/httpserver | ||
| std/[strutils, net], regex, results, chronicles, chronos, chronos/apps/http/httpserver |
There was a problem hiding this comment.
| std/[strutils, net], regex, results, chronicles, chronos, chronos/apps/http/httpserver | |
| std/[strutils, net], regex, results | |
| import chronicles, chronos, chronos/apps/http/httpserver |
| import | ||
| chronicles, | ||
| eth/keys, | ||
| stew/[arrayops, endians2], | ||
| stint, | ||
| results, | ||
| ./rln_interface, | ||
| ../conversion_utils, | ||
| ../protocol_types, | ||
| ../protocol_metrics |
There was a problem hiding this comment.
| import | |
| chronicles, | |
| eth/keys, | |
| stew/[arrayops, endians2], | |
| stint, | |
| results, | |
| ./rln_interface, | |
| ../conversion_utils, | |
| ../protocol_types, | |
| ../protocol_metrics | |
| import stew/[arrayops, endians2], | |
| stint, | |
| results | |
| import | |
| chronicles, | |
| eth/keys | |
| import | |
| ./rln_interface, | |
| ../conversion_utils, | |
| ../protocol_types, | |
| ../protocol_metrics |
| import | ||
| results, | ||
| chronicles, | ||
| chronos, | ||
| metrics, | ||
| ./common, | ||
| ./rpc, | ||
| ./rpc_codec, | ||
| ../node/peer_manager |
There was a problem hiding this comment.
| import | |
| results, | |
| chronicles, | |
| chronos, | |
| metrics, | |
| ./common, | |
| ./rpc, | |
| ./rpc_codec, | |
| ../node/peer_manager | |
| import | |
| results | |
| import | |
| chronicles, | |
| chronos, | |
| metrics | |
| import | |
| ./common, | |
| ./rpc, | |
| ./rpc_codec, | |
| ../node/peer_manager |
* Change generateRlnProof error handling * Fix imports * Remove result use
NagyZoltanPeter
left a comment
There was a problem hiding this comment.
My claude review found no serious issues with it. IMHO its better to get into master asap due to the wide blast of change radius.
Thanks for it.
Follow-up to the rebase onto master's repo-wide Option[T] -> Opt[T] change (#4035). Converts the code this branch adds to the new convention: - messaging/rest_api/types.nim: MessagingJsonEnvelope fields to Opt[T], Opt.some/Opt.none, and json_serialization/pkg/results instead of json_serialization/std/options. - tests: WakuNodeConf.clusterId is now Opt[uint16]; DTO fields are Opt. `Option[ContentBody]` in the handlers is presto's own API and stays as-is. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…bility (#4014) * WIP logosdeliverynode app initial commit * WIP - extra cli option * WIP: messaging client REST endpoints * Add event poll for messaging rest with cache mechanism * Messaging rest tests * test: assert 404 via raw string client in messaging REST test presto's typed REST client raises RestDecodingError when it cannot decode a non-2xx text error body into the response type. Add a RestResponse[string] stub (messagingGetSendEventsByIdRawV1) and point the "already-polled id -> 404" assertion at it, matching the relay REST test pattern. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * remove customized cli args as confutils has no support for it * Introduce --entry-layer and re-introduce --mode flags into cli args, applied new driver into LogosDelivery + tests * Add messaging REST client test * Add docker image build of logosdeliverynode for CI builds * Fix tests * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Refactor Messaging REST API to better match Messaging Send and Receive APIs * chore: migrate messaging REST API to Opt[T] Follow-up to the rebase onto master's repo-wide Option[T] -> Opt[T] change (#4035). Converts the code this branch adds to the new convention: - messaging/rest_api/types.nim: MessagingJsonEnvelope fields to Opt[T], Opt.some/Opt.none, and json_serialization/pkg/results instead of json_serialization/std/options. - tests: WakuNodeConf.clusterId is now Opt[uint16]; DTO fields are Opt. `Option[ContentBody]` in the handlers is presto's own API and stays as-is. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Description
This PR refactors the code to use Opt in place of Option.
Some tricky bits in the port that you'll notice when reviewing this PR:
marshal,unmarshal, and alsosize;Changes
Issue
closes #3955