From 482eefd55ef1caab5b67348bdd1689df0287efcc Mon Sep 17 00:00:00 2001 From: Jost Schulte Date: Tue, 11 Jul 2023 14:19:32 -0600 Subject: [PATCH 01/10] build(nix)!: upgrade to holochain v0.3.0-beta-dev.8 --- flake.lock | 529 +++++++++++++++++++++++++++++++++++++++++++++++++---- flake.nix | 6 +- 2 files changed, 496 insertions(+), 39 deletions(-) diff --git a/flake.lock b/flake.lock index 062a4b8..9dbe3d4 100644 --- a/flake.lock +++ b/flake.lock @@ -17,6 +17,23 @@ "type": "github" } }, + "cargo-chef_2": { + "flake": false, + "locked": { + "lastModified": 1672901199, + "narHash": "sha256-MHTuR4aQ1rQaBKx1vWDy2wbvcT0ZAzpkVB2zylSC+k0=", + "owner": "LukeMathWalker", + "repo": "cargo-chef", + "rev": "5c9f11578a2e0783cce27666737d50f84510b8b5", + "type": "github" + }, + "original": { + "owner": "LukeMathWalker", + "ref": "main", + "repo": "cargo-chef", + "type": "github" + } + }, "cargo-rdme": { "flake": false, "locked": { @@ -34,6 +51,23 @@ "type": "github" } }, + "cargo-rdme_2": { + "flake": false, + "locked": { + "lastModified": 1675118998, + "narHash": "sha256-lrYWqu3h88fr8gG3Yo5GbFGYaq5/1Os7UtM+Af0Bg4k=", + "owner": "orium", + "repo": "cargo-rdme", + "rev": "f9dbb6bccc078f4869f45ae270a2890ac9a75877", + "type": "github" + }, + "original": { + "owner": "orium", + "ref": "v1.1.0", + "repo": "cargo-rdme", + "type": "github" + } + }, "crane": { "inputs": { "flake-compat": "flake-compat", @@ -58,6 +92,31 @@ "type": "github" } }, + "crane_2": { + "inputs": { + "flake-compat": "flake-compat_3", + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "holochain", + "holochain", + "nixpkgs" + ], + "rust-overlay": "rust-overlay_2" + }, + "locked": { + "lastModified": 1675475924, + "narHash": "sha256-KWdfV9a6+zG6Ij/7PZYLnomjBZZUu8gdRy+hfjGrrJQ=", + "owner": "ipetkov", + "repo": "crane", + "rev": "1bde9c762ebf26de9f8ecf502357c92105bc4577", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, "crate2nix": { "flake": false, "locked": { @@ -74,6 +133,54 @@ "type": "github" } }, + "crate2nix_2": { + "flake": false, + "locked": { + "lastModified": 1675642992, + "narHash": "sha256-uDBDZuiq7qyg82Udp82/r4zg5HKfIzBQqgl2U9THiQM=", + "owner": "kolloch", + "repo": "crate2nix", + "rev": "45fc83132c8c91c77a1cd61fe0c945411d1edba8", + "type": "github" + }, + "original": { + "owner": "kolloch", + "repo": "crate2nix", + "type": "github" + } + }, + "empty": { + "flake": false, + "locked": { + "lastModified": 1683792623, + "narHash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=", + "owner": "steveej", + "repo": "empty", + "rev": "8e328e450e4cd32e072eba9e99fe92cf2a1ef5cf", + "type": "github" + }, + "original": { + "owner": "steveej", + "repo": "empty", + "type": "github" + } + }, + "empty_2": { + "flake": false, + "locked": { + "lastModified": 1683792623, + "narHash": "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=", + "owner": "steveej", + "repo": "empty", + "rev": "8e328e450e4cd32e072eba9e99fe92cf2a1ef5cf", + "type": "github" + }, + "original": { + "owner": "steveej", + "repo": "empty", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -106,6 +213,38 @@ "type": "github" } }, + "flake-compat_3": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_4": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -123,6 +262,23 @@ "type": "indirect" } }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_2" + }, + "locked": { + "lastModified": 1675295133, + "narHash": "sha256-dU8fuLL98WFXG0VnRgM00bqKX6CEPBLybhiIDIgO45o=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "bf53492df08f3178ce85e0c9df8ed8d03c030c9f", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, "flake-utils": { "locked": { "lastModified": 1667395993, @@ -139,6 +295,21 @@ } }, "flake-utils_2": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { "inputs": { "systems": "systems" }, @@ -156,67 +327,148 @@ "type": "github" } }, + "flake-utils_4": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "holochain": { "inputs": { "cargo-chef": "cargo-chef", "cargo-rdme": "cargo-rdme", "crane": "crane", "crate2nix": "crate2nix", + "empty": "empty", "flake-compat": "flake-compat_2", "flake-parts": "flake-parts", + "holochain": "holochain_2", + "lair": [ + "holochain", + "empty" + ], + "launcher": [ + "holochain", + "empty" + ], + "nix-filter": "nix-filter_2", + "nixpkgs": "nixpkgs_2", + "pre-commit-hooks-nix": "pre-commit-hooks-nix_2", + "rust-overlay": "rust-overlay_4", + "scaffolding": [ + "holochain", + "empty" + ], + "versions": [ + "versions" + ] + }, + "locked": { + "lastModified": 1689092049, + "narHash": "sha256-Bej7kWmHZQM5OZSPciRKcLKAVemefaSm7/+q13hSHnk=", + "owner": "holochain", + "repo": "holochain", + "rev": "43f0aa760bbba1afed8415d66c3f901a77d4655e", + "type": "github" + }, + "original": { + "owner": "holochain", + "repo": "holochain", + "type": "github" + } + }, + "holochain_2": { + "inputs": { + "cargo-chef": "cargo-chef_2", + "cargo-rdme": "cargo-rdme_2", + "crane": "crane_2", + "crate2nix": "crate2nix_2", + "empty": "empty_2", + "flake-compat": "flake-compat_4", + "flake-parts": "flake-parts_2", "holochain": [ "holochain", - "versions", - "holochain" + "holochain", + "empty" ], "lair": [ "holochain", - "versions", - "lair" + "holochain", + "empty" ], "launcher": [ "holochain", - "versions", - "launcher" + "holochain", + "empty" ], "nix-filter": "nix-filter", "nixpkgs": "nixpkgs", "pre-commit-hooks-nix": "pre-commit-hooks-nix", - "rust-overlay": "rust-overlay_2", + "rust-overlay": "rust-overlay_3", "scaffolding": [ "holochain", - "versions", - "scaffolding" + "holochain", + "empty" ], "versions": "versions" }, "locked": { - "lastModified": 1682670262, - "narHash": "sha256-2RWsHw4iwG6VzmI4wgwwCH9OZ/M+1Y9qus1Ff0jesks=", + "lastModified": 1688518351, + "narHash": "sha256-LU4/kPsHkMVGnWLUpNGpsmfep1NPFI8HXe7A1mwkzvM=", "owner": "holochain", "repo": "holochain", - "rev": "2d4044b8945c051d82cba920d871039a12ffa210", + "rev": "a92af07552c5cb70436c501b67e0c064ac699157", "type": "github" }, "original": { "owner": "holochain", + "ref": "holochain-0.3.0-beta-dev.8", "repo": "holochain", "type": "github" } }, - "holochain_2": { + "holochain_3": { + "flake": false, + "locked": { + "lastModified": 1686257124, + "narHash": "sha256-SvXGHOr96ob/NfQCeVJ2J4LWc83qkZn+/pnE9qVNB+I=", + "owner": "holochain", + "repo": "holochain", + "rev": "db5b8b27da3bf296958c3bf54ac3950dc60a39c8", + "type": "github" + }, + "original": { + "owner": "holochain", + "ref": "holochain-0.1.5", + "repo": "holochain", + "type": "github" + } + }, + "holochain_4": { "flake": false, "locked": { - "lastModified": 1681507583, - "narHash": "sha256-lRnums2gv1oXVwo4gMF2QAnzEu8prwxg1uKjUzNwJV4=", + "lastModified": 1684139928, + "narHash": "sha256-uno5MTiBwf9RiEiX6iKzJsB+3srJFKwV/1ReXzaZVVw=", "owner": "holochain", "repo": "holochain", - "rev": "ac50baed6b53e9d0552729e69e1e20312e4edc08", + "rev": "a91b262e87653f5f2e3a50c06eaac2bb81fb88d3", "type": "github" }, "original": { "owner": "holochain", - "ref": "holochain-0.1.4", + "ref": "holochain-0.2.1-beta-dev.0", "repo": "holochain", "type": "github" } @@ -224,16 +476,33 @@ "lair": { "flake": false, "locked": { - "lastModified": 1670953460, - "narHash": "sha256-cqOr7iWzsNeomYQiiFggzG5Dr4X0ysnTkjtA8iwDLAQ=", + "lastModified": 1682356264, + "narHash": "sha256-5ZYJ1gyyL3hLR8hCjcN5yremg8cSV6w1iKCOrpJvCmc=", "owner": "holochain", "repo": "lair", - "rev": "cbfbefefe43073904a914c8181a450209a74167b", + "rev": "43be404da0fd9d57bf4429c44def405bd6490f61", "type": "github" }, "original": { "owner": "holochain", - "ref": "lair_keystore-v0.2.3", + "ref": "lair_keystore-v0.2.4", + "repo": "lair", + "type": "github" + } + }, + "lair_2": { + "flake": false, + "locked": { + "lastModified": 1682356264, + "narHash": "sha256-5ZYJ1gyyL3hLR8hCjcN5yremg8cSV6w1iKCOrpJvCmc=", + "owner": "holochain", + "repo": "lair", + "rev": "43be404da0fd9d57bf4429c44def405bd6490f61", + "type": "github" + }, + "original": { + "owner": "holochain", + "ref": "lair_keystore-v0.2.4", "repo": "lair", "type": "github" } @@ -255,6 +524,23 @@ "type": "github" } }, + "launcher_2": { + "flake": false, + "locked": { + "lastModified": 1684183666, + "narHash": "sha256-rOE/W/BBYyZKOyypKb8X9Vpc4ty1TNRoI/fV5+01JPw=", + "owner": "holochain", + "repo": "launcher", + "rev": "75ecdd0aa191ed830cc209a984a6030e656042ff", + "type": "github" + }, + "original": { + "owner": "holochain", + "ref": "holochain-0.2", + "repo": "launcher", + "type": "github" + } + }, "nix-filter": { "locked": { "lastModified": 1675361037, @@ -270,13 +556,28 @@ "type": "github" } }, + "nix-filter_2": { + "locked": { + "lastModified": 1675361037, + "narHash": "sha256-CTbDuDxFD3U3g/dWUB+r+B/snIe+qqP1R+1myuFGe2I=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "e1b2f96c2a31415f362268bc48c3fccf47dff6eb", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1682526928, - "narHash": "sha256-2cKh4O6t1rQ8Ok+v16URynmb0rV7oZPEbXkU0owNLQs=", + "lastModified": 1686869522, + "narHash": "sha256-tbJ9B8WLCTnVP/LwESRlg0dII6Zyg2LmUU/mB9Lu98E=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d6b863fd9b7bb962e6f9fdf292419a775e772891", + "rev": "7c67f006ea0e7d0265f16d7df07cc076fdffd91f", "type": "github" }, "original": { @@ -303,6 +604,39 @@ "type": "github" } }, + "nixpkgs-lib_2": { + "locked": { + "dir": "lib", + "lastModified": 1675183161, + "narHash": "sha256-Zq8sNgAxDckpn7tJo7V1afRSk2eoVbu3OjI1QklGLNg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e1e1b192c1a5aab2960bf0a0bd53a2e8124fa18e", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1686869522, + "narHash": "sha256-tbJ9B8WLCTnVP/LwESRlg0dII6Zyg2LmUU/mB9Lu98E=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "7c67f006ea0e7d0265f16d7df07cc076fdffd91f", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, "pre-commit-hooks-nix": { "flake": false, "locked": { @@ -319,13 +653,30 @@ "type": "github" } }, + "pre-commit-hooks-nix_2": { + "flake": false, + "locked": { + "lastModified": 1676513100, + "narHash": "sha256-MK39nQV86L2ag4TmcK5/+r1ULpzRLPbbfvWbPvIoYJE=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "5f0cba88ac4d6dd8cad5c6f6f1540b3d6a21a798", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "root": { "inputs": { "holochain": "holochain", "nixpkgs": [ "holochain", "nixpkgs" - ] + ], + "versions": "versions_2" } }, "rust-overlay": { @@ -357,18 +708,70 @@ }, "rust-overlay_2": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": [ + "holochain", + "holochain", + "crane", + "flake-utils" + ], + "nixpkgs": [ + "holochain", + "holochain", + "crane", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1675391458, + "narHash": "sha256-ukDKZw922BnK5ohL9LhwtaDAdCsJL7L6ScNEyF1lO9w=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "383a4acfd11d778d5c2efcf28376cbd845eeaedf", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_3": { + "inputs": { + "flake-utils": "flake-utils_3", + "nixpkgs": [ + "holochain", + "holochain", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1688438033, + "narHash": "sha256-wOmpZis06pVKTR+5meGwhrW10/buf98lnA26uQLaqek=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "c3e43223dece545cfe06ddd92fd782adc73d56c3", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_4": { + "inputs": { + "flake-utils": "flake-utils_4", "nixpkgs": [ "holochain", "nixpkgs" ] }, "locked": { - "lastModified": 1682648393, - "narHash": "sha256-VH0/4PXTPHVc3E6NxuB51w2eW1/Yn8NGq+HkB8kA0cU=", + "lastModified": 1689042658, + "narHash": "sha256-p7cQAFNt5kX19sZvK74CmY0nTrtujpZg6sZUiV1ntAk=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "2c22a41baadfac75a4af5303fc3ef8d4145b795b", + "rev": "d7181bb2237035df17cab9295c95f987f5c527e6", "type": "github" }, "original": { @@ -380,11 +783,11 @@ "scaffolding": { "flake": false, "locked": { - "lastModified": 1682016510, - "narHash": "sha256-U6V453QPUGI6PhtO7kkQCFxEB9WZPiU6hjwyPUdEHaE=", + "lastModified": 1686617155, + "narHash": "sha256-ZeWnh27JNb/abu/ii8e3u4DHns49MOFMNXGPGFPqS0k=", "owner": "holochain", "repo": "scaffolding", - "rev": "85997cbc4c92f0fea87447d7c7daed1245b47700", + "rev": "861397c975542306be6d8529e5c6bdb21c7ba6a6", "type": "github" }, "original": { @@ -394,6 +797,23 @@ "type": "github" } }, + "scaffolding_2": { + "flake": false, + "locked": { + "lastModified": 1683890859, + "narHash": "sha256-/nG2TGU4Q7zy0KGS/opcW1836LZ7FJhA+/OEh5gNj34=", + "owner": "holochain", + "repo": "scaffolding", + "rev": "1ca1092ad5d147bd23a75444874830cc033aa9cf", + "type": "github" + }, + "original": { + "owner": "holochain", + "ref": "holochain-0.2", + "repo": "scaffolding", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, @@ -409,24 +829,59 @@ "type": "github" } }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "versions": { "inputs": { - "holochain": "holochain_2", + "holochain": "holochain_3", "lair": "lair", "launcher": "launcher", "scaffolding": "scaffolding" }, "locked": { + "lastModified": 1686618210, + "narHash": "sha256-lXY9ob0WAekcoEgWcFL3cJiPkwoKlsR2OMqG0S3vXzA=", + "path": "./versions/0_1", + "type": "path" + }, + "original": { "dir": "versions/0_1", - "lastModified": 1684218489, - "narHash": "sha256-k6FKy1k+/8qhnXWwWZcAR5F28Ip3CV+/ERoJ1xCSsCA=", "owner": "holochain", "repo": "holochain", - "rev": "e6d3e965814d0bf8f4c77a2f7c4116a27446ab4a", + "type": "github" + } + }, + "versions_2": { + "inputs": { + "holochain": "holochain_4", + "lair": "lair_2", + "launcher": "launcher_2", + "scaffolding": "scaffolding_2" + }, + "locked": { + "dir": "versions/0_2", + "lastModified": 1689092049, + "narHash": "sha256-Bej7kWmHZQM5OZSPciRKcLKAVemefaSm7/+q13hSHnk=", + "owner": "holochain", + "repo": "holochain", + "rev": "43f0aa760bbba1afed8415d66c3f901a77d4655e", "type": "github" }, "original": { - "dir": "versions/0_1", + "dir": "versions/0_2", "owner": "holochain", "repo": "holochain", "type": "github" diff --git a/flake.nix b/flake.nix index 02ad615..c11886e 100644 --- a/flake.nix +++ b/flake.nix @@ -4,9 +4,11 @@ inputs = { nixpkgs.follows = "holochain/nixpkgs"; + versions.url = "github:holochain/holochain?dir=versions/0_2"; holochain = { url = "github:holochain/holochain"; - inputs.versions.url = "github:holochain/holochain/?dir=versions/0_1"; + inputs.versions.follows = "versions"; + inputs.holochain.url = "github:holochain/holochain/holochain-0.3.0-beta-dev.8"; }; }; @@ -29,4 +31,4 @@ }; }; }; -} \ No newline at end of file +} From 02aabb9349020a7e5b249620d81be323068f72d2 Mon Sep 17 00:00:00 2001 From: Jost Schulte Date: Tue, 11 Jul 2023 14:20:04 -0600 Subject: [PATCH 02/10] refactor!: entry hashes from linkable --- Cargo.lock | 393 +++++++++++++++++++++++++-- Cargo.toml | 6 +- lib/prefix_index/src/prefix_index.rs | 92 +++++-- lib/prefix_index/src/validate.rs | 16 +- 4 files changed, 451 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b3a50b1..f098d25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -46,6 +46,15 @@ dependencies = [ "libc", ] +[[package]] +name = "approx" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" +dependencies = [ + "num-traits", +] + [[package]] name = "arrayref" version = "0.3.7" @@ -58,6 +67,17 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -237,6 +257,17 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "colored" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59" +dependencies = [ + "atty", + "lazy_static", + "winapi", +] + [[package]] name = "constant_time_eq" version = "0.1.5" @@ -498,6 +529,17 @@ dependencies = [ "serde", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -610,6 +652,95 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "futures" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" + +[[package]] +name = "futures-executor" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" + +[[package]] +name = "futures-macro" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "futures-sink" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" + +[[package]] +name = "futures-task" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" + +[[package]] +name = "futures-util" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + [[package]] name = "gcollections" version = "1.5.0" @@ -680,9 +811,9 @@ dependencies = [ [[package]] name = "hdi" -version = "0.2.2" +version = "0.4.0-beta-dev.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9f6105d20d9c8dcac3b967bef3de5c811d43de3079c60f05ddebb86421f362" +checksum = "c6e0352aefff46fa9e1b9172fd5326b4cc75bc1346712100fde8e87143d1ab09" dependencies = [ "hdk_derive", "holo_hash", @@ -697,9 +828,9 @@ dependencies = [ [[package]] name = "hdk" -version = "0.1.2" +version = "0.3.0-beta-dev.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a354d9b29d879b8e05c2e1e5f5a9657dac2a1f4be6732ecc4d72273cf6d30bbd" +checksum = "2afd4494fd611e20213496e54cd6186525eaa79f3a8b45445fb20d1e40679745" dependencies = [ "getrandom", "hdi", @@ -717,9 +848,9 @@ dependencies = [ [[package]] name = "hdk_derive" -version = "0.1.2" +version = "0.3.0-beta-dev.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b42de4f722e215382845ca26d6b71d557f843c674dfd9463cb517873c6cade8" +checksum = "32bad9b4735c59bc1b3b70ce7fe1270e1051afc0e8d0186d8c195550717e58ad" dependencies = [ "darling", "heck", @@ -737,6 +868,15 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + [[package]] name = "hermit-abi" version = "0.2.6" @@ -760,14 +900,15 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "holo_hash" -version = "0.1.2" +version = "0.3.0-beta-dev.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d8076a1021ca8bf729d4224c4facd24f06c3aebd3fd335080d1460495538dfd" +checksum = "8f77366144e6ff54b1ecfd95fb528c470c5ba3d86cb1d4d7c5553f2b5677124c" dependencies = [ "base64", "blake2b_simd", "derive_more", "holochain_serialized_bytes", + "holochain_wasmer_common", "kitsune_p2p_dht_arc", "serde", "serde_bytes", @@ -776,12 +917,13 @@ dependencies = [ [[package]] name = "holochain_integrity_types" -version = "0.1.2" +version = "0.3.0-beta-dev.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5755ca3e4d8d3121c8294b8ac21a1da072350519309381336ff9e0aaee80e1b5" +checksum = "56dec8f48078b5c348d6cdefcea9922d587c1c672b7c10ff0cb5fa72353809b7" dependencies = [ "holo_hash", "holochain_serialized_bytes", + "kitsune_p2p_dht", "kitsune_p2p_timestamp", "paste", "serde", @@ -817,9 +959,9 @@ dependencies = [ [[package]] name = "holochain_wasmer_common" -version = "0.0.83" +version = "0.0.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce2c50cfaf43ccfaf9c584eae3864dffb3f010f140dad6e52368f0969ce680d7" +checksum = "223daec7ca62d4e36841a99d8799b29cc616f5976ad0e2975e6ca6810de8f14f" dependencies = [ "holochain_serialized_bytes", "serde", @@ -832,9 +974,9 @@ dependencies = [ [[package]] name = "holochain_wasmer_guest" -version = "0.0.83" +version = "0.0.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5539ab71791a3f9d0febbd2822ba398ef34e18f55f86eafc4918a776d12d7db" +checksum = "92b2026e44595cb16108464973622577936605582aa22932933a5130ad32ce42" dependencies = [ "holochain_serialized_bytes", "holochain_wasmer_common", @@ -846,14 +988,17 @@ dependencies = [ [[package]] name = "holochain_zome_types" -version = "0.1.2" +version = "0.3.0-beta-dev.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd45986999baf8590ff444442cdbbd460ae26e8ecaa7494a69f081c897bbe714" +checksum = "56a1bb8fbc9799fe79730f43d2c3b0a944f68f2487b4b2db2c752d435e0fc6a0" dependencies = [ "holo_hash", "holochain_integrity_types", "holochain_serialized_bytes", "holochain_wasmer_common", + "kitsune_p2p_bin_data", + "kitsune_p2p_block", + "kitsune_p2p_dht", "kitsune_p2p_timestamp", "paste", "serde", @@ -952,6 +1097,15 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "itertools" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.6" @@ -967,11 +1121,61 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "kitsune_p2p_bin_data" +version = "0.3.0-beta-dev.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaa50a12a5755c2b9109cbc435a6565fe4b324f149c07848fc3e8655b4b0577c" +dependencies = [ + "base64", + "derive_more", + "kitsune_p2p_dht_arc", + "serde", + "serde_bytes", + "shrinkwraprs", +] + +[[package]] +name = "kitsune_p2p_block" +version = "0.3.0-beta-dev.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6a757e1dd315d66086fc9f013cb85d9c263eef7569db63ce0990e4ec12d6fd2" +dependencies = [ + "kitsune_p2p_bin_data", + "kitsune_p2p_timestamp", + "serde", + "serde_bytes", +] + +[[package]] +name = "kitsune_p2p_dht" +version = "0.3.0-beta-dev.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643901283087a01ee85fa3f2a650b2eb1931d7d9916a80d0ce836066b2a37758" +dependencies = [ + "colored", + "derivative", + "derive_more", + "futures", + "gcollections", + "intervallum", + "kitsune_p2p_dht_arc", + "kitsune_p2p_timestamp", + "must_future", + "num-traits", + "once_cell", + "rand", + "serde", + "statrs", + "thiserror", + "tracing", +] + [[package]] name = "kitsune_p2p_dht_arc" -version = "0.1.0" +version = "0.3.0-beta-dev.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0344da4e6309dfa0d7471e4b868e7dc829f109a99b3fd552abfd4d9850593cbf" +checksum = "bfbbc1c930888d6aa22099497139f0225e7dcdb90dd3e7fc2cc01dc9e2ba9f0e" dependencies = [ "derive_more", "gcollections", @@ -982,9 +1186,9 @@ dependencies = [ [[package]] name = "kitsune_p2p_timestamp" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89399225067e17ab204a3d496622dd7ab51959690676eee35c45c6ad9a725165" +checksum = "be6483b304900c20fa104c50947cc1adf0e277fccdba8e26134d7b49dbdfd2a0" dependencies = [ "chrono", "derive_more", @@ -1019,6 +1223,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "libm" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" + [[package]] name = "link-cplusplus" version = "1.0.8" @@ -1083,6 +1293,16 @@ dependencies = [ "libc", ] +[[package]] +name = "matrixmultiply" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "090126dc04f95dc0d1c1c91f61bdd474b3930ca064c1edc8a849da2c6cbe1e77" +dependencies = [ + "autocfg", + "rawpointer", +] + [[package]] name = "memchr" version = "2.5.0" @@ -1131,6 +1351,54 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" +[[package]] +name = "must_future" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a160ffed3c2f98d2906c67a9b6e4e1f09cca7e17e3f780286a349061459eeebe" +dependencies = [ + "futures", + "pin-utils", +] + +[[package]] +name = "nalgebra" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "462fffe4002f4f2e1f6a9dcf12cc1a6fc0e15989014efc02a941d3e0f5dc2120" +dependencies = [ + "approx", + "matrixmultiply", + "nalgebra-macros", + "num-complex", + "num-rational", + "num-traits", + "rand", + "rand_distr", + "simba", + "typenum", +] + +[[package]] +name = "nalgebra-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01fcc0b8149b4632adc89ac3b7b31a12fb6099a0317a4eb2ebff574ef7de7218" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "num-complex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" +dependencies = [ + "num-traits", +] + [[package]] name = "num-integer" version = "0.1.45" @@ -1141,6 +1409,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.15" @@ -1148,6 +1427,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -1212,9 +1492,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.5" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" +checksum = "b4b27ab7be369122c218afc2079489cdcb4b517c0a3fc386ff11e1fedfcc2b35" [[package]] name = "pest" @@ -1232,6 +1512,12 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1340,6 +1626,22 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rand_distr" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" +dependencies = [ + "num-traits", + "rand", +] + +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + [[package]] name = "rayon" version = "1.7.0" @@ -1638,12 +1940,46 @@ dependencies = [ "digest", ] +[[package]] +name = "shrinkwraprs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e63e6744142336dfb606fe2b068afa2e1cca1ee6a5d8377277a92945d81fa331" +dependencies = [ + "bitflags", + "itertools", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "simba" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e82063457853d00243beda9952e910b82593e4b07ae9f721b9278a99a0d3d5c" +dependencies = [ + "approx", + "num-complex", + "num-traits", + "paste", +] + [[package]] name = "simdutf8" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "slab" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +dependencies = [ + "autocfg", +] + [[package]] name = "smallvec" version = "1.10.0" @@ -1656,6 +1992,19 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "statrs" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05bdbb8e4e78216a85785a85d3ec3183144f98d0097b9281802c019bb07a6f05" +dependencies = [ + "approx", + "lazy_static", + "nalgebra", + "num-traits", + "rand", +] + [[package]] name = "strsim" version = "0.10.0" diff --git a/Cargo.toml b/Cargo.toml index 5048365..494369c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,9 +8,9 @@ opt-level = "z" members = ["dnas/*/zomes/coordinator/*", "dnas/*/zomes/integrity/*", "lib/*"] [workspace.dependencies] -hdi = "=0.2.2" -hdk = "=0.1.2" -holochain_integrity_types = "=0.1.2" +hdi = "=0.4.0-beta-dev.5" +hdk = "=0.3.0-beta-dev.7" +holochain_integrity_types = "=0.3.0-beta-dev.5" serde = "1" [workspace.dependencies.demo] diff --git a/lib/prefix_index/src/prefix_index.rs b/lib/prefix_index/src/prefix_index.rs index d4d0fd2..d7eedcf 100644 --- a/lib/prefix_index/src/prefix_index.rs +++ b/lib/prefix_index/src/prefix_index.rs @@ -1,6 +1,6 @@ -use hdk::{hash_path::path::Component, prelude::*}; use crate::utils::*; use crate::validate::*; +use hdk::{hash_path::path::Component, prelude::*}; use rand::prelude::*; #[derive(Clone, Debug, PartialEq, Deserialize, Serialize, SerializedBytes)] @@ -34,12 +34,18 @@ impl PrefixIndex { self.inner_add_result(text, None) } - pub fn add_result_with_label(&self, text: String, full_text: String) -> ExternResult { + pub fn add_result_with_label( + &self, + text: String, + full_text: String, + ) -> ExternResult { self.inner_add_result(text, Some(full_text)) } fn inner_add_result(&self, text: String, full_text: Option) -> ExternResult { - let typed_path = self.make_result_path(text.clone(), full_text)?.typed(self.link_type)?; + let typed_path = self + .make_result_path(text.clone(), full_text)? + .typed(self.link_type)?; typed_path.ensure()?; @@ -61,7 +67,9 @@ impl PrefixIndex { } fn inner_remove_result(&self, text: String, full_text: Option) -> ExternResult<()> { - let path = self.make_result_path(text.clone(), full_text)?.typed(self.link_type)?; + let path = self + .make_result_path(text.clone(), full_text)? + .typed(self.link_type)?; self.inner_remove_result_from_path(path)?; @@ -85,12 +93,22 @@ impl PrefixIndex { let result_children: Vec = children .clone() .into_iter() - .filter(|c| EntryHash::from(c.clone().target) == path_entry_hash) + .filter(|c| { + c.target.clone().try_into().is_ok_and(|link_entry_hash: EntryHash| { + link_entry_hash == path_entry_hash + }) + }) .collect(); // Delete children link corresponding to current path for child in result_children.clone().into_iter() { - if EntryHash::from(child.target) == path.path_entry_hash()? { + if child + .target + .try_into() + .is_ok_and(|child_entry_hash: EntryHash| { + child_entry_hash == path_entry_hash + }) + { delete_link(child.create_link_hash)?; } } @@ -125,7 +143,7 @@ impl PrefixIndex { .typed(self.link_type)?; debug!( - "Searching for '{:?}', staring at path '{:?}'", + "Searching for '{:?}', starting at path '{:?}'", query, path_to_string(path.clone()) ); @@ -141,7 +159,7 @@ impl PrefixIndex { } let base_path = Path::from(self.index_name.clone()).typed(self.link_type)?; - + self.inner_get_results(base_path, limit, true) } @@ -149,15 +167,20 @@ impl PrefixIndex { pub fn make_result_path(&self, text: String, full_text: Option) -> ExternResult { let mut path_components = Path::from(format!( "{}.{}:{}#{}", - self.index_name, self.width, self.depth, text.to_lowercase() - )).as_ref().clone(); - + self.index_name, + self.width, + self.depth, + text.to_lowercase() + )) + .as_ref() + .clone(); + match full_text { // Replace last component of path with full_text Some(full_text_string) => { - path_components.pop(); - path_components.push(Component::from(full_text_string)); - }, + path_components.pop(); + path_components.push(Component::from(full_text_string)); + } // Replace last component of path with original text (preserve case) None => { @@ -168,23 +191,37 @@ impl PrefixIndex { Ok(Path::from(path_components)) } - pub fn validate_create_link( - self, - action: CreateLink - ) -> ExternResult { - validate_create_link_prefix_index(action.clone(), action.base_address, action.target_address, action.tag, self) + pub fn validate_create_link(self, action: CreateLink) -> ExternResult { + validate_create_link_prefix_index( + action.clone(), + action.base_address, + action.target_address, + action.tag, + self, + ) } pub fn validate_delete_link( self, action: DeleteLink, - original_action: CreateLink + original_action: CreateLink, ) -> ExternResult { - validate_delete_link_prefix_index(action.clone(), original_action.clone(), original_action.base_address, original_action.target_address, original_action.tag) + validate_delete_link_prefix_index( + action.clone(), + original_action.clone(), + original_action.base_address, + original_action.target_address, + original_action.tag, + ) } /// Gets the deepest-most Paths that descend from `path`, or it's parents, up to limit - fn get_results_from_path(&self, path: TypedPath, limit: usize, shuffle: bool) -> ExternResult> { + fn get_results_from_path( + &self, + path: TypedPath, + limit: usize, + shuffle: bool, + ) -> ExternResult> { self.inner_get_results_from_path(path, limit, shuffle, vec![], vec![]) } @@ -230,8 +267,9 @@ impl PrefixIndex { match path.parent() { Some(parent) => { if !visited.contains(&parent) && !parent.is_root() { - return self - .inner_get_results_from_path(parent, limit, shuffle, visited, results); + return self.inner_get_results_from_path( + parent, limit, shuffle, visited, results, + ); } Ok(results) @@ -242,7 +280,6 @@ impl PrefixIndex { false => { if shuffle { let mut rng = rand::thread_rng(); - let y: f64 = rng.gen(); children.shuffle(&mut rng) } @@ -270,8 +307,9 @@ impl PrefixIndex { match path.parent() { Some(parent) => { if !visited.contains(&parent) && !parent.is_root() { - return self - .inner_get_results_from_path(parent, limit, shuffle, visited, results); + return self.inner_get_results_from_path( + parent, limit, shuffle, visited, results, + ); } Ok(results) diff --git a/lib/prefix_index/src/validate.rs b/lib/prefix_index/src/validate.rs index 43b9030..966661c 100644 --- a/lib/prefix_index/src/validate.rs +++ b/lib/prefix_index/src/validate.rs @@ -4,7 +4,7 @@ use hdk::hash_path::path::{root_hash, Component}; use hdk::prelude::*; pub fn validate_create_link_prefix_index( - action: CreateLink, + _action: CreateLink, base_address: AnyLinkableHash, target_address: AnyLinkableHash, tag: LinkTag, @@ -19,8 +19,13 @@ pub fn validate_create_link_prefix_index( let path: Path = Path::from(tag_string.clone()); // first component + let path_entry_hash = path.path_entry_hash()?; + let prefix_index_entry_hash = Path::from(prefix_index.index_name.clone()).path_entry_hash()?; if base_address == root_hash()? { - if EntryHash::from(target_address.clone()) != path.path_entry_hash()? { + if target_address + .try_into() + .is_ok_and(|target_entry_hash: EntryHash| target_entry_hash != path_entry_hash) + { return Ok(ValidateCallbackResult::Invalid( "PrefixIndex first component: target address must be index name".into(), )); @@ -32,8 +37,11 @@ pub fn validate_create_link_prefix_index( } } // second component - else if EntryHash::from(base_address) - == Path::from(prefix_index.index_name.clone()).path_entry_hash()? + else if base_address + .try_into() + .is_ok_and(|base_address_entry_hash: EntryHash| { + base_address_entry_hash == prefix_index_entry_hash + }) { if tag_string.chars().count() != prefix_index.width { return Ok(ValidateCallbackResult::Invalid("PrefixIndex second component: tag string must have same number of chars as prefix index width".into())); From a739465e6f6b3c427cc0db9cb1f5dcf589047c8e Mon Sep 17 00:00:00 2001 From: Jost Schulte Date: Tue, 11 Jul 2023 15:15:50 -0600 Subject: [PATCH 03/10] refactor: unstable is_ok_and --- lib/prefix_index/src/prefix_index.rs | 17 ++++++----------- lib/prefix_index/src/validate.rs | 17 +++++++---------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/lib/prefix_index/src/prefix_index.rs b/lib/prefix_index/src/prefix_index.rs index d7eedcf..96f3024 100644 --- a/lib/prefix_index/src/prefix_index.rs +++ b/lib/prefix_index/src/prefix_index.rs @@ -93,22 +93,17 @@ impl PrefixIndex { let result_children: Vec = children .clone() .into_iter() - .filter(|c| { - c.target.clone().try_into().is_ok_and(|link_entry_hash: EntryHash| { - link_entry_hash == path_entry_hash - }) + .filter(|c| match EntryHash::try_from(c.target.clone()) { + Ok(link_entry_hash) => link_entry_hash == path_entry_hash, + Err(_) => false, }) .collect(); // Delete children link corresponding to current path for child in result_children.clone().into_iter() { - if child - .target - .try_into() - .is_ok_and(|child_entry_hash: EntryHash| { - child_entry_hash == path_entry_hash - }) - { + let child_entry_hash = + EntryHash::try_from(child.target).map_err(|err| wasm_error!(err))?; + if child_entry_hash == path_entry_hash { delete_link(child.create_link_hash)?; } } diff --git a/lib/prefix_index/src/validate.rs b/lib/prefix_index/src/validate.rs index 966661c..4cc8845 100644 --- a/lib/prefix_index/src/validate.rs +++ b/lib/prefix_index/src/validate.rs @@ -22,10 +22,9 @@ pub fn validate_create_link_prefix_index( let path_entry_hash = path.path_entry_hash()?; let prefix_index_entry_hash = Path::from(prefix_index.index_name.clone()).path_entry_hash()?; if base_address == root_hash()? { - if target_address - .try_into() - .is_ok_and(|target_entry_hash: EntryHash| target_entry_hash != path_entry_hash) - { + let target_entry_hash = + EntryHash::try_from(target_address).map_err(|err| wasm_error!(err))?; + if target_entry_hash != path_entry_hash { return Ok(ValidateCallbackResult::Invalid( "PrefixIndex first component: target address must be index name".into(), )); @@ -37,12 +36,10 @@ pub fn validate_create_link_prefix_index( } } // second component - else if base_address - .try_into() - .is_ok_and(|base_address_entry_hash: EntryHash| { - base_address_entry_hash == prefix_index_entry_hash - }) - { + else if EntryHash::try_from(base_address).ok().map_or_else( + || false, + |base_address_entry_hash| base_address_entry_hash == prefix_index_entry_hash, + ) { if tag_string.chars().count() != prefix_index.width { return Ok(ValidateCallbackResult::Invalid("PrefixIndex second component: tag string must have same number of chars as prefix index width".into())); } From f5d593184f494ccaa7b432aca70a8e0c6c1223d5 Mon Sep 17 00:00:00 2001 From: Jost Schulte Date: Mon, 17 Jul 2023 15:44:37 -0600 Subject: [PATCH 04/10] build: upgrade to holochain 0.3.0-beta-dev.9 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- flake.lock | 32 ++++++++++++++++---------------- flake.nix | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f098d25..3d2221e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -828,9 +828,9 @@ dependencies = [ [[package]] name = "hdk" -version = "0.3.0-beta-dev.7" +version = "0.3.0-beta-dev.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2afd4494fd611e20213496e54cd6186525eaa79f3a8b45445fb20d1e40679745" +checksum = "ad6aa4fcf47e9bb0904d353d48f596152c903c8d35925466f8266de90d15296b" dependencies = [ "getrandom", "hdi", diff --git a/Cargo.toml b/Cargo.toml index 494369c..1b41c52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ members = ["dnas/*/zomes/coordinator/*", "dnas/*/zomes/integrity/*", "lib/*"] [workspace.dependencies] hdi = "=0.4.0-beta-dev.5" -hdk = "=0.3.0-beta-dev.7" +hdk = "=0.3.0-beta-dev.8" holochain_integrity_types = "=0.3.0-beta-dev.5" serde = "1" diff --git a/flake.lock b/flake.lock index 9dbe3d4..19f847f 100644 --- a/flake.lock +++ b/flake.lock @@ -376,11 +376,11 @@ ] }, "locked": { - "lastModified": 1689092049, - "narHash": "sha256-Bej7kWmHZQM5OZSPciRKcLKAVemefaSm7/+q13hSHnk=", + "lastModified": 1689609847, + "narHash": "sha256-8ZbkOzhN3KJJhrKflvSlZ3gJWzNtmIVLev0Hhs2wfDs=", "owner": "holochain", "repo": "holochain", - "rev": "43f0aa760bbba1afed8415d66c3f901a77d4655e", + "rev": "0425b371e9a590fe7968c736d9ba33f04bce7d5a", "type": "github" }, "original": { @@ -425,16 +425,16 @@ "versions": "versions" }, "locked": { - "lastModified": 1688518351, - "narHash": "sha256-LU4/kPsHkMVGnWLUpNGpsmfep1NPFI8HXe7A1mwkzvM=", + "lastModified": 1689122921, + "narHash": "sha256-svp33+JS3EFftd3Pw1pVgedRt0K7Okof6NSLRp2nXJY=", "owner": "holochain", "repo": "holochain", - "rev": "a92af07552c5cb70436c501b67e0c064ac699157", + "rev": "738e3c1db87a5af11d7f86c63f3e142d04629495", "type": "github" }, "original": { "owner": "holochain", - "ref": "holochain-0.3.0-beta-dev.8", + "ref": "holochain-0.3.0-beta-dev.9", "repo": "holochain", "type": "github" } @@ -745,11 +745,11 @@ ] }, "locked": { - "lastModified": 1688438033, - "narHash": "sha256-wOmpZis06pVKTR+5meGwhrW10/buf98lnA26uQLaqek=", + "lastModified": 1689042658, + "narHash": "sha256-p7cQAFNt5kX19sZvK74CmY0nTrtujpZg6sZUiV1ntAk=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "c3e43223dece545cfe06ddd92fd782adc73d56c3", + "rev": "d7181bb2237035df17cab9295c95f987f5c527e6", "type": "github" }, "original": { @@ -767,11 +767,11 @@ ] }, "locked": { - "lastModified": 1689042658, - "narHash": "sha256-p7cQAFNt5kX19sZvK74CmY0nTrtujpZg6sZUiV1ntAk=", + "lastModified": 1689561325, + "narHash": "sha256-+UABrHUXtWJSc9mM7oEKPIYQEhTzUVVNy2IPG9Lfrj0=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "d7181bb2237035df17cab9295c95f987f5c527e6", + "rev": "d8a38aea13c67dc2ce10cff93eb274dcf455753f", "type": "github" }, "original": { @@ -873,11 +873,11 @@ }, "locked": { "dir": "versions/0_2", - "lastModified": 1689092049, - "narHash": "sha256-Bej7kWmHZQM5OZSPciRKcLKAVemefaSm7/+q13hSHnk=", + "lastModified": 1689609847, + "narHash": "sha256-8ZbkOzhN3KJJhrKflvSlZ3gJWzNtmIVLev0Hhs2wfDs=", "owner": "holochain", "repo": "holochain", - "rev": "43f0aa760bbba1afed8415d66c3f901a77d4655e", + "rev": "0425b371e9a590fe7968c736d9ba33f04bce7d5a", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index c11886e..98082cd 100644 --- a/flake.nix +++ b/flake.nix @@ -8,7 +8,7 @@ holochain = { url = "github:holochain/holochain"; inputs.versions.follows = "versions"; - inputs.holochain.url = "github:holochain/holochain/holochain-0.3.0-beta-dev.8"; + inputs.holochain.url = "github:holochain/holochain/holochain-0.3.0-beta-dev.9"; }; }; From 185b233fe215a9b28d427898e62de2e10220b914 Mon Sep 17 00:00:00 2001 From: Jost Schulte Date: Mon, 17 Jul 2023 15:55:55 -0600 Subject: [PATCH 05/10] build(npm): upgrade client & tryorama --- package-lock.json | 60 +++++++++++++++++++++++++++++++++------------- tests/package.json | 4 ++-- 2 files changed, 45 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index 107b954..f8de5ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -387,21 +387,22 @@ } }, "node_modules/@holochain/client": { - "version": "0.12.5", - "resolved": "https://registry.npmjs.org/@holochain/client/-/client-0.12.5.tgz", - "integrity": "sha512-9Q1G8sKEGsqnCl067CaRbzwPZZ5zeDCJdvQ8TJpb+psP2kLJBbHZ2qulMXAlNUz7Pg0l4B1Eh/BFJByJHRLlow==", + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/@holochain/client/-/client-0.14.1.tgz", + "integrity": "sha512-5rWPIRdxhvV+SpKHegKsPSw7AcN1JjtLS5RhAlLT7dsXvn70BcMWsImhBs1sqw69QsbEMKlhqaOH+sOS5LkDBQ==", "dependencies": { "@holochain/serialization": "^0.1.0-beta-rc.3", "@msgpack/msgpack": "^2.7.2", + "@noble/ed25519": "^2.0.0", "@tauri-apps/api": "^1.2.0", "emittery": "^1.0.1", "isomorphic-ws": "^5.0.0", "js-base64": "^3.7.3", "lodash-es": "^4.17.21", - "tweetnacl": "^1.0.3" + "ws": "^8.13.0" }, "engines": { - "node": "^14.13.1 || >=16.0.0 || >=18.0.0" + "node": ">=16.0.0 || >=18.0.0" } }, "node_modules/@holochain/serialization": { @@ -410,11 +411,11 @@ "integrity": "sha512-DJx4V2KXHVLciyOGjOYKTM/JLBpBEZ3RsPIRCgf7qmwhQdxXvhi2p+oFFRD51yUT5uC1/MzIVeJCl/R60PwFbw==" }, "node_modules/@holochain/tryorama": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/@holochain/tryorama/-/tryorama-0.11.2.tgz", - "integrity": "sha512-RCi7QtGejpzfGIx1EKyTX+QnkooGaUAY0TiFHDc5uamCvNNX1Ya6Esgvyrt2zpO5YBUUrSbdbB1gBB3a8bwr7A==", + "version": "0.15.0-rc.1", + "resolved": "https://registry.npmjs.org/@holochain/tryorama/-/tryorama-0.15.0-rc.1.tgz", + "integrity": "sha512-R7MyojYcfzVePyXSWtVSFW2G7LUpErb/krLN12MIvNxGd9355Lb/mLl6phEdsnpAJx6fUejM0KXQvbHUnzXjeA==", "dependencies": { - "@holochain/client": "^0.12.0", + "@holochain/client": "^0.14.1", "get-port": "^6.1.2", "lodash": "^4.17.21", "uuid": "^8.3.2", @@ -422,7 +423,7 @@ "ws": "^8.11.0" }, "engines": { - "node": "^14.13.1 || >=16.0.0 || >=18.0.0" + "node": ">=16.0.0 || >=18.0.0" } }, "node_modules/@msgpack/msgpack": { @@ -433,6 +434,17 @@ "node": ">= 10" } }, + "node_modules/@noble/ed25519": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@noble/ed25519/-/ed25519-2.0.0.tgz", + "integrity": "sha512-/extjhkwFupyopDrt80OMWKdLgP429qLZj+z6sYJz90rF2Iz0gjZh2ArMKPImUl13Kx+0EXI2hN9T/KJV0/Zng==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ] + }, "node_modules/@tauri-apps/api": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@tauri-apps/api/-/api-1.2.0.tgz", @@ -1593,11 +1605,6 @@ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true }, - "node_modules/tweetnacl": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", - "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" - }, "node_modules/type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -1912,12 +1919,31 @@ }, "tests": { "dependencies": { - "@holochain/client": "^0.12.2", - "@holochain/tryorama": "^0.11.0", + "@holochain/client": "^0.15.0", + "@holochain/tryorama": "^0.15.0-rc.1", "@msgpack/msgpack": "^2.7.0", "typescript": "^4.9.4", "vitest": "^0.28.4" } + }, + "tests/node_modules/@holochain/client": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/@holochain/client/-/client-0.15.0.tgz", + "integrity": "sha512-4cZXSXEOf3XbYzq17Min5bymK/w4Ev3+S6doPj+1VQcZnn35JsP6eUdyKfRvSRopxykplXAM1xw0+8/j7DlHsA==", + "dependencies": { + "@holochain/serialization": "^0.1.0-beta-rc.3", + "@msgpack/msgpack": "^2.7.2", + "@noble/ed25519": "^2.0.0", + "@tauri-apps/api": "^1.2.0", + "emittery": "^1.0.1", + "isomorphic-ws": "^5.0.0", + "js-base64": "^3.7.3", + "lodash-es": "^4.17.21", + "ws": "^8.13.0" + }, + "engines": { + "node": ">=16.0.0 || >=18.0.0" + } } } } diff --git a/tests/package.json b/tests/package.json index 88d08e6..abe9774 100644 --- a/tests/package.json +++ b/tests/package.json @@ -6,8 +6,8 @@ }, "dependencies": { "@msgpack/msgpack": "^2.7.0", - "@holochain/client": "^0.12.2", - "@holochain/tryorama": "^0.11.0", + "@holochain/client": "^0.15.0", + "@holochain/tryorama": "^0.15.0-rc.1", "typescript": "^4.9.4", "vitest": "^0.28.4" }, From 59b2e0f123a65bde7a76c613e66d2cc8fe9d2caa Mon Sep 17 00:00:00 2001 From: Matt Gabrenya Date: Tue, 25 Jul 2023 13:59:14 -0700 Subject: [PATCH 06/10] build: bump holochain deps to 0.2.1 --- Cargo.lock | 44 ++++++++++++++++++++++---------------------- Cargo.toml | 6 +++--- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3d2221e..3af5861 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -811,9 +811,9 @@ dependencies = [ [[package]] name = "hdi" -version = "0.4.0-beta-dev.5" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6e0352aefff46fa9e1b9172fd5326b4cc75bc1346712100fde8e87143d1ab09" +checksum = "6115e6d52f5da0fe55ec9608ff93e5e61211a66a3628f97e0cbbfd4131787cf6" dependencies = [ "hdk_derive", "holo_hash", @@ -828,9 +828,9 @@ dependencies = [ [[package]] name = "hdk" -version = "0.3.0-beta-dev.8" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad6aa4fcf47e9bb0904d353d48f596152c903c8d35925466f8266de90d15296b" +checksum = "8f5690ef906744725fcd16ae3d13b0e2ba22f046f4a9be2dc21ec2e4b3cf049a" dependencies = [ "getrandom", "hdi", @@ -848,9 +848,9 @@ dependencies = [ [[package]] name = "hdk_derive" -version = "0.3.0-beta-dev.5" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32bad9b4735c59bc1b3b70ce7fe1270e1051afc0e8d0186d8c195550717e58ad" +checksum = "d220ca3a6c5992600052e025f0c3f2342d6a4cf7fe52687135acda9128a62eae" dependencies = [ "darling", "heck", @@ -900,9 +900,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "holo_hash" -version = "0.3.0-beta-dev.4" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f77366144e6ff54b1ecfd95fb528c470c5ba3d86cb1d4d7c5553f2b5677124c" +checksum = "a39f740985893adf2be5ad75987456ed2ce2f1d6d53cdf534e4fbe96ebae0940" dependencies = [ "base64", "blake2b_simd", @@ -917,9 +917,9 @@ dependencies = [ [[package]] name = "holochain_integrity_types" -version = "0.3.0-beta-dev.5" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dec8f48078b5c348d6cdefcea9922d587c1c672b7c10ff0cb5fa72353809b7" +checksum = "f92876d5a2fa142858efe38fe4f6b9f25ae1be9441bf90cb516ed613df77f50d" dependencies = [ "holo_hash", "holochain_serialized_bytes", @@ -988,9 +988,9 @@ dependencies = [ [[package]] name = "holochain_zome_types" -version = "0.3.0-beta-dev.6" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56a1bb8fbc9799fe79730f43d2c3b0a944f68f2487b4b2db2c752d435e0fc6a0" +checksum = "a5017d60431ed65bdb25974fdd98a267fccf0436725952cdd8ac0cce660c6c79" dependencies = [ "holo_hash", "holochain_integrity_types", @@ -1123,9 +1123,9 @@ dependencies = [ [[package]] name = "kitsune_p2p_bin_data" -version = "0.3.0-beta-dev.4" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaa50a12a5755c2b9109cbc435a6565fe4b324f149c07848fc3e8655b4b0577c" +checksum = "9845f57ef9189f403609ada819b26ca87e96ccf95fef02bebcdf83faa65b1924" dependencies = [ "base64", "derive_more", @@ -1137,9 +1137,9 @@ dependencies = [ [[package]] name = "kitsune_p2p_block" -version = "0.3.0-beta-dev.4" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6a757e1dd315d66086fc9f013cb85d9c263eef7569db63ce0990e4ec12d6fd2" +checksum = "3a29e6b5eeb78b37d9d0040855603f3a00c6c7055d933a6e5b6b31aa9529b326" dependencies = [ "kitsune_p2p_bin_data", "kitsune_p2p_timestamp", @@ -1149,9 +1149,9 @@ dependencies = [ [[package]] name = "kitsune_p2p_dht" -version = "0.3.0-beta-dev.3" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643901283087a01ee85fa3f2a650b2eb1931d7d9916a80d0ce836066b2a37758" +checksum = "8fb834fef2af5271ec002e2726b2be7755e9d7b7b666a5dcfa3847b3a3a89cfd" dependencies = [ "colored", "derivative", @@ -1173,9 +1173,9 @@ dependencies = [ [[package]] name = "kitsune_p2p_dht_arc" -version = "0.3.0-beta-dev.3" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfbbc1c930888d6aa22099497139f0225e7dcdb90dd3e7fc2cc01dc9e2ba9f0e" +checksum = "ee2d4d68c154cdc5391ea986eb278f5b34707908cf63674d9fe8e7142d49c449" dependencies = [ "derive_more", "gcollections", @@ -1186,9 +1186,9 @@ dependencies = [ [[package]] name = "kitsune_p2p_timestamp" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be6483b304900c20fa104c50947cc1adf0e277fccdba8e26134d7b49dbdfd2a0" +checksum = "b46a356525779ac9b2b4956cee7ea523c8723f1955596d5e070faac2723a0b65" dependencies = [ "chrono", "derive_more", diff --git a/Cargo.toml b/Cargo.toml index 1b41c52..f055972 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,9 +8,9 @@ opt-level = "z" members = ["dnas/*/zomes/coordinator/*", "dnas/*/zomes/integrity/*", "lib/*"] [workspace.dependencies] -hdi = "=0.4.0-beta-dev.5" -hdk = "=0.3.0-beta-dev.8" -holochain_integrity_types = "=0.3.0-beta-dev.5" +hdi = "=0.3.1" +hdk = "=0.2.1" +holochain_integrity_types = "=0.2.1" serde = "1" [workspace.dependencies.demo] From 895a758199cd30eddd472c6f6818d7d300635317 Mon Sep 17 00:00:00 2001 From: Matt Gabrenya Date: Tue, 25 Jul 2023 14:39:26 -0700 Subject: [PATCH 07/10] chore: bump flake lock --- flake.lock | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/flake.lock b/flake.lock index 19f847f..63f3b23 100644 --- a/flake.lock +++ b/flake.lock @@ -376,11 +376,11 @@ ] }, "locked": { - "lastModified": 1689609847, - "narHash": "sha256-8ZbkOzhN3KJJhrKflvSlZ3gJWzNtmIVLev0Hhs2wfDs=", + "lastModified": 1690302341, + "narHash": "sha256-ZVPP+5Lb8fyaKGI1zXFuh3fJn3hP5RoYxX5zb8b6QYA=", "owner": "holochain", "repo": "holochain", - "rev": "0425b371e9a590fe7968c736d9ba33f04bce7d5a", + "rev": "378dd3bb620e54663147af634ce4014651a156ec", "type": "github" }, "original": { @@ -459,16 +459,16 @@ "holochain_4": { "flake": false, "locked": { - "lastModified": 1684139928, - "narHash": "sha256-uno5MTiBwf9RiEiX6iKzJsB+3srJFKwV/1ReXzaZVVw=", + "lastModified": 1690227710, + "narHash": "sha256-HRVEz5Ldg2+pqciOpZ9fNdMfU93r/3LmUsbTA9jfDIY=", "owner": "holochain", "repo": "holochain", - "rev": "a91b262e87653f5f2e3a50c06eaac2bb81fb88d3", + "rev": "3f594f1a5cef41e896b99b6b46d336d54da3299d", "type": "github" }, "original": { "owner": "holochain", - "ref": "holochain-0.2.1-beta-dev.0", + "ref": "holochain-0.2.1", "repo": "holochain", "type": "github" } @@ -767,11 +767,11 @@ ] }, "locked": { - "lastModified": 1689561325, - "narHash": "sha256-+UABrHUXtWJSc9mM7oEKPIYQEhTzUVVNy2IPG9Lfrj0=", + "lastModified": 1690252178, + "narHash": "sha256-9oEz822bvbHobfCUjJLDor2BqW3I5tycIauzDlzOALY=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "d8a38aea13c67dc2ce10cff93eb274dcf455753f", + "rev": "8d64353ca827002fb8459e44d49116c78d868eba", "type": "github" }, "original": { @@ -873,11 +873,11 @@ }, "locked": { "dir": "versions/0_2", - "lastModified": 1689609847, - "narHash": "sha256-8ZbkOzhN3KJJhrKflvSlZ3gJWzNtmIVLev0Hhs2wfDs=", + "lastModified": 1690302341, + "narHash": "sha256-ZVPP+5Lb8fyaKGI1zXFuh3fJn3hP5RoYxX5zb8b6QYA=", "owner": "holochain", "repo": "holochain", - "rev": "0425b371e9a590fe7968c736d9ba33f04bce7d5a", + "rev": "378dd3bb620e54663147af634ce4014651a156ec", "type": "github" }, "original": { From a600cb31d4d37fd24411d6da76a0d3927366f6df Mon Sep 17 00:00:00 2001 From: Matt Gabrenya Date: Tue, 25 Jul 2023 15:05:15 -0700 Subject: [PATCH 08/10] ci: better caching in github action --- .github/workflows/test.yaml | 74 ++++++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4125849..de0d036 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,30 +1,68 @@ -name: "test" +name: CI + on: - # Trigger the workflow on push or pull request, - # but only for the main branch - push: - branches: [ main, develop ] pull_request: - branches: [ main, develop ] + push: + branches: + - "develop" + - "main" + +concurrency: + group: ${{ github.ref_name }} + cancel-in-progress: true jobs: - testbuild: - runs-on: ubuntu-latest + build-and-test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + fail-fast: false + steps: - - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v3 - name: Install nix - uses: cachix/install-nix-action@v18 - with: - install_url: https://releases.nixos.org/nix/nix-2.12.0/install - extra_nix_config: | - experimental-features = flakes nix-command + uses: cachix/install-nix-action@v22 - - uses: cachix/cachix-action@v10 + - name: Set up cachix + uses: cachix/cachix-action@v12 with: name: holochain-ci - - name: Install and test - run: | - nix develop --command bash -c "npm i && npm t" + - name: Restore cargo and build from cache + uses: actions/cache/restore@v3 + with: + path: | + .cargo + target + key: ${{ runner.os }}-build-${{ hashFiles('Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-build- + + - name: Install nix packages + run: nix develop -c $SHELL -c "echo Nix packages installed" + + - name: Install JS packages + run: nix develop -c $SHELL -c "npm ci" + + - name: Clippy + run: nix develop -c $SHELL -c "npm run cargo:clippy" + + - name: Check rust formatting + run: nix develop -c $SHELL -c "npm run cargo:fmt:check" + + - name: Build Happ + run: nix develop -c $SHELL -c "npm run build:happ" + + - name: Save cargo and build to cache + uses: actions/cache/save@v3 + with: + path: | + .cargo + target + key: ${{ runner.os }}-build-${{ hashFiles('Cargo.lock') }} + - name: Test with tryorama + run: nix develop -c $SHELL -c "npm test" From 7030515bc8f00608814c6c2445397eb009a147d2 Mon Sep 17 00:00:00 2001 From: Matt Gabrenya Date: Tue, 25 Jul 2023 16:12:59 -0700 Subject: [PATCH 09/10] chore: clippy + fmt --- .../coordinator/demo/src/demo_prefix_index.rs | 14 +--- dnas/demo/zomes/coordinator/demo/src/lib.rs | 2 +- dnas/demo/zomes/integrity/demo/src/lib.rs | 70 +++++++++------- lib/prefix_index/src/lib.rs | 2 +- lib/prefix_index/src/prefix_index.rs | 19 ++--- lib/prefix_index/src/utils.rs | 84 +++++++++---------- lib/prefix_index/src/validate.rs | 8 +- 7 files changed, 101 insertions(+), 98 deletions(-) diff --git a/dnas/demo/zomes/coordinator/demo/src/demo_prefix_index.rs b/dnas/demo/zomes/coordinator/demo/src/demo_prefix_index.rs index 9f5f940..0d17447 100644 --- a/dnas/demo/zomes/coordinator/demo/src/demo_prefix_index.rs +++ b/dnas/demo/zomes/coordinator/demo/src/demo_prefix_index.rs @@ -142,11 +142,7 @@ pub fn remove_hashtag_from_index_a(hashtag: String) -> ExternResult<()> { } fn make_hashtag_index_text(text: String) -> String { - text - .split('#') - .nth(1) - .unwrap_or(&text) - .to_string() + text.split('#').nth(1).unwrap_or(&text).to_string() } #[hdk_extern] @@ -180,9 +176,5 @@ pub fn remove_cashtag_from_index_a(cashtag: String) -> ExternResult<()> { } fn make_cashtag_index_text(text: String) -> String { - text - .split('$') - .nth(1) - .unwrap_or(&text) - .to_string() -} \ No newline at end of file + text.split('$').nth(1).unwrap_or(&text).to_string() +} diff --git a/dnas/demo/zomes/coordinator/demo/src/lib.rs b/dnas/demo/zomes/coordinator/demo/src/lib.rs index 8dfda2d..77bde24 100644 --- a/dnas/demo/zomes/coordinator/demo/src/lib.rs +++ b/dnas/demo/zomes/coordinator/demo/src/lib.rs @@ -25,6 +25,6 @@ pub fn post_commit(committed_actions: Vec) { } /// Don't modify this function if you want the scaffolding tool to generate appropriate signals for your entries and links -fn signal_action(action: SignedActionHashed) -> ExternResult<()> { +fn signal_action(_action: SignedActionHashed) -> ExternResult<()> { Ok(()) } diff --git a/dnas/demo/zomes/integrity/demo/src/lib.rs b/dnas/demo/zomes/integrity/demo/src/lib.rs index 1ed0114..197476e 100644 --- a/dnas/demo/zomes/integrity/demo/src/lib.rs +++ b/dnas/demo/zomes/integrity/demo/src/lib.rs @@ -82,11 +82,16 @@ pub fn validate(op: Op) -> ExternResult { match op.flattened::<(), LinkTypes>()? { FlatOp::StoreEntry(store_entry) => match store_entry { - OpEntry::CreateEntry { app_entry, action } => Ok(ValidateCallbackResult::Invalid( + OpEntry::CreateEntry { + app_entry: _, + action: _, + } => Ok(ValidateCallbackResult::Invalid( "There are no entry types in this integrity zome".to_string(), )), OpEntry::UpdateEntry { - app_entry, action, .. + app_entry: _, + action: _, + .. } => Ok(ValidateCallbackResult::Invalid( "There are no entry types in this integrity zome".to_string(), )), @@ -94,10 +99,10 @@ pub fn validate(op: Op) -> ExternResult { }, FlatOp::RegisterUpdate(update_entry) => match update_entry { OpUpdate::Entry { - original_action, - original_app_entry, - app_entry, - action, + original_action: _, + original_app_entry: _, + app_entry: _, + action: _, } => Ok(ValidateCallbackResult::Invalid( "There are no entry types in this integrity zome".to_string(), )), @@ -105,9 +110,9 @@ pub fn validate(op: Op) -> ExternResult { }, FlatOp::RegisterDelete(delete_entry) => match delete_entry { OpDelete::Entry { - original_action, - original_app_entry, - action, + original_action: _, + original_app_entry: _, + action: _, } => Ok(ValidateCallbackResult::Invalid( "There are no entry types in this integrity zome".to_string(), )), @@ -115,9 +120,9 @@ pub fn validate(op: Op) -> ExternResult { }, FlatOp::RegisterCreateLink { link_type, - base_address, - target_address, - tag, + base_address: _, + target_address: _, + tag: _, action, } => match link_type { LinkTypes::PrefixIndexA => prefix_index_a.validate_create_link(action), @@ -126,9 +131,9 @@ pub fn validate(op: Op) -> ExternResult { }, FlatOp::RegisterDeleteLink { link_type, - base_address, - target_address, - tag, + base_address: _, + target_address: _, + tag: _, original_action, action, } => match link_type { @@ -140,16 +145,19 @@ pub fn validate(op: Op) -> ExternResult { // Complementary validation to the `StoreEntry` Op, in which the record itself is validated // If you want to optimize performance, you can remove the validation for an entry type here and keep it in `StoreEntry` // Notice that doing so will cause `must_get_valid_record` for this record to return a valid record even if the `StoreEntry` validation failed - OpRecord::CreateEntry { app_entry, action } => Ok(ValidateCallbackResult::Invalid( + OpRecord::CreateEntry { + app_entry: _, + action: _, + } => Ok(ValidateCallbackResult::Invalid( "There are no entry types in this integrity zome".to_string(), )), // Complementary validation to the `RegisterUpdate` Op, in which the record itself is validated // If you want to optimize performance, you can remove the validation for an entry type here and keep it in `StoreEntry` and in `RegisterUpdate` // Notice that doing so will cause `must_get_valid_record` for this record to return a valid record even if the other validations failed OpRecord::UpdateEntry { - original_action_hash, - app_entry, - action, + original_action_hash: _, + app_entry: _, + action: _, .. } => Ok(ValidateCallbackResult::Invalid( "There are no entry types in this integrity zome".to_string(), @@ -158,8 +166,8 @@ pub fn validate(op: Op) -> ExternResult { // If you want to optimize performance, you can remove the validation for an entry type here and keep it in `RegisterDelete` // Notice that doing so will cause `must_get_valid_record` for this record to return a valid record even if the `RegisterDelete` validation failed OpRecord::DeleteEntry { - original_action_hash, - action, + original_action_hash: _, + action: _, .. } => Ok(ValidateCallbackResult::Invalid( "There are no entry types in this integrity zome".to_string(), @@ -168,9 +176,9 @@ pub fn validate(op: Op) -> ExternResult { // If you want to optimize performance, you can remove the validation for an entry type here and keep it in `RegisterCreateLink` // Notice that doing so will cause `must_get_valid_record` for this record to return a valid record even if the `RegisterCreateLink` validation failed OpRecord::CreateLink { - base_address, - target_address, - tag, + base_address: _, + target_address: _, + tag: _, link_type, action, } => match link_type { @@ -183,7 +191,7 @@ pub fn validate(op: Op) -> ExternResult { // Notice that doing so will cause `must_get_valid_record` for this record to return a valid record even if the `RegisterDeleteLink` validation failed OpRecord::DeleteLink { original_action_hash, - base_address, + base_address: _, action, } => { let record = must_get_valid_record(original_action_hash)?; @@ -204,9 +212,15 @@ pub fn validate(op: Op) -> ExternResult { }; match link_type { - LinkTypes::PrefixIndexA => prefix_index_a.validate_delete_link(action, create_link.clone()), - LinkTypes::PrefixIndexB => prefix_index_b.validate_delete_link(action, create_link.clone()), - LinkTypes::PrefixIndexC => prefix_index_c.validate_delete_link(action, create_link.clone()), + LinkTypes::PrefixIndexA => { + prefix_index_a.validate_delete_link(action, create_link) + } + LinkTypes::PrefixIndexB => { + prefix_index_b.validate_delete_link(action, create_link) + } + LinkTypes::PrefixIndexC => { + prefix_index_c.validate_delete_link(action, create_link) + } } } OpRecord::CreatePrivateEntry { .. } => Ok(ValidateCallbackResult::Valid), diff --git a/lib/prefix_index/src/lib.rs b/lib/prefix_index/src/lib.rs index 0e050f2..c96fd6e 100644 --- a/lib/prefix_index/src/lib.rs +++ b/lib/prefix_index/src/lib.rs @@ -5,5 +5,5 @@ //! Useful for type-ahead "search" or autocomplete features. pub mod prefix_index; pub use prefix_index::*; +mod utils; mod validate; -mod utils; \ No newline at end of file diff --git a/lib/prefix_index/src/prefix_index.rs b/lib/prefix_index/src/prefix_index.rs index 96f3024..c206784 100644 --- a/lib/prefix_index/src/prefix_index.rs +++ b/lib/prefix_index/src/prefix_index.rs @@ -68,7 +68,7 @@ impl PrefixIndex { fn inner_remove_result(&self, text: String, full_text: Option) -> ExternResult<()> { let path = self - .make_result_path(text.clone(), full_text)? + .make_result_path(text, full_text)? .typed(self.link_type)?; self.inner_remove_result_from_path(path)?; @@ -110,14 +110,14 @@ impl PrefixIndex { // Get other children of parent of path let mut other_children = vec![]; - for i in children.clone().into_iter() { + for i in children.into_iter() { if !result_children.contains(&i) { other_children.push(i); } } // If there are no other children of parent of path, delete parent of path - if other_children.len() == 0 && !parent.is_root() { + if other_children.is_empty() && !parent.is_root() { self.inner_remove_result_from_path(parent)?; } } @@ -202,7 +202,7 @@ impl PrefixIndex { original_action: CreateLink, ) -> ExternResult { validate_delete_link_prefix_index( - action.clone(), + action, original_action.clone(), original_action.base_address, original_action.target_address, @@ -228,20 +228,17 @@ impl PrefixIndex { ) -> ExternResult> { let results = self.get_results_from_path(path, limit, shuffle)?; - let leafs: Vec = results + let strings: Vec = results .into_iter() .filter(|r| r.leaf().is_some()) .map(|p| p.leaf().unwrap().clone()) - .collect(); - - let strings = leafs - .into_iter() .filter_map(|c| String::try_from(&c).ok()) .collect(); Ok(strings) } + #[allow(clippy::only_used_in_recursion)] fn inner_get_results_from_path( &self, path: TypedPath, @@ -253,7 +250,7 @@ impl PrefixIndex { visited.push(path.clone()); let mut children = get_children_paths(path.clone())?; - match children.len() == 0 { + match children.is_empty() { true => { if path.exists()? && !results.contains(&path) && results.len() < limit { results.push(path.clone()); @@ -287,7 +284,7 @@ impl PrefixIndex { visited.clone(), results.clone(), ) - .unwrap_or(vec![]); + .unwrap_or_default(); for grandchild in grandchildren.into_iter() { if grandchild.exists()? diff --git a/lib/prefix_index/src/utils.rs b/lib/prefix_index/src/utils.rs index 9a069d2..2b2dbdd 100644 --- a/lib/prefix_index/src/utils.rs +++ b/lib/prefix_index/src/utils.rs @@ -1,56 +1,56 @@ -use hdk::{prelude::*, hash_path::path::Component}; +use hdk::{hash_path::path::Component, prelude::*}; /// Duplicates of get_children from holochain TypedPath /// but without calling ensure() on those children pub fn get_children(path: TypedPath) -> ExternResult> { - let mut unwrapped = get_links( - path.path_entry_hash()?, - LinkTypeFilter::single_type(path.link_type.zome_index, path.link_type.zome_type), - None, - )?; - // Only need one of each hash to build the tree. - unwrapped.sort_unstable_by(|a, b| a.tag.cmp(&b.tag)); - unwrapped.dedup_by(|a, b| a.tag.eq(&b.tag)); - Ok(unwrapped) + let mut unwrapped = get_links( + path.path_entry_hash()?, + LinkTypeFilter::single_type(path.link_type.zome_index, path.link_type.zome_type), + None, + )?; + // Only need one of each hash to build the tree. + unwrapped.sort_unstable_by(|a, b| a.tag.cmp(&b.tag)); + unwrapped.dedup_by(|a, b| a.tag.eq(&b.tag)); + Ok(unwrapped) } /// Duplicates of get_children_paths from holochain TypedPath /// but without calling ensure() on those children pub fn get_children_paths(path: TypedPath) -> ExternResult> { - let children = get_children(path.clone())?; - let components: ExternResult>> = children - .into_iter() - .map(|link| { - let component_bytes = &link.tag.0[..]; - if component_bytes.is_empty() { - Ok(None) - } else { - Ok(Some( - SerializedBytes::from(UnsafeBytes::from(component_bytes.to_vec())) - .try_into() - .map_err(|e: SerializedBytesError| wasm_error!(e))?, - )) - } - }) - .collect(); - Ok(components? - .into_iter() - .map(|maybe_component| { - let mut new_path = path.path.clone(); - if let Some(component) = maybe_component { - new_path.append_component(component); - } - new_path.into_typed(path.link_type) - }) - .collect()) + let children = get_children(path.clone())?; + let components: ExternResult>> = children + .into_iter() + .map(|link| { + let component_bytes = &link.tag.0[..]; + if component_bytes.is_empty() { + Ok(None) + } else { + Ok(Some( + SerializedBytes::from(UnsafeBytes::from(component_bytes.to_vec())) + .try_into() + .map_err(|e: SerializedBytesError| wasm_error!(e))?, + )) + } + }) + .collect(); + Ok(components? + .into_iter() + .map(|maybe_component| { + let mut new_path = path.path.clone(); + if let Some(component) = maybe_component { + new_path.append_component(component); + } + new_path.into_typed(path.link_type) + }) + .collect()) } pub fn path_to_string(path: TypedPath) -> String { - let component_strings: Vec = path - .as_ref() - .into_iter() - .filter_map(|c| String::try_from(c).ok()) - .collect(); + let component_strings: Vec = path + .as_ref() + .iter() + .filter_map(|c| String::try_from(c).ok()) + .collect(); - component_strings.join(".") + component_strings.join(".") } diff --git a/lib/prefix_index/src/validate.rs b/lib/prefix_index/src/validate.rs index 4cc8845..365ba5f 100644 --- a/lib/prefix_index/src/validate.rs +++ b/lib/prefix_index/src/validate.rs @@ -39,11 +39,11 @@ pub fn validate_create_link_prefix_index( else if EntryHash::try_from(base_address).ok().map_or_else( || false, |base_address_entry_hash| base_address_entry_hash == prefix_index_entry_hash, - ) { - if tag_string.chars().count() != prefix_index.width { - return Ok(ValidateCallbackResult::Invalid("PrefixIndex second component: tag string must have same number of chars as prefix index width".into())); - } + ) && tag_string.chars().count() != prefix_index.width + { + return Ok(ValidateCallbackResult::Invalid("PrefixIndex second component: tag string must have same number of chars as prefix index width".into())); } + // third or later component // unable to validate since we don't have any way of getting the previous links in the path // (we can't assume this link author is also the previous link author, so we can't use must_get_agent_activity) From fc64456a988be6a63053c020078bb197a3d6a982 Mon Sep 17 00:00:00 2001 From: Matt Gabrenya Date: Tue, 25 Jul 2023 17:27:17 -0700 Subject: [PATCH 10/10] build: update nix flake for 0.2.1, fix github action commands --- .github/workflows/test.yaml | 4 ++-- flake.lock | 8 ++++---- flake.nix | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index de0d036..8e10f53 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -48,10 +48,10 @@ jobs: run: nix develop -c $SHELL -c "npm ci" - name: Clippy - run: nix develop -c $SHELL -c "npm run cargo:clippy" + run: nix develop -c $SHELL -c "cargo clippy" - name: Check rust formatting - run: nix develop -c $SHELL -c "npm run cargo:fmt:check" + run: nix develop -c $SHELL -c "cargo fmt" - name: Build Happ run: nix develop -c $SHELL -c "npm run build:happ" diff --git a/flake.lock b/flake.lock index 63f3b23..b967782 100644 --- a/flake.lock +++ b/flake.lock @@ -425,16 +425,16 @@ "versions": "versions" }, "locked": { - "lastModified": 1689122921, - "narHash": "sha256-svp33+JS3EFftd3Pw1pVgedRt0K7Okof6NSLRp2nXJY=", + "lastModified": 1690227710, + "narHash": "sha256-HRVEz5Ldg2+pqciOpZ9fNdMfU93r/3LmUsbTA9jfDIY=", "owner": "holochain", "repo": "holochain", - "rev": "738e3c1db87a5af11d7f86c63f3e142d04629495", + "rev": "3f594f1a5cef41e896b99b6b46d336d54da3299d", "type": "github" }, "original": { "owner": "holochain", - "ref": "holochain-0.3.0-beta-dev.9", + "ref": "holochain-0.2.1", "repo": "holochain", "type": "github" } diff --git a/flake.nix b/flake.nix index 98082cd..bbec34f 100644 --- a/flake.nix +++ b/flake.nix @@ -8,7 +8,7 @@ holochain = { url = "github:holochain/holochain"; inputs.versions.follows = "versions"; - inputs.holochain.url = "github:holochain/holochain/holochain-0.3.0-beta-dev.9"; + inputs.holochain.url = "github:holochain/holochain/holochain-0.2.1"; }; };