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:
- A local worker creates a file containing the computation result.
- An inherent is created with the data from this file.
- The author is registered as an evaluator.
- The result is added to the current evaluation pool.
- A flag is set to prevent other distance evaluations in the same block.
At the start of each new evaluation period:
- Old results set to expire at this period are removed.
- 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§
pub use crate::MAX_EVALUATIONS_PER_SESSION;
pub use crate::MAX_EVALUATORS_PER_SESSION;
pub use pallet::*;
pub use traits::*;
Modules§
- median 🔒
- The
pallet
module in each FRAME pallet hosts the most important items needed to construct this pallet. - types 🔒
- weights 🔒
Structs§
- Represents the result of a distance computation.
- Represents a pool where distance evaluation requests and results are stored.
- Represents a median accumulator.
Enums§
- Status of the distance evaluation of an identity.
- Represents the result of a median calculation.
Constants§
- Maximum number of identities to be evaluated in an evaluation period.
- Maximum number of evaluators in an evaluation period.