Crate pallet_distance

source ·
Expand description

§Distance Pallet

The distance pallet utilizes results provided in a file by the distance-oracle offchain worker. At a some point, an inherent is called to submit the results of this file to the blockchain. The pallet then selects the median of the results (reach perbill) from an evaluation pool and fills the storage with the result status. The status of an identity can be:

  • Non-existent: Distance evaluation has not been requested or has expired.
  • Pending: Distance evaluation for this identity has been requested and is awaiting results after two evaluation periods.
  • Valid: Distance has been evaluated positively for this identity.

The evaluation result is used by the duniter-wot pallet to determine if an identity can gain or should lose membership in the web of trust.

§Process

Any account can request a distance evaluation for a given identity provided it has enough currency to reserve. In this case, the distance status is marked as pending, and in the next evaluation period, inherents can start to publish results.

This is the process for publishing a result:

  1. A local worker creates a file containing the computation result.
  2. An inherent is created with the data from this file.
  3. The author is registered as an evaluator.
  4. The result is added to the current evaluation pool.
  5. A flag is set to prevent other distance evaluations in the same block.

At the start of each new evaluation period:

  1. Old results set to expire at this period are removed.
  2. Results from the current pool (results from the previous period’s pool) are processed, and for each identity:
    • The median of the distance results for this identity is chosen.
    • If the distance is acceptable, it is marked as valid.
    • If the distance is not acceptable, the result for this identity is discarded, and reserved currency is slashed (from the account which requested the evaluation).

Then, in other pallets, when a membership is claimed, it is possible to check if there is a valid distance evaluation for this identity.

§Pools

Evaluation pools consist of two components:

  • A set of evaluators.
  • A vector of results.

The evaluations are divided into three pools:

  • Pool number N - 1 % 3: Results from the previous evaluation period used in the current one (emptied for the next evaluation period).
  • Pool number N + 0 % 3: Inherent results are added here.
  • Pool number N + 1 % 3: Identities are added here for evaluation.

Re-exports§

Modules§

Structs§

Enums§

Constants§

Traits§

Type Aliases§