fix(pstoreds): Fix cyclic batch threshold handling and add error checking for peer ID decoding#3274
Open
tomasandroil wants to merge 4 commits intolibp2p:masterfrom
Open
fix(pstoreds): Fix cyclic batch threshold handling and add error checking for peer ID decoding#3274tomasandroil wants to merge 4 commits intolibp2p:masterfrom
tomasandroil wants to merge 4 commits intolibp2p:masterfrom
Conversation
Collaborator
|
Can you please add new tests for this as well? Thanks! |
Author
|
@MarcoPolo I have added the requested unit tests for both cyclic batch threshold handling and peer ID decoding error handling |
Author
|
Hi @MarcoPolo!
Let me know if you need anything else! 🔧 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request improves robustness and correctness in the
pstoredspackage by:cyclicBatchthreshold initialization that could cause unintended immediate commits.uniquePeerIdsto skip invalid datastore entries instead of causing potential panics.uniquePeerIds.Changes
thresholdfield innewCyclicBatch.base32.RawStdEncoding.DecodeStringandpeer.IDFromByteswhen extracting peer IDs.cyclic_batch_test.gowith a test verifying that batching only happens after the configured threshold is reached.peerstore_test.gowith a test verifying that invalid datastore entries are gracefully skipped inuniquePeerIds.Motivation
Robust error handling and correct thresholding are critical in persistent peerstore operations to ensure system stability, especially under datastore corruption scenarios or large-scale peer management.
Adding unit tests ensures that regressions in these critical code paths are less likely to occur in the future.
Testing
All new unit tests pass:
go test ./p2p/host/peerstore/pstoreds/...No regressions in existing functionality.