Skip to content

add results to peer lookup and tests#8146

Open
agnxsh wants to merge 6 commits intounstablefrom
lpcgc
Open

add results to peer lookup and tests#8146
agnxsh wants to merge 6 commits intounstablefrom
lpcgc

Conversation

@agnxsh
Copy link
Copy Markdown
Contributor

@agnxsh agnxsh commented Mar 21, 2026

No description provided.

@agnxsh agnxsh changed the title Lpcgc add results to peer lookup and tests Mar 21, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 21, 2026

Unit Test Results

         9 files   -          3    1 869 suites   - 619   36m 13s ⏱️ - 12m 37s
12 988 tests +       16  12 441 ✔️ +       16  547 💤 ±  0  0 ±0 
49 241 runs   - 16 347  48 605 ✔️  - 16 273  636 💤  - 74  0 ±0 

Results for commit c25677f. ± Comparison against base commit 2e451a4.

♻️ This comment has been updated with latest results.

peer = peer, status = remoteCgcResult.status
peer.updateScore(PeerScoreNoValues)
return intersection
let remoteCustodyGroupCount = remoteCgcResult.value
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This pattern is partly why Result exists though.

That is, yes, on inspection this is correct, but it's still not encapsulating the in-principle-unsafe case object access. Result has the ?, valueOr, etc helpers which, yes, ultimately do something similar, but are tested separately to be correct in this capacity. This code contains the equivalent of a direct foo.get or foo.unsafeGet, even if it is guarded appropriately.

The purpose of Result, then, is partly do allow ultimately something like:

  let remoteCustodyGroupCount = remoteCgcResult.valueOr:
    debug "Failed to lookup cgc from peer",
      peer = peer, status = remoteCgcResult.status
    peer.updateScore(PeerScoreNoValues)
    return intersection

to be written instead.

Ideally, the Nimbus codebase can, consistently with broad efficiency, minimize direct/statically-unsafe (treating nim-results as safe, for this purpose, because it is at least tested), avoid this kind of code as much as feasible.

return false
let
remoteCustodyGroupCount = peer.lookupCgcFromPeer()
remoteCustodyGroupCount = remoteCgcResult.value
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Similarly to the other comment, this is another equivalent-to-.get/.unsafeGet code style which could cause a runtime Defect and would be improved by using Result or Opt (i.e. Result with an error type of void).

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.

2 participants