Crate distance_oracle
source ·Expand description
§Distance Oracle
The Distance Oracle is a standalone program designed to calculate the distances between identities in the Duniter Web of Trust (WoT). This process is computationally intensive and is therefore decoupled from the main runtime. It allows smith users to choose whether to run the oracle and provide results to the network.
The oracle works in conjunction with the Inherent Data Provider and the Distance Pallet in the runtime to deliver periodic computation results. The Inherent Data Provider fetches and supplies these results to the runtime, ensuring that the necessary data for distance evaluations is available to be processed at the appropriate time in the runtime lifecycle.
§Structure
The Distance Oracle is organized into the following modules:
/distance-oracle/
: Contains the main binary for executing the distance computation./primitives/distance/
: Defines primitive types shared between the client and runtime./client/distance/
: Exposes thecreate_distance_inherent_data_provider
, which feeds data into the runtime through the Inherent Data Provider./pallets/distance/
: A pallet that handles distance-related types, traits, storage, and hooks in the runtime, coordinating the interaction between the oracle, inherent data provider, and runtime.
§How it works
- The Distance Pallet adds an evaluation request at period
i
in the runtime. - The Distance Oracle evaluates this request at period
i + 1
, computes the necessary results and stores them on disk. - The Inherent Data Provider reads this evaluation result from disk at period
i + 2
and provides it to the runtime to perform the required operations.
§Usage
§Docker Integration
To run the Distance Oracle, use the provided Docker setup. Refer to the docker-compose.yml file for an example configuration.
Example Output:
2023-12-09T14:45:05.942Z INFO [distance_oracle] Nothing to do: Pool does not exist
Waiting 1800 seconds before next execution...
Modules§
Structs§
- Represents configuration parameters.
- Represents a tipping amount.
Enums§
Constants§
- The file version must match the version used by the inherent data provider. This ensures that the smith avoids accidentally submitting invalid data in case there are changes in logic between the runtime and the oracle, thereby preventing potential penalties.
Functions§
- Evaluates distance for the current period and prepares results for storage.
- Calculates the fraction of accessible referees to total referees for a given identity.
- Recursively explores the certification graph to identify referees accessible within a given depth.
- Prepares the context for the next evaluation task.
- Runs the evaluation process, saves the results, and cleans up old files.