Libp2p real-time games, and social features

Disclaimer

  1. I’m not looking for code snippets or API references from specific implementations of libp2p, I’m just interested in having a worthwhile discussion so I can better brainstorm how I want the architecture for my project.

  2. I’m also not interested in blockchain, or crypto seeing as how libp2p does seem to have a somewhat dominant use case in those topics.

  3. I’m also not creating an FPS, so low-latency RTTs and/or high tick rates are more of a luxury feature in my current context.

  4. I plan to make primary use of the QUIC transport since I’ve seen some (non-libp2p) projects make use of it in real-time applications before, instead of using UDP with some homemade spice to make it a good fit for real-time games.


Realtime games

I’m invested in developing a game that needs worlds to sync in real-time, and I first want to know if anyone that has worked with libp2p knows that it can handle more than creating chat and/or file sharing apps. I only ask that because every Google search ends up talking about IPFS or other popular p2p/federated social platforms.

My current thoughts, and digging around in documentation have led me to three “backbones” of the architecture if you will; Rendezvous, Gossipsub, and Kad-DHT.

Rendezvous

Their prominent role is the “entry-point” for users to connect to and use the public network, finding joinable worlds, online users, etc…

Gossipsub

Possibly a more odd use-case for this protocol, using “Topics” as worlds that users “Subscribe” or join/connect to, and those users can “Publish” the changes they make to the world (i.e, an object they moved, a synced variable they changed like a boolean, etc…)

Kad-DHT

A distributed store of joinable worlds/topics, online users, available circuit relays, etc…

My main question

Is any of what I’ve written here a reasonable use case of libp2p and its protocols? The main thing that I’m possibly overthinking is if I’m going a little too outside the box in what I could use Gossipsub for, mainly the real-time world syncing, even if I were to make use of data compression before sending said data.

However, if you know, or believe it’s theoretically possible as a use case for libp2p, I’m also trying to find any papers on creating some form of “user profile” system that could be used in a p2p context, seeing as I want to allow users to add friends, and have some form of social presence on the platform so users can easily connect without the need for 3rd-party apps to communicate what their new PeerID is after they reconnect to the network.


Social features

As brought up before, I’m trying to find research or talks about creating user “profiles” that users/peers can use to easily find each other over the network without having to communicate what their new PeerIDs are when they reconnect to the network.

My initial thought is to make use of Kad-DHT as a distributed database for holding basic user social info, however, that brought up the question of how that data is protected, and if I could make use of a more convenient username and password method of gaining access to that data.

Of course, this is all coming from the idea I have that it’s probably not good practice to not generate a new keyring every time a peer wants to reconnect to the network. However, if that’s not the case, that could simplify everything regarding user profiles.

1 Like

Hey,
Cool use-case you are thinking of for p2p communications. So, as i understand you have few requirements:

  1. Sync state of players that are part of a game.
  2. Have some form of entry-point to the game, basically like a game board where can people can know which worlds are online and join etc.

You are right in looking to solve this via gossipsub. But rather than building these services on top, I would suggest that you take a look at Waku(a suite of protocols built on top of libp2p that provide various services).
Some of the services that Waku provides include:

  • relaying information across the network(via gossipsub). This could be useful for syncing changes published by users in the game. Waku also provides an abstraction on top of gossipSub with a concept of content-topics which you can use to filter out messages that are interesting for a user.
  • You second requirement matches with what the Store service Waku provides.
    These use-cases are very similar to a decentralized group chat (which is being built by Status on top of Waku)

We are also coming up with a public messaging relay and service network that would help relay messages across gossipSub network.

Would love to brainstorm more about your use-case as i am also thinking of coming up with building blocks that are required for decentralized gaming and am currently working on Waku. You can reach out to us via discord or continue the discussion further.

Hey!
I’m currently working on a Metaverse project, and I wanted to try using libp2p for some player interaction other then only messaging. I was searching for good use cases using the GossipSub protocol and I found your post, I was thinking on some world sync stuff too, but I’m afraid about latency between players… have you tested already this protocol on a real time game?

Unfortunately, I haven’t been able to get to a point that I am able to properly test the protocol in a real-time world syncing setting, I’m still learning how to integrate libp2p into a game engine, while switching jobs.

I too have the concern of latency with using GossipSub as a real-time protocol, however, I believe it should work if you where to treat world changes to non-static objects and data as individual messages, only when those objects are moved, or a synced variable is changed, instead of a full world state sync. Then latency would simply be down to the physical distance between players, and their internet speeds.