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

network: handle empty wsPeer supplied to transaction handler #6195

Merged
merged 6 commits into from
Dec 20, 2024

Conversation

algorandskiy
Copy link
Contributor

Summary

There is a race between pubsub new peer discovery and wsPeer registration:

{"time":"2024-12-04T16:42:43.237595Z","log":"[signal SIGSEGV: segmentation violation code=0x1 addr=0xa0 pc=0x1a46d72]"}
{"time":"2024-12-04T16:42:43.237610Z","log":"goroutine 1012678170 [running]:"}
{"time":"2024-12-04T16:42:43.237617Z","log":"github.com/algorand/go-algorand/network.(*wsPeer).RoutingAddr(0xc02a57b588?)"}
{"time":"2024-12-04T16:42:43.237623Z","log":"\tgithub.com/algorand/go-algorand/network/wsPeer.go:387 +0x12"}
{"time":"2024-12-04T16:42:43.237628Z","log":"github.com/algorand/go-algorand/data.(*TxHandler).incomingTxGroupAppRateLimit(0xc0000fec60, {0xc0b02a6008, 0x1, 0x2}, {0x2c51360, 0x0})"}
{"time":"2024-12-04T16:42:43.237634Z","log":"\tgithub.com/algorand/go-algorand/data/txHandler.go:722 +0xcd"}

Suggested fix is to use gsPeer temporary type good enough for tx handler.

Additional fixes:

  • Fix wsPeer's closers potential data dace by adding a mutex controlling access to it
  • Use Peer instead of wsPeer for broadcastRequest.except comparison so that get rid of runtime type cast.

Test Plan

Added a test confirming txTopicValidator does not call tx handler with an empty wsPeer.

Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 6 lines in your changes missing coverage. Please review.

Project coverage is 51.86%. Comparing base (b7b3e5e) to head (388dbc8).
Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
network/p2pNetwork.go 55.55% 4 Missing ⚠️
network/wsPeer.go 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6195      +/-   ##
==========================================
- Coverage   51.88%   51.86%   -0.02%     
==========================================
  Files         639      639              
  Lines       85489    85495       +6     
==========================================
- Hits        44359    44346      -13     
- Misses      38320    38339      +19     
  Partials     2810     2810              

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

network/p2pNetwork.go Outdated Show resolved Hide resolved
network/wsPeer.go Show resolved Hide resolved
@gmalouf gmalouf removed their assignment Dec 10, 2024
Copy link
Contributor

@gmalouf gmalouf left a comment

Choose a reason for hiding this comment

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

I'm generally okay with this pending questions CCE asked.

I'd probably add one additional sentence or a title tweak highlighting the problem being solved (it's a race condition that folks ran into on mainnet as I recall, just took some digging to find).

@algorandskiy
Copy link
Contributor Author

What does the gs in gsPeer stand for?

gossip or gossipSub

gmalouf
gmalouf previously approved these changes Dec 11, 2024
cce
cce previously approved these changes Dec 12, 2024
@algorandskiy algorandskiy dismissed stale reviews from cce and gmalouf via bf4c30c December 17, 2024 21:16
@algorandskiy algorandskiy requested review from cce and gmalouf December 17, 2024 21:16
@algorandskiy algorandskiy force-pushed the pavel/txhandler-nil-wsp2 branch from bf4c30c to 388dbc8 Compare December 17, 2024 21:52
@cce cce merged commit 005495b into algorand:master Dec 20, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants