-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add concurrency and scale testing #22
Conversation
WalkthroughThis update enhances the overall reliability and efficiency of the system by introducing timeout settings in CI tests, optimizing stream management in the P2P communication code, and improving concurrency control in state management. Additionally, a new comprehensive test suite for a four-node threshold signature scheme is added, ensuring robust testing of key generation and signing processes under various conditions. Changes
Sequence Diagram(s)sequenceDiagram
participant CI
participant TestJob
participant StreamManager
participant PeerGroup
participant LocalStateMgr
participant TSS
CI->>TestJob: Start tests with timeout
TestJob->>StreamManager: Manage streams
StreamManager->>PeerGroup: Check for valid subscriber
PeerGroup->>StreamManager: Valid/Invalid
StreamManager->>StreamManager: Add/Close stream based on check
LocalStateMgr->>LocalStateMgr: Acquire read lock
LocalStateMgr->>LocalStateMgr: Access shared state
LocalStateMgr->>LocalStateMgr: Release read lock
TSS->>TSS: Run four-node threshold signature tests
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
WARNING: DATA RACE Read at 0x00c005b2f898 by goroutine 50785: gitlab.com/thorchain/tss/go-tss/p2p.(*StreamMgr).ReleaseStream() /home/alex/workspace/github.com/zeta-chain/go-tss/p2p/stream_helper.go:53 +0x1f0 gitlab.com/thorchain/tss/go-tss/p2p.(*Communication).ReleaseStream() /home/alex/workspace/github.com/zeta-chain/go-tss/p2p/communication.go:484 +0x104 gitlab.com/thorchain/tss/go-tss/tss.(*TssServer).KeySign.func1() /home/alex/workspace/github.com/zeta-chain/go-tss/tss/keysign.go:219 +0xc4 runtime.deferreturn() /usr/local/go/src/runtime/panic.go:602 +0x5c gitlab.com/thorchain/tss/go-tss/tss.(*FourNodeScaleZetaSuite).doTestConcurrentKeySign.func1() /home/alex/workspace/github.com/zeta-chain/go-tss/tss/tss_4nodes_zeta_test.go:198 +0x294 gitlab.com/thorchain/tss/go-tss/tss.(*FourNodeScaleZetaSuite).doTestConcurrentKeySign.gowrap1() /home/alex/workspace/github.com/zeta-chain/go-tss/tss/tss_4nodes_zeta_test.go:203 +0x44 Previous write at 0x00c005b2f898 by goroutine 72246: gitlab.com/thorchain/tss/go-tss/p2p.(*StreamMgr).AddStream() /home/alex/workspace/github.com/zeta-chain/go-tss/p2p/stream_helper.go:76 +0x13c gitlab.com/thorchain/tss/go-tss/p2p.(*Communication).readFromStream() /home/alex/workspace/github.com/zeta-chain/go-tss/p2p/communication.go:176 +0x334 gitlab.com/thorchain/tss/go-tss/p2p.(*Communication).handleStream() /home/alex/workspace/github.com/zeta-chain/go-tss/p2p/communication.go:195 +0x10c gitlab.com/thorchain/tss/go-tss/p2p.(*Communication).handleStream-fm() <autogenerated>:1 +0x44 github.com/libp2p/go-libp2p/p2p/host/basic.(*BasicHost).SetStreamHandler.func1() /home/alex/go/pkg/mod/github.com/zeta-chain/go-libp2p@v0.0.0-20240710192637-567fbaacc2b4/p2p/host/basic/basic_host.go:580 +0xb4 github.com/libp2p/go-libp2p/p2p/host/basic.(*BasicHost).newStreamHandler.gowrap1() /home/alex/go/pkg/mod/github.com/zeta-chain/go-libp2p@v0.0.0-20240710192637-567fbaacc2b4/p2p/host/basic/basic_host.go:421 +0x6c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
Outside diff range, codebase verification and nitpick comments (3)
tss/tss_4nodes_zeta_test.go (1)
128-135
: Use a more descriptive error message.The panic message should be more descriptive to aid in debugging.
- panic(err) + panic(fmt.Sprintf("Failed to generate random hash: %v", err))p2p/communication.go (1)
180-183
: Ensure proper logging for stream closure.Add a log message when the stream is closed to aid in debugging.
- _ = stream.Close() + if err := stream.Close(); err != nil { + c.logger.Error().Err(err).Msg("Failed to close stream") + } else { + c.logger.Debug().Msg("Stream closed successfully") + }p2p/party_coordinator.go (1)
75-78
: Ensure proper logging for stream closure.Add a log message when the stream is closed to aid in debugging.
- _ = stream.Close() + if err := stream.Close(); err != nil { + pc.logger.Error().Err(err).Msg("Failed to close stream") + } else { + pc.logger.Debug().Msg("Stream closed successfully") + }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- .github/workflows/ci.yml (1 hunks)
- p2p/communication.go (1 hunks)
- p2p/party_coordinator.go (1 hunks)
- p2p/stream_helper.go (2 hunks)
- storage/localstate_mgr.go (1 hunks)
- tss/tss_4nodes_zeta_test.go (1 hunks)
Additional comments not posted (4)
.github/workflows/ci.yml (1)
23-23
: Confirm the correctness of the timeout flag and syntactical adjustment.The addition of the
-timeout 25m
flag is beneficial for preventing tests from running indefinitely, improving the reliability of the CI pipeline. The change from--race
to-race
is a minor syntactical adjustment but should be verified for correctness.p2p/stream_helper.go (2)
51-51
: Ensure thread safety when reading fromunusedStreams
.The read lock is correctly used to ensure thread safety when accessing
unusedStreams
.
61-61
: Confirm the correctness of deleting the "UNKNOWN" entry.Deleting the "UNKNOWN" entry from the
unusedStreams
map helps prevent potential memory leaks or stale references, enhancing the cleanup process.storage/localstate_mgr.go (1)
116-119
: Ensure thread safety when accessingkeyGenState
.The introduction of read locks around the access to the
keyGenState
map helps prevent race conditions when multiple goroutines access the shared state concurrently, enhancing concurrency control.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM; at the same time I agree with @fbac that closing a stream in a consumer is not a good idea, however it's not your choice per se (but a rebasing thing)
Add some custom tests to determine the limits and stability of the library.
Fix some data race issues found by the new tests. Also backport fb3ceba which I missed when I rebased the library (this fixes some more data races).
Related to zeta-chain/node#2562
Summary by CodeRabbit
New Features
Improvements
Bug Fixes