From a4c51f3b9ee1fad6ca737f507952bab8edc70a9d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Apr 2024 10:38:28 +0100 Subject: [PATCH 1/4] chore(deps): bump the patch-versions group with 9 updates (#4274) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: hanabi1224 --- Cargo.lock | 271 ++++++++++++++++++++++++++++------------------------- Cargo.toml | 8 +- 2 files changed, 146 insertions(+), 133 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 34304843524..e46a9ca6ffc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -226,12 +226,12 @@ dependencies = [ [[package]] name = "ariadne" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd002a6223f12c7a95cdd4b1cb3a0149d22d37f7a9ecdb2cb691a071fe236c29" +checksum = "44055e597c674aef7cb903b2b9f6e4cba1277ed0d2d61dae7cd52d7ffa81f8e2" dependencies = [ "unicode-width", - "yansi", + "yansi 1.0.1", ] [[package]] @@ -331,16 +331,16 @@ checksum = "136d4d23bcc79e27423727b36823d86233aad06dfea531837b038394d11e9928" dependencies = [ "concurrent-queue", "event-listener 5.3.0", - "event-listener-strategy 0.5.1", + "event-listener-strategy 0.5.2", "futures-core", "pin-project-lite", ] [[package]] name = "async-compression" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07dbbf24db18d609b1462965249abdf49129ccad073ec257da372adc83259c60" +checksum = "4e9eabd7a98fe442131a17c316bd9349c43695e49e730c3c8e12cfb5f4da2693" dependencies = [ "futures-core", "memchr", @@ -358,7 +358,7 @@ checksum = "b10202063978b3351199d68f8b22c4e47e4b1b822f8d43fd862d5ea8c006b29a" dependencies = [ "async-task", "concurrent-queue", - "fastrand 2.0.2", + "fastrand 2.1.0", "futures-lite 2.3.0", "slab", ] @@ -377,9 +377,9 @@ dependencies = [ [[package]] name = "async-fs" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc19683171f287921f2405677dd2ed2549c3b3bda697a563ebc3a121ace2aba1" +checksum = "ebcd09b382f40fcd159c2d695175b2ae620ffa5f3bd6f664131efff4e8b9e04a" dependencies = [ "async-lock 3.3.0", "blocking", @@ -556,9 +556,9 @@ dependencies = [ [[package]] name = "async-task" -version = "4.7.0" +version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" @@ -986,18 +986,16 @@ dependencies = [ [[package]] name = "blocking" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" +checksum = "495f7104e962b7356f0aeb34247aca1fe7d2e783b346582db7f2904cb5717e88" dependencies = [ "async-channel 2.2.1", "async-lock 3.3.0", "async-task", - "fastrand 2.0.2", "futures-io", "futures-lite 2.3.0", "piper", - "tracing", ] [[package]] @@ -1078,7 +1076,7 @@ dependencies = [ "cfg-if", "dashmap", "fast-float", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "icu_normalizer", "indexmap 2.2.6", "intrusive-collections", @@ -1113,7 +1111,7 @@ checksum = "c055ef3cd87ea7db014779195bc90c6adfc35de4902e3b2fe587adecbd384578" dependencies = [ "boa_macros", "boa_profiler", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "thin-vec", ] @@ -1125,7 +1123,7 @@ checksum = "0cacc9caf022d92195c827a3e5bf83f96089d4bfaff834b359ac7b6be46e9187" dependencies = [ "boa_gc", "boa_macros", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "indexmap 2.2.6", "once_cell", "phf", @@ -1504,9 +1502,9 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" dependencies = [ "crossbeam-utils", ] @@ -2095,7 +2093,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "lock_api", "once_cell", "parking_lot_core", @@ -2103,15 +2101,15 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" [[package]] name = "data-encoding-macro" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20c01c06f5f429efdf2bae21eb67c28b3df3cf85b7dd2d8ef09c0838dac5d33e" +checksum = "f1559b6cba622276d6d63706db152618eeb15b89b3e4041446b05876e352e639" dependencies = [ "data-encoding", "data-encoding-macro-internal", @@ -2119,9 +2117,9 @@ dependencies = [ [[package]] name = "data-encoding-macro-internal" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0047d07f2c89b17dd631c80450d69841a6b5d7fb17278cbc43d7e4cfcf2576f3" +checksum = "332d754c0af53bc87c108fed664d121ecf59207ec4196041f04d6ab9002ad33f" dependencies = [ "data-encoding", "syn 1.0.109", @@ -2599,9 +2597,9 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "332f51cb23d20b0de8458b86580878211da09bcd4503cb579c225b3d124cabb3" +checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" dependencies = [ "event-listener 5.3.0", "pin-project-lite", @@ -2673,9 +2671,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "fd-lock" @@ -3112,7 +3110,7 @@ checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.4.1", "windows-sys 0.52.0", ] @@ -3136,9 +3134,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.28" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" dependencies = [ "crc32fast", "miniz_oxide", @@ -3191,7 +3189,7 @@ dependencies = [ "ariadne", "assert_cmd", "async-compression", - "async-fs 2.1.1", + "async-fs 2.1.2", "async-trait", "asynchronous-codec 0.6.2", "axum 0.7.5", @@ -3567,7 +3565,7 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ - "fastrand 2.0.2", + "fastrand 2.1.0", "futures-core", "futures-io", "parking", @@ -3592,7 +3590,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35bd3cf68c183738046838e300353e4716c674dc5e56890de4826801a6622a28" dependencies = [ "futures-io", - "rustls 0.21.11", + "rustls 0.21.12", ] [[package]] @@ -4192,9 +4190,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", "allocator-api2", @@ -4269,7 +4267,7 @@ dependencies = [ "ipnet", "once_cell", "rand", - "socket2 0.5.6", + "socket2 0.5.7", "thiserror", "tinyvec", "tokio", @@ -4466,7 +4464,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", "tower-service", "tracing", @@ -4503,7 +4501,7 @@ dependencies = [ "http 0.2.12", "hyper 0.14.28", "log", - "rustls 0.21.11", + "rustls 0.21.12", "rustls-native-certs 0.6.3", "tokio", "tokio-rustls 0.24.1", @@ -4551,7 +4549,7 @@ dependencies = [ "http-body 1.0.0", "hyper 1.3.1", "pin-project-lite", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", "tower", "tower-service", @@ -4830,7 +4828,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "serde", ] @@ -4930,7 +4928,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ - "socket2 0.5.6", + "socket2 0.5.7", "widestring", "windows-sys 0.48.0", "winreg 0.50.0", @@ -5021,9 +5019,9 @@ dependencies = [ [[package]] name = "jsonrpsee" -version = "0.22.4" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4b0e68d9af1f066c06d6e2397583795b912d78537d7d907c561e82c13d69fa1" +checksum = "cfdb12a2381ea5b2e68c3469ec604a007b367778cdb14d09612c8069ebd616ad" dependencies = [ "jsonrpsee-core", "jsonrpsee-http-client", @@ -5035,9 +5033,9 @@ dependencies = [ [[package]] name = "jsonrpsee-client-transport" -version = "0.22.4" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92f254f56af1ae84815b9b1325094743dcf05b92abb5e94da2e81a35cff0cada" +checksum = "4978087a58c3ab02efc5b07c5e5e2803024536106fd5506f558db172c889b3aa" dependencies = [ "futures-util", "http 0.2.12", @@ -5056,9 +5054,9 @@ dependencies = [ [[package]] name = "jsonrpsee-core" -version = "0.22.4" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "274d68152c24aa78977243bb56f28d7946e6aa309945b37d33174a3f92d89a3a" +checksum = "b4b257e1ec385e07b0255dde0b933f948b5c8b8c28d42afda9587c3a967b896d" dependencies = [ "anyhow", "async-trait", @@ -5081,9 +5079,9 @@ dependencies = [ [[package]] name = "jsonrpsee-http-client" -version = "0.22.4" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac13bc1e44cd00448a5ff485824a128629c945f02077804cb659c07a0ba41395" +checksum = "1ccf93fc4a0bfe05d851d37d7c32b7f370fe94336b52a2f0efc5f1981895c2e5" dependencies = [ "async-trait", "hyper 0.14.28", @@ -5101,9 +5099,9 @@ dependencies = [ [[package]] name = "jsonrpsee-server" -version = "0.22.4" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b5bfbda5f8fb63f997102fd18f73e35e34c84c6dcdbdbbe72c6e48f6d2c959b" +checksum = "12d8b6a9674422a8572e0b0abb12feeb3f2aeda86528c80d0350c2bd0923ab41" dependencies = [ "futures-util", "http 0.2.12", @@ -5125,9 +5123,9 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.22.4" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dc828e537868d6b12bbb07ec20324909a22ced6efca0057c825c3e1126b2c6d" +checksum = "150d6168405890a7a3231a3c74843f58b8959471f6df76078db2619ddee1d07d" dependencies = [ "anyhow", "beef", @@ -5138,9 +5136,9 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-client" -version = "0.22.4" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32f00abe918bf34b785f87459b9205790e5361a3f7437adb50e928dc243f27eb" +checksum = "58b9db2dfd5bb1194b0ce921504df9ceae210a345bc2f6c5a61432089bbab070" dependencies = [ "http 0.2.12", "jsonrpsee-client-transport", @@ -5221,9 +5219,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" [[package]] name = "libipld" @@ -5571,7 +5569,7 @@ dependencies = [ "libp2p-swarm", "rand", "smallvec", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", "tracing", "void", @@ -5673,8 +5671,8 @@ dependencies = [ "quinn", "rand", "ring 0.16.20", - "rustls 0.21.11", - "socket2 0.5.6", + "rustls 0.21.12", + "socket2 0.5.7", "thiserror", "tokio", "tracing", @@ -5768,7 +5766,7 @@ dependencies = [ "libc", "libp2p-core", "libp2p-identity", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", "tracing", ] @@ -5785,7 +5783,7 @@ dependencies = [ "libp2p-identity", "rcgen", "ring 0.16.20", - "rustls 0.21.11", + "rustls 0.21.12", "rustls-webpki 0.101.7", "thiserror", "x509-parser", @@ -5907,9 +5905,9 @@ checksum = "f9d642685b028806386b2b6e75685faadd3eb65a85fff7df711ce18446a422da" [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -5940,7 +5938,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" dependencies = [ - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] @@ -6768,9 +6766,9 @@ checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" dependencies = [ "lock_api", "parking_lot_core", @@ -6778,18 +6776,18 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "backtrace", "cfg-if", "libc", "petgraph", - "redox_syscall", + "redox_syscall 0.5.1", "smallvec", "thread-id", - "windows-targets 0.48.5", + "windows-targets 0.52.5", ] [[package]] @@ -6963,7 +6961,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" dependencies = [ "atomic-waker", - "fastrand 2.0.2", + "fastrand 2.1.0", "futures-io", ] @@ -7143,7 +7141,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" dependencies = [ "diff", - "yansi", + "yansi 0.5.1", ] [[package]] @@ -7433,7 +7431,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.21.11", + "rustls 0.21.12", "thiserror", "tokio", "tracing", @@ -7449,7 +7447,7 @@ dependencies = [ "rand", "ring 0.16.20", "rustc-hash", - "rustls 0.21.11", + "rustls 0.21.12", "slab", "thiserror", "tinyvec", @@ -7464,7 +7462,7 @@ checksum = "055b4e778e8feb9f93c4e439f71dc2156ef13360b432b799e179a8c4cdf0b1d7" dependencies = [ "bytes", "libc", - "socket2 0.5.6", + "socket2 0.5.7", "tracing", "windows-sys 0.48.0", ] @@ -7490,15 +7488,15 @@ dependencies = [ [[package]] name = "ra_ap_limit" -version = "0.0.212" +version = "0.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3de0232917ce708e6ed2264c5cf67d30756d05c56254bc1de9b7ee2f4a5fdde1" +checksum = "8e555be1dc2c6e4e2cdb65f986e5ec3a3227c9a4eb69615f0272b692c3a248b9" [[package]] name = "ra_ap_parser" -version = "0.0.212" +version = "0.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc0600e9b61c2fd670f69d23f96124716f200c75f58b95896897308f813bf5d1" +checksum = "1d2beed86b04d7c3419f77ff8f8450a0f12f01fb049d9e4e58367414738c166e" dependencies = [ "drop_bomb", "ra-ap-rustc_lexer", @@ -7508,9 +7506,9 @@ dependencies = [ [[package]] name = "ra_ap_stdx" -version = "0.0.212" +version = "0.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e25be9b09b823e2bec65498b9b27a0b08d07616b0ff0062af0d3a939ad795b4" +checksum = "bb6fbb076b32f0a79d686d9991f3ad931d1fb0b03e6ce5a390436f0788b79fb4" dependencies = [ "always-assert", "crossbeam-channel", @@ -7523,9 +7521,9 @@ dependencies = [ [[package]] name = "ra_ap_syntax" -version = "0.0.212" +version = "0.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "020ab8cecd9210b70b98f423721e6ac72adc50d31beb6a9ed9868a705a86ff40" +checksum = "faa8ce2777da62688d90802121eb3e6c04db568433718358d61b56cd69e6348a" dependencies = [ "cov-mark", "either", @@ -7545,9 +7543,9 @@ dependencies = [ [[package]] name = "ra_ap_text_edit" -version = "0.0.212" +version = "0.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fde45d20d167acb082dfe813ff31ce2504d6f8319e861db3bbec86ce81bcab3c" +checksum = "0b5489b49675a4060d2b80cb4899b9bf572daf1a0a9a59b9e3c8f9c1ce24b0ad" dependencies = [ "itertools 0.12.1", "text-size", @@ -7678,6 +7676,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_syscall" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +dependencies = [ + "bitflags 2.5.0", +] + [[package]] name = "redox_users" version = "0.4.5" @@ -7752,7 +7759,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eae2a1ebfecc58aff952ef8ccd364329abe627762f5bf09ff42eb9d98522479" dependencies = [ - "hashbrown 0.14.3", + "hashbrown 0.14.5", "memchr", ] @@ -7785,7 +7792,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.11", + "rustls 0.21.12", "rustls-pemfile 1.0.4", "serde", "serde_json", @@ -7937,7 +7944,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a58fa8a7ccff2aec4f39cc45bf5f985cec7125ab271cf681c279fd00192b49" dependencies = [ "countme", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "memoffset 0.9.1", "rustc-hash", "text-size", @@ -8047,9 +8054,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.11" +version = "0.21.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring 0.17.8", @@ -8117,9 +8124,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" +checksum = "beb461507cee2c2ff151784c52762cf4d9ff6a61f3e80968600ed24fa837fa54" [[package]] name = "rustls-webpki" @@ -8231,9 +8238,9 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.16" +version = "0.8.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" +checksum = "7f55c82c700538496bdc329bb4918a81f87cc8888811bd123cf325a0f2f8d309" dependencies = [ "chrono", "dyn-clone", @@ -8245,14 +8252,14 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.16" +version = "0.8.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" +checksum = "83263746fe5e32097f06356968a077f96089739c927a61450efa069905eec108" dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 1.0.109", + "syn 2.0.60", ] [[package]] @@ -8319,9 +8326,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.198" +version = "1.0.199" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" +checksum = "0c9f6e76df036c77cd94996771fb40db98187f096dd0b9af39c6c6e452ba966a" dependencies = [ "serde_derive", ] @@ -8346,9 +8353,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.198" +version = "1.0.199" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" +checksum = "11bd257a6541e141e42ca6d24ae26f7714887b47e89aa739099104c7e4d3b7fc" dependencies = [ "proc-macro2", "quote", @@ -8357,13 +8364,13 @@ dependencies = [ [[package]] name = "serde_derive_internals" -version = "0.26.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" +checksum = "330f01ce65a3a5fe59a60c82f3c9a024b573b8a6e875bd233fe5f934e71d54e3" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.60", ] [[package]] @@ -8454,11 +8461,11 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.7.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee80b0e361bbf88fd2f6e242ccd19cfda072cb0faa6ae694ecee08199938569a" +checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" dependencies = [ - "base64 0.21.7", + "base64 0.22.0", "chrono", "hex", "indexmap 1.9.3", @@ -8472,9 +8479,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.7.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6561dc161a9224638a31d876ccdfefbc1df91d3f3a8342eddb35f055d48c7655" +checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" dependencies = [ "darling 0.20.8", "proc-macro2", @@ -8753,9 +8760,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", "windows-sys 0.52.0", @@ -9165,7 +9172,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", - "fastrand 2.0.2", + "fastrand 2.1.0", "rustix 0.38.34", "windows-sys 0.52.0", ] @@ -9364,7 +9371,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.6", + "socket2 0.5.7", "tokio-macros", "tracing", "windows-sys 0.48.0", @@ -9397,7 +9404,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.11", + "rustls 0.21.12", "tokio", ] @@ -9525,7 +9532,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.6", + "winnow 0.6.7", ] [[package]] @@ -9795,9 +9802,9 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" [[package]] name = "unicode-xid" @@ -10326,9 +10333,9 @@ dependencies = [ [[package]] name = "wide" -version = "0.7.16" +version = "0.7.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81a1851a719f11d1d2fea40e15c72f6c00de8c142d7ac47c1441cc7e4d0d5bc6" +checksum = "0f0e39d2c603fdc0504b12b458cf1f34e0b937ed2f4f2dc20796e3e86f34e11f" dependencies = [ "bytemuck", "safe_arch", @@ -10367,11 +10374,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -10601,9 +10608,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352" +checksum = "14b9415ee827af173ebb3f15f9083df5a122eb93572ec28741fb153356ea2578" dependencies = [ "memchr", ] @@ -10741,6 +10748,12 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + [[package]] name = "yasna" version = "0.5.2" diff --git a/Cargo.toml b/Cargo.toml index b83e8c358ec..b601d95d295 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,7 +92,7 @@ indicatif = { version = "0.17.6", features = ["tokio"] } integer-encoding = "4.0" is-terminal = "0.4" itertools = "0.12.1" -jsonrpsee = { version = "0.22.4", features = ["server", "ws-client", "http-client"] } +jsonrpsee = { version = "0.22", features = ["server", "ws-client", "http-client"] } jsonwebtoken = "9" kubert-prometheus-process = "0.1" libc = "0.2" @@ -160,7 +160,7 @@ reqwest = { version = "0.12", default-features = false, features = [ rlimit = "0.10.1" rs-car-ipfs = "0.3" rustyline = "14" -schemars = { version = "0.8.16", features = ["chrono", "uuid1"] } +schemars = { version = "0.8", features = ["chrono", "uuid1"] } scopeguard = "1.1.0" semver = "1.0" serde = { version = "1.0", default-features = false, features = ["derive"] } @@ -216,7 +216,7 @@ tracing-loki = { version = "0.2", default-features = false, features = ["compat- termios = "0.3" [dev-dependencies] -ariadne = "0.4.0" +ariadne = "0.4" assert_cmd = "2" bimap = "0.6.3" cargo_metadata = "0.18.0" @@ -236,7 +236,7 @@ proc-macro2 = { version = "1.0.78", default-features = false, features = ["span- quickcheck = "1" quickcheck_async = "0.1.1" quickcheck_macros = "1" -ra_ap_syntax = "0.0.212" +ra_ap_syntax = "0.0.213" regex-automata = "0.4" syn = { version = "2", default-features = false, features = ["full", "parsing", "visit", "printing", "extra-traits"] } tokio-test = "0.4" From f3f84f50db209a9e87016c2c8e9a7025fa1285ba Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Apr 2024 11:43:21 +0200 Subject: [PATCH 2/4] chore(deps): bump lycheeverse/lychee-action from 1.9.3 to 1.10.0 (#4275) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 02f88e7157c..a0dab8bb00c 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -40,7 +40,7 @@ jobs: timeout-minutes: ${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }} continue-on-error: true - name: Link Checker (Repo Readme) - uses: lycheeverse/lychee-action@v1.9.3 + uses: lycheeverse/lychee-action@v1.10.0 with: args: 'README.md' # Fail action on broken links @@ -58,7 +58,7 @@ jobs: CC: "sccache clang" CXX: "sccache clang++" - name: Link Checker (Library Documentation) - uses: lycheeverse/lychee-action@v1.9.3 + uses: lycheeverse/lychee-action@v1.10.0 with: args: './target/doc/forest_filecoin/**/index.html' # Fail action on broken links From 36d094f51ce330b17ed4b791c96e8acf685efea4 Mon Sep 17 00:00:00 2001 From: Aatif Syed <38045910+aatifsyed@users.noreply.github.com> Date: Tue, 30 Apr 2024 14:30:09 +0100 Subject: [PATCH 3/4] refactor: trait RpcMethod { const PERMISSION: ... } (#4277) --- src/rpc/auth_layer.rs | 206 ++++++++------------------------------ src/rpc/methods/auth.rs | 4 +- src/rpc/methods/beacon.rs | 3 +- src/rpc/methods/chain.rs | 20 +++- src/rpc/methods/common.rs | 6 +- src/rpc/methods/eth.rs | 10 +- src/rpc/methods/gas.rs | 6 +- src/rpc/methods/mpool.rs | 10 +- src/rpc/methods/net.rs | 11 +- src/rpc/methods/node.rs | 3 +- src/rpc/methods/state.rs | 43 +++++++- src/rpc/methods/sync.rs | 6 +- src/rpc/methods/wallet.rs | 14 ++- src/rpc/mod.rs | 12 ++- src/rpc/reflect/mod.rs | 11 ++ 15 files changed, 183 insertions(+), 182 deletions(-) diff --git a/src/rpc/auth_layer.rs b/src/rpc/auth_layer.rs index 81fdff5f5b5..4b49bbedece 100644 --- a/src/rpc/auth_layer.rs +++ b/src/rpc/auth_layer.rs @@ -4,8 +4,8 @@ use crate::auth::{verify_token, JWT_IDENTIFIER}; use crate::key_management::KeyStore; use crate::rpc::{ - auth, beacon, chain, common, eth, gas, mpool, net, node, state, sync, wallet, RpcMethod as _, - CANCEL_METHOD_NAME, + auth, beacon, chain, common, eth, gas, mpool, net, node, state, sync, wallet, Permission, + RpcMethod as _, CANCEL_METHOD_NAME, }; use ahash::{HashMap, HashMapExt as _}; use futures::future::BoxFuture; @@ -21,170 +21,42 @@ use tokio::sync::RwLock; use tower::Layer; use tracing::debug; -/// Access levels to be checked against JWT claims -enum Access { - Admin, - Sign, - Write, - Read, -} - -/// Access mapping between method names and access levels -/// Checked against JWT claims on every request -static ACCESS_MAP: Lazy> = Lazy::new(|| { +static METHOD_NAME2REQUIRED_PERMISSION: Lazy> = Lazy::new(|| { let mut access = HashMap::new(); - // Auth API - access.insert(auth::AuthNew::NAME, Access::Admin); - access.insert(auth::AuthVerify::NAME, Access::Read); - - // Beacon API - access.insert(beacon::BeaconGetEntry::NAME, Access::Read); - - // Chain API - access.insert(chain::ChainGetMessage::NAME, Access::Read); - access.insert(chain::ChainExport::NAME, Access::Read); - access.insert(chain::ChainReadObj::NAME, Access::Read); - access.insert(chain::ChainGetPath::NAME, Access::Read); - access.insert(chain::ChainHasObj::NAME, Access::Read); - access.insert(chain::ChainGetBlockMessages::NAME, Access::Read); - access.insert(chain::ChainGetTipSetByHeight::NAME, Access::Read); - access.insert(chain::ChainGetTipSetAfterHeight::NAME, Access::Read); - access.insert(chain::ChainGetGenesis::NAME, Access::Read); - access.insert(chain::ChainHead::NAME, Access::Read); - access.insert(chain::ChainGetBlock::NAME, Access::Read); - access.insert(chain::ChainGetTipSet::NAME, Access::Read); - access.insert(chain::ChainSetHead::NAME, Access::Admin); - access.insert(chain::ChainGetMinBaseFee::NAME, Access::Admin); - access.insert(chain::ChainTipSetWeight::NAME, Access::Read); - access.insert(chain::ChainGetMessagesInTipset::NAME, Access::Read); - access.insert(chain::ChainGetParentMessages::NAME, Access::Read); - access.insert(chain::CHAIN_NOTIFY, Access::Read); - access.insert(chain::ChainGetParentReceipts::NAME, Access::Read); - - // Message Pool API - access.insert(mpool::MpoolGetNonce::NAME, Access::Read); - access.insert(mpool::MpoolPending::NAME, Access::Read); - access.insert(mpool::MpoolSelect::NAME, Access::Read); - // Lotus limits `MPOOL_PUSH`` to `Access::Write`. However, since messages - // can always be pushed over the p2p protocol, limiting the RPC doesn't - // improve security. - access.insert(mpool::MpoolPush::NAME, Access::Read); - access.insert(mpool::MpoolPushMessage::NAME, Access::Sign); - - // Sync API - access.insert(sync::SyncCheckBad::NAME, Access::Read); - access.insert(sync::SyncMarkBad::NAME, Access::Admin); - access.insert(sync::SyncState::NAME, Access::Read); - access.insert(sync::SyncSubmitBlock::NAME, Access::Write); - - // Wallet API - access.insert(wallet::WalletBalance::NAME, Access::Read); - access.insert(wallet::WalletDefaultAddress::NAME, Access::Read); - access.insert(wallet::WalletExport::NAME, Access::Admin); - access.insert(wallet::WalletHas::NAME, Access::Write); - access.insert(wallet::WalletImport::NAME, Access::Admin); - access.insert(wallet::WalletList::NAME, Access::Write); - access.insert(wallet::WalletNew::NAME, Access::Write); - access.insert(wallet::WalletSetDefault::NAME, Access::Write); - access.insert(wallet::WalletSign::NAME, Access::Sign); - access.insert(wallet::WalletValidateAddress::NAME, Access::Read); - access.insert(wallet::WalletVerify::NAME, Access::Read); - access.insert(wallet::WalletDelete::NAME, Access::Write); - - // State API - access.insert(state::MinerGetBaseInfo::NAME, Access::Read); - access.insert(state::StateCall::NAME, Access::Read); - access.insert(state::StateNetworkName::NAME, Access::Read); - access.insert(state::StateReplay::NAME, Access::Read); - access.insert(state::StateGetActor::NAME, Access::Read); - access.insert(state::StateMarketBalance::NAME, Access::Read); - access.insert(state::StateMarketDeals::NAME, Access::Read); - access.insert(state::StateMinerInfo::NAME, Access::Read); - access.insert(state::StateMinerActiveSectors::NAME, Access::Read); - access.insert(state::StateMinerFaults::NAME, Access::Read); - access.insert(state::StateMinerRecoveries::NAME, Access::Read); - access.insert(state::StateMinerPower::NAME, Access::Read); - access.insert(state::StateMinerDeadlines::NAME, Access::Read); - access.insert(state::StateMinerProvingDeadline::NAME, Access::Read); - access.insert(state::StateMinerAvailableBalance::NAME, Access::Read); - access.insert(state::StateGetReceipt::NAME, Access::Read); - access.insert(state::StateWaitMsg::NAME, Access::Read); - access.insert(state::StateSearchMsg::NAME, Access::Read); - access.insert(state::StateSearchMsgLimited::NAME, Access::Read); - access.insert(state::StateNetworkVersion::NAME, Access::Read); - access.insert(state::StateAccountKey::NAME, Access::Read); - access.insert(state::StateLookupID::NAME, Access::Read); - access.insert(state::StateFetchRoot::NAME, Access::Read); - access.insert(state::StateGetRandomnessFromTickets::NAME, Access::Read); - access.insert(state::StateGetRandomnessFromBeacon::NAME, Access::Read); - access.insert(state::StateReadState::NAME, Access::Read); - access.insert(state::StateCirculatingSupply::NAME, Access::Read); - access.insert(state::StateSectorGetInfo::NAME, Access::Read); - access.insert(state::StateListMessages::NAME, Access::Read); - access.insert(state::StateListMiners::NAME, Access::Read); - access.insert(state::StateMinerSectorCount::NAME, Access::Read); - access.insert(state::StateMinerSectors::NAME, Access::Read); - access.insert(state::StateMinerPartitions::NAME, Access::Read); - access.insert(state::StateVerifiedClientStatus::NAME, Access::Read); - access.insert(state::StateMarketStorageDeal::NAME, Access::Read); - access.insert(state::StateVMCirculatingSupplyInternal::NAME, Access::Read); - access.insert(state::MsigGetAvailableBalance::NAME, Access::Read); - access.insert(state::MsigGetPending::NAME, Access::Read); - access.insert(state::StateDealProviderCollateralBounds::NAME, Access::Read); - access.insert(state::StateGetBeaconEntry::NAME, Access::Read); - access.insert(state::StateSectorPreCommitInfo::NAME, Access::Read); - - // Gas API - access.insert(gas::GasEstimateGasLimit::NAME, Access::Read); - access.insert(gas::GasEstimateGasPremium::NAME, Access::Read); - access.insert(gas::GasEstimateFeeCap::NAME, Access::Read); - access.insert(gas::GasEstimateMessageGas::NAME, Access::Read); - - // Common API - access.insert(common::Version::NAME, Access::Read); - access.insert(common::Session::NAME, Access::Read); - access.insert(common::Shutdown::NAME, Access::Admin); - access.insert(common::StartTime::NAME, Access::Read); - - // Net API - access.insert(net::NetAddrsListen::NAME, Access::Read); - access.insert(net::NetPeers::NAME, Access::Read); - access.insert(net::NetListening::NAME, Access::Read); - access.insert(net::NetInfo::NAME, Access::Read); - access.insert(net::NetConnect::NAME, Access::Write); - access.insert(net::NetDisconnect::NAME, Access::Write); - access.insert(net::NetAgentVersion::NAME, Access::Read); - access.insert(net::NetAutoNatStatus::NAME, Access::Read); - access.insert(net::NetVersion::NAME, Access::Read); - - // Node API - access.insert(node::NodeStatus::NAME, Access::Read); - - // Eth API - access.insert(eth::EthAccounts::NAME, Access::Read); - access.insert(eth::EthBlockNumber::NAME, Access::Read); - access.insert(eth::EthChainId::NAME, Access::Read); - access.insert(eth::EthGasPrice::NAME, Access::Read); - access.insert(eth::EthGetBalance::NAME, Access::Read); - access.insert(eth::EthSyncing::NAME, Access::Read); - access.insert(eth::EthGetBlockByNumber::NAME, Access::Read); - access.insert(eth::Web3ClientVersion::NAME, Access::Read); - - // Pubsub API - access.insert(CANCEL_METHOD_NAME, Access::Read); + macro_rules! insert { + ($ty:ty) => { + access.insert(<$ty>::NAME, <$ty>::PERMISSION); + }; + } + + auth::for_each_method!(insert); + beacon::for_each_method!(insert); + chain::for_each_method!(insert); + common::for_each_method!(insert); + gas::for_each_method!(insert); + mpool::for_each_method!(insert); + net::for_each_method!(insert); + state::for_each_method!(insert); + node::for_each_method!(insert); + sync::for_each_method!(insert); + wallet::for_each_method!(insert); + eth::for_each_method!(insert); + + access.insert(chain::CHAIN_NOTIFY, Permission::Read); + access.insert(CANCEL_METHOD_NAME, Permission::Read); access }); -/// Checks an access enumeration against provided JWT claims -fn check_access(access: &Access, claims: &[String]) -> bool { - match access { - Access::Admin => claims.contains(&"admin".to_owned()), - Access::Sign => claims.contains(&"sign".to_owned()), - Access::Write => claims.contains(&"write".to_owned()), - Access::Read => claims.contains(&"read".to_owned()), - } +fn is_allowed(required_by_method: Permission, claimed_by_user: &[String]) -> bool { + let needle = match required_by_method { + Permission::Admin => "admin", + Permission::Sign => "sign", + Permission::Write => "write", + Permission::Read => "read", + }; + claimed_by_user.iter().any(|haystack| haystack == needle) } #[derive(Clone)] @@ -194,10 +66,10 @@ pub struct AuthLayer { } impl Layer for AuthLayer { - type Service = AuthMiddleware; + type Service = Auth; fn layer(&self, service: S) -> Self::Service { - AuthMiddleware { + Auth { headers: self.headers.clone(), keystore: self.keystore.clone(), service, @@ -206,13 +78,13 @@ impl Layer for AuthLayer { } #[derive(Clone)] -pub struct AuthMiddleware { +pub struct Auth { headers: HeaderMap, keystore: Arc>, service: S, } -impl<'a, S> RpcServiceT<'a> for AuthMiddleware +impl<'a, S> RpcServiceT<'a> for Auth where S: RpcServiceT<'a> + Send + Sync + Clone + 'static, { @@ -267,9 +139,9 @@ async fn check_permissions( }; debug!("Decoded JWT Claims: {}", claims.join(",")); - match ACCESS_MAP.get(&method) { - Some(access) => { - if check_access(access, &claims) { + match METHOD_NAME2REQUIRED_PERMISSION.get(&method) { + Some(required_by_method) => { + if is_allowed(*required_by_method, &claims) { Ok(()) } else { Err(ErrorCode::InvalidRequest) diff --git a/src/rpc/methods/auth.rs b/src/rpc/methods/auth.rs index 610e4910cc6..9d4fb8da699 100644 --- a/src/rpc/methods/auth.rs +++ b/src/rpc/methods/auth.rs @@ -3,7 +3,7 @@ use crate::auth::*; use crate::lotus_json::lotus_json_with_self; -use crate::rpc::{ApiVersion, Ctx, RpcMethod, ServerError}; +use crate::rpc::{ApiVersion, Ctx, Permission, RpcMethod, ServerError}; use anyhow::Result; use chrono::Duration; use fvm_ipld_blockstore::Blockstore; @@ -25,6 +25,7 @@ impl RpcMethod<1> for AuthNew { const NAME: &'static str = "Filecoin.AuthNew"; const PARAM_NAMES: [&'static str; 1] = ["params"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Admin; type Params = (AuthNewParams,); type Ok = Vec; async fn handle( @@ -43,6 +44,7 @@ impl RpcMethod<1> for AuthVerify { const NAME: &'static str = "Filecoin.AuthVerify"; const PARAM_NAMES: [&'static str; 1] = ["header_raw"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (String,); type Ok = Vec; async fn handle( diff --git a/src/rpc/methods/beacon.rs b/src/rpc/methods/beacon.rs index ba099c16604..0e826b0e470 100644 --- a/src/rpc/methods/beacon.rs +++ b/src/rpc/methods/beacon.rs @@ -1,7 +1,7 @@ // Copyright 2019-2024 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT -use crate::rpc::{ApiVersion, Ctx, RpcMethod, ServerError}; +use crate::rpc::{ApiVersion, Ctx, Permission, RpcMethod, ServerError}; use crate::{beacon::BeaconEntry, shim::clock::ChainEpoch}; use anyhow::Result; use fvm_ipld_blockstore::Blockstore; @@ -21,6 +21,7 @@ impl RpcMethod<1> for BeaconGetEntry { const NAME: &'static str = "Filecoin.BeaconGetEntry"; const PARAM_NAMES: [&'static str; 1] = ["first"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (ChainEpoch,); type Ok = BeaconEntry; diff --git a/src/rpc/methods/chain.rs b/src/rpc/methods/chain.rs index ae8ef1ee887..25fbebeb774 100644 --- a/src/rpc/methods/chain.rs +++ b/src/rpc/methods/chain.rs @@ -12,7 +12,7 @@ use crate::lotus_json::{assert_all_snapshots, assert_unchanged_via_json}; use crate::lotus_json::{lotus_json_with_self, HasLotusJson, LotusJson}; use crate::message::{ChainMessage, SignedMessage}; use crate::rpc::types::ApiTipsetKey; -use crate::rpc::{ApiVersion, Ctx, RpcMethod, ServerError}; +use crate::rpc::{ApiVersion, Ctx, Permission, RpcMethod, ServerError}; use crate::shim::clock::ChainEpoch; use crate::shim::error::ExitCode; use crate::shim::message::Message; @@ -66,6 +66,7 @@ impl RpcMethod<1> for ChainGetMessage { const NAME: &'static str = "Filecoin.ChainGetMessage"; const PARAM_NAMES: [&'static str; 1] = ["msg_cid"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Cid,); type Ok = Message; @@ -91,6 +92,7 @@ impl RpcMethod<1> for ChainGetParentMessages { const NAME: &'static str = "Filecoin.ChainGetParentMessages"; const PARAM_NAMES: [&'static str; 1] = ["block_cid"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Cid,); type Ok = Vec; @@ -117,6 +119,7 @@ impl RpcMethod<1> for ChainGetParentReceipts { const NAME: &'static str = "Filecoin.ChainGetParentReceipts"; const PARAM_NAMES: [&'static str; 1] = ["block_cid"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Cid,); type Ok = Vec; @@ -193,6 +196,7 @@ impl RpcMethod<1> for ChainGetMessagesInTipset { const NAME: &'static str = "Filecoin.ChainGetMessagesInTipset"; const PARAM_NAMES: [&'static str; 1] = ["tsk"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (ApiTipsetKey,); type Ok = Vec; @@ -211,6 +215,7 @@ impl RpcMethod<1> for ChainExport { const NAME: &'static str = "Filecoin.ChainExport"; const PARAM_NAMES: [&'static str; 1] = ["params"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (ChainExportParams,); type Ok = Option; @@ -283,6 +288,7 @@ impl RpcMethod<1> for ChainReadObj { const NAME: &'static str = "Filecoin.ChainReadObj"; const PARAM_NAMES: [&'static str; 1] = ["cid"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Cid,); type Ok = Vec; @@ -305,6 +311,7 @@ impl RpcMethod<1> for ChainHasObj { const NAME: &'static str = "Filecoin.ChainHasObj"; const PARAM_NAMES: [&'static str; 1] = ["cid"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Cid,); type Ok = bool; @@ -322,6 +329,7 @@ impl RpcMethod<1> for ChainGetBlockMessages { const NAME: &'static str = "Filecoin.ChainGetBlockMessages"; const PARAM_NAMES: [&'static str; 1] = ["cid"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Cid,); type Ok = BlockMessages; @@ -359,6 +367,7 @@ impl RpcMethod<2> for ChainGetPath { const NAME: &'static str = "Filecoin.ChainGetPath"; const PARAM_NAMES: [&'static str; 2] = ["from", "to"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (TipsetKey, TipsetKey); type Ok = Vec; @@ -435,6 +444,7 @@ impl RpcMethod<2> for ChainGetTipSetByHeight { const NAME: &'static str = "Filecoin.ChainGetTipSetByHeight"; const PARAM_NAMES: [&'static str; 2] = ["height", "tsk"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (ChainEpoch, ApiTipsetKey); type Ok = Tipset; @@ -461,6 +471,7 @@ impl RpcMethod<2> for ChainGetTipSetAfterHeight { const NAME: &'static str = "Filecoin.ChainGetTipSetAfterHeight"; const PARAM_NAMES: [&'static str; 2] = ["height", "tsk"]; const API_VERSION: ApiVersion = ApiVersion::V1; + const PERMISSION: Permission = Permission::Read; type Params = (ChainEpoch, ApiTipsetKey); type Ok = Tipset; @@ -487,6 +498,7 @@ impl RpcMethod<0> for ChainGetGenesis { const NAME: &'static str = "Filecoin.ChainGetGenesis"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = Option; @@ -502,6 +514,7 @@ impl RpcMethod<0> for ChainHead { const NAME: &'static str = "Filecoin.ChainHead"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = Tipset; @@ -517,6 +530,7 @@ impl RpcMethod<1> for ChainGetBlock { const NAME: &'static str = "Filecoin.ChainGetBlock"; const PARAM_NAMES: [&'static str; 1] = ["cid"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Cid,); type Ok = CachingBlockHeader; @@ -539,6 +553,7 @@ impl RpcMethod<1> for ChainGetTipSet { const NAME: &'static str = "Filecoin.ChainGetTipSet"; const PARAM_NAMES: [&'static str; 1] = ["tsk"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (ApiTipsetKey,); type Ok = Tipset; @@ -560,6 +575,7 @@ impl RpcMethod<1> for ChainSetHead { const NAME: &'static str = "Filecoin.ChainSetHead"; const PARAM_NAMES: [&'static str; 1] = ["tsk"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Admin; type Params = (ApiTipsetKey,); type Ok = (); @@ -601,6 +617,7 @@ impl RpcMethod<1> for ChainGetMinBaseFee { const NAME: &'static str = "Filecoin.ChainGetMinBaseFee"; const PARAM_NAMES: [&'static str; 1] = ["lookback"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Admin; type Params = (u32,); type Ok = String; @@ -633,6 +650,7 @@ impl RpcMethod<1> for ChainTipSetWeight { const NAME: &'static str = "Filecoin.ChainTipSetWeight"; const PARAM_NAMES: [&'static str; 1] = ["tsk"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (ApiTipsetKey,); type Ok = BigInt; diff --git a/src/rpc/methods/common.rs b/src/rpc/methods/common.rs index c88ad1cb81b..e154a349cf8 100644 --- a/src/rpc/methods/common.rs +++ b/src/rpc/methods/common.rs @@ -3,7 +3,7 @@ use crate::lotus_json::lotus_json_with_self; use crate::rpc::error::ServerError; -use crate::rpc::{ApiVersion, Ctx, RpcMethod}; +use crate::rpc::{ApiVersion, Ctx, Permission, RpcMethod}; use fvm_ipld_blockstore::Blockstore; use once_cell::sync::Lazy; use schemars::JsonSchema; @@ -29,6 +29,7 @@ impl RpcMethod<0> for Session { const NAME: &'static str = "Filecoin.Session"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = Uuid; @@ -43,6 +44,7 @@ impl RpcMethod<0> for Version { const NAME: &'static str = "Filecoin.Version"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = PublicVersion; @@ -62,6 +64,7 @@ impl RpcMethod<0> for Shutdown { const NAME: &'static str = "Filecoin.Shutdown"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Admin; type Params = (); type Ok = (); @@ -77,6 +80,7 @@ impl RpcMethod<0> for StartTime { const NAME: &'static str = "Filecoin.StartTime"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = chrono::DateTime; diff --git a/src/rpc/methods/eth.rs b/src/rpc/methods/eth.rs index a5ce60ef624..28ee8e3ea74 100644 --- a/src/rpc/methods/eth.rs +++ b/src/rpc/methods/eth.rs @@ -10,7 +10,7 @@ use crate::lotus_json::LotusJson; use crate::lotus_json::{lotus_json_with_self, HasLotusJson}; use crate::message::{ChainMessage, Message as _, SignedMessage}; use crate::rpc::error::ServerError; -use crate::rpc::{ApiVersion, Ctx, RpcMethod}; +use crate::rpc::{ApiVersion, Ctx, Permission, RpcMethod}; use crate::shim::address::{Address as FilecoinAddress, Protocol}; use crate::shim::crypto::{Signature, SignatureType}; use crate::shim::econ::{TokenAmount, BLOCK_GAS_LIMIT}; @@ -651,6 +651,7 @@ impl RpcMethod<0> for Web3ClientVersion { const NAME: &'static str = "Filecoin.Web3ClientVersion"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V1; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = String; @@ -668,6 +669,7 @@ impl RpcMethod<0> for EthAccounts { const NAME: &'static str = "Filecoin.EthAccounts"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V1; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = Vec; @@ -686,6 +688,7 @@ impl RpcMethod<0> for EthBlockNumber { const NAME: &'static str = "Filecoin.EthBlockNumber"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V1; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = String; @@ -719,6 +722,7 @@ impl RpcMethod<0> for EthChainId { const NAME: &'static str = "Filecoin.EthChainId"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V1; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = String; @@ -739,6 +743,7 @@ impl RpcMethod<0> for EthGasPrice { const NAME: &'static str = "Filecoin.EthGasPrice"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V1; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = GasPriceResult; @@ -764,6 +769,7 @@ impl RpcMethod<2> for EthGetBalance { const NAME: &'static str = "Filecoin.EthGetBalance"; const PARAM_NAMES: [&'static str; 2] = ["address", "block_param"]; const API_VERSION: ApiVersion = ApiVersion::V1; + const PERMISSION: Permission = Permission::Read; type Params = (Address, BlockNumberOrHash); type Ok = BigInt; @@ -1263,6 +1269,7 @@ impl RpcMethod<2> for EthGetBlockByNumber { const NAME: &'static str = "Filecoin.EthGetBlockByNumber"; const PARAM_NAMES: [&'static str; 2] = ["block_param", "full_tx_info"]; const API_VERSION: ApiVersion = ApiVersion::V1; + const PERMISSION: Permission = Permission::Read; type Params = (BlockNumberOrHash, bool); type Ok = Block; @@ -1282,6 +1289,7 @@ impl RpcMethod<0> for EthSyncing { const NAME: &'static str = "Filecoin.EthSyncing"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V1; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = EthSyncingResult; diff --git a/src/rpc/methods/gas.rs b/src/rpc/methods/gas.rs index 1bea7e24b05..4418074b348 100644 --- a/src/rpc/methods/gas.rs +++ b/src/rpc/methods/gas.rs @@ -4,7 +4,7 @@ use crate::chain::{BASE_FEE_MAX_CHANGE_DENOM, BLOCK_GAS_TARGET}; use crate::message::{ChainMessage, Message as MessageTrait, SignedMessage}; -use crate::rpc::{error::ServerError, types::*, ApiVersion, Ctx, RpcMethod}; +use crate::rpc::{error::ServerError, types::*, ApiVersion, Ctx, Permission, RpcMethod}; use crate::shim::{ address::{Address, Protocol}, crypto::{Signature, SignatureType, SECP_SIG_LEN}, @@ -35,6 +35,7 @@ impl RpcMethod<3> for GasEstimateFeeCap { const NAME: &'static str = "Filecoin.GasEstimateFeeCap"; const PARAM_NAMES: [&'static str; 3] = ["message", "max_queue_blocks", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Message, i64, ApiTipsetKey); type Ok = String; @@ -73,6 +74,7 @@ impl RpcMethod<4> for GasEstimateGasPremium { const NAME: &'static str = "Filecoin.GasEstimateGasPremium"; const PARAM_NAMES: [&'static str; 4] = ["nblocksincl", "sender", "gas_limit", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (u64, Address, i64, ApiTipsetKey); type Ok = String; @@ -174,6 +176,7 @@ impl RpcMethod<2> for GasEstimateGasLimit { const NAME: &'static str = "Filecoin.GasEstimateGasLimit"; const PARAM_NAMES: [&'static str; 2] = ["msg", "tsk"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Message, ApiTipsetKey); type Ok = i64; @@ -192,6 +195,7 @@ impl RpcMethod<3> for GasEstimateMessageGas { const NAME: &'static str = "Filecoin.GasEstimateMessageGas"; const PARAM_NAMES: [&'static str; 3] = ["msg", "spec", "tsk"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Message, Option, ApiTipsetKey); type Ok = Message; diff --git a/src/rpc/methods/mpool.rs b/src/rpc/methods/mpool.rs index 37a49cabef9..ebee53f4087 100644 --- a/src/rpc/methods/mpool.rs +++ b/src/rpc/methods/mpool.rs @@ -5,7 +5,7 @@ use super::gas::estimate_message_gas; use crate::message::SignedMessage; use crate::rpc::error::ServerError; use crate::rpc::types::{ApiTipsetKey, MessageSendSpec}; -use crate::rpc::{ApiVersion, Ctx, RpcMethod}; +use crate::rpc::{ApiVersion, Ctx, Permission, RpcMethod}; use crate::shim::{ address::{Address, Protocol}, message::Message, @@ -31,6 +31,7 @@ impl RpcMethod<1> for MpoolGetNonce { const NAME: &'static str = "Filecoin.MpoolGetNonce"; const PARAM_NAMES: [&'static str; 1] = ["address"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address,); type Ok = u64; @@ -49,6 +50,7 @@ impl RpcMethod<1> for MpoolPending { const NAME: &'static str = "Filecoin.MpoolPending"; const PARAM_NAMES: [&'static str; 1] = ["tsk"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (ApiTipsetKey,); type Ok = Vec; @@ -124,6 +126,7 @@ impl RpcMethod<2> for MpoolSelect { const NAME: &'static str = "Filecoin.MpoolSelect"; const PARAM_NAMES: [&'static str; 2] = ["tsk", "tq"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (ApiTipsetKey, f64); type Ok = Vec; @@ -147,6 +150,10 @@ impl RpcMethod<1> for MpoolPush { const NAME: &'static str = "Filecoin.MpoolPush"; const PARAM_NAMES: [&'static str; 1] = ["msg"]; const API_VERSION: ApiVersion = ApiVersion::V0; + /// Lotus limits this method to [`Permission::Write`]. + /// However, since messages can always be pushed over the p2p protocol, + /// limiting the RPC doesn't improve security. + const PERMISSION: Permission = Permission::Read; type Params = (SignedMessage,); type Ok = Cid; @@ -166,6 +173,7 @@ impl RpcMethod<2> for MpoolPushMessage { const NAME: &'static str = "Filecoin.MpoolPushMessage"; const PARAM_NAMES: [&'static str; 2] = ["usmg", "spec"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Sign; type Params = (Message, Option); type Ok = SignedMessage; diff --git a/src/rpc/methods/net.rs b/src/rpc/methods/net.rs index 35c0840049d..2047846a85b 100644 --- a/src/rpc/methods/net.rs +++ b/src/rpc/methods/net.rs @@ -6,7 +6,7 @@ use std::str::FromStr; use crate::libp2p::{NetRPCMethods, NetworkMessage, PeerId}; use crate::lotus_json::lotus_json_with_self; -use crate::rpc::{ApiVersion, ServerError}; +use crate::rpc::{ApiVersion, Permission, ServerError}; use crate::rpc::{Ctx, RpcMethod}; use anyhow::Result; use cid::multibase; @@ -36,6 +36,7 @@ impl RpcMethod<0> for NetAddrsListen { const NAME: &'static str = "Filecoin.NetAddrsListen"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = AddrInfo; @@ -61,6 +62,7 @@ impl RpcMethod<0> for NetPeers { const NAME: &'static str = "Filecoin.NetPeers"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = Vec; @@ -91,6 +93,7 @@ impl RpcMethod<0> for NetListening { const NAME: &'static str = "Filecoin.NetListening"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V1; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = bool; @@ -105,6 +108,7 @@ impl RpcMethod<0> for NetInfo { const NAME: &'static str = "Forest.NetInfo"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = NetInfoResult; @@ -125,6 +129,7 @@ impl RpcMethod<1> for NetConnect { const NAME: &'static str = "Filecoin.NetConnect"; const PARAM_NAMES: [&'static str; 1] = ["info"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Write; type Params = (AddrInfo,); type Ok = (); @@ -157,6 +162,7 @@ impl RpcMethod<1> for NetDisconnect { const NAME: &'static str = "Filecoin.NetDisconnect"; const PARAM_NAMES: [&'static str; 1] = ["id"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Write; type Params = (String,); type Ok = (); @@ -184,6 +190,7 @@ impl RpcMethod<1> for NetAgentVersion { const NAME: &'static str = "Filecoin.NetAgentVersion"; const PARAM_NAMES: [&'static str; 1] = ["id"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (String,); type Ok = String; @@ -213,6 +220,7 @@ impl RpcMethod<0> for NetAutoNatStatus { const NAME: &'static str = "Filecoin.NetAutoNatStatus"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = NatStatusResult; @@ -233,6 +241,7 @@ impl RpcMethod<0> for NetVersion { const NAME: &'static str = "Filecoin.NetVersion"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V1; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = String; diff --git a/src/rpc/methods/node.rs b/src/rpc/methods/node.rs index d7e2db92aa7..42a89b124d4 100644 --- a/src/rpc/methods/node.rs +++ b/src/rpc/methods/node.rs @@ -5,7 +5,7 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH}; use crate::{ lotus_json::lotus_json_with_self, - rpc::{ApiVersion, Ctx, RpcMethod, ServerError}, + rpc::{ApiVersion, Ctx, Permission, RpcMethod, ServerError}, }; use fvm_ipld_blockstore::Blockstore; use schemars::JsonSchema; @@ -23,6 +23,7 @@ impl RpcMethod<0> for NodeStatus { const NAME: &'static str = "Filecoin.NodeStatus"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = NodeStatusResult; diff --git a/src/rpc/methods/state.rs b/src/rpc/methods/state.rs index 03a52e151a5..3b986941916 100644 --- a/src/rpc/methods/state.rs +++ b/src/rpc/methods/state.rs @@ -21,7 +21,7 @@ use crate::state_manager::MarketBalance; use crate::utils::db::car_stream::{CarBlock, CarWriter}; use crate::{ beacon::BeaconEntry, - rpc::{error::ServerError, types::*, ApiVersion, Ctx, RpcMethod}, + rpc::{types::*, ApiVersion, Ctx, Permission, RpcMethod, ServerError}, }; use ahash::{HashMap, HashMapExt}; use anyhow::Context as _; @@ -102,6 +102,7 @@ impl RpcMethod<3> for MinerGetBaseInfo { const NAME: &'static str = "Filecoin.MinerGetBaseInfo"; const PARAM_NAMES: [&'static str; 3] = ["address", "epoch", "tsk"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, i64, ApiTipsetKey); type Ok = Option; @@ -127,6 +128,7 @@ impl RpcMethod<2> for StateCall { const NAME: &'static str = "Filecoin.StateCall"; const PARAM_NAMES: [&'static str; 2] = ["message", "tsk"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Message, ApiTipsetKey); type Ok = ApiInvocResult; @@ -151,6 +153,7 @@ impl RpcMethod<2> for StateReplay { const NAME: &'static str = "Filecoin.StateReplay"; const PARAM_NAMES: [&'static str; 2] = ["cid", "tsk"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Cid, ApiTipsetKey); type Ok = InvocResult; @@ -181,6 +184,7 @@ impl RpcMethod<0> for StateNetworkName { const NAME: &'static str = "Filecoin.StateNetworkName"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = String; @@ -198,6 +202,7 @@ impl RpcMethod<1> for StateNetworkVersion { const NAME: &'static str = "Filecoin.StateNetworkVersion"; const PARAM_NAMES: [&'static str; 1] = ["tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (ApiTipsetKey,); type Ok = NetworkVersion; @@ -219,6 +224,7 @@ impl RpcMethod<2> for StateAccountKey { const NAME: &'static str = "Filecoin.StateAccountKey"; const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, ApiTipsetKey); type Ok = Address; @@ -243,6 +249,7 @@ impl RpcMethod<2> for StateLookupID { const NAME: &'static str = "Filecoin.StateLookupID"; const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, ApiTipsetKey); type Ok = Address; @@ -264,6 +271,7 @@ impl RpcMethod<2> for StateGetActor { const NAME: &'static str = "Filecoin.StateGetActor"; const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, ApiTipsetKey); type Ok = Option; @@ -286,6 +294,7 @@ impl RpcMethod<2> for StateMarketBalance { const NAME: &'static str = "Filecoin.StateMarketBalance"; const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, ApiTipsetKey); type Ok = MarketBalance; @@ -307,6 +316,7 @@ impl RpcMethod<1> for StateMarketDeals { const NAME: &'static str = "Filecoin.StateMarketDeals"; const PARAM_NAMES: [&'static str; 1] = ["tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (ApiTipsetKey,); type Ok = HashMap; @@ -353,6 +363,7 @@ impl RpcMethod<2> for StateMinerInfo { const NAME: &'static str = "Filecoin.StateMinerInfo"; const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, ApiTipsetKey); type Ok = MinerInfo; @@ -372,6 +383,7 @@ impl RpcMethod<2> for StateMinerActiveSectors { const NAME: &'static str = "Filecoin.StateMinerActiveSectors"; const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, ApiTipsetKey); type Ok = Vec; @@ -410,6 +422,7 @@ impl RpcMethod<3> for StateMinerPartitions { const NAME: &'static str = "Filecoin.StateMinerPartitions"; const PARAM_NAMES: [&'static str; 3] = ["address", "deadline_index", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, u64, ApiTipsetKey); type Ok = Vec; @@ -446,6 +459,7 @@ impl RpcMethod<3> for StateMinerSectors { const NAME: &'static str = "Filecoin.StateMinerSectors"; const PARAM_NAMES: [&'static str; 3] = ["address", "sectors", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, Option, ApiTipsetKey); type Ok = Vec; @@ -475,6 +489,7 @@ impl RpcMethod<2> for StateMinerSectorCount { const NAME: &'static str = "Filecoin.StateMinerSectorCount"; const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, ApiTipsetKey); type Ok = MinerSectors; @@ -512,6 +527,7 @@ impl RpcMethod<2> for StateMinerPower { const NAME: &'static str = "Filecoin.StateMinerPower"; const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, ApiTipsetKey); type Ok = MinerPower; @@ -533,6 +549,7 @@ impl RpcMethod<2> for StateMinerDeadlines { const NAME: &'static str = "Filecoin.StateMinerDeadlines"; const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, ApiTipsetKey); type Ok = Vec; @@ -566,6 +583,7 @@ impl RpcMethod<2> for StateMinerProvingDeadline { const NAME: &'static str = "Filecoin.StateMinerProvingDeadline"; const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, ApiTipsetKey); type Ok = ApiDeadlineInfo; @@ -591,6 +609,7 @@ impl RpcMethod<2> for StateMinerFaults { const NAME: &'static str = "Filecoin.StateMinerFaults"; const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, ApiTipsetKey); type Ok = BitField; @@ -612,6 +631,7 @@ impl RpcMethod<2> for StateMinerRecoveries { const NAME: &'static str = "Filecoin.StateMinerRecoveries"; const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, ApiTipsetKey); type Ok = BitField; @@ -633,6 +653,7 @@ impl RpcMethod<2> for StateMinerAvailableBalance { const NAME: &'static str = "Filecoin.StateMinerAvailableBalance"; const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, ApiTipsetKey); type Ok = TokenAmount; @@ -685,6 +706,7 @@ impl RpcMethod<2> for StateGetReceipt { const NAME: &'static str = "Filecoin.StateGetReceipt"; const PARAM_NAMES: [&'static str; 2] = ["cid", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Cid, ApiTipsetKey); type Ok = Receipt; @@ -711,6 +733,7 @@ impl RpcMethod<2> for StateWaitMsg { const NAME: &'static str = "Filecoin.StateWaitMsg"; const PARAM_NAMES: [&'static str; 2] = ["message_cid", "confidence"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Cid, i64); type Ok = MessageLookup; @@ -744,6 +767,7 @@ impl RpcMethod<1> for StateSearchMsg { const NAME: &'static str = "Filecoin.StateSearchMsg"; const PARAM_NAMES: [&'static str; 1] = ["message_cid"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Cid,); type Ok = MessageLookup; @@ -776,6 +800,7 @@ impl RpcMethod<2> for StateSearchMsgLimited { const NAME: &'static str = "Filecoin.StateSearchMsgLimited"; const PARAM_NAMES: [&'static str; 2] = ["message_cid", "look_back_limit"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Cid, i64); type Ok = MessageLookup; @@ -822,6 +847,7 @@ impl RpcMethod<2> for StateFetchRoot { const NAME: &'static str = "Filecoin.StateFetchRoot"; const PARAM_NAMES: [&'static str; 2] = ["root_cid", "save_to_file"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Cid, Option); type Ok = String; @@ -993,6 +1019,7 @@ impl RpcMethod<4> for StateGetRandomnessFromTickets { const PARAM_NAMES: [&'static str; 4] = ["personalization", "rand_epoch", "entropy", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (i64, ChainEpoch, Vec, ApiTipsetKey); type Ok = Vec; @@ -1028,6 +1055,7 @@ impl RpcMethod<4> for StateGetRandomnessFromBeacon { const PARAM_NAMES: [&'static str; 4] = ["personalization", "rand_epoch", "entropy", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (i64, ChainEpoch, Vec, ApiTipsetKey); type Ok = Vec; @@ -1062,6 +1090,7 @@ impl RpcMethod<2> for StateReadState { const NAME: &'static str = "Filecoin.StateReadState"; const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, ApiTipsetKey); type Ok = ApiActorState; @@ -1096,6 +1125,7 @@ impl RpcMethod<1> for StateCirculatingSupply { const NAME: &'static str = "Filecoin.StateCirculatingSupply"; const PARAM_NAMES: [&'static str; 1] = ["tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (ApiTipsetKey,); type Ok = TokenAmount; @@ -1123,6 +1153,7 @@ impl RpcMethod<2> for MsigGetAvailableBalance { const NAME: &'static str = "Filecoin.MsigGetAvailableBalance"; const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, ApiTipsetKey); type Ok = TokenAmount; @@ -1150,6 +1181,7 @@ impl RpcMethod<2> for MsigGetPending { const NAME: &'static str = "Filecoin.MsigGetPending"; const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, ApiTipsetKey); type Ok = Vec; @@ -1185,6 +1217,7 @@ impl RpcMethod<2> for StateVerifiedClientStatus { const NAME: &'static str = "Filecoin.StateVerifiedClientStatus"; const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, ApiTipsetKey); type Ok = Option; @@ -1205,6 +1238,7 @@ impl RpcMethod<1> for StateVMCirculatingSupplyInternal { const NAME: &'static str = "Filecoin.StateVMCirculatingSupplyInternal"; const PARAM_NAMES: [&'static str; 1] = ["tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (ApiTipsetKey,); type Ok = CirculatingSupply; @@ -1229,6 +1263,7 @@ impl RpcMethod<1> for StateListMiners { const NAME: &'static str = "Filecoin.StateListMiners"; const PARAM_NAMES: [&'static str; 1] = ["tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (ApiTipsetKey,); type Ok = Vec
; @@ -1257,6 +1292,7 @@ impl RpcMethod<2> for StateMarketStorageDeal { const NAME: &'static str = "Filecoin.StateMarketStorageDeal"; const PARAM_NAMES: [&'static str; 2] = ["deal_id", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (DealID, ApiTipsetKey); type Ok = ApiMarketDeal; @@ -1287,6 +1323,7 @@ impl RpcMethod<3> for StateDealProviderCollateralBounds { const NAME: &'static str = "Filecoin.StateDealProviderCollateralBounds"; const PARAM_NAMES: [&'static str; 3] = ["size", "verified", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (u64, bool, ApiTipsetKey); type Ok = DealCollateralBounds; @@ -1357,6 +1394,7 @@ impl RpcMethod<1> for StateGetBeaconEntry { const NAME: &'static str = "Filecoin.StateGetBeaconEntry"; const PARAM_NAMES: [&'static str; 1] = ["epoch"]; const API_VERSION: ApiVersion = ApiVersion::V1; + const PERMISSION: Permission = Permission::Read; type Params = (ChainEpoch,); type Ok = BeaconEntry; @@ -1393,6 +1431,7 @@ impl RpcMethod<3> for StateSectorPreCommitInfo { const NAME: &'static str = "Filecoin.StateSectorPreCommitInfo"; const PARAM_NAMES: [&'static str; 3] = ["miner_address", "sector_number", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, u64, ApiTipsetKey); type Ok = SectorPreCommitOnChainInfo; @@ -1516,6 +1555,7 @@ impl RpcMethod<3> for StateSectorGetInfo { const NAME: &'static str = "Filecoin.StateSectorGetInfo"; const PARAM_NAMES: [&'static str; 3] = ["miner_address", "sector_number", "tipset_key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, u64, ApiTipsetKey); type Ok = SectorOnChainInfo; @@ -1562,6 +1602,7 @@ impl RpcMethod<3> for StateListMessages { const NAME: &'static str = "Filecoin.StateListMessages"; const PARAM_NAMES: [&'static str; 3] = ["message_filter", "tipset_key", "max_height"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (MessageFilter, ApiTipsetKey, i64); type Ok = Vec; diff --git a/src/rpc/methods/sync.rs b/src/rpc/methods/sync.rs index e6600f9cc5d..51e4e3a6e98 100644 --- a/src/rpc/methods/sync.rs +++ b/src/rpc/methods/sync.rs @@ -4,7 +4,7 @@ use crate::blocks::GossipBlock; use crate::libp2p::{IdentTopic, NetworkMessage, PUBSUB_BLOCK_STR}; use crate::lotus_json::{lotus_json_with_self, LotusJson}; -use crate::rpc::{ApiVersion, Ctx, RpcMethod, ServerError}; +use crate::rpc::{ApiVersion, Ctx, Permission, RpcMethod, ServerError}; use cid::Cid; use fvm_ipld_blockstore::Blockstore; use fvm_ipld_encoding::to_vec; @@ -29,6 +29,7 @@ impl RpcMethod<1> for SyncCheckBad { const NAME: &'static str = "Filecoin.SyncCheckBad"; const PARAM_NAMES: [&'static str; 1] = ["cid"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Cid,); type Ok = String; @@ -46,6 +47,7 @@ impl RpcMethod<1> for SyncMarkBad { const NAME: &'static str = "Filecoin.SyncMarkBad"; const PARAM_NAMES: [&'static str; 1] = ["cid"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Admin; type Params = (Cid,); type Ok = (); @@ -65,6 +67,7 @@ impl RpcMethod<0> for SyncState { const NAME: &'static str = "Filecoin.SyncState"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = RPCSyncState; @@ -80,6 +83,7 @@ impl RpcMethod<1> for SyncSubmitBlock { const NAME: &'static str = "Filecoin.SyncSubmitBlock"; const PARAM_NAMES: [&'static str; 1] = ["blk"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Write; type Params = (GossipBlock,); type Ok = (); diff --git a/src/rpc/methods/wallet.rs b/src/rpc/methods/wallet.rs index cca29867925..6a13ff5e99b 100644 --- a/src/rpc/methods/wallet.rs +++ b/src/rpc/methods/wallet.rs @@ -4,7 +4,7 @@ use std::any::Any; use crate::key_management::{Key, KeyInfo}; -use crate::rpc::{ApiVersion, Ctx, RpcMethod, ServerError}; +use crate::rpc::{ApiVersion, Ctx, Permission, RpcMethod, ServerError}; use crate::shim::{ address::Address, crypto::{Signature, SignatureType}, @@ -37,6 +37,7 @@ impl RpcMethod<1> for WalletBalance { const NAME: &'static str = "Filecoin.WalletBalance"; const PARAM_NAMES: [&'static str; 1] = ["address"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address,); type Ok = TokenAmount; @@ -62,6 +63,7 @@ impl RpcMethod<0> for WalletDefaultAddress { const NAME: &'static str = "Filecoin.WalletDefaultAddress"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (); type Ok = Option
; @@ -77,6 +79,7 @@ impl RpcMethod<1> for WalletExport { const NAME: &'static str = "Filecoin.WalletExport"; const PARAM_NAMES: [&'static str; 1] = ["address"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Admin; type Params = (Address,); type Ok = KeyInfo; @@ -96,6 +99,7 @@ impl RpcMethod<1> for WalletHas { const NAME: &'static str = "Filecoin.WalletHas"; const PARAM_NAMES: [&'static str; 1] = ["address"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Write; type Params = (Address,); type Ok = bool; @@ -114,6 +118,7 @@ impl RpcMethod<1> for WalletImport { const NAME: &'static str = "Filecoin.WalletImport"; const PARAM_NAMES: [&'static str; 1] = ["key"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Admin; type Params = (KeyInfo,); type Ok = Address; @@ -137,6 +142,7 @@ impl RpcMethod<0> for WalletList { const NAME: &'static str = "Filecoin.WalletList"; const PARAM_NAMES: [&'static str; 0] = []; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Write; type Params = (); type Ok = Vec
; @@ -152,6 +158,7 @@ impl RpcMethod<1> for WalletNew { const NAME: &'static str = "Filecoin.WalletNew"; const PARAM_NAMES: [&'static str; 1] = ["signature_type"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Write; type Params = (SignatureType,); type Ok = Address; @@ -179,6 +186,7 @@ impl RpcMethod<1> for WalletSetDefault { const NAME: &'static str = "Filecoin.WalletSetDefault"; const PARAM_NAMES: [&'static str; 1] = ["address"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Write; type Params = (Address,); type Ok = (); @@ -201,6 +209,7 @@ impl RpcMethod<2> for WalletSign { const NAME: &'static str = "Filecoin.WalletSign"; const PARAM_NAMES: [&'static str; 2] = ["address", "message"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Sign; type Params = (Address, Vec); type Ok = Signature; @@ -238,6 +247,7 @@ impl RpcMethod<1> for WalletValidateAddress { const NAME: &'static str = "Filecoin.WalletValidateAddress"; const PARAM_NAMES: [&'static str; 1] = ["address"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (String,); type Ok = Address; @@ -252,6 +262,7 @@ impl RpcMethod<3> for WalletVerify { const NAME: &'static str = "Filecoin.WalletVerify"; const PARAM_NAMES: [&'static str; 3] = ["address", "message", "signature"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Read; type Params = (Address, Vec, Signature); type Ok = bool; @@ -269,6 +280,7 @@ impl RpcMethod<1> for WalletDelete { const NAME: &'static str = "Filecoin.WalletDelete"; const PARAM_NAMES: [&'static str; 1] = ["address"]; const API_VERSION: ApiVersion = ApiVersion::V0; + const PERMISSION: Permission = Permission::Write; type Params = (Address,); type Ok = (); diff --git a/src/rpc/mod.rs b/src/rpc/mod.rs index 8c01ccac6a1..f8c41ba9162 100644 --- a/src/rpc/mod.rs +++ b/src/rpc/mod.rs @@ -13,6 +13,7 @@ mod error; mod reflect; pub mod types; pub use methods::*; +use reflect::Permission; /// Protocol or transport-specific error #[allow(unused)] @@ -65,10 +66,8 @@ pub mod prelude { /// - If it is used _across_ API verticals, it should live in `src/rpc/types.rs` /// /// # Interactions with the [`lotus_json`] APIs -/// - Types defined in the module will only ever be deserialized as JSON, so there -/// will NEVER be a need to implement [`HasLotusJson`] for them. /// - Types may have fields which must go through [`LotusJson`], -/// and must reflect that in their [`JsonSchema`]. +/// and MUST reflect that in their [`JsonSchema`]. /// You have two options for this: /// - Use `#[attributes]` to control serialization and schema generation: /// ```ignore @@ -88,6 +87,13 @@ pub mod prelude { /// } /// ``` /// +/// # `for_each_method` +/// Each API vertical exposes a [`for_each_method!`](auth::for_each_method) macro, +/// which is used in three places: +/// - [`prelude`], where all the methods are exported for use in the codebase. +/// - [`auth_layer`], where their [`RpcMethod::PERMISSION`]s are registered. +/// - [`create_module`], where they're actually registered to be served. +/// /// [`lotus_json`]: crate::lotus_json /// [`HasLotusJson`]: crate::lotus_json::HasLotusJson /// [`LotusJson`]: crate::lotus_json::LotusJson diff --git a/src/rpc/reflect/mod.rs b/src/rpc/reflect/mod.rs index f8ca7deae5a..ba67da1fd11 100644 --- a/src/rpc/reflect/mod.rs +++ b/src/rpc/reflect/mod.rs @@ -65,6 +65,8 @@ pub trait RpcMethod { const PARAM_NAMES: [&'static str; ARITY]; /// See [`ApiVersion`]. const API_VERSION: ApiVersion; + /// See [`Permission`] + const PERMISSION: Permission; /// Types of each argument. [`Option`]-al arguments MUST follow mandatory ones. type Params: Params; /// Return value of this method. @@ -76,6 +78,15 @@ pub trait RpcMethod { ) -> impl Future> + Send; } +/// The permission required to call an RPC method. +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub enum Permission { + Admin, + Sign, + Write, + Read, +} + /// Lotus groups methods into API versions. /// /// These are significant because they are expressed in the URL path against which From 4095ddec87710e16fcc52aa3ce38af8cf137e442 Mon Sep 17 00:00:00 2001 From: Roman Useinov Date: Tue, 30 Apr 2024 16:08:14 +0200 Subject: [PATCH 4/4] [Fix] SyncSubmitBlock - queue block for syncing. (#4278) --- src/chain_sync/mod.rs | 2 ++ src/daemon/mod.rs | 7 ++++--- src/rpc/methods/sync.rs | 28 +++++++++++++++++++++++++++- src/rpc/mod.rs | 4 ++++ src/tool/subcommands/api_cmd.rs | 2 ++ 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/chain_sync/mod.rs b/src/chain_sync/mod.rs index e9a0eb8da66..de79dadaafa 100644 --- a/src/chain_sync/mod.rs +++ b/src/chain_sync/mod.rs @@ -10,6 +10,8 @@ mod sync_state; mod tipset_syncer; mod validation; +pub use validation::TipsetValidator; + pub use self::{ bad_block_cache::BadBlockCache, chain_muxer::{ChainMuxer, SyncConfig}, diff --git a/src/daemon/mod.rs b/src/daemon/mod.rs index f7dac316555..00ce9036705 100644 --- a/src/daemon/mod.rs +++ b/src/daemon/mod.rs @@ -267,7 +267,7 @@ pub(super) async fn start( info!("Using network :: {}", get_actual_chain_name(&network_name)); display_chain_logo(&config.chain); - let (tipset_sink, tipset_stream) = flume::bounded(20); + let (tipset_sender, tipset_receiver) = flume::bounded(20); // if bootstrap peers are not set, set them let config = if config.network.bootstrap_peers.is_empty() { @@ -328,8 +328,8 @@ pub(super) async fn start( network_send.clone(), network_rx, Arc::new(Tipset::from(&genesis_header)), - tipset_sink, - tipset_stream, + tipset_sender.clone(), + tipset_receiver, opts.stateless, )?; let bad_blocks = chain_muxer.bad_blocks_cloned(); @@ -383,6 +383,7 @@ pub(super) async fn start( beacon, chain_store: rpc_chain_store, shutdown: shutdown_send, + tipset_send: tipset_sender, }, rpc_address, ) diff --git a/src/rpc/methods/sync.rs b/src/rpc/methods/sync.rs index 51e4e3a6e98..e6b27b562dd 100644 --- a/src/rpc/methods/sync.rs +++ b/src/rpc/methods/sync.rs @@ -1,16 +1,18 @@ // Copyright 2019-2024 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT -use crate::blocks::GossipBlock; +use crate::blocks::{Block, FullTipset, GossipBlock, Tipset}; use crate::libp2p::{IdentTopic, NetworkMessage, PUBSUB_BLOCK_STR}; use crate::lotus_json::{lotus_json_with_self, LotusJson}; use crate::rpc::{ApiVersion, Ctx, Permission, RpcMethod, ServerError}; +use anyhow::Context as _; use cid::Cid; use fvm_ipld_blockstore::Blockstore; use fvm_ipld_encoding::to_vec; use nonempty::{nonempty, NonEmpty}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use std::sync::Arc; // Make sure to add any new methods here. macro_rules! for_each_method { @@ -22,6 +24,8 @@ macro_rules! for_each_method { }; } +use crate::chain; +use crate::chain_sync::TipsetValidator; pub(crate) use for_each_method; pub enum SyncCheckBad {} @@ -96,6 +100,26 @@ impl RpcMethod<1> for SyncSubmitBlock { ) -> Result { let encoded_message = to_vec(&block_msg)?; let pubsub_block_str = format!("{}/{}", PUBSUB_BLOCK_STR, ctx.network_name); + let (bls_messages, secp_messages) = + chain::store::block_messages(&ctx.chain_store.db, &block_msg.header)?; + let block = Block { + header: block_msg.header.clone(), + bls_messages, + secp_messages, + }; + let ts = FullTipset::from(block); + let genesis_ts = Arc::new(Tipset::from(ctx.chain_store.genesis_block_header())); + + TipsetValidator(&ts) + .validate( + ctx.chain_store.clone(), + ctx.bad_blocks.clone(), + genesis_ts, + ctx.state_manager.chain_config().block_delay_secs as u64, + ) + .context("failed to validate the tipset")?; + + ctx.tipset_send.send(Arc::new(ts.into_tipset()))?; ctx.network_send.send(NetworkMessage::PubsubMessage { topic: IdentTopic::new(pubsub_block_str), @@ -146,6 +170,7 @@ mod tests { }])); let (network_send, network_rx) = flume::bounded(5); + let (tipset_send, _) = flume::bounded(5); let mut services = JoinSet::new(); let db = Arc::new(MemoryDB::default()); let chain_config = Arc::new(ChainConfig::default()); @@ -208,6 +233,7 @@ mod tests { chain_store: cs_for_chain.clone(), beacon, shutdown: mpsc::channel(1).0, // dummy for tests + tipset_send, }); (state, network_rx) } diff --git a/src/rpc/mod.rs b/src/rpc/mod.rs index f8c41ba9162..2d2504e89f1 100644 --- a/src/rpc/mod.rs +++ b/src/rpc/mod.rs @@ -121,6 +121,7 @@ use crate::rpc::auth_layer::AuthLayer; use crate::rpc::channel::RpcModule as FilRpcModule; pub use crate::rpc::channel::CANCEL_METHOD_NAME; +use crate::blocks::Tipset; use fvm_ipld_blockstore::Blockstore; use hyper::server::conn::AddrStream; use hyper::service::{make_service_fn, service_fn}; @@ -148,6 +149,7 @@ pub struct RPCState { pub sync_state: Arc>, pub network_send: flume::Sender, pub network_name: String, + pub tipset_send: flume::Sender>, pub start_time: chrono::DateTime, pub beacon: Arc, pub shutdown: mpsc::Sender<()>, @@ -310,6 +312,7 @@ mod tests { .get_beacon_schedule(genesis.timestamp), ); let (network_send, _) = flume::bounded(0); + let (tipset_send, _) = flume::bounded(1); let network_name = get_network_name_from_genesis(genesis, &state_manager).unwrap(); let message_pool = MessagePool::new( MpoolRpcProvider::new(chain_store.publisher().clone(), state_manager.clone()), @@ -332,6 +335,7 @@ mod tests { chain_store, beacon, shutdown: mpsc::channel(1).0, // dummy for tests + tipset_send, } } } diff --git a/src/tool/subcommands/api_cmd.rs b/src/tool/subcommands/api_cmd.rs index c3efa7dd557..36dadc8e6f9 100644 --- a/src/tool/subcommands/api_cmd.rs +++ b/src/tool/subcommands/api_cmd.rs @@ -1087,6 +1087,7 @@ async fn start_offline_server( .get_beacon_schedule(chain_store.genesis_block_header().timestamp), ); let (network_send, _) = flume::bounded(5); + let (tipset_send, _) = flume::bounded(5); let network_name = get_network_name_from_genesis(&genesis_header, &state_manager)?; let message_pool = MessagePool::new( MpoolRpcProvider::new(chain_store.publisher().clone(), state_manager.clone()), @@ -1122,6 +1123,7 @@ async fn start_offline_server( chain_store, beacon, shutdown, + tipset_send, }; rpc_state.sync_state.write().set_stage(SyncStage::Idle); start_offline_rpc(rpc_state, rpc_port, shutdown_recv).await?;