Components

Transactor

The Transactor is a server that plays a crucial role in Race Protocol by acting as the central coordinator and facilitator of game interactions and transactions. Its primary responsibilities include:

  • Calculating Game State: The Transactor maintains the current state of the game based on the initial game data and the stream of events received from players and other servers.

  • Making Settlement Transactions: When a game concludes, the Transactor prepares and submits a settlement transaction to the blockchain. This transaction distributes winnings, handles player exits, and updates the game account with the final state.

  • Generating Randomness: The Transactor utilizes a secure P2P randomization process with other validator servers to generate randomness for the game. This randomness is used for various purposes, such as dealing cards or determining turn order.

  • Receiving Client Events: The Transactor receives game events from player clients via the Race SDK. These events represent player actions and decisions within the game.

  • Broadcasting Events: The Transactor broadcasts events to all connected participants, including players and validator servers. This ensures that everyone has a consistent view of the game state and its progress.

The Transactor interacts with the blockchain by:

  • Reading Game Account Data: The Transactor initially reads the game data from the on-chain game account to initialize the game state.

  • Submitting Settlement Transactions: As mentioned earlier, the Transactor submits settlement transactions to the blockchain to update the game account and distribute assets according to the game outcome.

The Transactor also interacts with other components:

  • Validator Servers: The Transactor collaborates with validator servers during the P2P randomization process to generate unpredictable and verifiable randomness for the game.

  • Clients: The Transactor receives events from player clients and broadcasts events to all participants, ensuring everyone has a synchronized view of the game.

Validator

Validator servers act as independent verifiers and contributors to the randomization process. Their primary responsibilities include:

  • Calculating Game State: Similar to the Transactor, validator servers maintain their own copy of the game state based on the initial data and received events. This allows them to independently verify the game's progress and ensure its integrity.

  • Voting on Transactor Inactivity: If the Transactor becomes unresponsive or behaves suspiciously, validator servers can vote to declare it inactive. When enough votes are gathered, the game is halted, and intervention is required to resolve the issue.

  • Generating Randomness: Validator servers participate in the P2P randomization process with the Transactor. They contribute their own random values and verify the overall randomness generation, ensuring it is unpredictable and fair.

Validator servers interact with the blockchain by:

  • Reading Game Account Data: Validators read the initial game data from the on-chain game account to initialize their local game state.

They also interact with the Transactor:

  • Randomization Process: Validators collaborate with the Transactor during the P2P randomization process to generate and verify the randomness used in the game.

Game Bundle

A Game Bundle is a WASM package that contains the compiled Rust code representing the core logic of a game. This bundle is published as an NFT on the blockchain, allowing for ownership and access control.

The process of publishing and accessing a game bundle involves:

  • Uploading WASM data to Decentralized Storage: The WASM data is uploaded to a decentralized storage solution like IPFS or Arweave.

  • Minting an NFT: An NFT is minted on the blockchain that points to the WASM data stored off-chain. This NFT represents ownership of the game bundle and allows developers to control access and potentially earn royalties.

  • Accessing the Game Logic: When a game account is created, it references the address of the corresponding game bundle NFT. The Transactor and validator servers then fetch the WASM data from the decentralized storage using the information in the NFT.

This approach allows for efficient storage and access of game logic while leveraging the benefits of blockchain technology for ownership and transparency.

Client

The client-side implementation of Race Protocol consists of the Race SDK, a TypeScript library that allows players to interact with the game and the Transactor server. The SDK handles tasks such as:

  • Connecting to the Transactor: The SDK establishes a secure connection with the Transactor server to send and receive game events and state updates.

  • Loading and Executing the Game Bundle: The SDK fetches the WASM game bundle from the decentralized storage and executes it in a secure sandbox environment on the client side.

  • Sending and Receiving Events: The SDK facilitates the exchange of game events between the player and the Transactor. Players send events representing their actions, and the Transactor broadcasts state updates and events to all connected clients.

  • Decrypting Hidden Information: When enough secrets are shared by the Transactor, the SDK can decrypt hidden information, such as player hands or random values, allowing players to see the complete game state.

The client-side runtime environment can be visualized as follows:

  1. Player interacts with the game UI.

  2. The Race SDK translates player actions into game events.

  3. The SDK sends the events to the Transactor server.

  4. The Transactor updates the game state and broadcasts events to all connected clients.

  5. The SDK receives events and updates the game state on the client side.

  6. The SDK may decrypt hidden information when enough secrets are available.

  7. The game UI is updated to reflect the latest game state.

This interaction between the client, SDK, and Transactor ensures a synchronized and secure gameplay experience for all participants.

Last updated