Refactoring Checkpoint: (WIP)

This commit is contained in:
2025-12-14 10:29:31 +03:00
parent 09735eb97a
commit c89d7cac55
1424 changed files with 6415 additions and 6064 deletions
@@ -1,5 +1,5 @@
[package]
name = "fork-tree"
name = "pez-fork-tree"
version = "12.0.0"
authors.workspace = true
edition.workspace = true
@@ -7,7 +7,7 @@ license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "Utility library for managing tree-like ordered data with logic for pruning the tree while finalizing nodes."
documentation = "https://docs.rs/fork-tree"
documentation = "https://docs.rs/pez-fork-tree"
readme = "README.md"
[lints]
@@ -856,7 +856,7 @@ mod test {
impl std::error::Error for TestError {}
fn test_fork_tree<'a>(
fn test_pez_fork_tree<'a>(
) -> (ForkTree<&'a str, u64, u32>, impl Fn(&&str, &&str) -> Result<bool, TestError>) {
let mut tree = ForkTree::new();
@@ -925,7 +925,7 @@ mod test {
#[test]
fn import_doesnt_revert() {
let (mut tree, is_descendent_of) = test_fork_tree();
let (mut tree, is_descendent_of) = test_pez_fork_tree();
tree.finalize_root(&"A");
@@ -936,7 +936,7 @@ mod test {
#[test]
fn import_doesnt_add_duplicates() {
let (mut tree, is_descendent_of) = test_fork_tree();
let (mut tree, is_descendent_of) = test_pez_fork_tree();
assert_eq!(tree.import("A", 10, 1, &is_descendent_of), Err(Error::Duplicate));
@@ -950,7 +950,7 @@ mod test {
#[test]
fn finalize_root_works() {
let finalize_a = || {
let (mut tree, ..) = test_fork_tree();
let (mut tree, ..) = test_pez_fork_tree();
assert_eq!(tree.roots().map(|(h, n, _)| (*h, *n)).collect::<Vec<_>>(), vec![("A", 10)]);
@@ -992,7 +992,7 @@ mod test {
#[test]
fn finalize_works() {
let (mut tree, is_descendent_of) = test_fork_tree();
let (mut tree, is_descendent_of) = test_pez_fork_tree();
let original_roots = tree.roots.clone();
@@ -1047,7 +1047,7 @@ mod test {
#[test]
fn finalize_with_ancestor_works() {
let (mut tree, is_descendent_of) = test_fork_tree();
let (mut tree, is_descendent_of) = test_pez_fork_tree();
let original_roots = tree.roots.clone();
@@ -1226,7 +1226,7 @@ mod test {
#[test]
fn iter_iterates_in_preorder() {
let (tree, ..) = test_fork_tree();
let (tree, ..) = test_pez_fork_tree();
assert_eq!(
tree.iter().map(|(h, n, _)| (*h, *n)).collect::<Vec<_>>(),
vec![
@@ -1306,9 +1306,9 @@ mod test {
#[test]
fn map_works() {
let (mut tree, _) = test_fork_tree();
let (mut tree, _) = test_pez_fork_tree();
// Extend the single root fork-tree to also exercise the roots order during map.
// Extend the single root pez-fork-tree to also exercise the roots order during map.
let is_descendent_of = |_: &&str, _: &&str| -> Result<bool, TestError> { Ok(false) };
let is_root = tree.import("A1", 10, 1, &is_descendent_of).unwrap();
assert!(is_root);
@@ -1328,7 +1328,7 @@ mod test {
#[test]
fn prune_works_for_in_tree_hashes() {
let (mut tree, is_descendent_of) = test_fork_tree();
let (mut tree, is_descendent_of) = test_pez_fork_tree();
let removed = tree.prune(&"C", &30, &is_descendent_of, &|_| true).unwrap();
@@ -1355,7 +1355,7 @@ mod test {
#[test]
fn prune_works_for_out_of_tree_hashes() {
let (mut tree, is_descendent_of) = test_fork_tree();
let (mut tree, is_descendent_of) = test_pez_fork_tree();
let removed = tree.prune(&"c", &25, &is_descendent_of, &|_| true).unwrap();
@@ -1374,7 +1374,7 @@ mod test {
#[test]
fn prune_works_for_not_direct_ancestor() {
let (mut tree, is_descendent_of) = test_fork_tree();
let (mut tree, is_descendent_of) = test_pez_fork_tree();
// This is to re-root the tree not at the immediate ancestor, but the one just before.
let removed = tree.prune(&"m", &45, &is_descendent_of, &|height| *height == 3).unwrap();
@@ -1391,7 +1391,7 @@ mod test {
#[test]
fn prune_works_for_far_away_ancestor() {
let (mut tree, is_descendent_of) = test_fork_tree();
let (mut tree, is_descendent_of) = test_pez_fork_tree();
let removed = tree.prune(&"m", &45, &is_descendent_of, &|height| *height == 2).unwrap();
@@ -1439,7 +1439,7 @@ mod test {
#[test]
fn rebalance_works() {
let (mut tree, _) = test_fork_tree();
let (mut tree, _) = test_pez_fork_tree();
// the tree is automatically rebalanced on import, therefore we should iterate in preorder
// exploring the longest forks first. check the ascii art above to understand the expected
@@ -1470,7 +1470,7 @@ mod test {
#[test]
fn drain_filter_works() {
let (mut tree, _) = test_fork_tree();
let (mut tree, _) = test_pez_fork_tree();
let filter = |h: &&str, _: &u64, _: &u32| match *h {
"A" | "B" | "F" | "G" => FilterAction::KeepNode,
@@ -1494,7 +1494,7 @@ mod test {
#[test]
fn find_node_index_works() {
let (tree, is_descendent_of) = test_fork_tree();
let (tree, is_descendent_of) = test_pez_fork_tree();
let path = tree
.find_node_index_where(&"D", &40, &is_descendent_of, &|_| true)
@@ -1563,7 +1563,7 @@ mod test {
#[test]
fn find_node_works() {
let (tree, is_descendent_of) = test_fork_tree();
let (tree, is_descendent_of) = test_pez_fork_tree();
let node = tree.find_node_where(&"B", &20, &is_descendent_of, &|_| true).unwrap().unwrap();
assert_eq!((node.hash, node.number), ("A", 10));
@@ -1580,7 +1580,7 @@ mod test {
#[test]
fn post_order_traversal_requirement() {
let (mut tree, is_descendent_of) = test_fork_tree();
let (mut tree, is_descendent_of) = test_pez_fork_tree();
// Test for the post-order DFS traversal requirement as specified by the
// `find_node_index_where` and `import` comments.
@@ -1,5 +1,5 @@
[package]
name = "generate-bags"
name = "pez-generate-bags"
version = "28.0.0"
authors.workspace = true
edition.workspace = true
@@ -7,7 +7,7 @@ license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "Bag threshold generation script for pezpallet-bag-list"
documentation = "https://docs.rs/generate-bags"
documentation = "https://docs.rs/pez-generate-bags"
[lints]
workspace = true
@@ -1,27 +1,27 @@
[package]
name = "node-runtime-generate-bags"
name = "node-runtime-pez-generate-bags"
version = "3.0.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "Bag threshold generation script for pezpallet-bag-list and kitchensink-runtime."
description = "Bag threshold generation script for pezpallet-bag-list and pez-kitchensink-runtime."
publish = false
documentation = "https://docs.rs/node-runtime-generate-bags"
documentation = "https://docs.rs/node-runtime-pez-generate-bags"
[lints]
workspace = true
[dependencies]
generate-bags = { workspace = true, default-features = true }
kitchensink-runtime = { workspace = true }
pez-generate-bags = { workspace = true, default-features = true }
pez-kitchensink-runtime = { workspace = true }
# third-party
clap = { features = ["derive"], workspace = true }
[features]
runtime-benchmarks = [
"generate-bags/runtime-benchmarks",
"kitchensink-runtime/runtime-benchmarks",
"pez-generate-bags/runtime-benchmarks",
"pez-kitchensink-runtime/runtime-benchmarks",
]
@@ -18,7 +18,7 @@
//! Make the set of bag thresholds to be used with pezpallet-bags-list.
use clap::Parser;
use generate_bags::generate_thresholds;
use pez_generate_bags::generate_thresholds;
use std::path::PathBuf;
#[derive(Debug, Parser)]
@@ -43,7 +43,7 @@ struct Opt {
fn main() -> Result<(), std::io::Error> {
let Opt { n_bags, output, total_issuance, minimum_balance } = Opt::parse();
generate_thresholds::<kitchensink_runtime::Runtime>(
generate_thresholds::<pez_kitchensink_runtime::Runtime>(
n_bags,
&output,
total_issuance,
@@ -37,12 +37,12 @@
//!
//! 2. Write a little program to generate the definitions. This program exists only to hook together
//! the runtime definitions with the various calculations here. Take a look at
//! _utils/pezframe/generate_bags/node-runtime_ for an example.
//! _utils/pezframe/pez_generate_bags/node-runtime_ for an example.
//!
//! 3. Run that program:
//!
//! ```sh,notrust
//! $ cargo run -p node-runtime-generate-bags -- --total-issuance 1234 --minimum-balance 1
//! $ cargo run -p node-runtime-pez-generate-bags -- --total-issuance 1234 --minimum-balance 1
//! output.rs ```
//!
//! 4. Update the runtime definition.
@@ -29,7 +29,7 @@ use pezsp_trie::StorageProof;
#[cfg(all(not(feature = "std"), feature = "runtime-benchmarks"))]
use {
pezcumulus_pallet_teyrchain_system::validate_block::{
pezcumulus_pezpallet_teyrchain_system::validate_block::{
trie_cache::CacheProvider, trie_recorder::SizeOnlyRecorderProvider,
},
pezsp_core::storage::StateVersion,
@@ -103,7 +103,7 @@ impl<B: traits::Block> StorageAccessParams<B> {
}
}
/// Imitates `pezcumulus_pallet_teyrchain_system::validate_block::implementation::validate_block`
/// Imitates `pezcumulus_pezpallet_teyrchain_system::validate_block::implementation::validate_block`
///
/// Only performs the storage access, this is used to benchmark the storage access cost.
#[doc(hidden)]
+1 -1
View File
@@ -98,7 +98,7 @@
//!
//! Each project can be skipped individually by using the environment variable
//! `SKIP_PROJECT_NAME_WASM_BUILD`. Where `PROJECT_NAME` needs to be replaced by the name of the
//! cargo project, e.g. `kitchensink-runtime` will be `NODE_RUNTIME`.
//! cargo project, e.g. `pez-kitchensink-runtime` will be `NODE_RUNTIME`.
//!
//! ## Prerequisites:
//!