diff --git a/Cargo.lock b/Cargo.lock index abdb791..29a3aea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1973,7 +1973,7 @@ checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" [[package]] name = "cross-domain-message-gossip" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "futures", "parity-scale-codec", @@ -2460,7 +2460,7 @@ dependencies = [ [[package]] name = "domain-block-preprocessor" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "async-trait", "domain-runtime-primitives", @@ -2488,7 +2488,7 @@ dependencies = [ [[package]] name = "domain-runtime-primitives" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "fp-account", "frame-support", @@ -3227,6 +3227,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "fs4" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d15c33be2d8e5bc0e6229c8c20905d69d6074c92c64c9b3485560b6d6dc1b68" +dependencies = [ + "rustix 0.38.31", + "windows-sys 0.52.0", +] + [[package]] name = "funty" version = "2.0.0" @@ -6608,7 +6618,7 @@ dependencies = [ [[package]] name = "orml-vesting" version = "0.4.1-dev" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "frame-support", "frame-system", @@ -6660,7 +6670,7 @@ dependencies = [ [[package]] name = "pallet-domains" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "domain-runtime-primitives", "frame-benchmarking", @@ -6686,7 +6696,7 @@ dependencies = [ [[package]] name = "pallet-messenger" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "frame-benchmarking", "frame-support", @@ -6697,6 +6707,7 @@ dependencies = [ "sp-core", "sp-domains", "sp-messenger", + "sp-mmr-primitives", "sp-runtime", "sp-std", "sp-trie", @@ -6723,7 +6734,7 @@ dependencies = [ [[package]] name = "pallet-offences-subspace" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "frame-support", "frame-system", @@ -6737,7 +6748,7 @@ dependencies = [ [[package]] name = "pallet-rewards" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "frame-support", "frame-system", @@ -6749,8 +6760,9 @@ dependencies = [ [[package]] name = "pallet-runtime-configs" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "parity-scale-codec", @@ -6762,7 +6774,7 @@ dependencies = [ [[package]] name = "pallet-subspace" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "frame-benchmarking", "frame-support", @@ -6785,7 +6797,7 @@ dependencies = [ [[package]] name = "pallet-subspace-mmr" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "frame-support", "frame-system", @@ -6837,7 +6849,7 @@ dependencies = [ [[package]] name = "pallet-transaction-fees" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "frame-support", "frame-system", @@ -6893,7 +6905,7 @@ dependencies = [ [[package]] name = "pallet-transporter" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "domain-runtime-primitives", "frame-benchmarking", @@ -8421,7 +8433,7 @@ dependencies = [ [[package]] name = "sc-consensus-subspace" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "async-trait", "futures", @@ -8461,7 +8473,7 @@ dependencies = [ [[package]] name = "sc-consensus-subspace-rpc" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "async-oneshot", "futures", @@ -8489,6 +8501,24 @@ dependencies = [ "tracing", ] +[[package]] +name = "sc-domains" +version = "0.1.0" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" +dependencies = [ + "sc-client-api", + "sc-executor", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-domains", + "sp-externalities", + "sp-io", + "sp-messenger-host-functions", + "sp-runtime", + "sp-subspace-mmr", +] + [[package]] name = "sc-executor" version = "0.10.0-dev" @@ -8813,7 +8843,7 @@ dependencies = [ [[package]] name = "sc-proof-of-time" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "atomic", "core_affinity", @@ -8836,6 +8866,7 @@ dependencies = [ "sp-runtime", "subspace-core-primitives", "subspace-proof-of-time", + "thread-priority", "tracing", ] @@ -9024,7 +9055,7 @@ version = "0.1.0" source = "git+https://github.com/subspace/polkadot-sdk?rev=d6b500960579d73c43fc4ef550b703acfa61c4c8#d6b500960579d73c43fc4ef550b703acfa61c4c8" dependencies = [ "clap 4.4.18", - "fs4", + "fs4 0.7.0", "log", "sp-core", "thiserror", @@ -9034,7 +9065,7 @@ dependencies = [ [[package]] name = "sc-subspace-block-relay" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "async-channel", "async-trait", @@ -9059,7 +9090,7 @@ dependencies = [ [[package]] name = "sc-subspace-chain-specs" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" [[package]] name = "sc-sysinfo" @@ -9785,7 +9816,7 @@ dependencies = [ [[package]] name = "sp-block-fees" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "async-trait", "domain-runtime-primitives", @@ -9879,7 +9910,7 @@ dependencies = [ [[package]] name = "sp-consensus-subspace" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "async-trait", "log", @@ -10015,7 +10046,7 @@ dependencies = [ [[package]] name = "sp-domain-digests" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "parity-scale-codec", "sp-runtime", @@ -10024,7 +10055,7 @@ dependencies = [ [[package]] name = "sp-domains" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "blake2 0.10.6", "domain-runtime-primitives", @@ -10056,7 +10087,7 @@ dependencies = [ [[package]] name = "sp-domains-fraud-proof" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "domain-block-preprocessor", "domain-runtime-primitives", @@ -10088,7 +10119,7 @@ dependencies = [ [[package]] name = "sp-executive" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "async-trait", "parity-scale-codec", @@ -10180,7 +10211,7 @@ dependencies = [ [[package]] name = "sp-messenger" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "frame-support", "hash-db", @@ -10191,11 +10222,32 @@ dependencies = [ "sp-api", "sp-core", "sp-domains", + "sp-mmr-primitives", "sp-runtime", "sp-std", "sp-trie", ] +[[package]] +name = "sp-messenger-host-functions" +version = "0.1.0" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" +dependencies = [ + "domain-block-preprocessor", + "parity-scale-codec", + "sc-executor", + "scale-info", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-domains", + "sp-externalities", + "sp-messenger", + "sp-runtime", + "sp-runtime-interface", + "sp-std", +] + [[package]] name = "sp-metadata-ir" version = "0.1.0" @@ -10240,7 +10292,7 @@ dependencies = [ [[package]] name = "sp-objects" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "sp-api", "sp-std", @@ -10428,13 +10480,15 @@ dependencies = [ [[package]] name = "sp-subspace-mmr" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "parity-scale-codec", "scale-info", + "sp-api", "sp-blockchain", "sp-core", "sp-externalities", + "sp-mmr-primitives", "sp-runtime", "sp-runtime-interface", "sp-std", @@ -10571,11 +10625,12 @@ dependencies = [ [[package]] name = "space-acres" -version = "0.1.3" +version = "0.1.4" dependencies = [ "anyhow", "arc-swap", "async-trait", + "backoff", "bytesize", "clap 4.4.18", "dark-light", @@ -10584,7 +10639,7 @@ dependencies = [ "event-listener-primitives", "file-rotate", "frame-system", - "fs4", + "fs4 0.7.0", "futures", "gtk4", "hex", @@ -10627,6 +10682,7 @@ dependencies = [ "subspace-service", "supports-color", "thiserror", + "thread-priority", "tokio", "tracing", "tracing-subscriber 0.3.18", @@ -10757,7 +10813,7 @@ dependencies = [ [[package]] name = "subspace-archiving" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "parity-scale-codec", "rayon", @@ -10770,7 +10826,7 @@ dependencies = [ [[package]] name = "subspace-core-primitives" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "blake3", "derive_more", @@ -10793,7 +10849,7 @@ dependencies = [ [[package]] name = "subspace-erasure-coding" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "kzg", "rust-kzg-blst", @@ -10803,12 +10859,13 @@ dependencies = [ [[package]] name = "subspace-farmer" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "anyhow", "async-lock 3.3.0", "async-trait", "atomic", + "backoff", "base58", "blake2 0.10.6", "blake3", @@ -10818,7 +10875,7 @@ dependencies = [ "derive_more", "event-listener-primitives", "fdlimit", - "fs4", + "fs4 0.8.0", "futures", "hex", "hwlocality", @@ -10849,6 +10906,7 @@ dependencies = [ "supports-color", "tempfile", "thiserror", + "thread-priority", "tokio", "tracing", "tracing-subscriber 0.3.18", @@ -10859,13 +10917,13 @@ dependencies = [ [[package]] name = "subspace-farmer-components" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "async-lock 3.3.0", "async-trait", "backoff", "bitvec", - "fs2", + "fs4 0.8.0", "futures", "hex", "libc", @@ -10890,7 +10948,7 @@ dependencies = [ [[package]] name = "subspace-metrics" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "actix-web", "prometheus", @@ -10901,7 +10959,7 @@ dependencies = [ [[package]] name = "subspace-networking" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "async-mutex", "async-trait", @@ -10911,7 +10969,7 @@ dependencies = [ "derive_more", "either", "event-listener-primitives", - "fs2", + "fs4 0.8.0", "futures", "futures-timer", "hex", @@ -10939,7 +10997,7 @@ dependencies = [ [[package]] name = "subspace-proof-of-space" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "chacha20", "derive_more", @@ -10952,7 +11010,7 @@ dependencies = [ [[package]] name = "subspace-proof-of-time" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "aes", "subspace-core-primitives", @@ -10962,7 +11020,7 @@ dependencies = [ [[package]] name = "subspace-rpc-primitives" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "hex", "serde", @@ -10974,7 +11032,7 @@ dependencies = [ [[package]] name = "subspace-runtime" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "domain-runtime-primitives", "frame-benchmarking", @@ -11011,6 +11069,7 @@ dependencies = [ "sp-domains-fraud-proof", "sp-inherents", "sp-messenger", + "sp-messenger-host-functions", "sp-mmr-primitives", "sp-objects", "sp-offchain", @@ -11028,7 +11087,7 @@ dependencies = [ [[package]] name = "subspace-runtime-primitives" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "pallet-transaction-payment", "sp-core", @@ -11040,7 +11099,7 @@ dependencies = [ [[package]] name = "subspace-service" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "async-trait", "cross-domain-message-gossip", @@ -11063,6 +11122,7 @@ dependencies = [ "sc-consensus-slots", "sc-consensus-subspace", "sc-consensus-subspace-rpc", + "sc-domains", "sc-executor", "sc-informant", "sc-network", @@ -11090,6 +11150,8 @@ dependencies = [ "sp-domains-fraud-proof", "sp-externalities", "sp-io", + "sp-messenger", + "sp-messenger-host-functions", "sp-mmr-primitives", "sp-objects", "sp-offchain", @@ -11114,7 +11176,7 @@ dependencies = [ [[package]] name = "subspace-verification" version = "0.1.0" -source = "git+https://github.com/subspace/subspace?rev=a41b193837d8a57e2749cae30f21bee729cfb165#a41b193837d8a57e2749cae30f21bee729cfb165" +source = "git+https://github.com/subspace/subspace?rev=1fd384b489e816679a95333b3ff3d9a2d2d8b0a1#1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" dependencies = [ "parity-scale-codec", "schnorrkel", @@ -11359,6 +11421,20 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "thread-priority" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a617e9eeeb20448b01a8e2427fb80dfbc9c49d79a1de3b11f25731edbf547e3c" +dependencies = [ + "bitflags 2.4.2", + "cfg-if", + "libc", + "log", + "rustversion", + "winapi", +] + [[package]] name = "thread_local" version = "1.1.7" diff --git a/Cargo.toml b/Cargo.toml index 8f2c129..b215776 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "space-acres" description = "Space Acres is an opinionated GUI application for farming on Subspace Network" license = "0BSD" -version = "0.1.3" +version = "0.1.4" authors = ["Nazar Mokrynskyi "] repository = "https://github.com/subspace/space-acres" edition = "2021" @@ -32,6 +32,7 @@ product-name = "Space Acres" anyhow = "1.0.79" arc-swap = "1.6.0" async-trait = "0.1.77" +backoff = { version = "0.4.0", features = ["futures", "tokio"] } bytesize = "1.3.0" clap = { version = "4.4.18", features = ["derive"] } dark-light = "1.0.0" @@ -63,27 +64,28 @@ sc-informant = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500 sc-network = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8", default-features = false } sc-service = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8", default-features = false } sc-storage-monitor = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8", default-features = false } -sc-subspace-chain-specs = { git = "https://github.com/subspace/subspace", rev = "a41b193837d8a57e2749cae30f21bee729cfb165" } +sc-subspace-chain-specs = { git = "https://github.com/subspace/subspace", rev = "1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" } semver = "1.0.21" serde = { version = "1.0.196", features = ["derive"]} serde_json = "1.0.113" simple_moving_average = "1.0.2" sp-core = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8", default-features = false } -sp-consensus-subspace = { git = "https://github.com/subspace/subspace", rev = "a41b193837d8a57e2749cae30f21bee729cfb165" } -sp-domains-fraud-proof = { git = "https://github.com/subspace/subspace", rev = "a41b193837d8a57e2749cae30f21bee729cfb165" } +sp-consensus-subspace = { git = "https://github.com/subspace/subspace", rev = "1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" } +sp-domains-fraud-proof = { git = "https://github.com/subspace/subspace", rev = "1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" } sp-runtime = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8", default-features = false } -subspace-core-primitives = { git = "https://github.com/subspace/subspace", rev = "a41b193837d8a57e2749cae30f21bee729cfb165" } -subspace-erasure-coding = { git = "https://github.com/subspace/subspace", rev = "a41b193837d8a57e2749cae30f21bee729cfb165" } -subspace-farmer = { git = "https://github.com/subspace/subspace", rev = "a41b193837d8a57e2749cae30f21bee729cfb165", default-features = false } -subspace-farmer-components = { git = "https://github.com/subspace/subspace", rev = "a41b193837d8a57e2749cae30f21bee729cfb165" } -subspace-networking = { git = "https://github.com/subspace/subspace", rev = "a41b193837d8a57e2749cae30f21bee729cfb165" } -subspace-proof-of-space = { git = "https://github.com/subspace/subspace", rev = "a41b193837d8a57e2749cae30f21bee729cfb165" } -subspace-rpc-primitives = { git = "https://github.com/subspace/subspace", rev = "a41b193837d8a57e2749cae30f21bee729cfb165" } -subspace-runtime = { git = "https://github.com/subspace/subspace", rev = "a41b193837d8a57e2749cae30f21bee729cfb165" } -subspace-runtime-primitives = { git = "https://github.com/subspace/subspace", rev = "a41b193837d8a57e2749cae30f21bee729cfb165" } -subspace-service = { git = "https://github.com/subspace/subspace", rev = "a41b193837d8a57e2749cae30f21bee729cfb165" } +subspace-core-primitives = { git = "https://github.com/subspace/subspace", rev = "1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" } +subspace-erasure-coding = { git = "https://github.com/subspace/subspace", rev = "1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" } +subspace-farmer = { git = "https://github.com/subspace/subspace", rev = "1fd384b489e816679a95333b3ff3d9a2d2d8b0a1", default-features = false } +subspace-farmer-components = { git = "https://github.com/subspace/subspace", rev = "1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" } +subspace-networking = { git = "https://github.com/subspace/subspace", rev = "1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" } +subspace-proof-of-space = { git = "https://github.com/subspace/subspace", rev = "1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" } +subspace-rpc-primitives = { git = "https://github.com/subspace/subspace", rev = "1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" } +subspace-runtime = { git = "https://github.com/subspace/subspace", rev = "1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" } +subspace-runtime-primitives = { git = "https://github.com/subspace/subspace", rev = "1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" } +subspace-service = { git = "https://github.com/subspace/subspace", rev = "1fd384b489e816679a95333b3ff3d9a2d2d8b0a1" } supports-color = "2.1.0" thiserror = "1.0.56" +thread-priority = "0.16.0" tokio = { version = "1.35.1", features = ["fs", "time"] } tracing = "0.1.40" tracing-subscriber = "0.3.18" diff --git a/src/backend.rs b/src/backend.rs index f5c825c..0f13657 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -13,34 +13,130 @@ use crate::backend::farmer::{ use crate::backend::networking::{create_network, NetworkOptions}; use crate::backend::node::{ dsn_bootstrap_nodes, BlockImported, ChainInfo, ChainSpec, ConsensusNode, - ConsensusNodeCreationError, SyncState, GENESIS_HASH, RPC_PORT, + ConsensusNodeCreationError, SyncState, GENESIS_HASH, }; +use backoff::ExponentialBackoff; use future::FutureExt; use futures::channel::mpsc; use futures::{future, select, SinkExt, StreamExt}; use parking_lot::Mutex; use sc_subspace_chain_specs::GEMINI_3H_CHAIN_SPEC; +use std::error::Error; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use std::path::{Path, PathBuf}; use std::pin::pin; -use std::sync::Arc; -use subspace_core_primitives::{BlockNumber, PublicKey}; +use std::sync::{Arc, Weak}; +use std::time::Duration; +use subspace_core_primitives::crypto::kzg::{embedded_kzg_settings, Kzg}; +use subspace_core_primitives::{BlockNumber, Piece, PieceIndex, PublicKey}; use subspace_farmer::farmer_cache::{FarmerCache, FarmerCacheWorker}; use subspace_farmer::single_disk_farm::SingleDiskFarm; +use subspace_farmer::utils::farmer_piece_getter::{ + DsnCacheRetryPolicy, FarmerPieceGetter, WeakFarmerPieceGetter, +}; +use subspace_farmer::utils::piece_validator::SegmentCommitmentPieceValidator; use subspace_farmer::utils::plotted_pieces::PlottedPieces; use subspace_farmer::utils::run_future_in_dedicated_thread; -use subspace_farmer::NodeRpcClient; +use subspace_farmer_components::PieceGetter; use subspace_networking::libp2p::identity::ed25519::{Keypair, SecretKey}; use subspace_networking::libp2p::multiaddr::Protocol; use subspace_networking::libp2p::Multiaddr; +use subspace_networking::utils::piece_provider::PieceProvider; use subspace_networking::{Node, NodeRunner}; use subspace_runtime_primitives::Balance; +use subspace_service::sync_from_dsn::DsnSyncPieceGetter; use tokio::fs; use tokio::fs::OpenOptions; use tokio::io::AsyncWriteExt; use tokio::runtime::Handle; +use tokio::sync::Semaphore; use tracing::{error, info_span, warn, Instrument}; +/// Get piece retry attempts number. +const PIECE_GETTER_MAX_RETRIES: u16 = 7; +/// Global limit on combined piece getter, a nice number that should result in enough pieces +/// downloading successfully during DSN sync +const PIECE_GETTER_MAX_CONCURRENCY: usize = 512; +/// Defines initial duration between get_piece calls. +const GET_PIECE_INITIAL_INTERVAL: Duration = Duration::from_secs(5); +/// Defines max duration between get_piece calls. +const GET_PIECE_MAX_INTERVAL: Duration = Duration::from_secs(40); + +#[derive(Debug, Clone)] +struct PieceGetterWrapper { + farmer_piece_getter: + FarmerPieceGetter, MaybeNodeRpcClient>, + semaphore: Arc, +} + +#[async_trait::async_trait] +impl DsnSyncPieceGetter for PieceGetterWrapper { + async fn get_piece( + &self, + piece_index: PieceIndex, + ) -> Result, Box> { + let _permit = self.semaphore.acquire().await; + Ok(self.farmer_piece_getter.get_piece_fast(piece_index).await) + } +} + +#[async_trait::async_trait] +impl PieceGetter for PieceGetterWrapper { + async fn get_piece( + &self, + piece_index: PieceIndex, + ) -> Result, Box> { + let _permit = self.semaphore.acquire().await; + self.farmer_piece_getter.get_piece(piece_index).await + } +} + +impl PieceGetterWrapper { + fn new( + farmer_piece_getter: FarmerPieceGetter< + SegmentCommitmentPieceValidator, + MaybeNodeRpcClient, + >, + ) -> Self { + let semaphore = Arc::new(Semaphore::new(PIECE_GETTER_MAX_CONCURRENCY)); + Self { + farmer_piece_getter, + semaphore, + } + } + + fn downgrade(&self) -> WeakPieceGetterWrapper { + WeakPieceGetterWrapper { + farmer_piece_getter: self.farmer_piece_getter.downgrade(), + semaphore: Arc::downgrade(&self.semaphore), + } + } +} + +// TODO: Derive `Debug` after https://github.com/subspace/subspace/pull/2573 +#[derive(Clone)] +struct WeakPieceGetterWrapper { + farmer_piece_getter: WeakFarmerPieceGetter< + SegmentCommitmentPieceValidator, + MaybeNodeRpcClient, + >, + semaphore: Weak, +} + +#[async_trait::async_trait] +impl PieceGetter for WeakPieceGetterWrapper { + async fn get_piece( + &self, + piece_index: PieceIndex, + ) -> Result, Box> { + let Some(semaphore) = self.semaphore.upgrade() else { + return Ok(None); + }; + let _permit = semaphore.acquire().await; + self.farmer_piece_getter.get_piece(piece_index).await + } +} + /// Major steps in application loading progress #[derive(Debug, Clone)] pub enum LoadingStep { @@ -289,12 +385,42 @@ async fn load( ) .await?; + let kzg = Kzg::new(embedded_kzg_settings()); + let piece_provider = PieceProvider::new( + node.clone(), + Some(SegmentCommitmentPieceValidator::new( + node.clone(), + maybe_node_client.clone(), + kzg.clone(), + )), + ); + + let piece_getter = PieceGetterWrapper::new(FarmerPieceGetter::new( + piece_provider, + farmer_cache.clone(), + maybe_node_client.clone(), + Arc::clone(&plotted_pieces), + DsnCacheRetryPolicy { + max_retries: PIECE_GETTER_MAX_RETRIES, + backoff: ExponentialBackoff { + initial_interval: GET_PIECE_INITIAL_INTERVAL, + max_interval: GET_PIECE_MAX_INTERVAL, + // Try until we get a valid piece + max_elapsed_time: None, + multiplier: 1.75, + ..ExponentialBackoff::default() + }, + }, + )); + let create_consensus_node_fut = create_consensus_node( &network_keypair, config.node_path.clone(), config.network.substrate_port, chain_spec, + Arc::new(piece_getter.clone()), node.clone(), + &maybe_node_client, notifications_sender, ); let consensus_node = match create_consensus_node_fut.await? { @@ -310,11 +436,12 @@ async fn load( let farmer = create_farmer( config.reward_address, config.farms.clone(), - node, plotted_pieces, farmer_cache, farmer_cache_worker, - &maybe_node_client, + maybe_node_client, + kzg, + piece_getter, notifications_sender, ) .await?; @@ -714,7 +841,6 @@ async fn create_networking_stack( .await?; let mut network_options = NetworkOptions { - // TODO: Persist keypair on disk keypair: network_keypair.clone(), bootstrap_nodes, listen_on: vec![ @@ -774,12 +900,15 @@ async fn create_networking_stack( )) } +#[allow(clippy::too_many_arguments)] async fn create_consensus_node( network_keypair: &Keypair, node_path: PathBuf, substrate_port: u16, chain_spec: ChainSpec, + piece_getter: Arc, node: Node, + maybe_node_rpc_client: &MaybeNodeRpcClient, notifications_sender: &mut mpsc::Sender, ) -> anyhow::Result { notifications_sender @@ -789,8 +918,15 @@ async fn create_consensus_node( }) .await?; - let create_consensus_node_fut = - node::create_consensus_node(network_keypair, node_path, substrate_port, chain_spec, node); + let create_consensus_node_fut = node::create_consensus_node( + network_keypair, + node_path, + substrate_port, + chain_spec, + piece_getter, + node, + maybe_node_rpc_client, + ); let consensus_node = match create_consensus_node_fut.await { Ok(consensus_node) => consensus_node, Err(ConsensusNodeCreationError::Service(error)) => { @@ -815,11 +951,12 @@ async fn create_consensus_node( async fn create_farmer( reward_address: PublicKey, disk_farms: Vec, - node: Node, plotted_pieces: Arc>>, farmer_cache: FarmerCache, farmer_cache_worker: FarmerCacheWorker, - maybe_node_client: &MaybeNodeRpcClient, + node_client: MaybeNodeRpcClient, + kzg: Kzg, + piece_getter: PieceGetterWrapper, notifications_sender: &mut mpsc::Sender, ) -> anyhow::Result { notifications_sender @@ -829,20 +966,15 @@ async fn create_farmer( }) .await?; - let node_client = NodeRpcClient::new(&format!("ws://127.0.0.1:{RPC_PORT}")).await?; - - // Inject working node client into wrapper we have created before such that networking can respond to incoming - // requests properly - maybe_node_client.inject(node_client.clone()); - let farmer_options = FarmerOptions { reward_address, disk_farms, node_client, - node, plotted_pieces, farmer_cache, farmer_cache_worker, + kzg, + piece_getter, }; let farmer = farmer::create_farmer(farmer_options).await?; diff --git a/src/backend/farmer.rs b/src/backend/farmer.rs index 458d23c..07653b8 100644 --- a/src/backend/farmer.rs +++ b/src/backend/farmer.rs @@ -2,10 +2,10 @@ pub(super) mod maybe_node_client; use crate::backend::farmer::maybe_node_client::MaybeNodeRpcClient; use crate::backend::utils::{Handler, HandlerFn}; +use crate::backend::PieceGetterWrapper; use crate::PosTable; use anyhow::anyhow; use event_listener_primitives::HandlerId; -use futures::channel::oneshot; use futures::future::BoxFuture; use futures::stream::{FuturesOrdered, FuturesUnordered}; use futures::{select, FutureExt, StreamExt}; @@ -14,7 +14,7 @@ use std::num::{NonZeroU8, NonZeroUsize}; use std::path::PathBuf; use std::sync::Arc; use std::{fmt, fs}; -use subspace_core_primitives::crypto::kzg::{embedded_kzg_settings, Kzg}; +use subspace_core_primitives::crypto::kzg::Kzg; use subspace_core_primitives::{PublicKey, Record, SectorIndex}; use subspace_erasure_coding::ErasureCoding; use subspace_farmer::farmer_cache::{FarmerCache, FarmerCacheWorker}; @@ -22,17 +22,14 @@ use subspace_farmer::single_disk_farm::farming::FarmingNotification; use subspace_farmer::single_disk_farm::{ SectorPlottingDetails, SectorUpdate, SingleDiskFarm, SingleDiskFarmError, SingleDiskFarmOptions, }; -use subspace_farmer::utils::farmer_piece_getter::FarmerPieceGetter; -use subspace_farmer::utils::piece_validator::SegmentCommitmentPieceValidator; use subspace_farmer::utils::plotted_pieces::PlottedPieces; use subspace_farmer::utils::{ all_cpu_cores, create_plotting_thread_pool_manager, recommended_number_of_farming_threads, run_future_in_dedicated_thread, thread_pool_core_indices, CpuCoreSet, }; -use subspace_farmer::{NodeClient, NodeRpcClient}; +use subspace_farmer::NodeClient; use subspace_farmer_components::plotting::PlottedSector; -use subspace_networking::utils::piece_provider::PieceProvider; -use subspace_networking::Node; +use thread_priority::ThreadPriority; use tokio::sync::Semaphore; use tracing::{error, info, info_span, Instrument}; @@ -148,11 +145,12 @@ pub struct DiskFarm { pub(super) struct FarmerOptions { pub(super) reward_address: PublicKey, pub(super) disk_farms: Vec, - pub(super) node_client: NodeRpcClient, - pub(super) node: Node, + pub(super) node_client: MaybeNodeRpcClient, + pub(super) piece_getter: PieceGetterWrapper, pub(super) plotted_pieces: Arc>>, pub(super) farmer_cache: FarmerCache, pub(super) farmer_cache_worker: FarmerCacheWorker, + pub(super) kzg: Kzg, } pub(super) async fn create_farmer(farmer_options: FarmerOptions) -> anyhow::Result { @@ -163,10 +161,11 @@ pub(super) async fn create_farmer(farmer_options: FarmerOptions) -> anyhow::Resu reward_address, disk_farms, node_client, - node, + piece_getter, plotted_pieces, farmer_cache, farmer_cache_worker, + kzg, } = farmer_options; if disk_farms.is_empty() { @@ -190,27 +189,11 @@ pub(super) async fn create_farmer(farmer_options: FarmerOptions) -> anyhow::Resu .await .map_err(|error| anyhow::anyhow!(error))?; - let kzg = Kzg::new(embedded_kzg_settings()); let erasure_coding = ErasureCoding::new( NonZeroUsize::new(Record::NUM_S_BUCKETS.next_power_of_two().ilog2() as usize) .expect("Not zero; qed"), ) .map_err(|error| anyhow::anyhow!(error))?; - let piece_provider = PieceProvider::new( - node.clone(), - Some(SegmentCommitmentPieceValidator::new( - node.clone(), - node_client.clone(), - kzg.clone(), - )), - ); - - let piece_getter = Arc::new(FarmerPieceGetter::new( - piece_provider, - farmer_cache.clone(), - node_client.clone(), - Arc::clone(&plotted_pieces), - )); let farmer_cache_worker_fut = Box::pin( farmer_cache_worker @@ -266,14 +249,10 @@ pub(super) async fn create_farmer(farmer_options: FarmerOptions) -> anyhow::Resu plotting_thread_pool_core_indices .into_iter() .zip(replotting_thread_pool_core_indices), + Some(ThreadPriority::Min), )?; - let mut plotting_delay_senders = Vec::with_capacity(disk_farms.len()); - for (disk_farm_index, disk_farm) in disk_farms.into_iter().enumerate() { - let (plotting_delay_sender, plotting_delay_receiver) = oneshot::channel(); - plotting_delay_senders.push(plotting_delay_sender); - let single_disk_farm_fut = SingleDiskFarm::new::<_, _, PosTable>( SingleDiskFarmOptions { directory: disk_farm.directory.clone(), @@ -291,7 +270,6 @@ pub(super) async fn create_farmer(farmer_options: FarmerOptions) -> anyhow::Resu farm_during_initial_plotting, farming_thread_pool_size: recommended_number_of_farming_threads(), plotting_thread_pool_manager: plotting_thread_pool_manager.clone(), - plotting_delay: Some(plotting_delay_receiver), disable_farm_locking: false, }, disk_farm_index, @@ -333,24 +311,20 @@ pub(super) async fn create_farmer(farmer_options: FarmerOptions) -> anyhow::Resu single_disk_farms.push(single_disk_farm); } - let cache_acknowledgement_receiver = farmer_cache - .replace_backing_caches( - single_disk_farms - .iter() - .map(|single_disk_farm| single_disk_farm.piece_cache()) - .collect(), - ) - .await; - - // Wait for cache initialization before starting plotting - tokio::spawn(async move { - if cache_acknowledgement_receiver.await.is_ok() { - for plotting_delay_sender in plotting_delay_senders { - // Doesn't matter if receiver is gone - let _ = plotting_delay_sender.send(()); - } - } - }); + drop( + farmer_cache + .replace_backing_caches( + single_disk_farms + .iter() + .map(|single_disk_farm| single_disk_farm.piece_cache()) + .collect(), + single_disk_farms + .iter() + .map(|single_disk_farm| single_disk_farm.plot_cache()) + .collect(), + ) + .await, + ); // Store piece readers so we can reference them later let piece_readers = single_disk_farms diff --git a/src/backend/node.rs b/src/backend/node.rs index e01c0d9..57c9a4e 100644 --- a/src/backend/node.rs +++ b/src/backend/node.rs @@ -1,5 +1,6 @@ mod utils; +use crate::backend::farmer::maybe_node_client::MaybeNodeRpcClient; use crate::backend::node::utils::account_storage_key; use crate::backend::utils::{Handler, HandlerFn}; use crate::PosTable; @@ -29,6 +30,7 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use std::time::Duration; use subspace_core_primitives::{BlockNumber, PublicKey}; +use subspace_farmer::NodeRpcClient; use subspace_networking::libp2p::identity::ed25519::Keypair; use subspace_networking::libp2p::Multiaddr; use subspace_networking::Node; @@ -38,6 +40,7 @@ use subspace_service::config::{ SubspaceConfiguration, SubspaceNetworking, SubstrateConfiguration, SubstrateNetworkConfiguration, SubstrateRpcConfiguration, }; +use subspace_service::sync_from_dsn::DsnSyncPieceGetter; use subspace_service::{FullClient, NewFull}; use tokio::fs; use tokio::time::MissedTickBehavior; @@ -424,7 +427,9 @@ pub(super) async fn create_consensus_node( base_path: PathBuf, substrate_port: u16, chain_spec: ChainSpec, + piece_getter: Arc, node: Node, + maybe_node_rpc_client: &MaybeNodeRpcClient, ) -> Result { set_default_ss58_version(&chain_spec); @@ -459,8 +464,7 @@ pub(super) async fn create_consensus_node( node, bootstrap_nodes: dsn_bootstrap_nodes, }, - // TODO: Custom piece getter - dsn_piece_getter: None, + dsn_piece_getter: Some(piece_getter), sync_from_dsn: true, is_timekeeper: false, timekeeper_cpu_cores: Default::default(), @@ -517,5 +521,17 @@ pub(super) async fn create_consensus_node( sc_service::Error::Other(format!("Failed to start storage monitor: {error:?}")) })?; + let node_client = NodeRpcClient::new(&format!("ws://127.0.0.1:{RPC_PORT}")) + .await + .map_err(|error| { + sc_service::Error::Application( + format!("Failed to connect to internal node RPC: {error}").into(), + ) + })?; + + // Inject working node client into wrapper we have created before such that networking can + // respond to incoming requests properly + maybe_node_rpc_client.inject(node_client); + Ok(ConsensusNode::new(consensus_node, pause_sync, chain_info)) } diff --git a/src/frontend/running.rs b/src/frontend/running.rs index d6a196f..dcb8355 100644 --- a/src/frontend/running.rs +++ b/src/frontend/running.rs @@ -119,7 +119,6 @@ impl Component for RunningView { gtk::Box { set_spacing: 5, - set_tooltip: "Plotting starts after piece cache sync is complete", gtk::Label { set_halign: gtk::Align::Start, @@ -294,13 +293,6 @@ impl RunningView { ); } FarmerNotification::FarmerCacheSyncProgress { progress } => { - let old_synced = self.farmer_state.piece_cache_sync_progress == 100.0; - let new_synced = progress == 100.0; - if old_synced != new_synced { - self.farms - .broadcast(FarmWidgetInput::PieceCacheSynced(new_synced)); - } - self.farmer_state.piece_cache_sync_progress = progress; } }, diff --git a/src/frontend/running/farm.rs b/src/frontend/running/farm.rs index 463a7bb..fe05455 100644 --- a/src/frontend/running/farm.rs +++ b/src/frontend/running/farm.rs @@ -84,7 +84,6 @@ pub(super) enum FarmWidgetInput { update: SectorUpdate, }, FarmingNotification(FarmingNotification), - PieceCacheSynced(bool), NodeSynced(bool), } @@ -97,7 +96,6 @@ pub(super) struct FarmWidget { sector_plotting_time: SingleSumSMA, last_sector_plotted: Option, plotting_state: PlottingState, - is_piece_cache_synced: bool, is_node_synced: bool, farm_during_initial_plotting: bool, sector_rows: gtk::Box, @@ -203,12 +201,8 @@ impl FactoryComponent for FarmWidget { }, #[transition = "SlideUpDown"] - match (self.plotting_state, self.is_piece_cache_synced) { - (_, false) => gtk::Label { - set_halign: gtk::Align::Start, - set_label: "Waiting for piece cache sync", - }, - (PlottingState::Plotting { kind, progress }, _) => gtk::Box { + match self.plotting_state { + PlottingState::Plotting { kind, progress } => gtk::Box { set_orientation: gtk::Orientation::Vertical, set_spacing: 10, @@ -276,7 +270,7 @@ impl FactoryComponent for FarmWidget { set_fraction: progress as f64 / 100.0, }, }, - (PlottingState::Idle, _) => gtk::Box { + PlottingState::Idle => gtk::Box { gtk::Label { #[watch] set_label: if self.is_node_synced { @@ -323,7 +317,6 @@ impl FactoryComponent for FarmWidget { sector_plotting_time: SingleSumSMA::from_zero(Duration::ZERO), last_sector_plotted: None, plotting_state: PlottingState::Idle, - is_piece_cache_synced: false, is_node_synced: false, farm_during_initial_plotting: init.farm_during_initial_plotting, sector_rows, @@ -416,9 +409,6 @@ impl FarmWidget { self.non_fatal_farming_error.replace(error); } }, - FarmWidgetInput::PieceCacheSynced(synced) => { - self.is_piece_cache_synced = synced; - } FarmWidgetInput::NodeSynced(synced) => { self.is_node_synced = synced; }