1067 Commits

Author SHA1 Message Date
web3-bot
ee9c8434f9
ci: uci/update-go (#638)
This PR was created automatically by the @web3-bot as a part of the
[Unified CI](https://github.com/ipdxco/unified-github-workflows)
project.
2025-08-21 10:13:04 +02:00
Marco Munizaga
abb8f8a2cd
Release v0.14.2 (#629)
Includes #627
2025-07-03 13:44:54 -07:00
Marco Munizaga
bc7e2e619d
Skip 32-bit tests in CI (#628)
This is roughly a third of our CI time, and, as far as I know, running
32bit tests has never caught an issue.

Also, I'm unaware of anyone using this library on a 32bit x86 system. I
believe the last 32bit x86 CPU released was the [pentium
4](https://en.wikipedia.org/wiki/List_of_Intel_Pentium_4_processors)
close to 20 years ago.
2025-07-03 12:04:07 -07:00
Marco Munizaga
631e47b133
Fix test races and enable race tests in CI (#626)
closes #624
2025-07-03 11:37:53 -07:00
Marco Munizaga
e38c340f93
Fix race when calling Preprocess and msg ID generator(#627)
Closes #624
2025-07-03 11:10:37 -07:00
Marco Munizaga
ae65ce484e
Release v0.14.1 (#623)
Includes #622
2025-06-25 16:15:26 -07:00
Marco Munizaga
fedbccc0c6
fix(BatchPublishing): Make topic.AddToBatch threadsafe (#622)
topic.Publish is already thread safe. topic.AddToBatch should strive to
follow similar semantics.

Looking at how this would integrate with Prysm, they use separate
goroutines per message they'd like to batch.
2025-06-25 12:38:21 -07:00
Marco Munizaga
3f89e4331c
Release v0.14.0 (#614)
This release contains a couple fixes and the new Batch Publishing
feature.

- #607 Batch Publishing. Useful if you are publishing a group of related
messages at once
- #612 Send IDONTWANT before initial publish. Useful when many nodes may
publish the same message at once.
- #609 Avoid sending an extra "IDONTWANT" to the peer that just sent you
a message.
- #615 10x faster rpc splitting.
2025-05-29 15:58:51 -07:00
Marco Munizaga
c405ca8028
refactor: 10x faster RPC splitting (#615)
Builds on #582. 10x faster than current master. 0 allocs.

The basic logic is the same as the old version, except we return an
`iter.Seq[RPC]` and yield `RPC` types instead of a slice of `*RPC`. This
lets us avoid allocations for heap pointers.

Please review @algorandskiy, and let me know if this improves your use
case.
2025-05-28 22:32:25 -07:00
Marco Munizaga
38ad16a687
test: Fix flaky TestMessageBatchPublish (#616)
Messages where being dropped in the validation queue if the machine was
not fast enough.
2025-05-27 09:04:26 -07:00
Marco Munizaga
9e5145fb29
Send IDONTWANT before first publish (#612)
See #610 

We previously send IDONTWANT only when forwarding. This has us send
IDONTWANT on our initial publish as well. Helps in the case that one or
more peers may also publish the same thing at around the same time (see
#610 for a longer explanation) and prevents "boomerang" duplicates where
a peer sends you back the message you sent before you get a chance to
send it to them.

This also serves as a hint to a peer that you are about to send them a
certain message.
2025-05-19 17:02:21 -07:00
Marco Munizaga
0c5ee7bbfe
feat(gossipsub): Add MessageBatch (#607)
to support batch publishing messages

Replaces #602.

Batch publishing lets the system know there are multiple related
messages to be published so it can prioritize sending different messages
before sending copies of messages. For example, with the default API,
when you publish two messages A and B, under the hood A gets sent to D=8
peers first, before B gets sent out. With this MessageBatch api we can
now send one copy of A _and then_ one copy of B before sending multiple
copies.

When a node has bandwidth constraints relative to the messages it is
publishing this improves dissemination time.

For more context see this post:
https://ethresear.ch/t/improving-das-performance-with-gossipsub-batch-publishing/21713
2025-05-08 10:23:02 -07:00
Marco Munizaga
50ccc5ca90
fix(IDONTWANT)!: Do not IDONTWANT your sender (#609)
We were sending IDONTWANT to the sender of the received message. This is
pointless, as the sender should not repeat a message it already sent.
The sender could also have tracked that it had sent this peer the
message (we don't do this currently, and it's probably not necessary).

@ppopth
2025-04-30 10:58:50 +03:00
web3-bot
95a070affb
ci: uci/copy-templates (#604)
This PR was created automatically by the @web3-bot as a part of the
[Unified CI](https://github.com/ipdxco/unified-github-workflows)
project.
2025-03-28 19:05:04 +01:00
Hlib Kanunnikov
68726389f2
feat: WithValidatorData publishing option (#603)
Micro optimization that helps preventing deserialization of published
messages in local subscribtions
2025-03-13 12:59:39 +02:00
Aayush Rajasekaran
f486808fbe
feat: avoid repeated checksum calculations (#599)
We don't need to recalculate the checksum for each peer.
2025-02-24 00:39:38 +02:00
Andrew Gillis
b50197ee8b
Upgrade go-libp2p to v0.39.1 (#598) 2025-02-18 05:41:46 -08:00
web3-bot
bfcc7c4889
ci: uci/update-go (#595)
This PR was created automatically by the @web3-bot as a part of the
[Unified CI](https://github.com/ipdxco/unified-github-workflows)
project.
2025-02-16 22:31:20 +01:00
Marco Munizaga
9b90c72ced
Release v0.13.0 (#593) 2025-02-06 20:19:16 -05:00
Pop Chunhapanya
bf5b583843
Allow cancelling IWANT using IDONTWANT (#591)
As specified in the Gossipsub v1.2 spec, we should allow cancelling
IWANT by IDONTWANT.

That is if IDONTWANT already arrived, we should not process IWANT.

However due to the code structure, we can cancel IWANT only in
handleIWant.


https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.2.md#cancelling-iwant
2024-12-30 22:25:26 +02: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
Nishant Das
3536508a9d
Fix the Router's Ability to Prune the Mesh Periodically (#589)
When a new peer wants to graft us into their mesh, we check our current
mesh size to determine whether we can add any more new peers to it. This
is done to prevent our mesh size from being greater than `Dhi` and
prevent mesh takeover attacks here:


c06df2f9a3/gossipsub.go (L943)

During every heartbeat we check our mesh size and if it is **greater**
than `Dhi` then we will prune our mesh back down to `D`.

c06df2f9a3/gossipsub.go (L1608)

However if you look closely at both lines there is a problematic end
result. Since we only stop grafting new peers into our mesh if our
current mesh size is **greater than or equal to** `Dhi` and we only
prune peers if the current mesh size is greater than `Dhi`.

This would result in the mesh being in a state of stasis at `Dhi`.
Rather than float between `D` and `Dhi` , the mesh stagnates at `Dhi` .
This would end up increasing the target degree of the node to `Dhi` from
`D`. This had been observed in ethereum mainnet by recording mesh
interactions and message fulfillment from those peers.

This PR fixes it by adding an equality check to the conditional so that
it can be periodically pruned. The PR also adds a regression test for
this particular case.
2024-12-26 20:02:14 +02:00
Yahya Hassanzadeh, Ph.D.
c06df2f9a3
Add Function to Enable Application Layer to Send Direct Control Messages (#562)
### PR Description

This PR addresses https://github.com/libp2p/go-libp2p-pubsub/issues/561;
i.e., adding a new `SendControl` function to the `GossipSubRouter`. This
will allow the application layer to send direct control messages to
peers, facilitating finer-grained testing.
2024-10-18 23:28:24 +03:00
Pavel Zbitskiy
f71345c1ec
Do not format expensive debug messages in non-debug levels in doDropRPC (#580)
In high load scenarios when consumer is slow, `doDropRPC` is called
often and makes extra unnecessary allocations formatting `log.Debug`
message.

Fixed by checking log level before running expensive formatting.

Before:
```
BenchmarkAllocDoDropRPC-10    	13684732	        76.28 ns/op	     144 B/op	       3 allocs/op
```

After:
```
BenchmarkAllocDoDropRPC-10    	28140273	        42.88 ns/op	     112 B/op	       1 allocs/op
```
2024-09-25 09:33:35 +03:00
Andrew Gillis
4c13974188
Update go-libp2p to latest (#578)
- Update to go-libp2p v0.36.3
2024-09-09 08:42:16 -07:00
web3-bot
b8a6a868ad
ci: uci/update-go (#577)
This PR was created automatically by the @web3-bot as a part of the
[Unified CI](https://github.com/ipdxco/unified-github-workflows)
project.
2024-08-26 16:58:30 +02:00
sukun
1aeb6ebc6a
chore: upgrade go-libp2p (#575)
Co-authored-by: Steven Allen <steven@stebalien.com>
2024-08-16 19:57:24 +03: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
Steven Allen
19ffbb3a48
Re-enable disabled gossipsub test (#566)
And change it to take into account the fact that libp2p now trims
connections immediately (when no grace-period is specified) instead of
waiting for a timeout.
2024-08-06 20:43:28 +00:00
Steven Allen
dc33a34d4d
ci: disable testing on macos (#571)
It appears to be a bit flaky and we have nothing macos specific in this repo.
2024-08-06 20:43:14 +00:00
Piotr Galar
5c9a4d0536 ci: create go-test-config.json 2024-08-06 19:52:49 +00: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
galargh
435b99e317 chore: go fmt 2024-08-06 19:52:49 +00:00
web3-bot
03952ea658 chore: add or force update version.json 2024-08-06 19:52:49 +00:00
web3-bot
ca1b3dabb7 chore: add or force update .github/workflows/tagpush.yml 2024-08-06 19:52:49 +00:00
web3-bot
b32ed641c0 chore: add or force update .github/workflows/release-check.yml 2024-08-06 19:52:49 +00:00
web3-bot
7c54be0278 chore: add or force update .github/workflows/releaser.yml 2024-08-06 19:52:49 +00:00
web3-bot
db70c1d678 chore: add or force update .github/workflows/go-check.yml 2024-08-06 19:52:49 +00:00
web3-bot
88c73f4a89 chore: add or force update .github/workflows/go-test.yml 2024-08-06 19:52:49 +00:00
Sorin Stanculeanu
e508d8643d
added missing Close call on the AddrBook member of GossipSubRouter (#568) 2024-07-11 18:25:52 +03:00
Steven Allen
093f13ce16
test: test notify protocols updated (#567)
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Co-authored-by: gfanton <8671905+gfanton@users.noreply.github.com>
2024-07-11 12:50:34 +00:00
Steven Allen
b23b3ee559
Switch to the new peer notify mechanism (#564)
1. Only listen for peers added and identify events.
2. Remove the old "Limited" check. Peers only show up as "Connected" if
they have non-limited connections.
3. Don't bother listening for new connections directly and/or
connectivity changes. We'll get a new identify event per new connection
regardless.

fixes #546
2024-07-11 11:46:35 +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
Mikel Cortes
8e498e9e96
Missing flood protection check for number of message IDs when handling Ihave messages (#560)
* check msgIDs in Ihave per topic

* remove coments as suggested
2024-06-27 12:00:36 +03:00
Marco Munizaga
dbd1c9eade
Fix: Own our CertifiedAddrBook (#555)
* Subscribe to libp2p events to maintain our own Certified Address Book

* Update go version

* Use TestGossipsubStarTopology test instead of new test

* Don't return an error in manageAddrBook

* Return on error while subscribing

* Use null resource manager so that the new IP limit doesn't break tests

* Mod tidy
2024-05-20 17:13:30 -07:00
Hlib Kanunnikov
7038c82c21
chores: bump go-libp2p (#558) 2024-05-20 16:20:16 -07:00
Marco Munizaga
3aa9d671ae
fix: Don't bother parsing an empty slice (#556) 2024-05-02 09:41:05 -07:00
Marco Munizaga
c0a528ee7b
Replace fragmentRPC with appendOrMergeRPC (#557)
This will allow us to add more logic around when we split/merge
messages. It will also allow us to build the outgoing rpcs as we go
rather than building one giant rpc and then splitting it.
2024-05-02 09:40:54 -07:00
GitHub
048a4d30d0 chore: Update .github/workflows/stale.yml [skip ci] 2024-01-31 16:51:10 +00:00