22 Commits

Author SHA1 Message Date
Marco Munizaga
631e47b133
Fix test races and enable race tests in CI (#626)
closes #624
2025-07-03 11:37:53 -07:00
Nishant Das
0936035d5f
Improve IDONTWANT Flood Protection (#590)
In this PR we add in a new config parameter called `MaxIDontWantLength`
which would be very similarly used as `MaxIHaveLength` has been used of
`IHAVE` messgaes . This parameter has been set as the value of `10` now.

The main purpose is to bring how IDONTWANT messages are handled in line
with how IHAVE have been handled. We add the relevant changes to the
`handleIDontWant` method along with adding in a new regression test for
this check.
2024-12-28 13:49:13 +02:00
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
galargh
097b4671b0 chore: staticcheck 2024-08-06 19:52:49 +00:00
galargh
8f56e8c97a chore: update rand usage 2024-08-06 19:52:49 +00:00
Steven Allen
1f5b81fb61
test: use the regular libp2p host (#565)
This removes dependencies on swarm/testing and the blank host.

1. swarm/testing really shouldn't be used at all except for internal
libp2p stuff.
2. The blank host should only be used in _very_ special cases (autonat,
mostly).
2024-07-11 10:32:18 +00: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
Ian Davis
2efd313b83
cleanup: fix vet and staticcheck failures (#435)
* cleanup: fix vet failures and most staticcheck failures

* Fix remaining staticcheck failures

* Give test goroutines chance to exit early when context is canceled
2021-07-22 15:27:32 -07:00
vyzo
d6c20b59fc remove multi-topic message support 2020-10-08 20:18:21 +03:00
Raúl Kripalani
ae55bf9603 upgrade deps + interoperable uvarint delimited writer/reader. 2020-07-30 14:00:54 +03:00
vyzo
fedb87bd57 deflake TestGossipsubAttackSpamIHAVE
travis managed to take more than 3 seconds for one or two heartbeat sleeps; give it 10 seconds.
2020-05-08 21:20:04 +03:00
vyzo
2dc46af415 update tests for quadratic p4 2020-05-08 21:20:04 +03:00
vyzo
883f8b8c92 update IHAVE spam test to test for behavioural tests because of broken promises 2020-05-08 16:45:31 +03:00
vyzo
5363d59203 better backoff handling
- Specify backoff in PRUNE message
- Obey peer backoff if specified
- Remove BackoffPenalty, handle lack of respect for backoff through P7
2020-05-07 01:45:04 +03:00
vyzo
11ef2a9cf2 fix the global variable mutation races 2020-04-22 21:08:13 +03:00
vyzo
a50deb04c0 a little bit more time to avoid races with restoring mutated config variables 2020-04-22 21:08:13 +03:00
vyzo
6a230e711e add a heartbeat's worth of delay before restoring mutated globals
the race detector cries on travis
2020-04-22 21:08:13 +03:00
vyzo
7efd666dc4 increase wait time for IWANT spam test to 1s 2020-04-22 21:08:13 +03:00
vyzo
a645afd1b3 add backoff penalty for GRAFT floods 2020-04-20 19:53:12 +03:00
vyzo
8150843cf3 improve handling of IHAVE floods 2020-04-20 19:53:12 +03:00
vyzo
78bbe13b49 fix data races in spam tests 2020-04-20 19:53:12 +03:00
vyzo
9b28f21a6b rename gossipsub_attack_test to gossipsub_spam_test 2020-04-20 19:53:12 +03:00