celestiaorg / celestiaorg/go-header
Migrate from mocknet to x/simlibp2p for libp2p test simulations
- Dominant language
- Go
- Stars
- 21
- Forks
- 33
- Avg merge
- 5d 20h
- Merged PRs (30d)
- 7
Description
## Context
The libp2p team is deprecating the `mocknet` package (`github.com/libp2p/go-libp2p/p2p/net/mock`) in favor of the new `x/simlibp2p` package. See [this comment](https://github.com/libp2p/go-libp2p/pull/3471#issuecomment-3975833470) from @MarcoPolo:
> We recently released the simlibp2p package under `x/simlibp2p`. That's the preferred way to simulate networks in tests as it supports everything a real QUIC transport supports and properly models congestion.
>
> I think we should deprecate our mocknet package. We aren't using it anywhere within go-libp2p, and I don't want to spend time maintaining it when we have a better alternative.
## Problem
`mocknet` has known limitations — for example, its streams don't support deadlines (`SetWriteDeadline` returns an error), which breaks gossipsub peer discovery in tests when pubsub uses write deadlines (introduced in [libp2p/go-libp2p-pubsub#631](https://github.com/libp2p/go-libp2p-pubsub/pull/631)). We currently work around this with a [fork](https://github.com/celestiaorg/go-libp2p/tree/fix/mocknet-deadline-noop) that noops the deadline methods.
`simlibp2p` uses real QUIC transport over simulated UDP, so it properly supports deadlines, congestion modeling, and all transport features without workarounds.
## References
- `x/simlibp2p` package: https://github.com/libp2p/go-libp2p/tree/master/x/simlibp2p
- Upstream PR comment: https://github.com/libp2p/go-libp2p/pull/3471#issuecomment-3975833470
- Current workaround: https://github.com/celestiaorg/go-libp2p/tree/fix/mocknet-deadline-noop
Contributor guide
Research direction
Start by locating the repository's uses of the deprecated mocknet package, then read the x/simlibp2p package and the linked upstream guidance. Migrate the relevant test simulations away from mocknet and remove the deadline workaround where it is no longer needed. Done means the affected tests pass with simulated QUIC and no mocknet dependency remains.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- networking, testing-qa
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100