Skip to content

Conversation

@skaunov
Copy link
Contributor

@skaunov skaunov commented Oct 10, 2025

Description

superseeds #6176, see #6176 (comment) for some details.

@skaunov skaunov changed the title fix[kad]: enable putting Record with None publisher in a confus… fix: enable putting Record with None publisher in a confus… Oct 10, 2025
@jxs jxs changed the title fix: enable putting Record with None publisher in a confus… feat(kad): enable putting Record without publisher Oct 20, 2025
Copy link
Member

@jxs jxs left a comment

Choose a reason for hiding this comment

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

Hi, and thanks for the cleaned up version.
left some suggestions

Comment on lines 567 to 568
// this test relies on counting republished `Record` against `records.len()`
records.retain(|r| r.publisher.is_some());
Copy link
Member

Choose a reason for hiding this comment

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

can we then add a new test for new_anonymous?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have not get any new ideas since #6176 (comment).

Notes & open questions

I don't have a fine test for this in mind as it doesn't really do anything (because replication context doesn't yield an event). Simultaneously I'm not really satisfied with the approach I took to adapt/fix the test (retaining only Record with publisher: Some); but I need a hint if that's possible to do better due to the same fact of how silent replication is.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, yeah I missed that, but then we don't need to do double iteration, this should work:

diff --git a/protocols/kad/src/behaviour/test.rs b/protocols/kad/src/behaviour/test.rs
index 41d03f4f77..f8f1ee0134 100644
--- a/protocols/kad/src/behaviour/test.rs
+++ b/protocols/kad/src/behaviour/test.rs
@@ -562,11 +562,7 @@
 /// is equal to the configured replication factor.
 #[test]
 fn put_record() {
-    fn prop(mut records: Vec<Record>, seed: Seed, filter_records: bool, drop_records: bool) {
-        tracing::trace!("remove records without a publisher");
-        // this test relies on counting republished `Record` against `records.len()`
-        records.retain(|r| r.publisher.is_some());
-
+    fn prop(records: Vec<Record>, seed: Seed, filter_records: bool, drop_records: bool) {
         let mut rng = StdRng::from_seed(seed.0);
         let replication_factor =
             NonZeroUsize::new(rng.gen_range(1..(K_VALUE.get() / 2) + 1)).unwrap();
@@ -613,6 +609,7 @@
         #[allow(clippy::mutable_key_type)] // False positive, we never modify `Bytes`.
         let records = records
             .into_iter()
+            // Exclude records without a publisher.
+            .filter(|r| r.publisher.is_some())
             .take(num_total)
             .map(|mut r| {
                 // We don't want records to expire prematurely, as they would

Copy link
Contributor Author

@skaunov skaunov Oct 21, 2025

Choose a reason for hiding this comment

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

Have it work for you? Looking at the checks below I read it that it doesn't pass anymore.

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