The Libp2p Pubsub Testnet (libp2p-pstn
) is a utility for initializing arbitrary networks of libp2p nodes connected by some topology. It provides useful benchmarking tools for designing and implementing p2p pubsub/messaging strategies and is composed of modules from the libp2p-pstn-*
ecosystem.
To install through npm:
> npm i libp2p-pstn --save
Run the UI client with the default topology (ring) and default/example pubsub events:
> npm start
Go to http://localhost:8080
in your browser. Open the console for logs, or just click the "Start Testnet Runner" button to kick off the pubsub test. Events will stream in followed by propagation stats and the full event log.
If you want to swap the topology (with a mesh or your own function) or rework the script for which nodes subscribe to what and who send what, open the runner.js
file in the root and customize the run
function. It should be pretty straightforward.
v0.0.3 Release Notes:
- If you refresh the client UI, you need to restart the server. This will be fixed soon.
- Using pregenerated full keys now and the handshake takes a while, so I've only spun up a few hundred nodes with this release
- The stats are basic, need to build this out
- This is the initial interface for working with nodes on a single process. It can be improved and will need to expand to support logging from multiple processes and the like
Nodes in the the network are structured as follows:
{
peerInfo: <peer_info_instance>,
libp2p: <libp2p_nstance>,
id: <peer_info_id_b58>,
pubsub: <pubsub_node_instance>
}
Returns a js-libp2p-pstn-stats
instance built from pubsub node activity event logs.
To run the UI client:
> npm start
To run the tests:
> npm test
libp2p-pstn
is composed of a small, developing ecosystem for testing p2p messaging strategies in libp2p
. They follow the libp2p-pstn-*
convention.
libp2p-pstn-logger
: Decorates a pubsub node instance and logs under thepstn:logger
namespace in a format consumable by a stats parser (repo). Currently built to work with floodsub.
libp2p-pstn-stats
: Generates in basic stats for a testnet instance based on logs from all pubsub node activity (repo).
-
libp2p-pstn-topo-*
: Topologies used to connect a testnet instance. -
libp2p-pstn-topo-ring
: Ring topology (repo). -
libp2p-pstn-topo-partialmesh
: Partial mesh topology with 2 connections per peer (repo).
PRs are welcome!
MIT © Gavin McDermott