diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 61d100c..87af391 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -41,3 +41,35 @@ jobs: - name: Ensure the rust code is formatted run: cargo fmt --all --check + + clippy: + needs: install + runs-on: ubuntu-latest + steps: + - name: Use cashed cargo + uses: actions/cache@v3 + with: + path: ~/.cargo + key: ${{ runner.os }}-rust-${{ hashFiles('rust-toolchain.toml') }} + + - name: Checkout the source code + uses: actions/checkout@v3 + + - name: Ensure clippy is happy + run: cargo clippy -- -D warnings + + build: + needs: install + runs-on: ubuntu-latest + steps: + - name: Use cashed cargo + uses: actions/cache@v3 + with: + path: ~/.cargo + key: ${{ runner.os }}-rust-${{ hashFiles('rust-toolchain.toml') }} + + - name: Checkout the source code + uses: actions/checkout@v3 + + - name: Ensure the project builds + run: cargo build diff --git a/.gitignore b/.gitignore index 0e8fe2d..66b1130 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ /target -/artifacts /out -parachains.json \ No newline at end of file +parachains.json diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000..c342153 --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,24 @@ +# Basic +edition = "2021" +hard_tabs = true +max_width = 100 +use_small_heuristics = "Max" +# Imports +imports_granularity = "Crate" +reorder_imports = true +# Consistency +newline_style = "Unix" +# Misc +chain_width = 80 +spaces_around_ranges = false +binop_separator = "Back" +reorder_impl_items = false +match_arm_leading_pipes = "Preserve" +match_arm_blocks = false +match_block_trailing_comma = true +trailing_comma = "Vertical" +trailing_semicolon = false +use_field_init_shorthand = true +# Format comments +comment_width = 100 +wrap_comments = true diff --git a/Cargo.lock b/Cargo.lock index 09bd5c6..8e17a63 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,30 +19,30 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aead" -version = "0.4.3" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" dependencies = [ + "crypto-common", "generic-array", ] [[package]] name = "aes" -version = "0.7.5" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" dependencies = [ "cfg-if", "cipher", "cpufeatures", - "opaque-debug", ] [[package]] name = "aes-gcm" -version = "0.9.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc3be92e19a7ef47457b8e6f90707e12b6ac5d20c6f3866584fa3be0787d839f" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" dependencies = [ "aead", "aes", @@ -74,9 +74,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.75" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +checksum = "59d2a3357dde987206219e78ecfbbb6e8dad06cbb65292758d3270e6254f7355" [[package]] name = "arrayref" @@ -110,17 +110,30 @@ dependencies = [ "futures-core", ] +[[package]] +name = "async-channel" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" +dependencies = [ + "concurrent-queue", + "event-listener 4.0.1", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + [[package]] name = "async-executor" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0c4a4f319e45986f347ee47fef8bf5e81c9abc3f6f58dc2391439f30df65f0" +checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" dependencies = [ - "async-lock", + "async-lock 3.2.0", "async-task", "concurrent-queue", "fastrand 2.0.1", - "futures-lite", + "futures-lite 2.1.0", "slab", ] @@ -130,10 +143,10 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06" dependencies = [ - "async-lock", + "async-lock 2.8.0", "autocfg", "blocking", - "futures-lite", + "futures-lite 1.13.0", ] [[package]] @@ -142,20 +155,39 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" dependencies = [ - "async-lock", + "async-lock 2.8.0", "autocfg", "cfg-if", "concurrent-queue", - "futures-lite", + "futures-lite 1.13.0", "log", "parking", - "polling", - "rustix 0.37.26", + "polling 2.8.0", + "rustix 0.37.27", "slab", "socket2 0.4.10", "waker-fn", ] +[[package]] +name = "async-io" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6afaa937395a620e33dc6a742c593c01aced20aa376ffb0f628121198578ccc7" +dependencies = [ + "async-lock 3.2.0", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite 2.1.0", + "parking", + "polling 3.3.1", + "rustix 0.38.28", + "slab", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "async-lock" version = "2.8.0" @@ -165,15 +197,26 @@ dependencies = [ "event-listener 2.5.3", ] +[[package]] +name = "async-lock" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7125e42787d53db9dd54261812ef17e937c95a51e4d291373b670342fa44310c" +dependencies = [ + "event-listener 4.0.1", + "event-listener-strategy", + "pin-project-lite", +] + [[package]] name = "async-net" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0434b1ed18ce1cf5769b8ac540e33f01fa9471058b5e89da9e06f3c882a8c12f" dependencies = [ - "async-io", + "async-io 1.13.0", "blocking", - "futures-lite", + "futures-lite 1.13.0", ] [[package]] @@ -182,33 +225,33 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea6438ba0a08d81529c69b36700fa2f95837bfe3e776ab39cde9c14d9149da88" dependencies = [ - "async-io", - "async-lock", + "async-io 1.13.0", + "async-lock 2.8.0", "async-signal", "blocking", "cfg-if", - "event-listener 3.0.0", - "futures-lite", - "rustix 0.38.20", - "windows-sys", + "event-listener 3.1.0", + "futures-lite 1.13.0", + "rustix 0.38.28", + "windows-sys 0.48.0", ] [[package]] name = "async-signal" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2a5415b7abcdc9cd7d63d6badba5288b2ca017e3fbd4173b8f405449f1a2399" +checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" dependencies = [ - "async-io", - "async-lock", + "async-io 2.2.2", + "async-lock 2.8.0", "atomic-waker", "cfg-if", "futures-core", "futures-io", - "rustix 0.38.20", + "rustix 0.38.28", "signal-hook-registry", "slab", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -230,24 +273,24 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.42", ] [[package]] name = "async-task" -version = "4.5.0" +version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4eb2cdb97421e01129ccb49169d8279ed21e829929144f4a22a6e54ac549ca1" +checksum = "e1d90cd0b264dfdd8eb5bad0a2c217c1f88fa96a8573f40e7b12de23fb468f46" [[package]] name = "async-trait" -version = "0.1.74" +version = "0.1.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +checksum = "fdf6721fb0140e4f897002dd086c06f6c27775df19cfe1fccb21181a48fd2c98" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.42", ] [[package]] @@ -414,16 +457,16 @@ dependencies = [ [[package]] name = "blocking" -version = "1.4.1" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c36a4d0d48574b3dd360b4b7d95cc651d2b6557b6402848a27d4b228a473e2a" +checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ - "async-channel", - "async-lock", + "async-channel 2.1.1", + "async-lock 3.2.0", "async-task", "fastrand 2.0.1", "futures-io", - "futures-lite", + "futures-lite 2.1.0", "piper", "tracing", ] @@ -478,21 +521,20 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chacha20" -version = "0.8.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" dependencies = [ "cfg-if", "cipher", "cpufeatures", - "zeroize", ] [[package]] name = "chacha20poly1305" -version = "0.9.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" +checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" dependencies = [ "aead", "chacha20", @@ -503,18 +545,20 @@ dependencies = [ [[package]] name = "cipher" -version = "0.3.0" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ - "generic-array", + "crypto-common", + "inout", + "zeroize", ] [[package]] name = "concurrent-queue" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" +checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" dependencies = [ "crossbeam-utils", ] @@ -550,9 +594,9 @@ dependencies = [ [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -560,39 +604,24 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" - -[[package]] -name = "corespace-weigher" -version = "0.1.0" -dependencies = [ - "csv", - "parity-scale-codec", - "rocket", - "rocket_cors", - "serde", - "serde_json", - "subxt", - "subxt-metadata", - "tokio", -] +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fbc60abd742b35f2492f808e1abbb83d45f72db402e14c55057edc9c7b1e9e4" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] [[package]] name = "crossbeam-queue" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" +checksum = "b9bcf5bdbfdd6030fb4a1c497b5d5fc5921aa2f60d359a17e249c0e6df3de153" dependencies = [ "cfg-if", "crossbeam-utils", @@ -600,9 +629,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +checksum = "c06d96137f14f244c37f989d9fff8f95e6c18b918e71f36638f8c49112e4c78f" dependencies = [ "cfg-if", ] @@ -620,6 +649,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", + "rand_core 0.6.4", "typenum", ] @@ -656,9 +686,9 @@ dependencies = [ [[package]] name = "ctr" -version = "0.7.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a232f92a03f37dd7d7dd2adc67166c77e9cd88de5b019b9a9eecfaeaf7bfd481" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" dependencies = [ "cipher", ] @@ -694,13 +724,13 @@ dependencies = [ [[package]] name = "curve25519-dalek-derive" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.42", ] [[package]] @@ -761,7 +791,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.38", + "syn 2.0.42", ] [[package]] @@ -783,14 +813,14 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", "quote", - "syn 2.0.38", + "syn 2.0.42", ] [[package]] name = "deranged" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +checksum = "8eb30d70a07a3b04884d2677f06bec33509dc67ca60d92949e5535352d3191dc" dependencies = [ "powerfmt", ] @@ -849,7 +879,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.38", + "syn 2.0.42", ] [[package]] @@ -915,12 +945,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -931,15 +961,36 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29e56284f00d94c1bc7fd3c77027b4623c88c1f53d8d2394c6199f2921dea325" +checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2" dependencies = [ "concurrent-queue", "parking", "pin-project-lite", ] +[[package]] +name = "event-listener" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84f2cdcf274580f2d63697192d744727b3198894b1bf02923643bf59e2c26712" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" +dependencies = [ + "event-listener 4.0.1", + "pin-project-lite", +] + [[package]] name = "fastrand" version = "1.9.0" @@ -957,9 +1008,9 @@ checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "fiat-crypto" -version = "0.2.1" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0870c84016d4b481be5c9f323c24f65e31e901ae618f0e80f4308fb00de1d2d" +checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" [[package]] name = "figment" @@ -995,9 +1046,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -1033,9 +1084,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" dependencies = [ "futures-channel", "futures-core", @@ -1047,9 +1098,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", "futures-sink", @@ -1057,15 +1108,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] name = "futures-lite" @@ -1082,28 +1133,41 @@ dependencies = [ "waker-fn", ] +[[package]] +name = "futures-lite" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeee267a1883f7ebef3700f262d2d54de95dfaf38189015a74fdc4e0c7ad8143" +dependencies = [ + "fastrand 2.0.1", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.42", ] [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-timer" @@ -1113,9 +1177,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-channel", "futures-core", @@ -1154,9 +1218,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "libc", @@ -1165,9 +1229,9 @@ dependencies = [ [[package]] name = "ghash" -version = "0.4.4" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" +checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" dependencies = [ "opaque-debug", "polyval", @@ -1175,9 +1239,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "glob" @@ -1187,9 +1251,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "h2" -version = "0.3.21" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" dependencies = [ "bytes", "fnv", @@ -1197,7 +1261,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.3", + "indexmap", "slab", "tokio", "tokio-util", @@ -1215,9 +1279,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ "serde", ] @@ -1272,9 +1336,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" dependencies = [ "bytes", "fnv", @@ -1283,9 +1347,9 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", "http", @@ -1306,9 +1370,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.27" +version = "0.14.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" dependencies = [ "bytes", "futures-channel", @@ -1321,7 +1385,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2 0.5.5", "tokio", "tower-service", "tracing", @@ -1330,9 +1394,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http", @@ -1352,9 +1416,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1391,22 +1455,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] - -[[package]] -name = "indexmap" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.2", + "hashbrown 0.14.3", "serde", ] @@ -1422,6 +1476,15 @@ version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb" +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array", +] + [[package]] name = "instant" version = "0.1.12" @@ -1445,7 +1508,7 @@ checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ "hermit-abi", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1455,8 +1518,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "rustix 0.38.20", - "windows-sys", + "rustix 0.38.28", + "windows-sys 0.48.0", ] [[package]] @@ -1470,9 +1533,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "jsonrpsee" @@ -1513,7 +1576,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da2327ba8df2fdbd5e897e2b5ed25ce7f299d345b9736b6828814c3dbd1fd47b" dependencies = [ "anyhow", - "async-lock", + "async-lock 2.8.0", "async-trait", "beef", "futures-timer", @@ -1579,9 +1642,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.149" +version = "0.2.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" [[package]] name = "libm" @@ -1645,9 +1708,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.4.10" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "lock_api" @@ -1736,13 +1799,13 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", "wasi", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1860,9 +1923,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" @@ -1884,9 +1947,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "parity-scale-codec" -version = "3.6.5" +version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" +checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" dependencies = [ "arrayvec 0.7.4", "bitvec", @@ -1898,11 +1961,11 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.5" +version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" +checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 2.0.1", "proc-macro2", "quote", "syn 1.0.109", @@ -1932,9 +1995,9 @@ checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.4.1", + "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -1954,9 +2017,9 @@ dependencies = [ [[package]] name = "pear" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a386cd715229d399604b50d1361683fe687066f42d56f54be995bc6868f71c" +checksum = "4ccca0f6c17acc81df8e242ed473ec144cbf5c98037e69aa6d144780aad103c8" dependencies = [ "inlinable_string", "pear_codegen", @@ -1965,21 +2028,21 @@ dependencies = [ [[package]] name = "pear_codegen" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f0f13dac8069c139e8300a6510e3f4143ecf5259c60b116a9b271b4ca0d54" +checksum = "2e22670e8eb757cff11d6c199ca7b987f352f0346e0be4dd23869ec72cb53c77" dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.38", + "syn 2.0.42", ] [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" @@ -1998,7 +2061,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.42", ] [[package]] @@ -2026,9 +2089,9 @@ dependencies = [ [[package]] name = "platforms" -version = "3.1.2" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4503fa043bf02cee09a9582e9554b4c6403b2ef55e4612e96561d294419429f8" +checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" [[package]] name = "polling" @@ -2043,14 +2106,28 @@ dependencies = [ "libc", "log", "pin-project-lite", - "windows-sys", + "windows-sys 0.48.0", +] + +[[package]] +name = "polling" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf63fa624ab313c11656b4cda960bfc46c410187ad493c41f6ba2d8c1e991c9e" +dependencies = [ + "cfg-if", + "concurrent-queue", + "pin-project-lite", + "rustix 0.38.28", + "tracing", + "windows-sys 0.52.0", ] [[package]] name = "poly1305" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" dependencies = [ "cpufeatures", "opaque-debug", @@ -2059,9 +2136,9 @@ dependencies = [ [[package]] name = "polyval" -version = "0.5.3" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" +checksum = "d52cff9d1d4dee5fe6d03729099f4a310a41179e0a10dbf542039873f2e826fb" dependencies = [ "cfg-if", "cpufeatures", @@ -2104,6 +2181,16 @@ dependencies = [ "toml_edit 0.19.15", ] +[[package]] +name = "proc-macro-crate" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a" +dependencies = [ + "toml_datetime", + "toml_edit 0.20.2", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -2130,9 +2217,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" dependencies = [ "unicode-ident", ] @@ -2145,7 +2232,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.42", "version_check", "yansi", ] @@ -2201,15 +2288,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_syscall" version = "0.4.1" @@ -2221,22 +2299,22 @@ dependencies = [ [[package]] name = "ref-cast" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acde58d073e9c79da00f2b5b84eed919c8326832648a5b109b3fce1bb1175280" +checksum = "53313ec9f12686aeeffb43462c3ac77aa25f590a5f630eb2cde0de59417b29c7" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7473c2cfcf90008193dd0e3e16599455cb601a9fce322b5bb55de799664925" +checksum = "2566c4bf6845f2c2e83b27043c3f5dfcd5ba8f2937d6c00dc009bfb51a079dc4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.42", ] [[package]] @@ -2285,16 +2363,16 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "ring" -version = "0.17.5" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" +checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" dependencies = [ "cc", "getrandom", "libc", "spin", "untrusted", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2311,7 +2389,7 @@ dependencies = [ "either", "figment", "futures", - "indexmap 2.0.2", + "indexmap", "log", "memchr", "multer", @@ -2343,11 +2421,11 @@ checksum = "a2238066abf75f21be6cd7dc1a09d5414a671f4246e384e49fe3f8a4936bd04c" dependencies = [ "devise", "glob", - "indexmap 2.0.2", + "indexmap", "proc-macro2", "quote", "rocket_http", - "syn 2.0.38", + "syn 2.0.42", "unicode-xid", "version_check", ] @@ -2380,7 +2458,7 @@ dependencies = [ "futures", "http", "hyper", - "indexmap 2.0.2", + "indexmap", "log", "memchr", "pear", @@ -2396,6 +2474,18 @@ dependencies = [ "uncased", ] +[[package]] +name = "routes" +version = "0.1.0" +dependencies = [ + "csv", + "rocket", + "rocket_cors", + "serde_json", + "shared", + "types", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -2425,36 +2515,36 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.26" +version = "0.37.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f3f8f960ed3b5a59055428714943298bf3fa2d4a1d53135084e0544829d995" +checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" dependencies = [ "bitflags 1.3.2", "errno", "io-lifetimes", "libc", "linux-raw-sys 0.3.8", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "rustix" -version = "0.38.20" +version = "0.38.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ce50cb2e16c2903e30d1cbccfd8387a74b9d4c938b6a4c5ec6cc7556f7a8a0" +checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" dependencies = [ "bitflags 2.4.1", "errno", "libc", - "linux-raw-sys 0.4.10", - "windows-sys", + "linux-raw-sys 0.4.12", + "windows-sys 0.52.0", ] [[package]] name = "rustls" -version = "0.21.8" +version = "0.21.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" +checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", "ring", @@ -2476,9 +2566,9 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ "base64 0.21.5", ] @@ -2512,9 +2602,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "scale-bits" @@ -2549,7 +2639,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27873eb6005868f8cc72dcfe109fae664cf51223d35387bc2f28be4c28d94c47" dependencies = [ "darling 0.14.4", - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -2577,7 +2667,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "995491f110efdc6bea96d6a746140e32bfceb4ea47510750a5467295a4707a25" dependencies = [ "darling 0.14.4", - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -2603,7 +2693,7 @@ version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -2635,7 +2725,7 @@ version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" dependencies = [ - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2722,7 +2812,7 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.42", ] [[package]] @@ -2738,13 +2828,22 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" dependencies = [ "serde", ] +[[package]] +name = "server" +version = "0.1.0" +dependencies = [ + "rocket", + "rocket_cors", + "routes", +] + [[package]] name = "sha-1" version = "0.9.8" @@ -2801,6 +2900,14 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shared" +version = "0.1.0" +dependencies = [ + "serde_json", + "types", +] + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -2827,9 +2934,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "smol" @@ -2837,15 +2944,15 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13f2b548cd8447f8de0fdf1c592929f70f4fc7039a05e47404b0d096ec6987a1" dependencies = [ - "async-channel", + "async-channel 1.9.0", "async-executor", "async-fs", - "async-io", - "async-lock", + "async-io 1.13.0", + "async-lock 2.8.0", "async-net", "async-process", "blocking", - "futures-lite", + "futures-lite 1.13.0", ] [[package]] @@ -2855,7 +2962,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cce5e2881b30bad7ef89f383a816ad0b22c45915911f28499026de4a76d20ee" dependencies = [ "arrayvec 0.7.4", - "async-lock", + "async-lock 2.8.0", "atomic 0.5.3", "base64 0.21.5", "bip39", @@ -2869,7 +2976,7 @@ dependencies = [ "fnv", "futures-channel", "futures-util", - "hashbrown 0.14.2", + "hashbrown 0.14.3", "hex", "hmac 0.12.1", "itertools", @@ -2906,7 +3013,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b2f7b4687b83ff244ef6137735ed5716ad37dcdf3ee16c4eb1a32fb9808fa47" dependencies = [ - "async-lock", + "async-lock 2.8.0", "blake2-rfc", "derive_more", "either", @@ -2914,7 +3021,7 @@ dependencies = [ "fnv", "futures-channel", "futures-util", - "hashbrown 0.14.2", + "hashbrown 0.14.3", "hex", "itertools", "log", @@ -2931,9 +3038,9 @@ dependencies = [ [[package]] name = "snow" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9d1425eb528a21de2755c75af4c9b5d57f50a0d4c3b7f1828a4cd03f8ba155" +checksum = "58021967fd0a5eeeb23b08df6cc244a4d4a5b4aec1d27c9e02fad1a58b4cd74e" dependencies = [ "aes-gcm", "blake2", @@ -2962,7 +3069,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -3097,7 +3204,7 @@ dependencies = [ "quote", "scale-info", "subxt-metadata", - "syn 2.0.38", + "syn 2.0.42", "thiserror", "tokio", ] @@ -3128,7 +3235,7 @@ dependencies = [ "darling 0.20.3", "proc-macro-error", "subxt-codegen", - "syn 2.0.38", + "syn 2.0.42", ] [[package]] @@ -3157,9 +3264,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.38" +version = "2.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "5b7d0a2c048d661a1a59fcd7355baa232f7ed34e0ee4df2eef3c1c1c0d3852d8" dependencies = [ "proc-macro2", "quote", @@ -3174,55 +3281,55 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", "fastrand 2.0.1", - "redox_syscall 0.3.5", - "rustix 0.38.20", - "windows-sys", + "redox_syscall", + "rustix 0.38.28", + "windows-sys 0.48.0", ] [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "f11c217e1416d6f036b870f14e0413d480dbf28edbee1f877abaf0206af43bb7" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-core" -version = "1.0.38" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d97345f6437bb2004cd58819d8a9ef8e36cdd7661c2abc4bbde0a7c40d9f497" +checksum = "c001ee18b7e5e3f62cbf58c7fe220119e68d902bb7443179c0c8aef30090e999" dependencies = [ "thiserror-core-impl", ] [[package]] name = "thiserror-core-impl" -version = "1.0.38" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10ac1c5050e43014d16b2f94d0d2ce79e65ffdd8b38d8048f9c8f6a8a6da62ac" +checksum = "e4c60d69f36615a077cc7663b9cb8e42275722d23e58a7fa3d2c7f2915d09d04" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.42", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "01742297787513b79cf8e29d1056ede1313e2420b7b3b15d0a768b4921f549df" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.42", ] [[package]] @@ -3237,9 +3344,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" +checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" dependencies = [ "deranged", "itoa", @@ -3257,9 +3364,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" dependencies = [ "time-core", ] @@ -3290,9 +3397,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.33.0" +version = "1.35.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" +checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" dependencies = [ "backtrace", "bytes", @@ -3304,18 +3411,18 @@ dependencies = [ "signal-hook-registry", "socket2 0.5.5", "tokio-macros", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.42", ] [[package]] @@ -3341,9 +3448,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -3356,21 +3463,21 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.8" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" +checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.21.0", + "toml_edit 0.20.2", ] [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" dependencies = [ "serde", ] @@ -3381,18 +3488,18 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.2", + "indexmap", "toml_datetime", "winnow", ] [[package]] name = "toml_edit" -version = "0.21.0" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ - "indexmap 2.0.2", + "indexmap", "serde", "serde_spanned", "toml_datetime", @@ -3446,7 +3553,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.42", ] [[package]] @@ -3488,11 +3595,23 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "tracker" +version = "0.1.0" +dependencies = [ + "csv", + "shared", + "subxt", + "subxt-metadata", + "tokio", + "types", +] + [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "twox-hash" @@ -3511,6 +3630,14 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "types" +version = "0.1.0" +dependencies = [ + "rocket", + "serde", +] + [[package]] name = "ubyte" version = "0.10.4" @@ -3563,9 +3690,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" [[package]] name = "unicode-ident" @@ -3590,11 +3717,11 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "universal-hash" -version = "0.4.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" dependencies = [ - "generic-array", + "crypto-common", "subtle", ] @@ -3606,9 +3733,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -3717,7 +3844,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -3726,7 +3853,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] @@ -3735,13 +3871,28 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -3750,47 +3901,89 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "winnow" -version = "0.5.17" +version = "0.5.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3b801d0e0a6726477cc207f60162da452f3a95adb368399bef20a946e06f65c" +checksum = "9b5c3db89721d50d0e2a673f5043fc4722f76dcc352d7b1ab8b8288bed4ed2c5" dependencies = [ "memchr", ] @@ -3821,9 +4014,9 @@ checksum = "ff4524214bc4629eba08d78ceb1d6507070cc0bcbbed23af74e19e6e924a24cf" [[package]] name = "zeroize" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" dependencies = [ "zeroize_derive", ] @@ -3836,5 +4029,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.42", ] diff --git a/Cargo.toml b/Cargo.toml index 0e6adc0..4a1bb47 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,25 +1,14 @@ -[package] -name = "corespace-weigher" -version = "0.1.0" +[workspace.package] +authors = ["RegionX "] edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[[bin]] -name = "consumption-tracker" -path = "src/main.rs" - -[[bin]] -name = "api" -path = "src/api.rs" - -[dependencies] -csv = "1.3.0" -parity-scale-codec = "3.6.5" -rocket = { version = "0.5.0", features=["json"] } -rocket_cors = "0.6.0" -serde = "1.0.193" -serde_json = "1.0.108" -subxt = "0.32.1" -subxt-metadata = "0.32.1" -tokio = { version = "1", features = ["full"] } +repository = "https://github.com/RegionX-Labs/CorespaceWeigher.git" +license = "GPL-3.0-only" + +[workspace] +members = [ + "bin/server", + "bin/tracker", + "routes", + "shared", + "types", +] diff --git a/artifacts/metadata.scale b/artifacts/metadata.scale new file mode 100644 index 0000000..802b6f2 Binary files /dev/null and b/artifacts/metadata.scale differ diff --git a/bin/server/Cargo.toml b/bin/server/Cargo.toml new file mode 100644 index 0000000..0143216 --- /dev/null +++ b/bin/server/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "server" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +rocket = { version = "0.5.0", features=["json"] } +rocket_cors = "0.6.0" + +routes = { path = "../../routes" } diff --git a/bin/server/src/main.rs b/bin/server/src/main.rs new file mode 100644 index 0000000..ee1abf8 --- /dev/null +++ b/bin/server/src/main.rs @@ -0,0 +1,32 @@ +// This file is part of RegionX. +// +// RegionX is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// RegionX is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with RegionX. If not, see . + +/// Web API for interacting with the Consumption Tracker service. +/// +/// This API exposes two main endpoints: +/// - `/consumption`: Used to query consumption data associated with a parachain. +/// - `/register`: Used to register a parachain for consumption tracking. +use rocket_cors::CorsOptions; +use routes::{consumption::consumption, register::register_para}; + +#[macro_use] +extern crate rocket; + +#[launch] +fn rocket() -> _ { + rocket::build() + .attach(CorsOptions::default().to_cors().unwrap()) + .mount("/", routes![consumption, register_para]) +} diff --git a/bin/tracker/Cargo.toml b/bin/tracker/Cargo.toml new file mode 100644 index 0000000..9f30637 --- /dev/null +++ b/bin/tracker/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "tracker" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +csv = "1.3.0" +subxt = "0.32.1" +subxt-metadata = "0.32.1" +tokio = { version = "1", features = ["full"] } + +types = { path = "../../types" } +shared = { path = "../../shared" } diff --git a/bin/tracker/src/main.rs b/bin/tracker/src/main.rs new file mode 100644 index 0000000..f93188a --- /dev/null +++ b/bin/tracker/src/main.rs @@ -0,0 +1,159 @@ +// This file is part of RegionX. +// +// RegionX is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// RegionX is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with RegionX. If not, see . + +//! # Consumption Tracker +//! +//! This is the main source file for the Consumption Tracker binary. +//! +//! ## Overview +//! +//! The program is designed to fetch weight utilization data from a predefined set +//! of parachains. The obtained weight information is then stored in the `out` +//! directory as multiple CSV files. +//! +//! ## Output Structure +//! +//! Each parachain has its own dedicated output file, and these files are updated +//! every time a new block is finalized and the weight consumption data is +//! successfully queried. +//! +//! ## Data structure +//! +//! The data stored is the 2D weight consumption per each dispatch class. +//! The data is stored in the CSV file within the following sequence: +//! +//! | block_number | normal_dispatch_ref_time | operational_dispatch_ref_time | mandatory_dispatch_ref_time | normal_proof_size | operational_proof_size | mandatory_proof_size | +//! |--------------|---------------------------|-------------------------------|-----------------------------|-------------------|-------------------------|-----------------------| +//! | ... | ... | ... | ... | ... | ... | ... | +//! +//! The percentages themselves are stored by representing them as decimal numbers; +//! for example, 50.5% is stored as 0.505 with a precision of three decimals. + +use csv::WriterBuilder; +use shared::{file_path, parachains, round_to}; +use std::fs::OpenOptions; +use subxt::{OnlineClient, PolkadotConfig}; +use types::{Parachain, WeightConsumption}; + +#[subxt::subxt(runtime_metadata_path = "../../artifacts/metadata.scale")] +mod polkadot {} + +#[tokio::main] +async fn main() -> Result<(), Box> { + // Asynchronously subscribes to follow the latest finalized block of each parachain + // and continuously fetches the weight consumption. + let tasks: Vec<_> = parachains() + .into_iter() + .map(|para| tokio::spawn(async move { track_weight_consumption(para).await })) + .collect(); + + for task in tasks { + task.await.expect("Failed to track consumption"); + } + + Ok(()) +} + +async fn track_weight_consumption(para: Parachain) { + if let Ok(api) = OnlineClient::::from_url(¶.rpc_url).await { + let mut blocks_sub = api + .blocks() + .subscribe_finalized() + .await + .expect("Failed to subscribe to finalized blocks"); + + // Wait for new finalized blocks, then fetch and output the weight consumption accordingly. + while let Some(Ok(block)) = blocks_sub.next().await { + let block_number = block.header().number; + if let Ok(consumption) = weight_consumption(api.clone(), block_number).await { + let _ = write_consumption(para.clone(), consumption); + } + } + } +} + +fn write_consumption( + para: Parachain, + consumption: WeightConsumption, +) -> Result<(), std::io::Error> { + let file_path = file_path(para); + let file = OpenOptions::new().write(true).create(true).append(true).open(file_path)?; + + let mut wtr = WriterBuilder::new().from_writer(file); + + // The data is stored in the sequence described at the beginning of the file. + wtr.write_record(&[ + // Block number: + consumption.block_number.to_string(), + // Reftime consumption: + consumption.ref_time.normal.to_string(), + consumption.ref_time.operational.to_string(), + consumption.ref_time.mandatory.to_string(), + // Proof size: + consumption.proof_size.normal.to_string(), + consumption.proof_size.operational.to_string(), + consumption.proof_size.mandatory.to_string(), + ])?; + + wtr.flush() +} + +async fn weight_consumption( + api: OnlineClient, + block_number: u32, +) -> Result> { + let weight_query = polkadot::storage().system().block_weight(); + let weight_consumed = api + .storage() + .at_latest() + .await? + .fetch(&weight_query) + .await? + .ok_or("Failed to query consumption")?; + + let weight_limit_query = polkadot::constants().system().block_weights(); + let weight_limit = api.constants().at(&weight_limit_query)?; + + let proof_limit = weight_limit.max_block.proof_size; + // NOTE: This will be the same for all parachains within the same network until elastic scaling + // is enabled. + let ref_time_limit = weight_limit.max_block.ref_time; + + let normal_ref_time = weight_consumed.normal.ref_time; + let operational_ref_time = weight_consumed.operational.ref_time; + let mandatory_ref_time = weight_consumed.mandatory.ref_time; + + let normal_proof_size = weight_consumed.normal.proof_size; + let operational_proof_size = weight_consumed.operational.proof_size; + let mandatory_proof_size = weight_consumed.mandatory.proof_size; + + let consumption = WeightConsumption { + block_number, + ref_time: ( + round_to(normal_ref_time as f32 / ref_time_limit as f32, 3), + round_to(operational_ref_time as f32 / ref_time_limit as f32, 3), + round_to(mandatory_ref_time as f32 / ref_time_limit as f32, 3), + ) + .into(), + proof_size: ( + round_to(normal_proof_size as f32 / proof_limit as f32, 3), + round_to(operational_proof_size as f32 / proof_limit as f32, 3), + round_to(mandatory_proof_size as f32 / proof_limit as f32, 3), + ) + .into(), + }; + + Ok(consumption) +} diff --git a/routes/Cargo.toml b/routes/Cargo.toml new file mode 100644 index 0000000..88494bf --- /dev/null +++ b/routes/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "routes" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +csv = "1.3.0" +rocket = { version = "0.5.0", features=["json"] } +rocket_cors = "0.6.0" +serde_json = "1.0.108" + +types = { path = "../types" } +shared = { path = "../shared" } diff --git a/routes/src/consumption.rs b/routes/src/consumption.rs new file mode 100644 index 0000000..1769613 --- /dev/null +++ b/routes/src/consumption.rs @@ -0,0 +1,48 @@ +// This file is part of RegionX. +// +// RegionX is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// RegionX is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with RegionX. If not, see . + +use crate::Error; +use csv::ReaderBuilder; +use rocket::get; +use shared::{file_path, parachain}; +use std::fs::File; +use types::{ParaId, WeightConsumption}; + +/// Query the consumption data of a parachain. +/// +/// This will return an error in case there is no data associated with the specific parachain. +#[get("/consumption//?&")] +pub fn consumption( + relay: &str, + para_id: ParaId, + page: Option, + page_size: Option, +) -> Result { + let para = parachain(relay.into(), para_id).ok_or(Error::NotRegistered)?; + + let file = File::open(file_path(para)).map_err(|_| Error::ConsumptionDataNotFound)?; + let mut rdr = ReaderBuilder::new().has_headers(false).from_reader(file); + + let (page, page_size) = (page.unwrap_or_default(), page_size.unwrap_or(u32::MAX)); + + let weight_consumptions: Vec = rdr + .deserialize::() + .filter_map(|result| result.ok()) + .skip((page.saturating_add(page_size)) as usize) + .take(page_size as usize) + .collect(); + + serde_json::to_string(&weight_consumptions).map_err(|_| Error::InvalidData) +} diff --git a/routes/src/lib.rs b/routes/src/lib.rs new file mode 100644 index 0000000..47dc7b4 --- /dev/null +++ b/routes/src/lib.rs @@ -0,0 +1,52 @@ +// This file is part of RegionX. +// +// RegionX is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// RegionX is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with RegionX. If not, see . + +use rocket::{http::Status, response::Responder, Request, Response}; + +/// Web API for interacting with the Consumption Tracker service. +/// +/// This API exposes two main endpoints: +/// - `/consumption`: Used to query consumption data associated with a parachain. +/// - `/register`: Used to register a parachain for consumption tracking. + +#[derive(Debug)] +pub enum Error { + /// Cannot register an already registered parachain. + AlreadyRegistered, + /// Tried to get the consumption of a parachain that is not registered. + NotRegistered, + /// Indicates that the consumption data for the parachain was not found. + /// + /// This should be only encountered if the consumption file has not been generated yet, + /// which is only possible if the parachain has been registered within the last few seconds. + ConsumptionDataNotFound, + /// The stored data is invalid. This should never really happen. + InvalidData, + /// Failed to find the parachains data. This isn't a user error, but a bug in the code itself. + ParasDataNotFound, +} + +impl<'r> Responder<'r, 'static> for Error { + fn respond_to(self, _: &'r Request<'_>) -> Result, Status> { + let body = format!("Error: {:?}", self); + Response::build() + .status(Status::InternalServerError) + .sized_body(body.len(), std::io::Cursor::new(body)) + .ok() + } +} + +pub mod consumption; +pub mod register; diff --git a/routes/src/register.rs b/routes/src/register.rs new file mode 100644 index 0000000..e9079a2 --- /dev/null +++ b/routes/src/register.rs @@ -0,0 +1,54 @@ +// This file is part of RegionX. +// +// RegionX is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// RegionX is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with RegionX. If not, see . + +use crate::*; +use rocket::{post, serde::json::Json}; +use shared::{parachain, PARACHAINS}; +use std::{ + fs::OpenOptions, + io::{Read, Seek, Write}, +}; +use types::Parachain; + +/// Register a parachain for resource utilization tracking. +#[post("/register_para", data = "")] +pub fn register_para(para: Json) -> Result { + let mut file = OpenOptions::new() + .read(true) + .write(true) + .create(true) + .open(PARACHAINS) + .map_err(|_| Error::ParasDataNotFound)?; + + let mut content = String::new(); + file.read_to_string(&mut content).map_err(|_| Error::InvalidData)?; + + let mut paras: Vec = + serde_json::from_str(&content).map_err(|_| Error::InvalidData)?; + + if parachain(para.relay_chain.clone(), para.para_id).is_some() { + return Err(Error::AlreadyRegistered); + } + + paras.push(para.into_inner()); + let json_data = serde_json::to_string_pretty(¶s).expect("Failed to serialize"); + + file.set_len(0).expect("Failed to truncate file"); + file.seek(std::io::SeekFrom::Start(0)).expect("Failed to seek to the beginning"); + + file.write_all(json_data.as_bytes()).unwrap(); + + Ok(Default::default()) +} diff --git a/shared/Cargo.toml b/shared/Cargo.toml new file mode 100644 index 0000000..3b3e2af --- /dev/null +++ b/shared/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "shared" +version = "0.1.0" +authors.workspace = true +edition.workspace = true +repository.workspace = true +license.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +types = { path = "../types" } +serde_json = "1.0.108" diff --git a/shared/src/lib.rs b/shared/src/lib.rs new file mode 100644 index 0000000..bde3836 --- /dev/null +++ b/shared/src/lib.rs @@ -0,0 +1,49 @@ +// This file is part of RegionX. +// +// RegionX is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// RegionX is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with RegionX. If not, see . + +use std::{fs::File, io::Read}; +use types::{ParaId, Parachain, RelayChain}; + +pub const PARACHAINS: &str = "parachains.json"; + +pub fn parachains() -> Vec { + let mut file = File::open(PARACHAINS).expect("Hardcoded path is known good; qed"); + + let mut content = String::new(); + if file.read_to_string(&mut content).is_ok() { + let paras: Vec = serde_json::from_str(&content).unwrap_or_default(); + paras + } else { + Default::default() + } +} + +#[allow(dead_code)] +pub fn parachain(relay_chain: RelayChain, para_id: ParaId) -> Option { + parachains() + .iter() + .find(|para| para.relay_chain == relay_chain && para.para_id == para_id) + .cloned() +} + +pub fn file_path(para: Parachain) -> String { + format!("out/{}-{}.csv", para.relay_chain, para.para_id) +} + +#[allow(dead_code)] +pub fn round_to(number: f32, decimals: i32) -> f32 { + let factor = 10f32.powi(decimals); + (number * factor).round() / factor +} diff --git a/src/api.rs b/src/api.rs deleted file mode 100644 index 1b87332..0000000 --- a/src/api.rs +++ /dev/null @@ -1,116 +0,0 @@ -/// Web API for interacting with the Consumption Tracker service. -/// -/// This API exposes two main endpoints: -/// - `/consumption`: Used to query consumption data associated with a parachain. -/// - `/register`: Used to register a parachain for consumption tracking. -use csv::ReaderBuilder; -use rocket::{http::Status, response::Responder, serde::json::Json, Request, Response}; -use rocket_cors::CorsOptions; -use std::{ - fs::{File, OpenOptions}, - io::{Read, Seek, Write}, -}; - -mod shared; -use shared::*; - -mod types; -use types::*; - -#[macro_use] -extern crate rocket; - -#[derive(Debug)] -enum Error { - /// Cannot register an already registered parachain. - AlreadyRegistered, - /// Tried to get the consumption of a parachain that is not registered. - NotRegistered, - /// Indicates that the consumption data for the parachain was not found. - /// - /// This should be only encountered if the consumption file has not been generated yet, - /// which is only possible if the parachain has been registered within the last few seconds. - ConsumptionDataNotFound, - /// The stored data is invalid. This should never really happen. - InvalidData, - /// Failed to find the parachains data. This isn't a user error, but a bug in the code itself. - ParasDataNotFound, -} - -impl<'r> Responder<'r, 'static> for Error { - fn respond_to(self, _: &'r Request<'_>) -> Result, Status> { - let body = format!("Error: {:?}", self); - Response::build() - .status(Status::InternalServerError) - .sized_body(body.len(), std::io::Cursor::new(body)) - .ok() - } -} - -/// Query the consumption data of a parachain. -/// -/// This will return an error in case there is no data associated with the specific parachain. -#[get("/consumption//?&")] -fn consumption( - relay: &str, - para_id: ParaId, - page: Option, - page_size: Option, -) -> Result { - let para = parachain(relay.into(), para_id).ok_or(Error::NotRegistered)?; - - let file = File::open(file_path(para)).map_err(|_| Error::ConsumptionDataNotFound)?; - let mut rdr = ReaderBuilder::new().has_headers(false).from_reader(file); - - let (page, page_size) = (page.unwrap_or_default(), page_size.unwrap_or(u32::MAX)); - - - let weight_consumptions: Vec = rdr - .deserialize::() - .filter_map(|result| result.ok()) - .skip((page.saturating_add(page_size)) as usize) - .take(page_size as usize) - .collect(); - - serde_json::to_string(&weight_consumptions).map_err(|_| Error::InvalidData) -} - -/// Register a parachain for resource utilization tracking. -#[post("/register_para", data = "")] -fn register_para(para: Json) -> Result { - let mut file = OpenOptions::new() - .read(true) - .write(true) - .create(true) - .open(PARACHAINS) - .map_err(|_| Error::ParasDataNotFound)?; - - let mut content = String::new(); - file.read_to_string(&mut content) - .map_err(|_| Error::InvalidData)?; - - let mut paras: Vec = - serde_json::from_str(&content).map_err(|_| Error::InvalidData)?; - - if parachain(para.relay_chain.clone(), para.para_id.clone()).is_some() { - return Err(Error::AlreadyRegistered); - } - - paras.push(para.into_inner()); - let json_data = serde_json::to_string_pretty(¶s).expect("Failed to serialize"); - - file.set_len(0).expect("Failed to truncate file"); - file.seek(std::io::SeekFrom::Start(0)) - .expect("Failed to seek to the beginning"); - - file.write_all(json_data.as_bytes()).unwrap(); - - Ok(format!("")) -} - -#[launch] -fn rocket() -> _ { - rocket::build() - .attach(CorsOptions::default().to_cors().unwrap()) - .mount("/", routes![consumption, register_para]) -} diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index 1540244..0000000 --- a/src/main.rs +++ /dev/null @@ -1,152 +0,0 @@ -//! # Consumption Tracker -//! -//! This is the main source file for the Consumption Tracker binary. -//! -//! ## Overview -//! -//! The program is designed to fetch weight utilization data from a predefined set -//! of parachains. The obtained weight information is then stored in the `out` -//! directory as multiple CSV files. -//! -//! ## Output Structure -//! -//! Each parachain has its own dedicated output file, and these files are updated -//! every time a new block is finalized and the weight consumption data is -//! successfully queried. -//! -//! ## Data structure -//! -//! The data stored is the 2D weight consumption per each dispatch class. -//! The data is stored in the CSV file within the following sequence: -//! -//! | block_number | normal_dispatch_ref_time | operational_dispatch_ref_time | mandatory_dispatch_ref_time | normal_proof_size | operational_proof_size | mandatory_proof_size | -//! |--------------|---------------------------|-------------------------------|-----------------------------|-------------------|-------------------------|-----------------------| -//! | ... | ... | ... | ... | ... | ... | ... | -//! -//! The percentages themselves are stored by representing them as decimal numbers; -//! for example, 50.5% is stored as 0.505 with a precision of three decimals. - -use csv::WriterBuilder; -use std::fs::OpenOptions; -use subxt::{OnlineClient, PolkadotConfig}; - -mod shared; -use shared::*; - -pub mod types; -use types::*; - -#[subxt::subxt(runtime_metadata_path = "artifacts/metadata.scale")] -mod polkadot {} - -#[tokio::main] -async fn main() -> Result<(), Box> { - // Asynchronously subscribes to follow the latest finalized block of each parachain - // and continuously fetches the weight consumption. - let tasks: Vec<_> = parachains() - .into_iter() - .map(|para| tokio::spawn(async move { track_weight_consumption(para).await })) - .collect(); - - for task in tasks { - task.await.expect("Failed to track consumption"); - } - - Ok(()) -} - -async fn track_weight_consumption(para: Parachain) { - if let Ok(api) = OnlineClient::::from_url(¶.rpc_url).await { - let mut blocks_sub = api - .blocks() - .subscribe_finalized() - .await - .expect("Failed to subscribe to finalized blocks"); - - // Wait for new finalized blocks, then fetch and output the weight consumption accordingly. - while let Some(Ok(block)) = blocks_sub.next().await { - let block_number = block.header().number; - if let Ok(consumption) = weight_consumption(api.clone(), block_number).await { - let _ = write_consumption(para.clone(), consumption); - } - } - } -} - -fn write_consumption( - para: Parachain, - consumption: WeightConsumption, -) -> Result<(), std::io::Error> { - let file_path = file_path(para); - let file = OpenOptions::new() - .write(true) - .create(true) - .append(true) - .open(file_path)?; - - let mut wtr = WriterBuilder::new().from_writer(file); - - // The data is stored in the sequence described at the beginning of the file. - wtr.write_record(&[ - // Block number: - consumption.block_number.to_string(), - // Reftime consumption: - consumption.ref_time.normal.to_string(), - consumption.ref_time.operational.to_string(), - consumption.ref_time.mandatory.to_string(), - // Proof size: - consumption.proof_size.normal.to_string(), - consumption.proof_size.operational.to_string(), - consumption.proof_size.mandatory.to_string(), - ])?; - - wtr.flush() -} - -async fn weight_consumption( - api: OnlineClient, - block_number: u32, -) -> Result> { - let weight_query = polkadot::storage().system().block_weight(); - let weight_consumed = api - .storage() - .at_latest() - .await? - .fetch(&weight_query) - .await? - .ok_or("Failed to query consumption")?; - - let weight_limit_query = polkadot::constants().system().block_weights(); - let weight_limit = api.constants().at(&weight_limit_query)?; - - let proof_limit = weight_limit.max_block.proof_size; - // NOTE: This will be the same for all parachains within the same network until elastic scaling - // is enabled. - let ref_time_limit = weight_limit.max_block.ref_time; - - let normal_ref_time = weight_consumed.normal.ref_time; - let operational_ref_time = weight_consumed.operational.ref_time; - let mandatory_ref_time = weight_consumed.mandatory.ref_time; - - let normal_proof_size = weight_consumed.normal.proof_size; - let operational_proof_size = weight_consumed.operational.proof_size; - let mandatory_proof_size = weight_consumed.mandatory.proof_size; - - let consumption = WeightConsumption { - block_number, - ref_time: ( - round_to(normal_ref_time as f32 / ref_time_limit as f32, 3), - round_to(operational_ref_time as f32 / ref_time_limit as f32, 3), - round_to(mandatory_ref_time as f32 / ref_time_limit as f32, 3), - ) - .into(), - proof_size: ( - round_to(normal_proof_size as f32 / proof_limit as f32, 3), - round_to(operational_proof_size as f32 / proof_limit as f32, 3), - round_to(mandatory_proof_size as f32 / proof_limit as f32, 3), - ) - .into(), - }; - - Ok(consumption) -} diff --git a/src/shared.rs b/src/shared.rs deleted file mode 100644 index 372a038..0000000 --- a/src/shared.rs +++ /dev/null @@ -1,34 +0,0 @@ -use crate::types::*; -use std::{fs::File, io::Read}; - -pub const PARACHAINS: &str = "parachains.json"; - -pub fn parachains() -> Vec { - let mut file = File::open(PARACHAINS).expect("Hardcoded path is known good; qed"); - - let mut content = String::new(); - if file.read_to_string(&mut content).is_ok() { - let paras: Vec = serde_json::from_str(&content).unwrap_or_default(); - paras - } else { - Default::default() - } -} - -#[allow(dead_code)] -pub fn parachain(relay_chain: RelayChain, para_id: ParaId) -> Option { - parachains() - .iter() - .find(|para| para.relay_chain == relay_chain && para.para_id == para_id) - .cloned() -} - -pub fn file_path(para: Parachain) -> String { - format!("out/{}-{}.csv", para.relay_chain, para.para_id) -} - -#[allow(dead_code)] -pub fn round_to(number: f32, decimals: i32) -> f32 { - let factor = 10f32.powi(decimals); - (number * factor).round() / factor -} diff --git a/src/types.rs b/src/types.rs deleted file mode 100644 index 94a2f65..0000000 --- a/src/types.rs +++ /dev/null @@ -1,110 +0,0 @@ -use serde::{Deserialize, Serialize}; -use std::fmt; - -pub type ParaId = u32; - -#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] -#[serde(crate = "rocket::serde")] -pub enum RelayChain { - Polkadot, - Kusama, -} - -impl fmt::Display for RelayChain { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - RelayChain::Polkadot => write!(f, "Polkadot"), - RelayChain::Kusama => write!(f, "Kusama"), - } - } -} - -impl From<&str> for RelayChain { - fn from(s: &str) -> Self { - match s.to_lowercase().as_str() { - "polkadot" => RelayChain::Polkadot, - "kusama" => RelayChain::Kusama, - _ => panic!("Invalid relay chain: {}", s), - } - } -} - -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(crate = "rocket::serde")] -pub struct Parachain { - /// Name of the parachain. - pub name: String, - /// The rpc url endpoint from where we can query the weight consumption. - // - // TODO: instead of having only one rpc url specified there should be a fallback. - pub rpc_url: String, - /// The `ParaId` of the parachain. - pub para_id: ParaId, - /// The relay chain that the parachain is using for block validation. - pub relay_chain: RelayChain, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct WeightConsumption { - /// The block number for which the weight consumption is related to. - pub block_number: u32, - /// The ref_time consumption over all the dispatch classes. - pub ref_time: DispatchClassConsumption, - /// The proof size over all dispatch classes. - pub proof_size: DispatchClassConsumption, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct DispatchClassConsumption { - /// The percentage of the weight used by user submitted extrinsics compared to the - /// maximum potential. - pub normal: f32, - /// The percentage of the weight used by user operational dispatches compared to the - /// maximum potential. - pub operational: f32, - /// The percentage of the weight used by the mandatory tasks of a parachain compared - /// to the maximum potential. - pub mandatory: f32, -} - -/// A shorthand for converting a tuple of `f32`s into `DispatchClassConsumption`. -/// -/// The order in which the values need to be provided is: `normal`, `operational`, `mandatory`. -impl From<(f32, f32, f32)> for DispatchClassConsumption { - fn from(value: (f32, f32, f32)) -> Self { - DispatchClassConsumption { - normal: value.0, - operational: value.1, - mandatory: value.2, - } - } -} - -impl fmt::Display for WeightConsumption { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!( - f, - "\n\tNormal ref_time consumption: {}", - self.ref_time.normal - )?; - write!( - f, - "\n\tOperational ref_time consumption: {}", - self.ref_time.operational - )?; - write!( - f, - "\n\tMandatory ref_time consumption: {}", - self.ref_time.mandatory - )?; - - write!(f, "\n\tNormal proof size: {}", self.proof_size.normal)?; - write!( - f, - "\n\tOperational proof size: {}", - self.proof_size.operational - )?; - write!(f, "\n\tMandatory proof size: {}", self.proof_size.mandatory)?; - Ok(()) - } -} diff --git a/types/Cargo.toml b/types/Cargo.toml new file mode 100644 index 0000000..5d173af --- /dev/null +++ b/types/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "types" +version = "0.1.0" +authors.workspace = true +edition.workspace = true +repository.workspace = true +license.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +serde = "1.0.193" +rocket = { version = "0.5.0", features=["json"] } + diff --git a/types/src/lib.rs b/types/src/lib.rs new file mode 100644 index 0000000..7dbc301 --- /dev/null +++ b/types/src/lib.rs @@ -0,0 +1,105 @@ +// This file is part of RegionX. +// +// RegionX is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// RegionX is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with RegionX. If not, see . + +use serde::{Deserialize, Serialize}; +use std::fmt; + +pub type ParaId = u32; + +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] +#[serde(crate = "rocket::serde")] +pub enum RelayChain { + Polkadot, + Kusama, +} + +impl fmt::Display for RelayChain { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + RelayChain::Polkadot => write!(f, "Polkadot"), + RelayChain::Kusama => write!(f, "Kusama"), + } + } +} + +impl From<&str> for RelayChain { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "polkadot" => RelayChain::Polkadot, + "kusama" => RelayChain::Kusama, + _ => panic!("Invalid relay chain: {}", s), + } + } +} + +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(crate = "rocket::serde")] +pub struct Parachain { + /// Name of the parachain. + pub name: String, + /// The rpc url endpoint from where we can query the weight consumption. + // + // TODO: instead of having only one rpc url specified there should be a fallback. + pub rpc_url: String, + /// The `ParaId` of the parachain. + pub para_id: ParaId, + /// The relay chain that the parachain is using for block validation. + pub relay_chain: RelayChain, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct WeightConsumption { + /// The block number for which the weight consumption is related to. + pub block_number: u32, + /// The ref_time consumption over all the dispatch classes. + pub ref_time: DispatchClassConsumption, + /// The proof size over all dispatch classes. + pub proof_size: DispatchClassConsumption, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct DispatchClassConsumption { + /// The percentage of the weight used by user submitted extrinsics compared to the + /// maximum potential. + pub normal: f32, + /// The percentage of the weight used by user operational dispatches compared to the + /// maximum potential. + pub operational: f32, + /// The percentage of the weight used by the mandatory tasks of a parachain compared + /// to the maximum potential. + pub mandatory: f32, +} + +/// A shorthand for converting a tuple of `f32`s into `DispatchClassConsumption`. +/// +/// The order in which the values need to be provided is: `normal`, `operational`, `mandatory`. +impl From<(f32, f32, f32)> for DispatchClassConsumption { + fn from(value: (f32, f32, f32)) -> Self { + DispatchClassConsumption { normal: value.0, operational: value.1, mandatory: value.2 } + } +} + +impl fmt::Display for WeightConsumption { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "\n\tNormal ref_time consumption: {}", self.ref_time.normal)?; + write!(f, "\n\tOperational ref_time consumption: {}", self.ref_time.operational)?; + write!(f, "\n\tMandatory ref_time consumption: {}", self.ref_time.mandatory)?; + + write!(f, "\n\tNormal proof size: {}", self.proof_size.normal)?; + write!(f, "\n\tOperational proof size: {}", self.proof_size.operational)?; + write!(f, "\n\tMandatory proof size: {}", self.proof_size.mandatory)?; + Ok(()) + } +}