Fix #262 distance oracle pool index
-
Fixed #262 (closed): Switched to continuous indexing for naming distance evaluation files to prevent old files from being picked up by the inherent, avoiding unexpected behavior. -
Added crate-level documentation to provide an overview of the distance oracle's purpose and usage. -
Added a landing page for documentation duniter/index.html
. -
Added a prefix check to prevent mismatches between the oracle and runtime versions, avoiding the Smith being penalized for a negligence error. -
Added log for distance-oracle started from the main binary. -
Refactored run
andrun_and_save
oracle main functions:- Split into three thematic functions for better modularity:
- Checks if there is work to do and ensures files can be saved successfully.
- Handles the distance evaluation logic.
- Saves the computed distance to a file and cleans up outdated files.
- Split into three thematic functions for better modularity:
Merge request reports
Activity
changed milestone to %runtime-900
added RN-runtime label
assigned to @bgallois
added 2 commits
mentioned in merge request !291 (merged)
requested review from @HugoTrentesaux
added 9 commits
-
e64bfca8...3ef713ee - 3 commits from branch
master
- ac88efdc - fix #262 (closed)
- 259a0bb5 - fix missing log arg
- 23558c1e - refactor oracle
- a5475c1d - update crate docs
- 52d465b6 - fix after rebase
- 6551494b - change file naming to first period block
Toggle commit list-
e64bfca8...3ef713ee - 3 commits from branch
added 1 commit
- 4c0ee21f - TMP change file naming to first period block
changed title from Fix #262 (closed) to Fix #262 (closed) distance oracle pool index
27 use api::{AccountId, IdtyIndex}; 59 use api::{AccountId, EvaluationPool, IdtyIndex, H256}; 28 60 29 61 use codec::Encode; 30 62 use fnv::{FnvHashMap, FnvHashSet}; 31 use log::{debug, error, info}; 63 use log::{debug, info, warn}; 32 64 use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; 33 65 use std::{io::Write, path::PathBuf}; 34 66 35 // TODO select metadata file using features 67 /// The file version must match the version used by the inherent data provider. 68 /// This ensures that the smith avoids accidentally submitting invalid data 69 /// in case there are changes in logic between the runtime and the oracle, 70 /// thereby preventing potential penalties. 71 const VERSION_PREFIX: &str = "001-"; The TODO was about how to handle the different runtimes between gdev/gtest/g1 (in the same repo). I don't know if the version prefix solves this problem, it depends on the workflow adopted for runtime upgrades through the different chains. But OK to remove the TODO, as tests will break if something goes wrong then, so it can't be forgotten.
165 .read_dir() 166 .unwrap_or_else(|e| { 167 panic!( 168 "Cannot read distance evaluation result directory `{:?}`: {:?}", 169 settings.evaluation_result_dir, e 170 ) 171 }) 172 .flatten() 173 .filter_map(|entry| { 174 entry 175 .file_name() 176 .into_string() 177 .ok() 178 .and_then(|name| { 179 name.split('-') 180 .last()? The file will be deleted also,
split
thenlast
on a string where the separator is absent will return the string.Edited by Benjamin GalloisIt will apply only to file names that are numerical.
To be extra safe, maybe we can change the path argument to be
my_path
and let the oracle append the subdirdistance
instead using directly the argument path to write the data.Edited by Benjamin Galloischanged this line in version 11 of the diff
- distance-oracle/README.md deleted 100644 → 0
1 # Distance oracle I'm requesting a review from @tuxmain and will keep looking at the documentation part before approving
requested review from @tuxmain and removed review request for @HugoTrentesaux
- Resolved by Hugo Trentesaux
cargo xtask gen-doc
gives meQmRcMBUkvvC6Pbb4kPooeB6Tj2akMhdeuBycVZ48LG6imV
intarget/doc
can you reproduce?If so, I do not see
duniter/index.html
, is it supposed to be there? Or should I build with an other command?
added RN-binary label
32 //! ## How it works 33 //! - The **Distance Pallet** adds an evaluation request at period `i` in the runtime. 34 //! - The **Distance Oracle** evaluates this request at period `i + 1`, computes the necessary results and stores them on disk. 35 //! - 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. 36 //! 37 //! ## Usage 38 //! 39 //! ### Docker Integration 40 //! 41 //! To run the Distance Oracle, use the provided Docker setup. Refer to the [docker-compose.yml](../docker-compose.yml) file for an example configuration. 42 //! 43 //! Example Output: 44 //! ```text 45 //! 2023-12-09T14:45:05.942Z INFO [distance_oracle] Nothing to do: Pool does not exist 46 //! Waiting 1800 seconds before next execution... 47 //! ``` True, we have to define a documentation strategy. We can discuss it in #233 (closed) or in a new issue, but I think the closer it is to the code the better.
It does not prevent from having more complete and less up to date documentation on the Duniter website for example.
- Resolved by Pascal Engélibert
- Resolved by Pascal Engélibert
mentioned in commit ebc4730c