How are there no servers - RenegadeMinds/testbed GitHub Wiki

How Are There No Servers?

Games on the XAYA platform can run serverless and upstoppable. They are resistant to censorship. But exactly how that happens may seem like black magic to some. Here, the magician reveals his tricks!

How Traditional Game Servers Work

Before examining how XAYA games run serverless, we must examine the traditional online game with a game server. The following diagram illustrates the relationships between the server and game clients.

Traditional online game server

This is a very familiar scenario.

The game server contains a database and processes all the important game logic. It then relays information to the game clients, who then run minor game logic and display the game for the player.

Client-Server Components

The main components of the server and client are:

  1. Game server
    1. Database on server
    2. Game logic on server
  2. Game client
    1. Limited game logic
    2. Front end or display logic
  3. The internet

The XAYA Architecture

The XAYA blockchain is a decentralised data store. There are 3 main components to a XAYA application or game.

  1. XAYA daemon
  2. Game state processor
  3. Front end

3 main parts

The XAYA daemon (xayad) is the software that interfaces with the XAYA blockchain. It has a JSON-RPC interface to create accounts, make moves in games, etc.

The Game State Processor (GSP) is where moves are processed and new game states are created.

The front end is where the game is displayed for players. It consumes game states. All the blockchain goodness is invisible to them and "just works".

Replacing the Client-Server Relationship with P2P Nodes

For XAYA, instead of client-server relationships, we have P2P nodes interacting with each other.

The following diagram is analogous to the diagram above for a game server with the client-server relationship replace by nodes.

XAYA P2P network

The XAYA "client" is a node that connects to the network via P2P and all nodes then relay information to each other. This happens incredibly fast and is near real time, just as the above network with a game server is near real time.

NOTE: Servers are generally on top of internet backbones and enjoy a speed advantage over P2P networks where additional node jumps may be required. Delays between fast servers at 10+ ms and P2P networks at 50~250 ms may be signficant in some games, but insignificant in other games. However, as the advantage/disadvantage applies equally to all players, the games are still fair.

This is how the server is replaced, i.e. with P2P nodes.

Another Way to See It

You can think of it this way:

  1. The XAYA daemon replaces:
    1. The server's network functionality with a P2P network and,
    2. The server's database with the XAYA blockchain.
  2. The GSP replaces:
    1. The server's game logic as all game logic is run by all nodes.
  3. The GSP gets data from the database/blockchain, i.e. through the XAYA daemon.
  4. The GSP processes all game logic that would be done on either the server or the client and passes that to the front end. (The GSP runs on the client/node.)
  5. The front end displays the game state, or more simply, it just displays the game for people to play.

You can visualise the role movement as shown in the following diagram.

Role movement for decentralisation

TADA! Done.

It's really that simple.

While there's a truckload of code behind all of that, that's what happens.

Pure. Blockchain. Magic.

⚠️ **GitHub.com Fallback** ⚠️