ajuna-network / worker

SubstraTEE worker for SubstraTEE node
Apache License 2.0
8 stars 1 forks source link

Create a new game in the sgx-runtime #5

Closed haerdib closed 2 years ago

haerdib commented 2 years ago

In a next step, for every new imported and validated parentchain block we query the queued game state of the node GameQueues. If games are found, we create an ack_game extrinsic with all game hashes, including our tee_id (extrinsic signature should probably contain all information already), and send it to the node. The next validateer importing this ack_game extrinsic will check the following:

If everything passed, the validateer will create the game, include it in the sidechain block, that will be broadcasted to its peers. The peers will import sidechain block and include the new game in their registry. Only then, they will import the parentchain block containing the ack_extrinsic, which will not be executed, as the game has been registered already.

Tasks:

darkfriend77 commented 2 years ago

@darkfriend77 did I get that correct with the queue_game extrinsic of layer one that triggers a new game?

@haerdib after at least 2 players used gameRegistry.queue(), the gameregistry will start to create games and add them into the game queue. queue_game, is only internally executed by the on_initialize which is getting matches from the matchmaker and creates game.

GameRegistry (1)

Testing the game is pretty simple.

  1. Launch ajuna-node (branch: https://github.com/ajuna-network/ajuna-node/tree/ajuna-network)

  2. Queue Alice, gameRegistry.queue()

  3. Queue Bob, gameRegistry.queue()

After that, a queue should exist with one game_id

At this point L1 is waiting on Ajuna TEE to acknowledge a game .... once TEE has created the game it should call.

  1. AjunaTEE, gameRegistry.ackGame(...)

After acknowledging the queue should be empty again and the game in the registry should have changed it's state from waiting to accept.

once the Ajuna TEE reads that the game is accepted it can set the game engine on running

haerdib commented 2 years ago

Here's a proposed sequence diagram:

ajuna_block_import

I hope this makes somewhat sense. If you detect an issue, please let me know immediately.

haerdib commented 2 years ago

With https://github.com/ajuna-network/worker/commit/00f336e6832c63586443bdb63b9f17b8b57b996f we have successfully demonstrated the creation of a new game. So I'm closing this issue for now.