Skip to content

[Dev]: Deterministic tournament operations #101

@TylerBloom

Description

@TylerBloom

Unmet Need:

The Squire model for communication between clients and the backend requires that tournament operations be entirely deterministic. While there has been a good deal of effort put into ensuring this, we are still operating under several assumptions. These assumptions need to be tested.

Id Generation

One of the biggest sources of non-determinism is UUID generation. Currently, there are two methods in squire_lib/src/identifiers.rs that are used throughout the project to generate IDs. This ensures a uniform process for generating IDs. These methods take some salt (a timestamp) and some hashable data. The timestamp is hashed and is used to create the top 64 bits of the ID, and the other data is hashed and forms the lower 64 bits. The timestamps are passed as arguments from the tournament's apply_op method, which is passed from the SquireSDK's TournamentManager, so this salt is the same for all clients as it is shared as part of the tournament syncing process defined in the SDK.

However, hashing functions will not necessarily generate the same output on all platforms. This will cause the lower bits to potentially differ. To account and test for this, a suite of timestamp-data pairs should be generated (and stored statically) as well as the resulting UUID. These will form regression tests. Tests need to be added that will compute the UUID from the data and ensure the resulting UUID equals the known ID. These tests will run in CI, which will ensure platform independence. If the current method of ID creation fails this test, we need to look for a platform-independent hasher. Something like this hasher.

Metadata

Metadata

Assignees

Labels

in progessActively being worked onrequirementA requirement for the next major release

Type

No type

Projects

Status

In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions