From 07983b4731d902e012d1a40e178c25b5277a4a0f Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 28 Oct 2024 11:09:41 +0800 Subject: [PATCH 1/6] feat(cli): implement forest-cli f3 manifest --- Cargo.lock | 350 ++++++++++++++++++++------------- Cargo.toml | 2 + src/cli/main.rs | 1 + src/cli/subcommands/f3_cmd.rs | 67 +++++++ src/cli/subcommands/mod.rs | 11 +- src/lotus_json/duration.rs | 22 +++ src/lotus_json/mod.rs | 1 + src/rpc/methods/f3.rs | 6 +- src/rpc/methods/f3/types.rs | 134 ++++++++++++- templates/cli/f3/manifest.stpl | 29 +++ 10 files changed, 473 insertions(+), 150 deletions(-) create mode 100644 src/cli/subcommands/f3_cmd.rs create mode 100644 src/lotus_json/duration.rs create mode 100644 templates/cli/f3/manifest.stpl diff --git a/Cargo.lock b/Cargo.lock index 227df639f893..3f641f07b423 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -145,9 +145,9 @@ checksum = "735d4f398ca57cfa2880225c2bf81c3b9af3be5bb22e44ae70118dad38713e84" [[package]] name = "anstream" -version = "0.6.15" +version = "0.6.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338" dependencies = [ "anstyle", "anstyle-parse", @@ -160,43 +160,43 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" +checksum = "8365de52b16c035ff4fcafe0092ba9390540e3e352870ac09933bebcaa2c8c56" [[package]] name = "anstyle-parse" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.4" +version = "3.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" dependencies = [ "anstyle", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" dependencies = [ "backtrace", ] @@ -283,7 +283,7 @@ checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", "synstructure 0.13.1", ] @@ -295,7 +295,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -345,9 +345,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.16" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "103db485efc3e41214fe4fda9f3dbeae2eb9082f48fd236e6095627a9422066e" +checksum = "0cb8f1d480b0ea3783ab015936d2a55c87e219676f0c0b7dec61494043f21857" dependencies = [ "brotli", "flate2", @@ -443,7 +443,7 @@ dependencies = [ "futures-lite 2.3.0", "parking", "polling 3.7.3", - "rustix 0.38.37", + "rustix 0.38.38", "slab", "tracing", "windows-sys 0.59.0", @@ -493,7 +493,7 @@ dependencies = [ "cfg-if", "event-listener 3.1.0", "futures-lite 1.13.0", - "rustix 0.38.37", + "rustix 0.38.38", "windows-sys 0.48.0", ] @@ -509,7 +509,7 @@ dependencies = [ "cfg-if", "futures-core", "futures-io", - "rustix 0.38.37", + "rustix 0.38.38", "signal-hook-registry", "slab", "windows-sys 0.59.0", @@ -560,7 +560,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -577,7 +577,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -834,7 +834,7 @@ dependencies = [ "regex", "rustc-hash 1.1.0", "shlex", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -1087,9 +1087,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.2" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" dependencies = [ "serde", ] @@ -1154,7 +1154,7 @@ dependencies = [ "quote", "serde", "serde_json", - "syn 2.0.79", + "syn 2.0.85", "tempfile", "toml 0.8.19", ] @@ -1170,9 +1170,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.30" +version = "1.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945" +checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" dependencies = [ "jobserver", "libc", @@ -1352,7 +1352,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -1369,9 +1369,9 @@ checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" [[package]] name = "colorchoice" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "colored" @@ -1431,9 +1431,9 @@ dependencies = [ [[package]] name = "console-api" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ed14aa9c9f927213c6e4f3ef75faaad3406134efe84ba2cb7983431d5f0931" +checksum = "8030735ecb0d128428b64cd379809817e620a40e5001c54465b99ec5feec2857" dependencies = [ "futures-core", "prost 0.13.3", @@ -1444,9 +1444,9 @@ dependencies = [ [[package]] name = "console-subscriber" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e3a111a37f3333946ebf9da370ba5c5577b18eb342ec683eb488dd21980302" +checksum = "6539aa9c6a4cd31f4b1c040f860a1eac9aa80e7df6b05d506a6e7179936d6a01" dependencies = [ "console-api", "crossbeam-channel", @@ -2010,7 +2010,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -2045,7 +2045,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -2056,7 +2056,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -2094,7 +2094,7 @@ dependencies = [ "proc-macro2", "quote", "semver", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -2140,7 +2140,7 @@ checksum = "74ef43543e701c01ad77d3a5922755c6a1d71b22d942cb8042be4994b380caff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -2152,7 +2152,7 @@ dependencies = [ "proc-macro2", "quote", "structmeta", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -2163,7 +2163,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -2184,7 +2184,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -2194,7 +2194,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -2207,7 +2207,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -2228,7 +2228,7 @@ dependencies = [ "convert_case 0.6.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", "unicode-xid", ] @@ -2307,7 +2307,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -2454,7 +2454,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -2576,7 +2576,7 @@ checksum = "ce8cd46a041ad005ab9c71263f9a0ff5b529eac0fe4cc9b4a20f4f0765d8cf4b" dependencies = [ "execute-command-tokens", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -2607,6 +2607,17 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" +[[package]] +name = "fancy-duration" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3ae60718ae501dca9d27fd0e322683c86a95a1a01fac1807aa2f9b035cc0882" +dependencies = [ + "anyhow", + "lazy_static", + "regex", +] + [[package]] name = "fastrand" version = "1.9.0" @@ -3100,9 +3111,9 @@ dependencies = [ [[package]] name = "flume" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" +checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" dependencies = [ "futures-core", "futures-sink", @@ -3170,6 +3181,7 @@ dependencies = [ "displaydoc", "ethereum-types", "ez-jsonrpc-types", + "fancy-duration", "fil_actor_account_state", "fil_actor_cron_state", "fil_actor_datacap_state", @@ -3182,7 +3194,7 @@ dependencies = [ "fil_actor_system_state", "fil_actor_verifreg_state", "fil_actors_shared", - "flume 0.11.0", + "flume 0.11.1", "fs_extra", "futures", "fvm 2.9.1", @@ -3265,6 +3277,7 @@ dependencies = [ "rlp", "rs-car-ipfs", "rust2go", + "sailfish", "schemars", "scopeguard", "semver", @@ -3285,7 +3298,7 @@ dependencies = [ "statrs", "strum", "strum_macros", - "syn 2.0.79", + "syn 2.0.85", "tabled", "tap", "tar", @@ -3318,7 +3331,7 @@ name = "forest-interop-tests" version = "0.1.0" dependencies = [ "anyhow", - "flume 0.11.0", + "flume 0.11.1", "forest-filecoin", "futures", "libipld", @@ -3537,7 +3550,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -3959,7 +3972,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc3655aa6818d65bc620d6911f05aa7b6aeb596291e1e9f79e52df85583d1e30" dependencies = [ - "rustix 0.38.37", + "rustix 0.38.38", "windows-targets 0.52.6", ] @@ -4031,7 +4044,7 @@ checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -4292,6 +4305,15 @@ dependencies = [ "hmac 0.8.1", ] +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "hostname" version = "0.3.1" @@ -4681,9 +4703,9 @@ dependencies = [ [[package]] name = "insta" -version = "1.40.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6593a41c7a73841868772495db7dc1e8ecab43bb5c0b6da2059246c4b506ab60" +checksum = "a1f72d3e19488cf7d8ea52d2fc0f8754fc933398b337cd3cbdb28aaeb35159ef" dependencies = [ "console", "lazy_static", @@ -4822,6 +4844,12 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "itoap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9028f49264629065d057f340a86acb84867925865f73bbf8d47b4d149a7e88b8" + [[package]] name = "jni" version = "0.19.0" @@ -5078,9 +5106,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.159" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libipld" @@ -5172,9 +5200,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +checksum = "3bda4c6077b0b08da2c48b172195795498381a7c8988c9e6212a6c55c5b9bd70" [[package]] name = "libmimalloc-sys" @@ -5285,7 +5313,7 @@ dependencies = [ "futures-timer", "libp2p-identity", "multiaddr", - "multihash 0.19.1", + "multihash 0.19.2", "multistream-select", "once_cell", "parking_lot", @@ -5384,7 +5412,7 @@ dependencies = [ "ed25519-dalek", "hkdf", "libsecp256k1", - "multihash 0.19.1", + "multihash 0.19.2", "p256", "quick-protobuf", "rand", @@ -5481,7 +5509,7 @@ dependencies = [ "libp2p-core", "libp2p-identity", "multiaddr", - "multihash 0.19.1", + "multihash 0.19.2", "once_cell", "quick-protobuf", "rand", @@ -5606,7 +5634,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -5900,7 +5928,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.38.37", + "rustix 0.38.38", ] [[package]] @@ -6038,7 +6066,7 @@ dependencies = [ "data-encoding", "libp2p-identity", "multibase", - "multihash 0.19.1", + "multihash 0.19.2", "percent-encoding", "serde", "static_assertions", @@ -6082,13 +6110,13 @@ dependencies = [ [[package]] name = "multihash" -version = "0.19.1" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076d548d76a0e2a0d4ab471d0b1c36c577786dfc4471242035d97a12a735c492" +checksum = "cc41f430805af9d1cf4adae4ed2149c759b877b01d909a1f40256188d09345d2" dependencies = [ "core2", "serde", - "unsigned-varint 0.7.2", + "unsigned-varint 0.8.0", ] [[package]] @@ -6154,7 +6182,7 @@ checksum = "254a5372af8fc138e36684761d3c0cdb758a4410e938babcff1c860ce14ddbfc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -6364,7 +6392,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -6725,29 +6753,29 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf123a161dde1e524adf36f90bc5d8d3462824a9c43553ad07a8183161189ec" +checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" +checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pin-utils" @@ -6836,7 +6864,7 @@ dependencies = [ "concurrent-queue", "hermit-abi 0.4.0", "pin-project-lite", - "rustix 0.38.37", + "rustix 0.38.38", "tracing", "windows-sys 0.59.0", ] @@ -6950,12 +6978,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.22" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" +checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -7025,9 +7053,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.88" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -7042,7 +7070,7 @@ dependencies = [ "hex", "lazy_static", "procfs-core", - "rustix 0.38.37", + "rustix 0.38.38", ] [[package]] @@ -7075,7 +7103,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -7108,7 +7136,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -7121,7 +7149,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -7497,9 +7525,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -7735,7 +7763,7 @@ dependencies = [ "rust2go-cli", "rust2go-convert", "rust2go-macro", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -7758,7 +7786,7 @@ checksum = "c501dad4b73f3fa62258bed2623cb695f69686a8c304d6b90f807f9b19772fb6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -7776,7 +7804,7 @@ dependencies = [ "proc-macro2", "quote", "rust2go-common", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -7837,9 +7865,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.37" +version = "0.38.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" dependencies = [ "bitflags 2.6.0", "errno", @@ -7971,6 +7999,44 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "sailfish" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d5cd6d4f24f3ab107e949ab424738cf55b03deddce3b184c46985d7b1394ef" +dependencies = [ + "itoap", + "ryu", + "sailfish-macros", + "version_check", +] + +[[package]] +name = "sailfish-compiler" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7254ec7b3651f7f723a9073153f5dcddc1f2bf1bf8d1b23ac71c236ef6360d2b" +dependencies = [ + "filetime", + "home", + "memchr", + "proc-macro2", + "quote", + "serde", + "syn 2.0.85", + "toml 0.8.19", +] + +[[package]] +name = "sailfish-macros" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00812289fe1891c191cc2d9db461352fc410619e07ec2bb748faaa06412619d0" +dependencies = [ + "proc-macro2", + "sailfish-compiler", +] + [[package]] name = "salsa20" version = "0.10.2" @@ -8021,7 +8087,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -8079,9 +8145,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" dependencies = [ "serde_derive", ] @@ -8106,13 +8172,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -8123,7 +8189,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -8140,9 +8206,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", "memchr", @@ -8168,7 +8234,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -8261,7 +8327,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -8478,7 +8544,7 @@ checksum = "0eb01866308440fc64d6c44d9e86c5cc17adfe33c4d6eed55da9145044d0ffc1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -8771,7 +8837,7 @@ dependencies = [ "proc-macro2", "quote", "structmeta-derive", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -8782,7 +8848,7 @@ checksum = "a60bcaff7397072dca0017d1db428e30d5002e00b6847703e2e42005c95fbe00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -8804,7 +8870,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -8826,9 +8892,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" dependencies = [ "proc-macro2", "quote", @@ -8870,7 +8936,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -8949,7 +9015,7 @@ dependencies = [ "cfg-if", "fastrand 2.1.1", "once_cell", - "rustix 0.38.37", + "rustix 0.38.38", "windows-sys 0.59.0", ] @@ -8985,22 +9051,22 @@ checksum = "f18aa187839b2bdb1ad2fa35ead8c4c2976b64e4363c386d45ac0f7ee85c9233" [[package]] name = "thiserror" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -9125,9 +9191,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.40.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "bytes", @@ -9150,7 +9216,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -9386,7 +9452,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -9663,9 +9729,9 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "value-bag" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a84c137d37ab0142f0f2ddfe332651fdbf252e7b7dbb4e67b6c1f1b2e925101" +checksum = "3ef4c4aa54d5d05a279399bfa921ec387b7aba77caf7a682ae8d86785b8fdad2" [[package]] name = "version_check" @@ -9741,7 +9807,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", "wasm-bindgen-shared", ] @@ -9775,7 +9841,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9815,9 +9881,9 @@ dependencies = [ [[package]] name = "wasm-streams" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e072d4e72f700fb3443d8fe94a39315df013eef1104903cdb0a2abd322bbecd" +checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" dependencies = [ "futures-util", "js-sys", @@ -9911,7 +9977,7 @@ dependencies = [ "once_cell", "paste", "rayon", - "rustix 0.38.37", + "rustix 0.38.38", "serde", "serde_derive", "serde_json", @@ -9949,7 +10015,7 @@ dependencies = [ "postcard", "psm", "rayon", - "rustix 0.38.37", + "rustix 0.38.38", "serde", "serde_derive", "smallvec", @@ -9993,7 +10059,7 @@ dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", "wasmtime-component-util", "wasmtime-wit-bindgen", "wit-parser", @@ -10155,7 +10221,7 @@ dependencies = [ "memoffset 0.9.1", "paste", "psm", - "rustix 0.38.37", + "rustix 0.38.38", "sptr", "wasm-encoder 0.201.0", "wasmtime-asm-macros 19.0.2", @@ -10212,7 +10278,7 @@ checksum = "ffaafa5c12355b1a9ee068e9295d50c4ca0a400c721950cdae4f5b54391a2da5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -10223,7 +10289,7 @@ checksum = "a4b0c1f76891f778db9602ee3fbb4eb7e9a3f511847d1fb1b69eddbcea28303c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -10670,7 +10736,7 @@ checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" dependencies = [ "libc", "linux-raw-sys 0.4.14", - "rustix 0.38.37", + "rustix 0.38.38", ] [[package]] @@ -10762,7 +10828,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -10782,7 +10848,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index ddb9bb2ab40c..4f622a7e5168 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,6 +48,7 @@ directories = "5" displaydoc = "0.2" ethereum-types = "0.15" ez-jsonrpc-types = "0.3" +fancy-duration = "0.9" fil_actor_account_state = { version = "17.0.3" } fil_actor_cron_state = { version = "17.0.3" } fil_actor_datacap_state = { version = "17.0.3" } @@ -155,6 +156,7 @@ rlimit = "0.10" rlp = "0.6" rs-car-ipfs = "0.3" rust2go = { version = "0.3" } +sailfish = "0.9" schemars = { version = "0.8", features = ["chrono", "uuid1"] } scopeguard = "1" semver = "1" diff --git a/src/cli/main.rs b/src/cli/main.rs index bc37b121b334..e6a663fe8a14 100644 --- a/src/cli/main.rs +++ b/src/cli/main.rs @@ -48,6 +48,7 @@ where Subcommand::Attach { .. } => bail!("the `attach` subcommand has been removed. Please raise an issue if this breaks a workflow for you"), Subcommand::Shutdown(cmd) => cmd.run(client).await, Subcommand::Healthcheck(cmd) => cmd.run(client).await, + Subcommand::F3(cmd) => cmd.run(client).await, } }) } diff --git a/src/cli/subcommands/f3_cmd.rs b/src/cli/subcommands/f3_cmd.rs new file mode 100644 index 000000000000..7db77230da9e --- /dev/null +++ b/src/cli/subcommands/f3_cmd.rs @@ -0,0 +1,67 @@ +// Copyright 2019-2024 ChainSafe Systems +// SPDX-License-Identifier: Apache-2.0, MIT + +use crate::rpc::{self, f3::F3Manifest, prelude::*}; +use cid::Cid; +use clap::{Subcommand, ValueEnum}; +use sailfish::TemplateSimple; +use serde::{Deserialize, Serialize}; + +/// Output format +#[derive(ValueEnum, Debug, Clone, Default, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub enum F3OutputFormat { + /// Text + #[default] + Text, + /// JSON + Json, +} + +/// Manages Filecoin Fast Finality (F3) interactions +#[derive(Debug, Subcommand)] +pub enum F3Commands { + /// Gets the current manifest used by F3 + Manifest { + /// The output format. + #[arg(long, value_enum, default_value_t = F3OutputFormat::Text)] + output: F3OutputFormat, + }, +} + +impl F3Commands { + pub async fn run(self, client: rpc::Client) -> anyhow::Result<()> { + match self { + Self::Manifest { output } => { + let manifest = client.call(F3GetManifest::request(())?).await?; + match output { + F3OutputFormat::Text => { + let template = ManifestTemplate::new(manifest); + println!("{}", template.render_once()?); + } + F3OutputFormat::Json => { + println!("{}", serde_json::to_string_pretty(&manifest)?); + } + } + Ok(()) + } + } + } +} + +#[derive(TemplateSimple, Debug, Clone, Serialize, Deserialize)] +#[template(path = "cli/f3/manifest.stpl")] +struct ManifestTemplate { + manifest: F3Manifest, + is_initial_power_table_defined: bool, +} + +impl ManifestTemplate { + fn new(manifest: F3Manifest) -> Self { + let is_initial_power_table_defined = manifest.initial_power_table != Cid::default(); + Self { + manifest, + is_initial_power_table_defined, + } + } +} diff --git a/src/cli/subcommands/mod.rs b/src/cli/subcommands/mod.rs index f314e6f84aba..bcb311f7506f 100644 --- a/src/cli/subcommands/mod.rs +++ b/src/cli/subcommands/mod.rs @@ -9,6 +9,7 @@ mod auth_cmd; mod chain_cmd; mod config_cmd; +mod f3_cmd; mod healthcheck_cmd; mod info_cmd; mod mpool_cmd; @@ -30,9 +31,9 @@ use tracing::error; pub(super) use self::{ auth_cmd::AuthCommands, chain_cmd::ChainCommands, config_cmd::ConfigCommands, - healthcheck_cmd::HealthcheckCommand, mpool_cmd::MpoolCommands, net_cmd::NetCommands, - send_cmd::SendCommand, shutdown_cmd::ShutdownCommand, snapshot_cmd::SnapshotCommands, - state_cmd::StateCommands, sync_cmd::SyncCommands, + f3_cmd::F3Commands, healthcheck_cmd::HealthcheckCommand, mpool_cmd::MpoolCommands, + net_cmd::NetCommands, send_cmd::SendCommand, shutdown_cmd::ShutdownCommand, + snapshot_cmd::SnapshotCommands, state_cmd::StateCommands, sync_cmd::SyncCommands, }; use crate::cli::subcommands::info_cmd::InfoCommand; @@ -99,6 +100,10 @@ pub enum Subcommand { /// Print healthcheck info #[command(subcommand)] Healthcheck(HealthcheckCommand), + + /// Manages Filecoin Fast Finality (F3) interactions + #[command(subcommand)] + F3(F3Commands), } /// Format a vector to a prettified string diff --git a/src/lotus_json/duration.rs b/src/lotus_json/duration.rs new file mode 100644 index 000000000000..624e6a013774 --- /dev/null +++ b/src/lotus_json/duration.rs @@ -0,0 +1,22 @@ +// Copyright 2019-2024 ChainSafe Systems +// SPDX-License-Identifier: Apache-2.0, MIT + +use super::*; +use std::time::Duration; + +impl HasLotusJson for Duration { + type LotusJson = u64; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![(json!(15000000000_u64), Duration::from_secs(15))] + } + + fn into_lotus_json(self) -> Self::LotusJson { + self.as_nanos() as _ + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self::from_nanos(lotus_json) + } +} diff --git a/src/lotus_json/mod.rs b/src/lotus_json/mod.rs index 4216722f12c7..944c4d2e0c49 100644 --- a/src/lotus_json/mod.rs +++ b/src/lotus_json/mod.rs @@ -195,6 +195,7 @@ decl_and_test!( big_int for num::BigInt, block_header for crate::blocks::CachingBlockHeader, cid for ::cid::Cid, + duration for std::time::Duration, election_proof for crate::blocks::ElectionProof, extended_sector_info for crate::shim::sector::ExtendedSectorInfo, gossip_block for crate::blocks::GossipBlock, diff --git a/src/rpc/methods/f3.rs b/src/rpc/methods/f3.rs index e679898b2bc1..c393111b0007 100644 --- a/src/rpc/methods/f3.rs +++ b/src/rpc/methods/f3.rs @@ -10,7 +10,7 @@ mod types; mod util; -pub use self::types::F3LeaseManager; +pub use self::types::{F3LeaseManager, F3Manifest}; use self::{types::*, util::*}; use super::wallet::WalletSign; use crate::{ @@ -673,7 +673,7 @@ impl RpcMethod<0> for F3GetProgress { pub enum F3GetManifest {} impl F3GetManifest { - async fn run() -> anyhow::Result { + async fn run() -> anyhow::Result { let client = get_rpc_http_client()?; let response = client.request(Self::NAME, ArrayParams::new()).await?; Ok(response) @@ -687,7 +687,7 @@ impl RpcMethod<0> for F3GetManifest { const PERMISSION: Permission = Permission::Read; type Params = (); - type Ok = serde_json::Value; + type Ok = F3Manifest; async fn handle(_: Ctx, (): Self::Params) -> Result { Ok(Self::run().await?) diff --git a/src/rpc/methods/f3/types.rs b/src/rpc/methods/f3/types.rs index 99dc06587724..bc1f6ecb9d01 100644 --- a/src/rpc/methods/f3/types.rs +++ b/src/rpc/methods/f3/types.rs @@ -4,7 +4,7 @@ use super::*; use crate::{ blocks::{Tipset, TipsetKey}, - lotus_json::{base64_standard, lotus_json_with_self, HasLotusJson}, + lotus_json::{base64_standard, lotus_json_with_self, HasLotusJson, LotusJson}, networks::NetworkChain, }; use cid::{multihash::MultihashDigest as _, Cid}; @@ -16,7 +16,7 @@ use once_cell::sync::Lazy; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use serde_with::{serde_as, DisplayFromStr}; -use std::cmp::Ordering; +use std::{cmp::Ordering, time::Duration}; const MAX_LEASE_INSTANCES: u64 = 5; @@ -154,6 +154,82 @@ pub struct F3Instant { } lotus_json_with_self!(F3Instant); +#[derive(PartialEq, Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "PascalCase")] +pub struct GpbftConfig { + #[schemars(with = "u64")] + #[serde(with = "crate::lotus_json")] + pub delta: Duration, + pub delta_back_off_exponent: f64, + pub max_lookahead_rounds: u64, + #[schemars(with = "u64")] + #[serde(with = "crate::lotus_json")] + pub rebroadcast_backoff_base: Duration, + pub rebroadcast_backoff_exponent: f64, + pub rebroadcast_backoff_spread: f64, + #[schemars(with = "u64")] + #[serde(with = "crate::lotus_json")] + pub rebroadcast_backoff_max: Duration, +} + +#[derive(PartialEq, Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "PascalCase")] +pub struct EcConfig { + #[schemars(with = "u64")] + #[serde(with = "crate::lotus_json")] + pub period: Duration, + pub finality: i64, + pub delay_multiplier: f64, + pub base_decision_backoff_table: Vec, + pub head_lookback: i64, + pub finalize: bool, +} + +#[derive(PartialEq, Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "PascalCase")] +pub struct CertificateExchangeConfig { + #[schemars(with = "u64")] + #[serde(with = "crate::lotus_json")] + pub client_request_timeout: Duration, + #[schemars(with = "u64")] + #[serde(with = "crate::lotus_json")] + pub server_request_timeout: Duration, + #[schemars(with = "u64")] + #[serde(with = "crate::lotus_json")] + pub minimum_poll_interval: Duration, + #[schemars(with = "u64")] + #[serde(with = "crate::lotus_json")] + pub maximum_poll_interval: Duration, +} + +#[serde_as] +#[derive(PartialEq, Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "PascalCase")] +pub struct F3Manifest { + pub protocol_version: u64, + pub pause: bool, + pub initial_instance: u64, + pub bootstrap_epoch: i64, + pub network_name: String, // Note: NetworkChain::Calibnet.to_string() != "calibrationnet" + #[schemars(with = "LotusJson>")] + #[serde(with = "crate::lotus_json")] + pub explicit_power: Vec, + #[serde(rename = "IgnoreECPower")] + pub ignore_ec_power: bool, + #[schemars(with = "String")] + #[serde(with = "crate::lotus_json")] + pub initial_power_table: Cid, + pub committee_lookback: u64, + #[schemars(with = "u64")] + #[serde(with = "crate::lotus_json")] + pub catch_up_alignment: Duration, + pub gpbft: GpbftConfig, + #[serde(rename = "EC")] + pub ec: EcConfig, + pub certificate_exchange: CertificateExchangeConfig, +} +lotus_json_with_self!(F3Manifest); + #[derive(PartialEq, Debug, Clone, Serialize, Deserialize, JsonSchema)] #[serde(rename_all = "PascalCase")] pub struct F3Participant { @@ -479,4 +555,58 @@ mod tests { let active_participants = lm.get_active_participants(17); assert!(!active_participants.contains_key(&miner)); } + + #[test] + fn f3_manifest_serde_roundtrip() { + // lotus f3 manifest --output json + let lotus_json = serde_json::json!({ + "Pause": false, + "ProtocolVersion": 4, + "InitialInstance": 0, + "BootstrapEpoch": 2081674, + "NetworkName": "calibrationnet", + "ExplicitPower": null, + "IgnoreECPower": false, + "InitialPowerTable": { + "/": "bafy2bzaceab236vmmb3n4q4tkvua2n4dphcbzzxerxuey3mot4g3cov5j3r2c" + }, + "CommitteeLookback": 10, + "CatchUpAlignment": 15000000000_u64, + "Gpbft": { + "Delta": 6000000000_u64, + "DeltaBackOffExponent": 2_f64, + "MaxLookaheadRounds": 5, + "RebroadcastBackoffBase": 6000000000_u64, + "RebroadcastBackoffExponent": 1.3, + "RebroadcastBackoffSpread": 0.1, + "RebroadcastBackoffMax": 60000000000_u64 + }, + "EC": { + "Period": 30000000000_u64, + "Finality": 900, + "DelayMultiplier": 2_f64, + "BaseDecisionBackoffTable": [ + 1.3, + 1.69, + 2.2, + 2.86, + 3.71, + 4.83, + 6.27, + 7.5 + ], + "HeadLookback": 0, + "Finalize": true + }, + "CertificateExchange": { + "ClientRequestTimeout": 10000000000_u64, + "ServerRequestTimeout": 60000000000_u64, + "MinimumPollInterval": 30000000000_u64, + "MaximumPollInterval": 120000000000_u64 + } + }); + let manifest: F3Manifest = serde_json::from_value(lotus_json.clone()).unwrap(); + let serialized = serde_json::to_value(manifest.clone()).unwrap(); + assert_eq!(lotus_json, serialized); + } } diff --git a/templates/cli/f3/manifest.stpl b/templates/cli/f3/manifest.stpl new file mode 100644 index 000000000000..3e1a3eb17d5a --- /dev/null +++ b/templates/cli/f3/manifest.stpl @@ -0,0 +1,29 @@ +Manifest: + Protocol Version: <%= manifest.protocol_version %> + Paused: <%= manifest.pause %> + Initial Instance: <%= manifest.initial_instance %> + Initial Power Table: <% if is_initial_power_table_defined { %><%= manifest.initial_power_table.to_string() %><% } else { %>unknown<% } %> + Bootstrap Epoch: <%= manifest.bootstrap_epoch %> + Network Name: <%= manifest.network_name %> + Ignore EC Power: <%= manifest.ignore_ec_power %> + Committee Lookback: <%= manifest.committee_lookback %> + Catch Up Alignment: <%= fancy_duration::FancyDuration(manifest.catch_up_alignment).to_string() %> + + GPBFT Delta: <%= fancy_duration::FancyDuration(manifest.gpbft.delta).to_string() %> + GPBFT Delta BackOff Exponent: <%= manifest.gpbft.delta_back_off_exponent %> + GPBFT Max Lookahead Rounds: <%= manifest.gpbft.max_lookahead_rounds %> + GPBFT Rebroadcast Backoff Base: <%= fancy_duration::FancyDuration(manifest.gpbft.rebroadcast_backoff_base).to_string() %> + GPBFT Rebroadcast Backoff Exponent: <%= manifest.gpbft.rebroadcast_backoff_exponent %> + GPBFT Rebroadcast Backoff Spread: <%= manifest.gpbft.rebroadcast_backoff_spread %> + GPBFT Rebroadcast Backoff Max: <%= fancy_duration::FancyDuration(manifest.gpbft.rebroadcast_backoff_max).to_string() %> + + EC Period: <%= fancy_duration::FancyDuration(manifest.ec.period).to_string() %> + EC Finality: <%= manifest.ec.finality %> + EC Delay Multiplier: <%= manifest.ec.delay_multiplier %> + EC Head Lookback: <%= manifest.ec.head_lookback %> + EC Finalize: <%= manifest.ec.finalize %> + + Certificate Exchange Client Timeout: <%= fancy_duration::FancyDuration(manifest.certificate_exchange.client_request_timeout).to_string() %> + Certificate Exchange Server Timeout: <%= fancy_duration::FancyDuration(manifest.certificate_exchange.server_request_timeout).to_string() %> + Certificate Exchange Min Poll Interval: <%= fancy_duration::FancyDuration(manifest.certificate_exchange.minimum_poll_interval).to_string() %> + Certificate Exchange Max Poll Interval: <%= fancy_duration::FancyDuration(manifest.certificate_exchange.maximum_poll_interval).to_string() %> From e7cd520cf1a1d7cc8f77c1369dc4fa34f554b7fe Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 28 Oct 2024 11:28:45 +0800 Subject: [PATCH 2/6] more tests --- src/cli/subcommands/f3_cmd.rs | 59 +++++++++++++++++++++++++++++++++++ src/lotus_json/duration.rs | 18 +++++++++++ 2 files changed, 77 insertions(+) diff --git a/src/cli/subcommands/f3_cmd.rs b/src/cli/subcommands/f3_cmd.rs index 7db77230da9e..4a73de7acf76 100644 --- a/src/cli/subcommands/f3_cmd.rs +++ b/src/cli/subcommands/f3_cmd.rs @@ -65,3 +65,62 @@ impl ManifestTemplate { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_manifest_template() { + // lotus f3 manifest --output json + let lotus_json = serde_json::json!({ + "Pause": false, + "ProtocolVersion": 4, + "InitialInstance": 0, + "BootstrapEpoch": 2081674, + "NetworkName": "calibrationnet", + "ExplicitPower": null, + "IgnoreECPower": false, + "InitialPowerTable": { + "/": "bafy2bzaceab236vmmb3n4q4tkvua2n4dphcbzzxerxuey3mot4g3cov5j3r2c" + }, + "CommitteeLookback": 10, + "CatchUpAlignment": 15000000000_u64, + "Gpbft": { + "Delta": 6000000000_u64, + "DeltaBackOffExponent": 2_f64, + "MaxLookaheadRounds": 5, + "RebroadcastBackoffBase": 6000000000_u64, + "RebroadcastBackoffExponent": 1.3, + "RebroadcastBackoffSpread": 0.1, + "RebroadcastBackoffMax": 60000000000_u64 + }, + "EC": { + "Period": 30000000000_u64, + "Finality": 900, + "DelayMultiplier": 2_f64, + "BaseDecisionBackoffTable": [ + 1.3, + 1.69, + 2.2, + 2.86, + 3.71, + 4.83, + 6.27, + 7.5 + ], + "HeadLookback": 0, + "Finalize": true + }, + "CertificateExchange": { + "ClientRequestTimeout": 10000000000_u64, + "ServerRequestTimeout": 60000000000_u64, + "MinimumPollInterval": 30000000000_u64, + "MaximumPollInterval": 120000000000_u64 + } + }); + let manifest: F3Manifest = serde_json::from_value(lotus_json.clone()).unwrap(); + let template = ManifestTemplate::new(manifest); + println!("{}", template.render_once().unwrap()); + } +} diff --git a/src/lotus_json/duration.rs b/src/lotus_json/duration.rs index 624e6a013774..70a01e200852 100644 --- a/src/lotus_json/duration.rs +++ b/src/lotus_json/duration.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0, MIT use super::*; +use fancy_duration::FancyDuration; use std::time::Duration; impl HasLotusJson for Duration { @@ -20,3 +21,20 @@ impl HasLotusJson for Duration { Self::from_nanos(lotus_json) } } + +impl HasLotusJson for FancyDuration { + type LotusJson = u64; + + #[cfg(test)] + fn snapshots() -> Vec<(serde_json::Value, Self)> { + vec![(json!(15000000000_u64), Self(Duration::from_secs(15)))] + } + + fn into_lotus_json(self) -> Self::LotusJson { + self.0.as_nanos() as _ + } + + fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { + Self(Duration::from_nanos(lotus_json)) + } +} From 5ac7bec3020b34d29967351cac13e8926f45d2c4 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 28 Oct 2024 11:32:08 +0800 Subject: [PATCH 3/6] rpc --- scripts/tests/api_compare/filter-list | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/tests/api_compare/filter-list b/scripts/tests/api_compare/filter-list index 86a63a4f6529..72b86badc3f2 100644 --- a/scripts/tests/api_compare/filter-list +++ b/scripts/tests/api_compare/filter-list @@ -8,3 +8,5 @@ !Filecoin.EthGetTransactionReceipt # TODO(elmattic): https://github.com/ChainSafe/forest/issues/4851 !Filecoin.EthGetLogs +# Enable after Lotus image is upgraded to a release in which F3IntitialPowerTable is hard coded. +!Filecoin.F3GetManifest From b1332cd899c246f379f71d457eff1c79c9cf2051 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 28 Oct 2024 11:36:33 +0800 Subject: [PATCH 4/6] revert --- scripts/tests/api_compare/filter-list | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/tests/api_compare/filter-list b/scripts/tests/api_compare/filter-list index 72b86badc3f2..86a63a4f6529 100644 --- a/scripts/tests/api_compare/filter-list +++ b/scripts/tests/api_compare/filter-list @@ -8,5 +8,3 @@ !Filecoin.EthGetTransactionReceipt # TODO(elmattic): https://github.com/ChainSafe/forest/issues/4851 !Filecoin.EthGetLogs -# Enable after Lotus image is upgraded to a release in which F3IntitialPowerTable is hard coded. -!Filecoin.F3GetManifest From c860332a496346c181d5ccab9ae00a3264564f63 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 28 Oct 2024 17:00:18 +0800 Subject: [PATCH 5/6] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1afe9dd2a72e..c15bd6d71efe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,9 @@ ### Added +- [#4937](https://github.com/ChainSafe/forest/pull/4937) Added + `forest-cli f3 manifest` CLI command. + ### Changed ### Removed From ea011d7a30d17d27c9c2ca40fbd0e0898d0a8212 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 28 Oct 2024 21:41:39 +0800 Subject: [PATCH 6/6] replace fancy_duration with humantime --- Cargo.lock | 20 ++++---------------- Cargo.toml | 1 - src/lotus_json/duration.rs | 18 ------------------ templates/cli/f3/manifest.stpl | 18 +++++++++--------- 4 files changed, 13 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3f641f07b423..4f2f1801bbdb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2607,17 +2607,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" -[[package]] -name = "fancy-duration" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3ae60718ae501dca9d27fd0e322683c86a95a1a01fac1807aa2f9b035cc0882" -dependencies = [ - "anyhow", - "lazy_static", - "regex", -] - [[package]] name = "fastrand" version = "1.9.0" @@ -3181,7 +3170,6 @@ dependencies = [ "displaydoc", "ethereum-types", "ez-jsonrpc-types", - "fancy-duration", "fil_actor_account_state", "fil_actor_cron_state", "fil_actor_datacap_state", @@ -5200,9 +5188,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bda4c6077b0b08da2c48b172195795498381a7c8988c9e6212a6c55c5b9bd70" +checksum = "a00419de735aac21d53b0de5ce2c03bd3627277cf471300f27ebc89f7d828047" [[package]] name = "libmimalloc-sys" @@ -7878,9 +7866,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.15" +version = "0.23.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993" +checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" dependencies = [ "log", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index 4f622a7e5168..00840a98de48 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,6 @@ directories = "5" displaydoc = "0.2" ethereum-types = "0.15" ez-jsonrpc-types = "0.3" -fancy-duration = "0.9" fil_actor_account_state = { version = "17.0.3" } fil_actor_cron_state = { version = "17.0.3" } fil_actor_datacap_state = { version = "17.0.3" } diff --git a/src/lotus_json/duration.rs b/src/lotus_json/duration.rs index 70a01e200852..624e6a013774 100644 --- a/src/lotus_json/duration.rs +++ b/src/lotus_json/duration.rs @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0, MIT use super::*; -use fancy_duration::FancyDuration; use std::time::Duration; impl HasLotusJson for Duration { @@ -21,20 +20,3 @@ impl HasLotusJson for Duration { Self::from_nanos(lotus_json) } } - -impl HasLotusJson for FancyDuration { - type LotusJson = u64; - - #[cfg(test)] - fn snapshots() -> Vec<(serde_json::Value, Self)> { - vec![(json!(15000000000_u64), Self(Duration::from_secs(15)))] - } - - fn into_lotus_json(self) -> Self::LotusJson { - self.0.as_nanos() as _ - } - - fn from_lotus_json(lotus_json: Self::LotusJson) -> Self { - Self(Duration::from_nanos(lotus_json)) - } -} diff --git a/templates/cli/f3/manifest.stpl b/templates/cli/f3/manifest.stpl index 3e1a3eb17d5a..23662058774a 100644 --- a/templates/cli/f3/manifest.stpl +++ b/templates/cli/f3/manifest.stpl @@ -7,23 +7,23 @@ Manifest: Network Name: <%= manifest.network_name %> Ignore EC Power: <%= manifest.ignore_ec_power %> Committee Lookback: <%= manifest.committee_lookback %> - Catch Up Alignment: <%= fancy_duration::FancyDuration(manifest.catch_up_alignment).to_string() %> + Catch Up Alignment: <%= humantime::format_duration(manifest.catch_up_alignment).to_string() %> - GPBFT Delta: <%= fancy_duration::FancyDuration(manifest.gpbft.delta).to_string() %> + GPBFT Delta: <%= humantime::format_duration(manifest.gpbft.delta).to_string() %> GPBFT Delta BackOff Exponent: <%= manifest.gpbft.delta_back_off_exponent %> GPBFT Max Lookahead Rounds: <%= manifest.gpbft.max_lookahead_rounds %> - GPBFT Rebroadcast Backoff Base: <%= fancy_duration::FancyDuration(manifest.gpbft.rebroadcast_backoff_base).to_string() %> + GPBFT Rebroadcast Backoff Base: <%= humantime::format_duration(manifest.gpbft.rebroadcast_backoff_base).to_string() %> GPBFT Rebroadcast Backoff Exponent: <%= manifest.gpbft.rebroadcast_backoff_exponent %> GPBFT Rebroadcast Backoff Spread: <%= manifest.gpbft.rebroadcast_backoff_spread %> - GPBFT Rebroadcast Backoff Max: <%= fancy_duration::FancyDuration(manifest.gpbft.rebroadcast_backoff_max).to_string() %> + GPBFT Rebroadcast Backoff Max: <%= humantime::format_duration(manifest.gpbft.rebroadcast_backoff_max).to_string() %> - EC Period: <%= fancy_duration::FancyDuration(manifest.ec.period).to_string() %> + EC Period: <%= humantime::format_duration(manifest.ec.period).to_string() %> EC Finality: <%= manifest.ec.finality %> EC Delay Multiplier: <%= manifest.ec.delay_multiplier %> EC Head Lookback: <%= manifest.ec.head_lookback %> EC Finalize: <%= manifest.ec.finalize %> - Certificate Exchange Client Timeout: <%= fancy_duration::FancyDuration(manifest.certificate_exchange.client_request_timeout).to_string() %> - Certificate Exchange Server Timeout: <%= fancy_duration::FancyDuration(manifest.certificate_exchange.server_request_timeout).to_string() %> - Certificate Exchange Min Poll Interval: <%= fancy_duration::FancyDuration(manifest.certificate_exchange.minimum_poll_interval).to_string() %> - Certificate Exchange Max Poll Interval: <%= fancy_duration::FancyDuration(manifest.certificate_exchange.maximum_poll_interval).to_string() %> + Certificate Exchange Client Timeout: <%= humantime::format_duration(manifest.certificate_exchange.client_request_timeout).to_string() %> + Certificate Exchange Server Timeout: <%= humantime::format_duration(manifest.certificate_exchange.server_request_timeout).to_string() %> + Certificate Exchange Min Poll Interval: <%= humantime::format_duration(manifest.certificate_exchange.minimum_poll_interval).to_string() %> + Certificate Exchange Max Poll Interval: <%= humantime::format_duration(manifest.certificate_exchange.maximum_poll_interval).to_string() %>