Skip to content

p2p feature PR: CR fixes#6038

Merged
algorandskiy merged 13 commits intoalgorand:feature/p2pfrom
algorandskiy:pavel/p2p-cr-fixes
Jun 21, 2024
Merged

p2p feature PR: CR fixes#6038
algorandskiy merged 13 commits intoalgorand:feature/p2pfrom
algorandskiy:pavel/p2p-cr-fixes

Conversation

@algorandskiy
Copy link
Copy Markdown
Contributor

@algorandskiy algorandskiy commented Jun 20, 2024

Summary

Addressed most code review items from #5939

Additionally fixed two data races:

  1. peerstore data race seen in this build
  2. logrus.Formatter concurrent access seen locally

Also fixed node.ledger descriptors leak that prevented ./nodetest -race to pass due to extra connection opened by libp2p

Remaining items:

@algorandskiy algorandskiy added Skip-Release-Notes p2p Work related to the p2p project labels Jun 20, 2024
@algorandskiy algorandskiy requested review from cce and gmalouf June 20, 2024 20:15
@algorandskiy algorandskiy self-assigned this Jun 20, 2024
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 20, 2024

Codecov Report

Attention: Patch coverage is 52.08333% with 23 lines in your changes missing coverage. Please review.

Project coverage is 56.12%. Comparing base (0dd0cb7) to head (c8af9fb).

Files Patch % Lines
data/txHandler.go 23.07% 9 Missing and 1 partial ⚠️
network/p2p/peerstore/peerstore.go 78.94% 4 Missing ⚠️
network/hybridNetwork.go 0.00% 2 Missing ⚠️
network/p2p/logger.go 0.00% 2 Missing ⚠️
network/p2pNetwork.go 0.00% 2 Missing ⚠️
daemon/algod/server.go 0.00% 1 Missing ⚠️
network/p2p/http.go 0.00% 1 Missing ⚠️
network/wsNetwork.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           feature/p2p    #6038   +/-   ##
============================================
  Coverage        56.11%   56.12%           
============================================
  Files              488      488           
  Lines            69419    69427    +8     
============================================
+ Hits             38957    38965    +8     
- Misses           27807    27814    +7     
+ Partials          2655     2648    -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@algorandskiy algorandskiy requested a review from jasonpaulos June 21, 2024 18:22
var host interface{} = req.Host
addrOrPeerID := req.Host
// p2p/http clients have per-connection transport and address info so use that
if len(req.Host) == 0 && req.URL != nil && len(req.URL.Host) == 0 {
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.

Just thinking out loud — there's no way a weird HTTP request that didn't come through libp2p HTTP mode could force an invalid cast to (*peer.AddrInfo) below for a URL by requesting an empty host or something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good point, added a type check and return an error. That's why we practice CR :)


// networkNames: lists the networks to which the given address belongs.
networkNames map[string]bool
mu *deadlock.RWMutex
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.

a quick git grep deadlock.RWMutex shows that in the rest of the codebase we seem to always use deadlock.RWMutex as a value not a pointer.. but I guess that would require storing *addressData in the metadata instead of a value?

Suggested change
mu *deadlock.RWMutex
networkNamesMu deadlock.RWMutex

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it have to be a pointer since there are type casts and copying

Copy link
Copy Markdown
Contributor

@jasonpaulos jasonpaulos left a comment

Choose a reason for hiding this comment

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

Addressed my concerns, and the other changes look good as well (especially getting rid of the interface{} types)

@algorandskiy algorandskiy merged commit 8a584dd into algorand:feature/p2p Jun 21, 2024
@algorandskiy algorandskiy deleted the pavel/p2p-cr-fixes branch March 16, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p2p Work related to the p2p project Skip-Release-Notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants