27 Commits

Author SHA1 Message Date
Pop Chunhapanya
b421b3ab05
GossipSub v1.2: IDONTWANT control message and priority queue. (#553)
## GossipSub v1.2 implementation

Specification: libp2p/specs#548

### Work Summary
Sending IDONTWANT

Implement a smart queue
Add priorities to the smart queue

    Put IDONTWANT packets into the smart priority queue as soon as the node gets the packets

Handling IDONTWANT

Use a map to remember the message ids whose IDONTWANT packets have been received
Implement max_idontwant_messages (ignore the IDONWANT packets if the max is reached)
Clear the message IDs from the cache after 3 heartbeats

    Hash the message IDs before putting them into the cache.

More requested features

    Add a feature test to not send IDONTWANT if the other side doesnt support it

### Commit Summary

* Replace sending channel with the smart rpcQueue

Since we want to implement a priority queue later, we need to replace
the normal sending channels with the new smart structures first.

* Implement UrgentPush in the smart rpcQueue

UrgentPush allows you to push an rpc packet to the front of the queue so
that it will be popped out fast.

* Add IDONTWANT to rpc.proto and trace.proto

* Send IDONTWANT right before validation step

Most importantly, this commit adds a new method called PreValidation to
the interface PubSubRouter, which will be called right before validating
the gossipsub message.

In GossipSubRouter, PreValidation will send the IDONTWANT controll
messages to all the mesh peers of the topics of the received messages.

* Test GossipSub IDONWANT sending

* Send IDONWANT only for large messages

* Handle IDONTWANT control messages

When receiving IDONTWANTs, the host should remember the message ids
contained in IDONTWANTs using a hash map.

When receiving messages with those ids, it shouldn't forward them to the
peers who already sent the IDONTWANTs.

When the maximum number of IDONTWANTs is reached for any particular
peer, the host should ignore any excessive IDONTWANTs from that peer.

* Clear expired message IDs from the IDONTWANT cache

If the messages IDs received from IDONTWANTs are older than 3
heartbeats, they should be removed from the IDONTWANT cache.

* Keep the hashes of IDONTWANT message ids instead

Rather than keeping the raw message ids, keep their hashes instead to
save memory and protect again memory DoS attacks.

* Increase GossipSubMaxIHaveMessages to 1000

* fixup! Clear expired message IDs from the IDONTWANT cache

* Not send IDONTWANT if the receiver doesn't support

* fixup! Replace sending channel with the smart rpcQueue

* Not use pointers in rpcQueue

* Simply rcpQueue by using only one mutex

* Check ctx error in rpc sending worker

Co-authored-by: Steven Allen <steven@stebalien.com>

* fixup! Simply rcpQueue by using only one mutex

* fixup! Keep the hashes of IDONTWANT message ids instead

* Use AfterFunc instead implementing our own

* Fix misc lint errors

* fixup! Fix misc lint errors

* Revert "Increase GossipSubMaxIHaveMessages to 1000"

This reverts commit 6fabcdd068a5f5238c5280a3460af9c3998418ec.

* Increase GossipSubMaxIDontWantMessages to 1000

* fixup! Handle IDONTWANT control messages

* Skip TestGossipsubConnTagMessageDeliveries

* Skip FuzzAppendOrMergeRPC

* Revert "Skip FuzzAppendOrMergeRPC"

This reverts commit f141e13234de0960d139339acb636a1afea9e219.

* fixup! Send IDONWANT only for large messages

* fixup! fixup! Keep the hashes of IDONTWANT message ids instead

* fixup! Implement UrgentPush in the smart rpcQueue

* fixup! Use AfterFunc instead implementing our own

---------

Co-authored-by: Steven Allen <steven@stebalien.com>
2024-08-16 18:16:35 +03:00
Marten Seemann
4f56e8f0a7
update go-libp2p to v0.22.0 (#498)
* update go-libp2p to v0.22.0

* skip TestGossipsubConnTagMessageDeliveries
2022-08-26 02:45:41 -07:00
Wondertan
f9b2412210 fix: use RawID in traceRPCMeta to avoid allocations 2022-01-23 09:29:32 +02:00
Wondertan
0e687f24a6 feat: integrate msgIdGenerator 2022-01-23 09:29:32 +02:00
Michael Muré
65f48fb2c8 rename RawTracer's DroppedInSubscribe into UndeliverableMessage 2021-07-13 08:58:00 -07:00
Michael Muré
9be1c593c6 add a new RawTracer event to track messages dropped in Subscribe 2021-07-13 08:58:00 -07:00
Michael Muré
50b1cfadc8 expose more events for RawTracer 2021-07-13 08:58:00 -07:00
vyzo
5457a2845b expose internalTracer as RawTracer 2021-03-16 08:28:02 +02:00
vyzo
352c6b993e populate receivedFrom field in delivery trace 2020-12-16 20:17:23 +02:00
vyzo
d6c20b59fc remove multi-topic message support 2020-10-08 20:18:21 +03:00
vyzo
93f4f91dcf trace throttle peers to avoid breaking promises unfairly 2020-09-07 13:38:02 +03:00
vyzo
5a3055d33a track topics in Reject/Duplicate/Deliver events 2020-07-31 19:15:31 +03:00
vyzo
d3ae6ab3a7 extended internal tracing for multiple objects, not just score 2020-05-08 16:45:31 +03:00
vyzo
e17e266aa9 track message delivery time within the validation pipeline 2020-04-18 11:09:06 +03:00
vyzo
455a836d7d hook the tracer for peer scoring 2020-04-18 11:09:06 +03:00
vyzo
2e7cdebf34 trace peer exchange 2020-03-24 15:52:34 +02:00
Yusef Napora
a4d562cb83 set sendTo to remote peer id in trace events 2020-03-15 21:00:39 -04:00
protolambda
7981f9bfbd
fixes #247: implement msg id function as pubsub option 2019-12-16 03:54:40 +01:00
vyzo
0aa629c79c use *pb.TraceEvent as argument for Trace in the EventTracer interface 2019-11-15 20:42:04 +02:00
vyzo
8ff321c529 move tracer implementation to its own file 2019-11-15 20:42:04 +02:00
vyzo
3545acf029 json tracer 2019-11-15 20:42:04 +02:00
vyzo
3f30acdcf7 track topics in message tracing 2019-11-15 20:42:04 +02:00
vyzo
ae0fcc6b4d add traces for send/drop rpc
forgotten!
2019-11-15 20:42:04 +02:00
vyzo
151ec25616 implement tracing details 2019-11-15 20:42:04 +02:00
vyzo
fb11aa9857 initialize tracer with peer ID, trace RPC from join/leave announcements 2019-11-15 20:42:04 +02:00
vyzo
89c7ed46e3 trace publish 2019-11-15 20:42:04 +02:00
vyzo
67275a6382 tracing scaffolding 2019-11-15 20:42:04 +02:00