From 13a6cf5aaa45a7c4cf3725679bc3cbf42a25a4b6 Mon Sep 17 00:00:00 2001 From: bitful-pannul Date: Mon, 15 Jul 2024 13:53:51 +0200 Subject: [PATCH 1/5] update kimap first block, separate subscriptions in kns --- Cargo.lock | 420 +++++++++--------- .../packages/app_store/app_store/src/lib.rs | 2 +- .../kns_indexer/kns_indexer/src/lib.rs | 93 ++-- 3 files changed, 269 insertions(+), 246 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2ca34aa17..bcc2b5532 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -92,28 +92,27 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "096bfe5b4ae72138eab21ba5789e74e09f80461352b2261dfde69e7538f0b3f6" +checksum = "0ba1c79677c9ce51c8d45e20845b05e6fb070ea2c863fba03ad6af2c778474bd" dependencies = [ - "alloy-consensus 0.1.3", + "alloy-consensus 0.1.4", "alloy-contract", "alloy-core", - "alloy-eips 0.1.3", - "alloy-genesis 0.1.3", - "alloy-json-rpc 0.1.3", + "alloy-eips 0.1.4", + "alloy-genesis 0.1.4", + "alloy-json-rpc 0.1.4", "alloy-network", "alloy-provider", "alloy-pubsub", "alloy-rpc-client", - "alloy-rpc-types 0.1.3", - "alloy-serde 0.1.3", + "alloy-rpc-types 0.1.4", + "alloy-serde 0.1.4", "alloy-signer", "alloy-signer-local", - "alloy-transport 0.1.3", + "alloy-transport 0.1.4", "alloy-transport-http", "alloy-transport-ws", - "reqwest 0.12.5", ] [[package]] @@ -142,23 +141,23 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f63a6c9eb45684a5468536bc55379a2af0f45ffa5d756e4e4964532737e1836" +checksum = "da374e868f54c7f4ad2ad56829827badca388efd645f8cf5fccc61c2b5343504" dependencies = [ - "alloy-eips 0.1.3", + "alloy-eips 0.1.4", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.1.3", + "alloy-serde 0.1.4", "c-kzg", "serde", ] [[package]] name = "alloy-contract" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c26b7d34cb76f826558e9409a010e25257f7bfb5aa5e3dd0042c564664ae159" +checksum = "7dc6957ff706f9e5f6fd42f52a93e4bce476b726c92d077b348de28c4a76730c" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -168,7 +167,7 @@ dependencies = [ "alloy-pubsub", "alloy-rpc-types-eth", "alloy-sol-types", - "alloy-transport 0.1.3", + "alloy-transport 0.1.4", "futures", "futures-util", "thiserror", @@ -176,9 +175,9 @@ dependencies = [ [[package]] name = "alloy-core" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5af3faff14c12c8b11037e0a093dd157c3702becb8435577a2408534d0758315" +checksum = "529fc6310dc1126c8de51c376cbc59c79c7f662bd742be7dc67055d5421a81b4" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -188,9 +187,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6e6436a9530f25010d13653e206fab4c9feddacf21a54de8d7311b275bc56b" +checksum = "413902aa18a97569e60f679c23f46a18db1656d87ab4d4e49d0e1e52042f66df" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -218,13 +217,13 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa4b0fc6a572ef2eebda0a31a5e393d451abda703fec917c75d9615d8c978cf2" +checksum = "f76ecab54890cdea1e4808fc0891c7e6cfcf71fe1a9fe26810c7280ef768f4ed" dependencies = [ "alloy-primitives", "alloy-rlp", - "alloy-serde 0.1.3", + "alloy-serde 0.1.4", "c-kzg", "once_cell", "serde", @@ -243,20 +242,20 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48450f9c6f0821c1eee00ed912942492ed4f11dd69532825833de23ecc7a2256" +checksum = "bca15afde1b6d15e3fc1c97421262b1bbb37aee45752e3c8b6d6f13f776554ff" dependencies = [ "alloy-primitives", - "alloy-serde 0.1.3", + "alloy-serde 0.1.4", "serde", ] [[package]] name = "alloy-json-abi" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaeaccd50238126e3a0ff9387c7c568837726ad4f4e399b528ca88104d6c25ef" +checksum = "bc05b04ac331a9f07e3a4036ef7926e49a8bf84a99a1ccfc7e2ab55a5fcbb372" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -278,9 +277,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d484c2a934d0a4d86f8ad4db8113cb1d607707a6c54f6e78f4f1b4451b47aa70" +checksum = "6d6f34930b7e3e2744bcc79056c217f00cb2abb33bc5d4ff88da7623c5bb078b" dependencies = [ "alloy-primitives", "serde", @@ -291,16 +290,16 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a20eba9bc551037f0626d6d29e191888638d979943fa4e842e9e6fc72bf0565" +checksum = "25f6895fc31b48fa12306ef9b4f78b7764f8bd6d7d91cdb0a40e233704a0f23f" dependencies = [ - "alloy-consensus 0.1.3", - "alloy-eips 0.1.3", - "alloy-json-rpc 0.1.3", + "alloy-consensus 0.1.4", + "alloy-eips 0.1.4", + "alloy-json-rpc 0.1.4", "alloy-primitives", "alloy-rpc-types-eth", - "alloy-serde 0.1.3", + "alloy-serde 0.1.4", "alloy-signer", "alloy-sol-types", "async-trait", @@ -311,9 +310,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f783611babedbbe90db3478c120fb5f5daacceffc210b39adc0af4fe0da70bad" +checksum = "ccb3ead547f4532bc8af961649942f0b9c16ee9226e26caa3f38420651cc0bf4" dependencies = [ "alloy-rlp", "bytes", @@ -333,20 +332,20 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad5d89acb7339fad13bc69e7b925232f242835bfd91c82fcb9326b36481bd0f0" +checksum = "9c538bfa893d07e27cb4f3c1ab5f451592b7c526d511d62b576a2ce59e146e4a" dependencies = [ "alloy-chains", - "alloy-consensus 0.1.3", - "alloy-eips 0.1.3", - "alloy-json-rpc 0.1.3", + "alloy-consensus 0.1.4", + "alloy-eips 0.1.4", + "alloy-json-rpc 0.1.4", "alloy-network", "alloy-primitives", "alloy-pubsub", "alloy-rpc-client", "alloy-rpc-types-eth", - "alloy-transport 0.1.3", + "alloy-transport 0.1.4", "alloy-transport-http", "alloy-transport-ws", "async-stream", @@ -367,13 +366,13 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034258dfaa51c278e1f7fcc46e587d10079ec9372866fa48c5df9d908fc1f6b1" +checksum = "0a7341322d9bc0e49f6e9fd9f2eb8e30f73806f2dd12cbb3d6bab2694c921f87" dependencies = [ - "alloy-json-rpc 0.1.3", + "alloy-json-rpc 0.1.4", "alloy-primitives", - "alloy-transport 0.1.3", + "alloy-transport 0.1.4", "bimap", "futures", "serde", @@ -403,19 +402,19 @@ checksum = "d83524c1f6162fcb5b0decf775498a125066c86dda6066ed609531b0e912f85a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] name = "alloy-rpc-client" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479ce003e8c74bbbc7d4235131c1d6b7eaf14a533ae850295b90d240340989cb" +checksum = "5ba31bae67773fd5a60020bea900231f8396202b7feca4d0c70c6b59308ab4a8" dependencies = [ - "alloy-json-rpc 0.1.3", + "alloy-json-rpc 0.1.4", "alloy-primitives", "alloy-pubsub", - "alloy-transport 0.1.3", + "alloy-transport 0.1.4", "alloy-transport-http", "alloy-transport-ws", "futures", @@ -450,25 +449,25 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dfa1dd3e0bc3a3d89744fba8d1511216e83257160da2cd028a18b7d9c026030" +checksum = "184a7a42c7ba9141cc9e76368356168c282c3bc3d9e5d78f3556bdfe39343447" dependencies = [ "alloy-rpc-types-eth", - "alloy-serde 0.1.3", + "alloy-serde 0.1.4", ] [[package]] name = "alloy-rpc-types-eth" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13bd7aa9ff9e67f1ba7ee0dd8cebfc95831d1649b0e4eeefae940dc3681079fa" +checksum = "ab4123ee21f99ba4bd31bfa36ba89112a18a500f8b452f02b35708b1b951e2b9" dependencies = [ - "alloy-consensus 0.1.3", - "alloy-eips 0.1.3", + "alloy-consensus 0.1.4", + "alloy-eips 0.1.4", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.1.3", + "alloy-serde 0.1.4", "alloy-sol-types", "itertools 0.13.0", "serde", @@ -488,9 +487,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8913f9e825068d77c516188c221c44f78fd814fce8effe550a783295a2757d19" +checksum = "9416c52959e66ead795a11f4a86c248410e9e368a0765710e57055b8a1774dd6" dependencies = [ "alloy-primitives", "serde", @@ -499,9 +498,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f740e13eb4c6a0e4d0e49738f1e86f31ad2d7ef93be499539f492805000f7237" +checksum = "b33753c09fa1ad85e5b092b8dc2372f1e337a42e84b9b4cff9fede75ba4adb32" dependencies = [ "alloy-primitives", "async-trait", @@ -513,11 +512,11 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87db68d926887393a1d0f9c43833b44446ea29d603291e7b20e5d115f31aa4e3" +checksum = "6dfc9c26fe6c6f1bad818c9a976de9044dd12e1f75f1f156a801ee3e8148c1b6" dependencies = [ - "alloy-consensus 0.1.3", + "alloy-consensus 0.1.4", "alloy-network", "alloy-primitives", "alloy-signer", @@ -529,23 +528,23 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bad41a7c19498e3f6079f7744656328699f8ea3e783bdd10d85788cd439f572" +checksum = "2b40397ddcdcc266f59f959770f601ce1280e699a91fc1862f29cef91707cd09" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] name = "alloy-sol-macro-expander" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd9899da7d011b4fe4c406a524ed3e3f963797dbc93b45479d60341d3a27b252" +checksum = "867a5469d61480fea08c7333ffeca52d5b621f5ca2e44f271b117ec1fc9a0525" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -555,16 +554,16 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", "syn-solidity", "tiny-keccak", ] [[package]] name = "alloy-sol-macro-input" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32d595768fdc61331a132b6f65db41afae41b9b97d36c21eb1b955c422a7e60" +checksum = "2e482dc33a32b6fadbc0f599adea520bd3aaa585c141a80b404d0a3e3fa72528" dependencies = [ "alloy-json-abi", "const-hex", @@ -573,24 +572,25 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.68", + "syn 2.0.71", "syn-solidity", ] [[package]] name = "alloy-sol-type-parser" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baa2fbd22d353d8685bd9fee11ba2d8b5c3b1d11e56adb3265fcf1f32bfdf404" +checksum = "cbcba3ca07cf7975f15d871b721fb18031eec8bce51103907f6dcce00b255d98" dependencies = [ + "serde", "winnow 0.6.13", ] [[package]] name = "alloy-sol-types" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a49042c6d3b66a9fe6b2b5a8bf0d39fc2ae1ee0310a2a26ffedd79fb097878dd" +checksum = "a91ca40fa20793ae9c3841b83e74569d1cc9af29a2f5237314fd3452d51e38c7" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -619,11 +619,11 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd9773e4ec6832346171605c776315544bd06e40f803e7b5b7824b325d5442ca" +checksum = "01b51a291f949f755e6165c3ed562883175c97423703703355f4faa4b7d0a57c" dependencies = [ - "alloy-json-rpc 0.1.3", + "alloy-json-rpc 0.1.4", "base64 0.22.1", "futures-util", "futures-utils-wasm", @@ -632,17 +632,18 @@ dependencies = [ "thiserror", "tokio", "tower", + "tracing", "url", ] [[package]] name = "alloy-transport-http" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff8ef947b901c0d4e97370f9fa25844cf8b63b1a58fd4011ee82342dc8a9fc6b" +checksum = "86d65871f9f1cafe1ed25cde2f1303be83e6473e995a2d56c275ae4fcce6119c" dependencies = [ - "alloy-json-rpc 0.1.3", - "alloy-transport 0.1.3", + "alloy-json-rpc 0.1.4", + "alloy-transport 0.1.4", "reqwest 0.12.5", "serde_json", "tower", @@ -652,12 +653,12 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d92049d6642a18c9849ce7659430151e7c92b51552a0cabdc038c1af4cd7308" +checksum = "aec83fd052684556c78c54df111433493267234d82321c2236560c752f595f20" dependencies = [ "alloy-pubsub", - "alloy-transport 0.1.3", + "alloy-transport 0.1.4", "futures", "http 1.1.0", "rustls", @@ -922,18 +923,18 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] name = "async-trait" -version = "0.1.80" +version = "0.1.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -961,7 +962,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -1056,7 +1057,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -1148,9 +1149,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" dependencies = [ "serde", ] @@ -1192,9 +1193,9 @@ dependencies = [ [[package]] name = "cap-fs-ext" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fc2d2954524be4866aaa720f008fba9995de54784957a1b0e0119992d6d5e52" +checksum = "eb23061fc1c4ead4e45ca713080fe768e6234e959f5a5c399c39eb41aa34e56e" dependencies = [ "cap-primitives", "cap-std", @@ -1204,9 +1205,9 @@ dependencies = [ [[package]] name = "cap-net-ext" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799c81d79ea9c71a1438efd417c788214bc9e7986046d3710b6bbe60da4d8275" +checksum = "f83ae11f116bcbafc5327c6af250341db96b5930046732e1905f7dc65887e0e1" dependencies = [ "cap-primitives", "cap-std", @@ -1216,9 +1217,9 @@ dependencies = [ [[package]] name = "cap-primitives" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00172660727e2d7f808e7cc2bfffd093fdb3ea2ff2ef819289418a3c3ffab5ac" +checksum = "6d00bd8d26c4270d950eaaa837387964a2089a1c3c349a690a1fa03221d29531" dependencies = [ "ambient-authority", "fs-set-times", @@ -1233,9 +1234,9 @@ dependencies = [ [[package]] name = "cap-rand" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "270f1d341a2afc62604f8f688bee4e444d052b7a74c1458dd3aa7efb47d4077f" +checksum = "dbcb16a619d8b8211ed61f42bd290d2a1ac71277a69cf8417ec0996fa92f5211" dependencies = [ "ambient-authority", "rand 0.8.5", @@ -1243,9 +1244,9 @@ dependencies = [ [[package]] name = "cap-std" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd9187bb3f7478a4c135ea10473a41a5f029d2ac800c1adf64f35ec7d4c8603" +checksum = "19eb8e3d71996828751c1ed3908a439639752ac6bdc874e41469ef7fc15fbd7f" dependencies = [ "cap-primitives", "io-extras", @@ -1255,9 +1256,9 @@ dependencies = [ [[package]] name = "cap-time-ext" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91666f31e30c85b1d2ee8432c90987f752c45f5821f5638027b41e73e16a395b" +checksum = "61142dc51e25b7acc970ca578ce2c3695eac22bbba46c1073f5f583e78957725" dependencies = [ "ambient-authority", "cap-primitives", @@ -1280,13 +1281,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.104" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74b6a57f98764a267ff415d50a25e6e166f3831a5071af4995296ea97d210490" +checksum = "324c74f2155653c90b04f25b2a47a8a631360cb908f92a772695f430c7e31052" dependencies = [ "jobserver", "libc", - "once_cell", ] [[package]] @@ -1381,9 +1381,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.8" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d" +checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" dependencies = [ "clap_builder", "clap_derive", @@ -1391,9 +1391,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.8" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708" +checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" dependencies = [ "anstream", "anstyle", @@ -1410,7 +1410,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -1795,7 +1795,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -1905,7 +1905,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -1943,7 +1943,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -2037,7 +2037,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -2382,7 +2382,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -2720,9 +2720,9 @@ dependencies = [ [[package]] name = "http-body" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", "http 1.1.0", @@ -2737,7 +2737,7 @@ dependencies = [ "bytes", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "pin-project-lite", ] @@ -2755,9 +2755,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.29" +version = "0.14.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" dependencies = [ "bytes", "futures-channel", @@ -2779,16 +2779,16 @@ dependencies = [ [[package]] name = "hyper" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4fe55fb7a772d59a5ff1dfbff4fe0258d19b89fec4b233e75d35d5d2316badc" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ "bytes", "futures-channel", "futures-util", "h2 0.4.5", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "httparse", "itoa", "pin-project-lite", @@ -2805,7 +2805,7 @@ checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.4.0", + "hyper 1.4.1", "hyper-util", "rustls", "rustls-pki-types", @@ -2822,7 +2822,7 @@ checksum = "6eea26c5d0b6ab9d72219f65000af310f042a740926f7b2fa3553e774036e2e7" dependencies = [ "derive_builder", "dns-lookup", - "hyper 0.14.29", + "hyper 0.14.30", "tokio", "tower-service", "tracing", @@ -2835,7 +2835,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", - "hyper 0.14.29", + "hyper 0.14.30", "native-tls", "tokio", "tokio-native-tls", @@ -2849,7 +2849,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.4.0", + "hyper 1.4.1", "hyper-util", "native-tls", "tokio", @@ -2867,8 +2867,8 @@ dependencies = [ "futures-channel", "futures-util", "http 1.1.0", - "http-body 1.0.0", - "hyper 1.4.0", + "http-body 1.0.1", + "hyper 1.4.1", "pin-project-lite", "socket2 0.5.7", "tokio", @@ -3896,7 +3896,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -3925,9 +3925,9 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "open" -version = "5.2.0" +version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d2c909a3fce3bd80efef4cd1c6c056bd9376a8fe06fcfdbebaf32cb485a7e37" +checksum = "61a877bf6abd716642a53ef1b89fb498923a4afca5c754f9050b4d081c05c4b3" dependencies = [ "is-wsl", "libc", @@ -3957,7 +3957,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -4179,7 +4179,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -4324,7 +4324,7 @@ version = "0.1.0" source = "git+https://github.com/kinode-dao/process_macros?rev=626e501#626e501d351e3365480ec6f770d474ed4ae339bf" dependencies = [ "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -4366,7 +4366,7 @@ dependencies = [ "futures-core", "futures-util", "http 0.2.12", - "hyper 0.14.29", + "hyper 0.14.30", "hyper-system-resolver", "pin-project-lite", "thiserror", @@ -4682,7 +4682,7 @@ dependencies = [ "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.29", + "hyper 0.14.30", "hyper-tls 0.5.0", "ipnet", "js-sys", @@ -4721,9 +4721,9 @@ dependencies = [ "futures-util", "h2 0.4.5", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "http-body-util", - "hyper 1.4.0", + "hyper 1.4.1", "hyper-rustls", "hyper-tls 0.6.0", "hyper-util", @@ -4921,9 +4921,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.10" +version = "0.23.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" +checksum = "4828ea528154ae444e5a642dbb7d5623354030dc9822b83fd9bb79683c7399d0" dependencies = [ "once_cell", "ring", @@ -5039,9 +5039,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ "bitflags 2.6.0", "core-foundation", @@ -5052,9 +5052,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" +checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" dependencies = [ "core-foundation-sys", "libc", @@ -5092,22 +5092,22 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -5399,7 +5399,7 @@ checksum = "8286dc044d09abcb8bf85440b94f2c41aee322733a58cd195cf830ee660cadf5" dependencies = [ "headers", "http 0.2.12", - "hyper 0.14.29", + "hyper 0.14.30", "include_dir", "log", "mime_guess", @@ -5439,7 +5439,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -5461,9 +5461,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.68" +version = "2.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +checksum = "b146dcf730474b4bcd16c311627b31ede9ab149045db4d6088b3becaea046462" dependencies = [ "proc-macro2", "quote", @@ -5472,14 +5472,14 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d71e19bca02c807c9faa67b5a47673ff231b6e7449b251695188522f1dc44b2" +checksum = "c837dc8852cb7074e46b444afb81783140dab12c58867b49fb3898fbafedf7ea" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -5539,9 +5539,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.14" +version = "0.12.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" +checksum = "4873307b7c257eddcb50c9bedf158eb669578359fb28428bef438fec8e6ba7c2" [[package]] name = "tempfile" @@ -5585,22 +5585,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "f2675633b1499176c2dff06b0856a27976a8f9d436737b4cf4f312d4d91d8bbb" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "d20468752b09f49e909e55a5d338caa8bedf615594e9d80bc4c565d30faf798c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -5664,9 +5664,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6b6a2fb3a985e99cebfaefa9faa3024743da73304ca1c683a36429613d3d22" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -5703,7 +5703,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -5791,7 +5791,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.14", + "toml_edit 0.22.15", ] [[package]] @@ -5816,9 +5816,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.14" +version = "0.22.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" +checksum = "d59a3a72298453f564e2b111fa896f8d07fabb36f51f06d7e875fc5e0b5a3ef1" dependencies = [ "indexmap", "serde", @@ -5899,7 +5899,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -6209,9 +6209,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.9.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" [[package]] name = "valuable" @@ -6270,7 +6270,7 @@ dependencies = [ "futures-util", "headers", "http 0.2.12", - "hyper 0.14.29", + "hyper 0.14.30", "log", "mime", "mime_guess", @@ -6341,7 +6341,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", "wasm-bindgen-shared", ] @@ -6375,7 +6375,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6406,9 +6406,9 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.212.0" +version = "0.213.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501940df4418b8929eb6d52f1aade1fdd15a5b86c92453cb696e3c906bd3fc33" +checksum = "850e4e6a56413a8f33567741a2388c8f6dafd841a939d945c7248671a8739dd8" dependencies = [ "leb128", ] @@ -6533,7 +6533,7 @@ dependencies = [ "sha2", "toml", "windows-sys 0.52.0", - "zstd 0.13.1", + "zstd 0.13.2", ] [[package]] @@ -6545,7 +6545,7 @@ dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", "wasmtime-component-util", "wasmtime-wit-bindgen", "wit-parser 0.201.0", @@ -6719,7 +6719,7 @@ checksum = "ffaafa5c12355b1a9ee068e9295d50c4ca0a400c721950cdae4f5b54391a2da5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -6799,24 +6799,24 @@ dependencies = [ [[package]] name = "wast" -version = "212.0.0" +version = "213.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4606a05fb0aae5d11dd7d8280a640d88a63ee019360ba9be552da3d294b8d1f5" +checksum = "cd051172bc72db3567b039f710f27d6d80f358b8333088eb4c4c12dac2a4d993" dependencies = [ "bumpalo", "leb128", "memchr", "unicode-width", - "wasm-encoder 0.212.0", + "wasm-encoder 0.213.0", ] [[package]] name = "wat" -version = "1.212.0" +version = "1.213.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c74ca7f93f11a5d6eed8499f2a8daaad6e225cab0151bc25a091fff3b987532f" +checksum = "5be77619385eca699d204399d2ffc9b1dfda1df3320266773d2d664ecb06cf3e" dependencies = [ - "wast 212.0.0", + "wast 213.0.0", ] [[package]] @@ -6877,7 +6877,7 @@ dependencies = [ "proc-macro2", "quote", "shellexpand", - "syn 2.0.68", + "syn 2.0.71", "witx", ] @@ -6889,7 +6889,7 @@ checksum = "acdb12de36507498abaa3a042f895a43ee00a2f6125b6901b9a27edf72bfdbe7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", "wiggle-generate", ] @@ -7188,7 +7188,7 @@ dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", "wit-bindgen-core", "wit-bindgen-rust", ] @@ -7305,7 +7305,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -7325,7 +7325,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.71", ] [[package]] @@ -7372,7 +7372,7 @@ dependencies = [ "thiserror", "time", "zopfli", - "zstd 0.13.1", + "zstd 0.13.2", ] [[package]] @@ -7400,11 +7400,11 @@ dependencies = [ [[package]] name = "zstd" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d789b1514203a1120ad2429eae43a7bd32b90976a7bb8a05f7ec02fa88cc23a" +checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9" dependencies = [ - "zstd-safe 7.1.0", + "zstd-safe 7.2.0", ] [[package]] @@ -7419,18 +7419,18 @@ dependencies = [ [[package]] name = "zstd-safe" -version = "7.1.0" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd99b45c6bc03a018c8b8a86025678c87e55526064e38f9df301989dce7ec0a" +checksum = "fa556e971e7b568dc775c136fc9de8c779b1c2fc3a63defaafadffdbd3181afa" dependencies = [ "zstd-sys", ] [[package]] name = "zstd-sys" -version = "2.0.11+zstd.1.5.6" +version = "2.0.12+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75652c55c0b6f3e6f12eb786fe1bc960396bf05a1eb3bf1f3691c3610ac2e6d4" +checksum = "0a4e40c320c3cb459d9a9ff6de98cff88f4751ee9275d140e2be94a2b74e4c13" dependencies = [ "cc", "pkg-config", diff --git a/kinode/packages/app_store/app_store/src/lib.rs b/kinode/packages/app_store/app_store/src/lib.rs index 73370c8b4..55ada9799 100644 --- a/kinode/packages/app_store/app_store/src/lib.rs +++ b/kinode/packages/app_store/app_store/src/lib.rs @@ -56,7 +56,7 @@ const KIMAP_ADDRESS: &str = "0x7290Aa297818d0b9660B2871Bb87f85a3f9B4559"; // opt const KIMAP_ADDRESS: &str = "0x0165878A594ca255338adfa4d48449f69242Eb8F"; // note temp kimap address! #[cfg(not(feature = "simulation-mode"))] -const KIMAP_FIRST_BLOCK: u64 = 118_590_088; +const KIMAP_FIRST_BLOCK: u64 = 122_295_937; #[cfg(feature = "simulation-mode")] const KIMAP_FIRST_BLOCK: u64 = 1; diff --git a/kinode/packages/kns_indexer/kns_indexer/src/lib.rs b/kinode/packages/kns_indexer/kns_indexer/src/lib.rs index 1fbe5e06e..eac8b4512 100644 --- a/kinode/packages/kns_indexer/kns_indexer/src/lib.rs +++ b/kinode/packages/kns_indexer/kns_indexer/src/lib.rs @@ -33,7 +33,7 @@ const CHAIN_ID: u64 = 10; // optimism const CHAIN_ID: u64 = 31337; // local #[cfg(not(feature = "simulation-mode"))] -const KIMAP_FIRST_BLOCK: u64 = 114_923_786; // optimism, adjust +const KIMAP_FIRST_BLOCK: u64 = 114_923_786; // optimism #[cfg(feature = "simulation-mode")] const KIMAP_FIRST_BLOCK: u64 = 1; // local @@ -90,7 +90,7 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> { #[cfg(feature = "simulation-mode")] add_temp_hardcoded_tlzs(&mut state); - let _notes = vec![ + let notes = vec![ keccak256("~net-key"), keccak256("~ws-port"), keccak256("~routers"), @@ -98,17 +98,20 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> { keccak256("~ip"), ]; - let filter = eth::Filter::new() + // sub_id: 1 + let mints_filter = eth::Filter::new() .address(state.contract_address.parse::().unwrap()) .from_block(state.block - 1) .to_block(eth::BlockNumberOrTag::Latest) - .events(vec![ - "Mint(bytes32,bytes32,bytes,bytes)", - "Note(bytes32,bytes32,bytes,bytes,bytes)", - ]); - // .topic3(_notes); - // TODO: potentially remove labelhash from Mint event, then we can filter Notes while getting all Mint events? - // do this with 2 subscriptions, for now, get all Note events. + .event("Mint(bytes32,bytes32,bytes,bytes)"); + + // sub_id: 2 + let notes_filter = eth::Filter::new() + .address(state.contract_address.parse::().unwrap()) + .from_block(state.block - 1) + .to_block(eth::BlockNumberOrTag::Latest) + .event("Note(bytes32,bytes32,bytes,bytes,bytes)") + .topic3(notes); // 60s timeout -- these calls can take a long time // if they do time out, we try them again @@ -123,27 +126,13 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> { ), ); - subscribe_to_logs(ð_provider, state.block - 1, filter.clone()); + subscribe_to_logs(ð_provider, state.block - 1, mints_filter.clone(), 1); + subscribe_to_logs(ð_provider, state.block - 1, notes_filter.clone(), 2); + println!("subscribed to logs successfully"); // if block in state is < current_block, get logs from that part. - loop { - match eth_provider.get_logs(&filter) { - Ok(logs) => { - for log in logs { - if let Err(e) = handle_log(&our, &mut state, &log, ð_provider) { - // print errors at verbosity=1 - print_to_terminal(1, &format!("log-handling error! {e:?}")); - } - } - break; - } - Err(e) => { - println!("got eth error while fetching logs: {e:?}, trying again in 5s..."); - std::thread::sleep(std::time::Duration::from_secs(5)); - continue; - } - } - } + fetch_and_process_logs(ð_provider, &our, &mut state, &mints_filter); + fetch_and_process_logs(ð_provider, &our, &mut state, ¬es_filter); let mut pending_requests: BTreeMap> = BTreeMap::new(); @@ -164,7 +153,8 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> { ð_provider, &mut pending_requests, &body, - &filter, + &mints_filter, + ¬es_filter, )?; } else { let request = serde_json::from_slice(&body)?; @@ -219,7 +209,8 @@ fn handle_eth_message( eth_provider: ð::Provider, pending_requests: &mut BTreeMap>, body: &[u8], - filter: ð::Filter, + mints_filter: ð::Filter, + notes_filter: ð::Filter, ) -> anyhow::Result<()> { let Ok(eth_result) = serde_json::from_slice::(body) else { return Err(anyhow::anyhow!("got invalid message")); @@ -236,7 +227,11 @@ fn handle_eth_message( } Err(e) => { println!("got eth subscription error ({e:?}), resubscribing"); - subscribe_to_logs(ð_provider, state.block - 1, filter.clone()); + if e.id == 1 { + subscribe_to_logs(ð_provider, state.block - 1, mints_filter.clone(), 1); + } else if e.id == 2 { + subscribe_to_logs(ð_provider, state.block - 1, notes_filter.clone(), 2); + } } } @@ -418,6 +413,30 @@ fn handle_log( // helpers +fn fetch_and_process_logs( + eth_provider: ð::Provider, + our: &Address, + state: &mut State, + filter: ð::Filter, +) { + loop { + match eth_provider.get_logs(filter) { + Ok(logs) => { + for log in logs { + if let Err(e) = handle_log(our, state, &log, eth_provider) { + print_to_terminal(1, &format!("log-handling error! {e:?}")); + } + } + return (); + } + Err(e) => { + println!("got eth error while fetching logs: {e:?}, trying again in 5s..."); + std::thread::sleep(std::time::Duration::from_secs(5)); + } + } + } +} + fn get_node_name(state: &mut State, parent_hash: &str) -> String { let mut current_hash = parent_hash; let mut components = Vec::new(); // Collect components in a vector @@ -511,9 +530,14 @@ pub fn bytes_to_port(bytes: &[u8]) -> anyhow::Result { } } -fn subscribe_to_logs(eth_provider: ð::Provider, from_block: u64, filter: eth::Filter) { +fn subscribe_to_logs( + eth_provider: ð::Provider, + from_block: u64, + filter: eth::Filter, + sub_id: u64, +) { loop { - match eth_provider.subscribe(1, filter.clone().from_block(from_block)) { + match eth_provider.subscribe(sub_id, filter.clone().from_block(from_block)) { Ok(()) => break, Err(_) => { println!("failed to subscribe to chain! trying again in 5s..."); @@ -522,5 +546,4 @@ fn subscribe_to_logs(eth_provider: ð::Provider, from_block: u64, filter: eth: } } } - println!("subscribed to logs successfully"); } From 0cf68da4f8eb8e3aca6535289e848bce82c7e543 Mon Sep 17 00:00:00 2001 From: bitful-pannul Date: Mon, 15 Jul 2024 17:39:38 +0200 Subject: [PATCH 2/5] net & kns: move getname requests to kns --- Cargo.lock | 4 +- .../packages/app_store/app_store/Cargo.toml | 2 +- .../packages/app_store/app_store/src/state.rs | 55 +++++++++---------- .../kns_indexer/kns_indexer/src/lib.rs | 8 ++- 4 files changed, 35 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bcc2b5532..4fc875580 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -753,7 +753,7 @@ dependencies = [ "alloy-sol-types", "anyhow", "bincode", - "kinode_process_lib 0.8.3 (git+https://github.com/kinode-dao/process_lib?rev=f8500a6)", + "kinode_process_lib 0.8.3 (git+https://github.com/kinode-dao/process_lib?rev=d2d3270)", "rand 0.8.5", "serde", "serde_json", @@ -3343,7 +3343,7 @@ dependencies = [ [[package]] name = "kinode_process_lib" version = "0.8.3" -source = "git+https://github.com/kinode-dao/process_lib?rev=f8500a6#f8500a62a07c0558145ee1583155331f83dfd018" +source = "git+https://github.com/kinode-dao/process_lib?rev=d2d3270#d2d32701be454ae4ff1238006f936c1b26f8cd28" dependencies = [ "alloy", "alloy-primitives", diff --git a/kinode/packages/app_store/app_store/Cargo.toml b/kinode/packages/app_store/app_store/Cargo.toml index 9604b1f64..3207fda1d 100644 --- a/kinode/packages/app_store/app_store/Cargo.toml +++ b/kinode/packages/app_store/app_store/Cargo.toml @@ -11,7 +11,7 @@ alloy-primitives = "0.7.6" alloy-sol-types = "0.7.6" anyhow = "1.0" bincode = "1.3.3" -kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "f8500a6" } +kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "d2d3270" } rand = "0.8" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/kinode/packages/app_store/app_store/src/state.rs b/kinode/packages/app_store/app_store/src/state.rs index cdd9de9d3..a5338056c 100644 --- a/kinode/packages/app_store/app_store/src/state.rs +++ b/kinode/packages/app_store/app_store/src/state.rs @@ -3,9 +3,8 @@ use crate::{KIMAP_ADDRESS, VFS_TIMEOUT}; use alloy_sol_types::{sol, SolEvent}; use kinode_process_lib::kernel_types::Erc721Metadata; use kinode_process_lib::{ - eth, kernel_types as kt, - net::{get_name, namehash}, - println, vfs, Address, Message, NodeId, PackageId, Request, + eth, kernel_types as kt, kimap::Kimap, net::get_name, println, vfs, Address, Message, NodeId, + PackageId, Request, }; use serde::{Deserialize, Serialize}; use std::collections::{HashMap, HashSet}; @@ -96,6 +95,8 @@ pub struct State { pub our: Address, /// the eth provider we are using -- not persisted pub provider: eth::Provider, + /// the kimap helper we are using -- not persisted + pub kimap: Kimap, /// the address of the contract we are using to read package listings pub contract_address: String, /// the last block at which we saved the state of the listings to disk. @@ -151,7 +152,8 @@ impl State { pub fn from_serialized(our: Address, provider: eth::Provider, s: SerializedState) -> Self { State { our, - provider, + provider: provider.clone(), + kimap: Kimap::new(provider, eth::Address::from_str(KIMAP_ADDRESS).unwrap()), contract_address: s.contract_address, last_saved_block: s.last_saved_block, package_hashes: s.package_hashes, @@ -171,7 +173,8 @@ impl State { ) -> anyhow::Result { let mut state = State { our, - provider, + provider: provider.clone(), + kimap: Kimap::new(provider, eth::Address::from_str(KIMAP_ADDRESS).unwrap()), contract_address, last_saved_block: crate::KIMAP_FIRST_BLOCK, package_hashes: HashMap::new(), @@ -348,31 +351,22 @@ impl State { ) -> Result<(), AppStoreLogError> { let block_number: u64 = log.block_number.ok_or(AppStoreLogError::NoBlockNumber)?; - // basic plan... - // when we get either metadata-uri or metadata-hash, we fetch the other one and see if they match. - // if they do, we update the metadata for the package. - // note: if either of hash/uri doens't match//errors, we probably shouldn't throw errors except for in verbose mode. - - // TEMP WAIT while we solve kns_indexer getting race condition - std::thread::sleep(std::time::Duration::from_millis(100)); match log.topics()[0] { Note::SIGNATURE_HASH => { let note = Note::decode_log_data(log.data(), false) .map_err(|_| AppStoreLogError::DecodeLogError)?; - // get package_name from the api (add to process_lib)! - let name = get_name(¬e.nodehash.to_string(), None).map_err(|e| { - println!("Error decoding name: {:?}", e); - AppStoreLogError::DecodeLogError - })?; + let name = + get_name(¬e.nodehash.to_string(), log.block_number, None).map_err(|e| { + println!("Error decoding name: {:?}", e); + AppStoreLogError::DecodeLogError + })?; let note_str = String::from_utf8_lossy(¬e.note).to_string(); - let kimap = self - .provider - .kimap_with_address(eth::Address::from_str(KIMAP_ADDRESS).unwrap()); // println!("got note {note_str} for {name}"); // let notehash = note.notehash.to_string(); + // let notehash = note.notehash.to_string(); // let full_name = format!("{note_str}.{name}"); match note_str.as_str() { @@ -380,11 +374,12 @@ impl State { let metadata_url = String::from_utf8_lossy(¬e.data).to_string(); // generate ~metadata-hash notehash let meta_note_name = format!("~metadata-hash.{name}"); - let package_hash_note = namehash(&meta_note_name); - let (_tba, _owner, data) = kimap.get(&package_hash_note).map_err(|e| { - println!("Error getting metadata hash: {:?}", e); - AppStoreLogError::DecodeLogError - })?; + + let (_tba, _owner, data) = + self.kimap.get(&meta_note_name).map_err(|e| { + println!("Error getting metadata hash: {:?}", e); + AppStoreLogError::DecodeLogError + })?; if let Some(hash_note) = data { let metadata_hash = String::from_utf8_lossy(&hash_note).to_string(); @@ -444,11 +439,11 @@ impl State { let metadata_hash = String::from_utf8_lossy(¬e.data).to_string(); // generate ~metadata-uri notehash let meta_note_name = format!("~metadata-uri.{name}"); - let package_uri_note = namehash(&meta_note_name); - let (_tba, _owner, data) = kimap.get(&package_uri_note).map_err(|e| { - println!("Error getting metadata uri: {:?}", e); - AppStoreLogError::DecodeLogError - })?; + let (_tba, _owner, data) = + self.kimap.get(&meta_note_name).map_err(|e| { + println!("Error getting metadata uri: {:?}", e); + AppStoreLogError::DecodeLogError + })?; if let Some(uri_note) = data { let metadata_url = String::from_utf8_lossy(&uri_note).to_string(); diff --git a/kinode/packages/kns_indexer/kns_indexer/src/lib.rs b/kinode/packages/kns_indexer/kns_indexer/src/lib.rs index eac8b4512..36aa05054 100644 --- a/kinode/packages/kns_indexer/kns_indexer/src/lib.rs +++ b/kinode/packages/kns_indexer/kns_indexer/src/lib.rs @@ -167,7 +167,9 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> { }) => { if *block <= state.block { Response::new() - .body(serde_json::to_vec(&state.names.get(hash))?) + .body(rmp_serde::to_vec(&crate::net::NetResponse::Name( + state.names.get(hash).cloned(), + ))?) .send()?; } else { pending_requests @@ -392,6 +394,10 @@ fn handle_log( _ => {} } + if let Some(block) = log.block_number { + state.block = block; + } + if let Some(node) = node { if let Some(node_info) = state.nodes.get(&node) { if node_info.public_key != "" From 6fe711a06778d47b30cc4b6d9f56e18f6818ecb4 Mon Sep 17 00:00:00 2001 From: dr-frmr Date: Mon, 15 Jul 2024 19:02:21 +0200 Subject: [PATCH 3/5] net: remove all namehash usage! --- kinode/src/net/connect.rs | 6 +----- kinode/src/net/mod.rs | 19 +++---------------- kinode/src/net/types.rs | 3 +-- kinode/src/net/utils.rs | 7 +++---- lib/src/core.rs | 4 ---- 5 files changed, 8 insertions(+), 31 deletions(-) diff --git a/kinode/src/net/connect.rs b/kinode/src/net/connect.rs index d6f82fb8b..9b8b85544 100644 --- a/kinode/src/net/connect.rs +++ b/kinode/src/net/connect.rs @@ -101,11 +101,7 @@ async fn connect_via_router( routers.shuffle(&mut rand::thread_rng()); routers }; - for router_namehash in &routers_shuffled { - let Some(router_name) = data.names.get(router_namehash) else { - // router does not exist in PKI that we know of - continue; - }; + for router_name in &routers_shuffled { if router_name.as_ref() == ext.our.name { // we can't route through ourselves continue; diff --git a/kinode/src/net/mod.rs b/kinode/src/net/mod.rs index 01e87a346..0433bd5fe 100644 --- a/kinode/src/net/mod.rs +++ b/kinode/src/net/mod.rs @@ -3,8 +3,7 @@ use lib::types::core::{ NetworkErrorSender, NodeRouting, PrintSender, }; use types::{ - IdentityExt, NetData, OnchainPKI, PKINames, Peers, PendingPassthroughs, TCP_PROTOCOL, - WS_PROTOCOL, + IdentityExt, NetData, OnchainPKI, Peers, PendingPassthroughs, TCP_PROTOCOL, WS_PROTOCOL, }; use {dashmap::DashMap, ring::signature::Ed25519KeyPair, std::sync::Arc, tokio::task::JoinSet}; @@ -47,17 +46,12 @@ pub async fn networking( // and store a mapping of peers we have an active route for let pki: OnchainPKI = Arc::new(DashMap::new()); let peers: Peers = Arc::new(DashMap::new()); - // keep a mapping of namehashes (used onchain) to node-ids. - // this allows us to act as a translator for others, and translate - // our own router namehashes if we are indirect. - let names: PKINames = Arc::new(DashMap::new()); // only used by routers let pending_passthroughs: PendingPassthroughs = Arc::new(DashMap::new()); let net_data = NetData { pki, peers, - names, pending_passthroughs, }; @@ -165,16 +159,13 @@ async fn handle_local_request( // we shouldn't get these locally, ignore } Ok(NetAction::KnsUpdate(log)) => { - utils::ingest_log(log, &data.pki, &data.names); + utils::ingest_log(log, &data.pki); } Ok(NetAction::KnsBatchUpdate(logs)) => { for log in logs { - utils::ingest_log(log, &data.pki, &data.names); + utils::ingest_log(log, &data.pki); } } - Ok(NetAction::AddName(hash, name)) => { - data.names.insert(hash, name); - } Ok(gets) => { let (response_body, response_blob) = match gets { NetAction::GetPeers => ( @@ -190,10 +181,6 @@ async fn handle_local_request( NetResponse::Peer(data.pki.get(&peer).map(|p| p.clone())), None, ), - NetAction::GetName(namehash) => ( - NetResponse::Name(data.names.get(&namehash).map(|n| n.clone())), - None, - ), NetAction::GetDiagnostics => { let mut printout = String::new(); printout.push_str(&format!( diff --git a/kinode/src/net/types.rs b/kinode/src/net/types.rs index 28aed56c7..08a5cbd37 100644 --- a/kinode/src/net/types.rs +++ b/kinode/src/net/types.rs @@ -55,8 +55,8 @@ pub struct RoutingRequest { } pub type Peers = Arc>; -pub type PKINames = Arc>; pub type OnchainPKI = Arc>; + /// (from, target) -> from's socket pub type PendingPassthroughs = Arc>; pub enum PendingStream { @@ -98,6 +98,5 @@ pub struct IdentityExt { pub struct NetData { pub pki: OnchainPKI, pub peers: Peers, - pub names: PKINames, pub pending_passthroughs: PendingPassthroughs, } diff --git a/kinode/src/net/utils.rs b/kinode/src/net/utils.rs index e997641f7..5a7c595c4 100644 --- a/kinode/src/net/utils.rs +++ b/kinode/src/net/utils.rs @@ -1,6 +1,6 @@ use crate::net::types::{ - HandshakePayload, OnchainPKI, PKINames, Peers, PendingPassthroughs, PendingStream, - RoutingRequest, TCP_PROTOCOL, WS_PROTOCOL, + HandshakePayload, OnchainPKI, Peers, PendingPassthroughs, PendingStream, RoutingRequest, + TCP_PROTOCOL, WS_PROTOCOL, }; use lib::types::core::{ Identity, KernelMessage, KnsUpdate, Message, MessageSender, NetAction, NetworkErrorSender, @@ -175,7 +175,7 @@ pub async fn maintain_passthrough(socket_1: PendingStream, socket_2: PendingStre } } -pub fn ingest_log(log: KnsUpdate, pki: &OnchainPKI, names: &PKINames) { +pub fn ingest_log(log: KnsUpdate, pki: &OnchainPKI) { pki.insert( log.name.clone(), Identity { @@ -191,7 +191,6 @@ pub fn ingest_log(log: KnsUpdate, pki: &OnchainPKI, names: &PKINames) { }, }, ); - names.insert(log.node, log.name); } pub fn validate_signature(from: &str, signature: &[u8], message: &[u8], pki: &OnchainPKI) -> bool { diff --git a/lib/src/core.rs b/lib/src/core.rs index 24a43bef5..24bdde43e 100644 --- a/lib/src/core.rs +++ b/lib/src/core.rs @@ -2005,14 +2005,10 @@ pub enum NetAction { /// in the future could get from remote provider KnsUpdate(KnsUpdate), KnsBatchUpdate(Vec), - /// add a (namehash -> name) to our representation of the PKI - AddName(String, String), /// get a list of peers we are connected to GetPeers, /// get the [`Identity`] struct for a single peer GetPeer(String), - /// get the [`NodeId`] associated with a given namehash, if any - GetName(String), /// get a user-readable diagnostics string containing networking inforamtion GetDiagnostics, /// sign the attached blob payload, sign with our node's networking key. From 77fb6b325c32ab6f443636ab16b95c092765b564 Mon Sep 17 00:00:00 2001 From: dr-frmr Date: Tue, 16 Jul 2024 13:20:42 +0200 Subject: [PATCH 4/5] fix: remove from_block --- .../kns_indexer/kns_indexer/src/lib.rs | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/kinode/packages/kns_indexer/kns_indexer/src/lib.rs b/kinode/packages/kns_indexer/kns_indexer/src/lib.rs index 36aa05054..0ebb21b12 100644 --- a/kinode/packages/kns_indexer/kns_indexer/src/lib.rs +++ b/kinode/packages/kns_indexer/kns_indexer/src/lib.rs @@ -101,14 +101,12 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> { // sub_id: 1 let mints_filter = eth::Filter::new() .address(state.contract_address.parse::().unwrap()) - .from_block(state.block - 1) .to_block(eth::BlockNumberOrTag::Latest) .event("Mint(bytes32,bytes32,bytes,bytes)"); // sub_id: 2 let notes_filter = eth::Filter::new() .address(state.contract_address.parse::().unwrap()) - .from_block(state.block - 1) .to_block(eth::BlockNumberOrTag::Latest) .event("Note(bytes32,bytes32,bytes,bytes,bytes)") .topic3(notes); @@ -126,13 +124,13 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> { ), ); - subscribe_to_logs(ð_provider, state.block - 1, mints_filter.clone(), 1); - subscribe_to_logs(ð_provider, state.block - 1, notes_filter.clone(), 2); + subscribe_to_logs(ð_provider, mints_filter.clone(), 1); + subscribe_to_logs(ð_provider, notes_filter.clone(), 2); println!("subscribed to logs successfully"); // if block in state is < current_block, get logs from that part. - fetch_and_process_logs(ð_provider, &our, &mut state, &mints_filter); - fetch_and_process_logs(ð_provider, &our, &mut state, ¬es_filter); + fetch_and_process_logs(ð_provider, &our, &mut state, mints_filter.clone()); + fetch_and_process_logs(ð_provider, &our, &mut state, notes_filter.clone()); let mut pending_requests: BTreeMap> = BTreeMap::new(); @@ -230,9 +228,9 @@ fn handle_eth_message( Err(e) => { println!("got eth subscription error ({e:?}), resubscribing"); if e.id == 1 { - subscribe_to_logs(ð_provider, state.block - 1, mints_filter.clone(), 1); + subscribe_to_logs(ð_provider, mints_filter.clone(), 1); } else if e.id == 2 { - subscribe_to_logs(ð_provider, state.block - 1, notes_filter.clone(), 2); + subscribe_to_logs(ð_provider, notes_filter.clone(), 2); } } } @@ -423,10 +421,11 @@ fn fetch_and_process_logs( eth_provider: ð::Provider, our: &Address, state: &mut State, - filter: ð::Filter, + filter: eth::Filter, ) { + let filter = filter.from_block(state.block - 1); loop { - match eth_provider.get_logs(filter) { + match eth_provider.get_logs(&filter) { Ok(logs) => { for log in logs { if let Err(e) = handle_log(our, state, &log, eth_provider) { @@ -536,14 +535,9 @@ pub fn bytes_to_port(bytes: &[u8]) -> anyhow::Result { } } -fn subscribe_to_logs( - eth_provider: ð::Provider, - from_block: u64, - filter: eth::Filter, - sub_id: u64, -) { +fn subscribe_to_logs(eth_provider: ð::Provider, filter: eth::Filter, sub_id: u64) { loop { - match eth_provider.subscribe(sub_id, filter.clone().from_block(from_block)) { + match eth_provider.subscribe(sub_id, filter.clone()) { Ok(()) => break, Err(_) => { println!("failed to subscribe to chain! trying again in 5s..."); From bb47a5588245e1e241dc6ef54acab9f7550d3510 Mon Sep 17 00:00:00 2001 From: bitful-pannul Date: Tue, 16 Jul 2024 15:12:50 +0200 Subject: [PATCH 5/5] new knsUpdate types --- Cargo.lock | 30 ++------- .../packages/app_store/app_store/Cargo.toml | 2 +- .../kns_indexer/kns_indexer/Cargo.toml | 4 +- .../kns_indexer/kns_indexer/src/lib.rs | 63 +++++++------------ lib/src/core.rs | 28 +++++++-- 5 files changed, 52 insertions(+), 75 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4fc875580..40a9375b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -753,7 +753,7 @@ dependencies = [ "alloy-sol-types", "anyhow", "bincode", - "kinode_process_lib 0.8.3 (git+https://github.com/kinode-dao/process_lib?rev=d2d3270)", + "kinode_process_lib 0.8.3", "rand 0.8.5", "serde", "serde_json", @@ -3321,29 +3321,7 @@ dependencies = [ [[package]] name = "kinode_process_lib" version = "0.8.3" -source = "git+https://github.com/kinode-dao/process_lib?rev=c8442ef#c8442ef6e0f6aefc1d8caa30b32a991303da8dd9" -dependencies = [ - "alloy", - "alloy-primitives", - "alloy-sol-macro", - "alloy-sol-types", - "anyhow", - "bincode", - "http 1.1.0", - "mime_guess", - "rand 0.8.5", - "rmp-serde", - "serde", - "serde_json", - "thiserror", - "url", - "wit-bindgen", -] - -[[package]] -name = "kinode_process_lib" -version = "0.8.3" -source = "git+https://github.com/kinode-dao/process_lib?rev=d2d3270#d2d32701be454ae4ff1238006f936c1b26f8cd28" +source = "git+https://github.com/kinode-dao/process_lib?rev=ce53825#ce53825d26be79c09edc175480364bd4a31ae100" dependencies = [ "alloy", "alloy-primitives", @@ -3401,14 +3379,14 @@ dependencies = [ [[package]] name = "kns_indexer" -version = "0.1.0" +version = "0.2.0" dependencies = [ "alloy-primitives", "alloy-sol-types", "anyhow", "bincode", "hex", - "kinode_process_lib 0.8.3 (git+https://github.com/kinode-dao/process_lib?rev=c8442ef)", + "kinode_process_lib 0.8.3", "rmp-serde", "serde", "serde_json", diff --git a/kinode/packages/app_store/app_store/Cargo.toml b/kinode/packages/app_store/app_store/Cargo.toml index 3207fda1d..c12532966 100644 --- a/kinode/packages/app_store/app_store/Cargo.toml +++ b/kinode/packages/app_store/app_store/Cargo.toml @@ -11,7 +11,7 @@ alloy-primitives = "0.7.6" alloy-sol-types = "0.7.6" anyhow = "1.0" bincode = "1.3.3" -kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "d2d3270" } +kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "ce53825" } rand = "0.8" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/kinode/packages/kns_indexer/kns_indexer/Cargo.toml b/kinode/packages/kns_indexer/kns_indexer/Cargo.toml index 49c04a9c0..f7faef7aa 100644 --- a/kinode/packages/kns_indexer/kns_indexer/Cargo.toml +++ b/kinode/packages/kns_indexer/kns_indexer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kns_indexer" -version = "0.1.0" +version = "0.2.0" edition = "2021" [features] @@ -12,7 +12,7 @@ alloy-primitives = "0.7.0" alloy-sol-types = "0.7.0" bincode = "1.3.3" hex = "0.4.3" -kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "c8442ef" } +kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "ce53825" } rmp-serde = "1.1.2" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/kinode/packages/kns_indexer/kns_indexer/src/lib.rs b/kinode/packages/kns_indexer/kns_indexer/src/lib.rs index 0ebb21b12..eeb3d42b5 100644 --- a/kinode/packages/kns_indexer/kns_indexer/src/lib.rs +++ b/kinode/packages/kns_indexer/kns_indexer/src/lib.rs @@ -1,18 +1,16 @@ use crate::kinode::process::kns_indexer::{ GetStateRequest, IndexerRequests, NamehashToNameRequest, NodeInfoRequest, }; -use alloy_primitives::{keccak256, FixedBytes}; -use alloy_sol_types::{sol, SolCall, SolEvent}; +use alloy_primitives::keccak256; +use alloy_sol_types::{sol, SolEvent}; use kinode_process_lib::{ - await_message, call_init, - eth::{self, Provider, TransactionInput, TransactionRequest}, - net, print_to_terminal, println, Address, Message, Request, Response, + await_message, call_init, eth, net, print_to_terminal, println, Address, Message, Request, + Response, }; use serde::{Deserialize, Serialize}; use std::{ collections::{hash_map::HashMap, BTreeMap}, net::{IpAddr, Ipv4Addr, Ipv6Addr}, - str::FromStr, }; wit_bindgen::generate!({ @@ -51,6 +49,14 @@ struct State { block: u64, } +// note: not defined in wit api right now like IndexerRequests. +#[derive(Clone, Debug, Serialize, Deserialize)] +enum IndexerResponses { + Name(Option), + NodeInfo(Option), + GetState(State), +} + sol! { event Mint(bytes32 indexed parenthash, bytes32 indexed childhash,bytes indexed labelhash, bytes name); event Note(bytes32 indexed nodehash, bytes32 indexed notehash, bytes indexed labelhash, bytes note, bytes data); @@ -158,14 +164,13 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> { let request = serde_json::from_slice(&body)?; match request { - // IndexerRequests, especially NamehashToName, relevant anymore? if they're mostly queried from the net runtime? IndexerRequests::NamehashToName(NamehashToNameRequest { ref block, ref hash, }) => { if *block <= state.block { Response::new() - .body(rmp_serde::to_vec(&crate::net::NetResponse::Name( + .body(serde_json::to_vec(&IndexerResponses::Name( state.names.get(hash).cloned(), ))?) .send()?; @@ -179,7 +184,9 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> { IndexerRequests::NodeInfo(NodeInfoRequest { ref name, block }) => { if block <= state.block { Response::new() - .body(serde_json::to_vec(&state.nodes.get(name))?) + .body(serde_json::to_vec(&IndexerResponses::NodeInfo( + state.nodes.get(name).cloned(), + ))?) .send()?; } else { pending_requests @@ -190,7 +197,9 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> { } IndexerRequests::GetState(GetStateRequest { block }) => { if block <= state.block { - Response::new().body(serde_json::to_vec(&state)?).send()?; + Response::new() + .body(serde_json::to_vec(&state.clone())?) + .send()?; } else { pending_requests .entry(block) @@ -219,7 +228,7 @@ fn handle_eth_message( match eth_result { Ok(eth::EthSub { result, .. }) => { if let eth::SubscriptionResult::Log(log) = result { - if let Err(e) = handle_log(our, state, &log, eth_provider) { + if let Err(e) = handle_log(our, state, &log) { // print errors at verbosity=1 print_to_terminal(1, &format!("log-handling error! {e:?}")); } @@ -275,12 +284,7 @@ fn handle_eth_message( Ok(()) } -fn handle_log( - our: &Address, - state: &mut State, - log: ð::Log, - eth_provider: &Provider, -) -> anyhow::Result<()> { +fn handle_log(our: &Address, state: &mut State, log: ð::Log) -> anyhow::Result<()> { let mut node: Option = None; match log.topics()[0] { Mint::SIGNATURE_HASH => { @@ -291,19 +295,6 @@ fn handle_log( let name = get_full_name(state, &label, &parent_hash); - let get_call = getCall { - node: FixedBytes::<32>::from_str(&child_hash).unwrap(), - } - .abi_encode(); - let get_tx = TransactionRequest::default() - .to(state.contract_address.parse::().unwrap()) - .input(TransactionInput::new(get_call.into())); - let res = eth_provider - .call(get_tx, None) - .map_err(|e| anyhow::anyhow!("tba get_call error: {:?}", e))?; - - let get_return = getCall::abi_decode_returns(&res, false)?; - let tba = get_return.tokenBoundAccount.to_string(); state.names.insert(child_hash.clone(), name.clone()); // println!("got mint, name: {name}, child_hash: {child_hash}, tba: {tba}",); state @@ -311,22 +302,12 @@ fn handle_log( .entry(name.clone()) .or_insert_with(|| net::KnsUpdate { name: name.clone(), - // tbh owner should be a separate one from tba. (although we won't index transfers so won't be up to date) - owner: tba, - node: child_hash.clone(), public_key: String::new(), ips: Vec::new(), ports: BTreeMap::new(), routers: Vec::new(), }); - Request::new() - .target((&our.node, "net", "distro", "sys")) - .body(rmp_serde::to_vec(&net::NetAction::AddName( - child_hash, - name.clone(), - ))?) - .send()?; node = Some(name); } Note::SIGNATURE_HASH => { @@ -428,7 +409,7 @@ fn fetch_and_process_logs( match eth_provider.get_logs(&filter) { Ok(logs) => { for log in logs { - if let Err(e) = handle_log(our, state, &log, eth_provider) { + if let Err(e) = handle_log(our, state, &log) { print_to_terminal(1, &format!("log-handling error! {e:?}")); } } diff --git a/lib/src/core.rs b/lib/src/core.rs index 24bdde43e..a7eff11d2 100644 --- a/lib/src/core.rs +++ b/lib/src/core.rs @@ -2035,8 +2035,6 @@ pub enum NetResponse { Peers(Vec), /// response to [`NetAction::GetPeer`] Peer(Option), - /// response to [`NetAction::GetName`] - Name(Option), /// response to [`NetAction::GetDiagnostics`]. a user-readable string. Diagnostics(String), /// response to [`NetAction::Sign`]. contains the signature in blob @@ -2048,11 +2046,13 @@ pub enum NetResponse { Verified(bool), } +// +// KNS parts of the networking protocol +// + #[derive(Clone, Debug, Serialize, Deserialize, Hash, Eq, PartialEq)] pub struct KnsUpdate { - pub name: String, // actual username / domain name - pub owner: String, - pub node: String, // hex namehash of node + pub name: String, pub public_key: String, pub ips: Vec, pub ports: BTreeMap, @@ -2064,3 +2064,21 @@ impl KnsUpdate { self.ports.get(protocol) } } + +#[derive(Debug, Serialize, Deserialize)] +pub enum IndexerRequests { + NamehashToName(NamehashToNameRequest), + // other KNS requests are not used in process_lib, can be found in the kns api. +} + +#[derive(Clone, Debug, Serialize, Deserialize, Hash, Eq, PartialEq)] +pub struct NamehashToNameRequest { + pub hash: String, + pub block: Option, +} + +#[derive(Debug, Serialize, Deserialize)] +pub enum IndexerResponses { + Name(Option), + // other KNS responses are not used in process_lib, can be found in the kns api. +}