Skip to content

Commit

Permalink
Merge pull request #304 from autonomys/update-subspace
Browse files Browse the repository at this point in the history
Update Subspace and drop legacy compatibility code
  • Loading branch information
nazar-pc authored Sep 25, 2024
2 parents ca23a82 + ffa15bd commit 9175fde
Show file tree
Hide file tree
Showing 15 changed files with 80 additions and 225 deletions.
81 changes: 37 additions & 44 deletions Cargo.lock

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "space-acres"
description = "Space Acres is an opinionated GUI application for farming on Autonomys Network"
license = "0BSD"
version = "0.1.36"
version = "0.2.0-pre-release"
authors = ["Nazar Mokrynskyi <[email protected]>"]
repository = "https://github.com/autonomys/space-acres"
edition = "2021"
Expand Down Expand Up @@ -68,14 +68,14 @@ reqwest = { version = "0.12.4", default-features = false, features = ["json", "r
sc-client-api = { git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631", default-features = false }
sc-client-db = { git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631", default-features = false }
sc-consensus-slots = { git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631", default-features = false }
sc-consensus-subspace = { git = "https://github.com/subspace/subspace", rev = "3727d07430d323b5616a3908a2f87762f6acf6fc" }
sc-consensus-subspace = { git = "https://github.com/subspace/subspace", rev = "6dc72222145aaf4ac3d925913b81467eac02f02e" }
sc-informant = { git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631", default-features = false }
sc-network = { git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631", default-features = false }
sc-network-types = { git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631", default-features = false }
sc-rpc = { git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631", default-features = false }
sc-service = { git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631", default-features = false }
sc-storage-monitor = { git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631", default-features = false }
sc-subspace-chain-specs = { git = "https://github.com/subspace/subspace", rev = "3727d07430d323b5616a3908a2f87762f6acf6fc" }
sc-subspace-chain-specs = { git = "https://github.com/subspace/subspace", rev = "6dc72222145aaf4ac3d925913b81467eac02f02e" }
sc-utils = { git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631", default-features = false }
schnellru = "0.2.3"
semver = "1.0.23"
Expand All @@ -85,23 +85,23 @@ simple_moving_average = "1.0.2"
sp-api = { git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631", default-features = false }
sp-blockchain = { git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631", default-features = false }
sp-consensus = { git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631", default-features = false }
sp-consensus-subspace = { git = "https://github.com/subspace/subspace", rev = "3727d07430d323b5616a3908a2f87762f6acf6fc" }
sp-consensus-subspace = { git = "https://github.com/subspace/subspace", rev = "6dc72222145aaf4ac3d925913b81467eac02f02e" }
sp-core = { git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631", default-features = false }
sp-domains-fraud-proof = { git = "https://github.com/subspace/subspace", rev = "3727d07430d323b5616a3908a2f87762f6acf6fc" }
sp-objects = { git = "https://github.com/subspace/subspace", rev = "3727d07430d323b5616a3908a2f87762f6acf6fc" }
sp-domains-fraud-proof = { git = "https://github.com/subspace/subspace", rev = "6dc72222145aaf4ac3d925913b81467eac02f02e" }
sp-objects = { git = "https://github.com/subspace/subspace", rev = "6dc72222145aaf4ac3d925913b81467eac02f02e" }
sp-runtime = { git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631", default-features = false }
subspace-archiving = { git = "https://github.com/subspace/subspace", rev = "3727d07430d323b5616a3908a2f87762f6acf6fc" }
subspace-core-primitives = { git = "https://github.com/subspace/subspace", rev = "3727d07430d323b5616a3908a2f87762f6acf6fc" }
subspace-erasure-coding = { git = "https://github.com/subspace/subspace", rev = "3727d07430d323b5616a3908a2f87762f6acf6fc" }
subspace-fake-runtime-api = { git = "https://github.com/subspace/subspace", rev = "3727d07430d323b5616a3908a2f87762f6acf6fc" }
subspace-farmer = { git = "https://github.com/subspace/subspace", rev = "3727d07430d323b5616a3908a2f87762f6acf6fc", default-features = false }
subspace-farmer-components = { git = "https://github.com/subspace/subspace", rev = "3727d07430d323b5616a3908a2f87762f6acf6fc" }
subspace-networking = { git = "https://github.com/subspace/subspace", rev = "3727d07430d323b5616a3908a2f87762f6acf6fc" }
subspace-proof-of-space = { git = "https://github.com/subspace/subspace", rev = "3727d07430d323b5616a3908a2f87762f6acf6fc" }
subspace-proof-of-space-gpu = { git = "https://github.com/subspace/subspace", rev = "3727d07430d323b5616a3908a2f87762f6acf6fc", optional = true }
subspace-rpc-primitives = { git = "https://github.com/subspace/subspace", rev = "3727d07430d323b5616a3908a2f87762f6acf6fc" }
subspace-runtime-primitives = { git = "https://github.com/subspace/subspace", rev = "3727d07430d323b5616a3908a2f87762f6acf6fc" }
subspace-service = { git = "https://github.com/subspace/subspace", rev = "3727d07430d323b5616a3908a2f87762f6acf6fc" }
subspace-archiving = { git = "https://github.com/subspace/subspace", rev = "6dc72222145aaf4ac3d925913b81467eac02f02e" }
subspace-core-primitives = { git = "https://github.com/subspace/subspace", rev = "6dc72222145aaf4ac3d925913b81467eac02f02e" }
subspace-erasure-coding = { git = "https://github.com/subspace/subspace", rev = "6dc72222145aaf4ac3d925913b81467eac02f02e" }
subspace-fake-runtime-api = { git = "https://github.com/subspace/subspace", rev = "6dc72222145aaf4ac3d925913b81467eac02f02e" }
subspace-farmer = { git = "https://github.com/subspace/subspace", rev = "6dc72222145aaf4ac3d925913b81467eac02f02e", default-features = false }
subspace-farmer-components = { git = "https://github.com/subspace/subspace", rev = "6dc72222145aaf4ac3d925913b81467eac02f02e" }
subspace-networking = { git = "https://github.com/subspace/subspace", rev = "6dc72222145aaf4ac3d925913b81467eac02f02e" }
subspace-proof-of-space = { git = "https://github.com/subspace/subspace", rev = "6dc72222145aaf4ac3d925913b81467eac02f02e" }
subspace-proof-of-space-gpu = { git = "https://github.com/subspace/subspace", rev = "6dc72222145aaf4ac3d925913b81467eac02f02e", optional = true }
subspace-rpc-primitives = { git = "https://github.com/subspace/subspace", rev = "6dc72222145aaf4ac3d925913b81467eac02f02e" }
subspace-runtime-primitives = { git = "https://github.com/subspace/subspace", rev = "6dc72222145aaf4ac3d925913b81467eac02f02e" }
subspace-service = { git = "https://github.com/subspace/subspace", rev = "6dc72222145aaf4ac3d925913b81467eac02f02e" }
supports-color = "3.0.0"
sys-locale = "0.3.1"
tempfile = "3.10.1"
Expand Down
4 changes: 0 additions & 4 deletions res/translations/de-DE/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,8 @@ status_bar_message_configuration_is_invalid = Konfiguration ist ungültig: {$err
status_bar_message_restart_is_needed_for_configuration = Ein Neustart der Anwendung ist erforderlich, damit die Konfigurationsänderungen wirksam werden
status_bar_message_failed_to_save_configuration = Fehler beim Speichern der Konfigurationsänderungen: {$error}
status_bar_message_restarted_after_crash = Space Acres wurde nach einem Absturz automatisch neu gestartet. Überprüfe die Anwendungs- und Systemprotokolle für Details
# TODO: Translate
status_bar_message_unoptimized_node_db = Node database is unoptimized and needs re-syncing for optimal performance
status_bar_button_restart = Neustart
status_bar_button_ok = Ok
# TODO: Translate
status_bar_button_resync_node = Resync node
about_system_information =
Konfigurationsverzeichnis: {$config_directory}
Expand Down
2 changes: 0 additions & 2 deletions res/translations/en/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,8 @@ status_bar_message_configuration_is_invalid = Configuration is invalid: {$error}
status_bar_message_restart_is_needed_for_configuration = Application restart is needed for configuration changes to take effect
status_bar_message_failed_to_save_configuration = Failed to save configuration changes: {$error}
status_bar_message_restarted_after_crash = Space Acres automatically restarted after crash, check application and system logs for details
status_bar_message_unoptimized_node_db = Node database is unoptimized and needs re-syncing for optimal performance
status_bar_button_restart = Restart
status_bar_button_ok = Ok
status_bar_button_resync_node = Resync node
about_system_information =
Config directory: {$config_directory}
Expand Down
2 changes: 0 additions & 2 deletions res/translations/es/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,8 @@ status_bar_message_configuration_is_invalid = La configuración es invalida: {$e
status_bar_message_restart_is_needed_for_configuration = La aplicación necesita reiniciarse para que los cambios tengan efecto
status_bar_message_failed_to_save_configuration = Fallo al guardar los cambios: {$error}
status_bar_message_restarted_after_crash = Space Acres se ha reiniciado automáticamente después de un error, mira la traza de la aplicación y del sistema para más detalles.
status_bar_message_unoptimized_node_db = La base de datos del nodo no está optimizada y necesita resincronizarse para un rendimiento óptimo
status_bar_button_restart = Reiniciar
status_bar_button_ok = Vale
status_bar_button_resync_node = Resincronizar nodo
about_system_information =
Carpeta de configuración: {$config_directory}
Expand Down
4 changes: 1 addition & 3 deletions res/translations/fr/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ running_node_status_syncing_speed_hours_eta = , {NUMBER($a_blocks_per_second, mi
running_node_status_syncing_speed_minutes_eta = , {NUMBER($a_blocks_per_second, minimumFractionDigits: 2, maximumFractionDigits: 2)} blocs/s (~{NUMBER($b_hours_remaining, minimumFractionDigits: 2, maximumFractionDigits: 2)} minutes restantes)
running_node_status_syncing_speed_seconds_eta = , {NUMBER($a_blocks_per_second, minimumFractionDigits: 2, maximumFractionDigits: 2)} blocs/s (~{NUMBER($b_hours_remaining, minimumFractionDigits: 2, maximumFractionDigits: 2)} secondes restantes)
running_node_status_syncing =
{$sync_kind ->
{$sync_kind ->
[dsn] Synchronisation depuis DSN
[regular] Synchronisation régulière
*[unknown] Type de synchronisation inconnu {$sync_kind}
Expand Down Expand Up @@ -188,10 +188,8 @@ status_bar_message_configuration_is_invalid = La configuration est invalide : {$
status_bar_message_restart_is_needed_for_configuration = Redémarrez l'application pour que les modifications de configuration prennent effet
status_bar_message_failed_to_save_configuration = Échec de la sauvegarde de la configuration : {$error}
status_bar_message_restarted_after_crash = Space Acres s'est automatiquement redémarré après un crash. Consultez l'application et le journal système pour plus de détails
status_bar_message_unoptimized_node_db = La base de données du nœud n'est pas optimisée, une resynchronisation est nécessaire pour des performances optimales
status_bar_button_restart = Redémarrer
status_bar_button_ok = OK
status_bar_button_resync_node = Resynchroniser le nœud
about_system_information =
Répertoire de configuration : {$config_directory}
Expand Down
4 changes: 0 additions & 4 deletions res/translations/rs/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,8 @@ status_bar_message_configuration_is_invalid = Konfiguracija je nevažeća: {$err
status_bar_message_restart_is_needed_for_configuration = Potreban je restart aplikacije za primenu promena u konfiguraciji
status_bar_message_failed_to_save_configuration = Nije uspelo čuvanje promena konfiguracije: {$error}
status_bar_message_restarted_after_crash = Space Acres se automatski restartovao nakon kraha, proveri dnevnik aplikacije za više informacija
# TODO: Translate
status_bar_message_unoptimized_node_db = Node database is unoptimized and needs re-syncing for optimal performance
status_bar_button_restart = Ponovo pokreni
status_bar_button_ok = U redu
# TODO: Translate
status_bar_button_resync_node = Resync node
about_system_information =
Konfiguracioni direktorijum: {$config_directory}
Expand Down
2 changes: 0 additions & 2 deletions res/translations/ru-RU/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,8 @@ status_bar_message_configuration_is_invalid = Неверная конфигур
status_bar_message_restart_is_needed_for_configuration = Перезапустите приложение, чтобы изменения конфигурации вступили в силу
status_bar_message_failed_to_save_configuration = Не удалось сохранить изменения конфигурации: {$error}
status_bar_message_restarted_after_crash = Space Acres автоматически перезапускается после сбоя. Подробности можно найти в приложении и системном журнале
status_bar_message_unoptimized_node_db = БД не оптимизирована, нужна ре-синхронизации для оптимальной производительности
status_bar_button_restart = Перезапустить
status_bar_button_ok = Ok
status_bar_button_resync_node = Ресинхронизировать
about_system_information =
Директория конфигурации: {$config_directory}
Expand Down
2 changes: 0 additions & 2 deletions res/translations/zh-CN/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,8 @@ status_bar_message_configuration_is_invalid = 配置不可用: {$error}
status_bar_message_restart_is_needed_for_configuration = 重启以使配置修改生效
status_bar_message_failed_to_save_configuration = 保存配置修改失败: {$error}
status_bar_message_restarted_after_crash = Space Acres在崩溃后自动重启,请在日志中查看详细信息
status_bar_message_unoptimized_node_db = 节点数据库未优化,需要重新同步以达到最优性能
status_bar_button_restart = 重启
status_bar_button_ok = 正常
status_bar_button_resync_node = 重新同步节点
about_system_information =
配置目录: {$config_directory}
Expand Down
33 changes: 4 additions & 29 deletions src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use backoff::ExponentialBackoff;
use future::FutureExt;
use futures::channel::mpsc;
use futures::{future, select, SinkExt, StreamExt};
use sc_subspace_chain_specs::GEMINI_3H_CHAIN_SPEC;
use sc_subspace_chain_specs::DEVNET_CHAIN_SPEC;
use sp_consensus_subspace::ChainConstants;
use std::error::Error;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
Expand Down Expand Up @@ -257,7 +257,6 @@ pub enum BackendNotification {
chain_info: ChainInfo,
chain_constants: ChainConstants,
},
UnoptimizedNodeDb,
Node(NodeNotification),
Farmer(FarmerNotification<FarmIndex>),
Stopped {
Expand Down Expand Up @@ -713,7 +712,8 @@ async fn load_chain_specification(
))
.await?;

let chain_spec = node::load_chain_specification(GEMINI_3H_CHAIN_SPEC.as_bytes())
// TODO: Switch to non-devnet chain spec
let chain_spec = node::load_chain_specification(DEVNET_CHAIN_SPEC.as_bytes())
.map_err(|error| anyhow::anyhow!(error))?;

notifications_sender
Expand Down Expand Up @@ -948,12 +948,6 @@ async fn create_consensus_node(
}
};

if !consensus_node.optimized_node_db() {
notifications_sender
.send(BackendNotification::UnoptimizedNodeDb)
.await?;
}

notifications_sender
.send(BackendNotification::Loading(
LoadingStep::ConsensusNodeCreatedSuccessfully,
Expand Down Expand Up @@ -1124,8 +1118,7 @@ pub async fn wipe(
}))
.await?;

// TODO: Remove "paritydb" once support for upgrade from Gemini 3g is no longer necessary
for subdirectory in &["db", "network", "paritydb"] {
for subdirectory in &["db", "network"] {
let path = path.join(subdirectory);

if fs::try_exists(&path).await.unwrap_or(true) {
Expand All @@ -1151,21 +1144,3 @@ pub async fn wipe(

Ok(())
}

// TODO: This is a temporary upgrade note that should be removed after Gemini 3h
pub fn wipe_node_db(node_path: &Path) {
let node_db_path = node_path.join("db");
let mut attempts = 0_usize;

while node_db_path.exists()
&& let Err(error) = std::fs::remove_dir_all(&node_db_path)
{
warn!(%error, "Failed to remove node `db` directory, trying again in a bit");
std::thread::sleep(Duration::from_secs(1));
attempts += 1;

if attempts >= 100 {
return;
}
}
}
32 changes: 10 additions & 22 deletions src/backend/farmer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub(super) mod maybe_node_client;
use crate::backend::farmer::maybe_node_client::MaybeNodeClient;
use crate::backend::utils::{Handler, HandlerFn};
use crate::backend::PieceGetterWrapper;
use crate::{PosTable, PosTableLegacy};
use crate::PosTable;
use anyhow::anyhow;
use async_lock::{Mutex as AsyncMutex, RwLock as AsyncRwLock};
use bytesize::ByteSize;
Expand Down Expand Up @@ -312,9 +312,9 @@ where
let global_mutex = Arc::default();

#[cfg(feature = "_gpu")]
let mut modern_plotter = None::<Arc<dyn Plotter + Send + Sync>>;
let mut plotter = None::<Arc<dyn Plotter + Send + Sync>>;
#[cfg(not(feature = "_gpu"))]
let modern_plotter = None::<Arc<dyn Plotter + Send + Sync>>;
let plotter = None::<Arc<dyn Plotter + Send + Sync>>;

#[cfg(feature = "cuda")]
{
Expand Down Expand Up @@ -348,26 +348,16 @@ where
)
.map_err(|error| anyhow::anyhow!("Failed to initialize CUDA plotter: {error}"))?;

modern_plotter.replace(Arc::new(cuda_plotter));
plotter.replace(Arc::new(cuda_plotter));
}
}

let legacy_cpu_plotter = Arc::new(CpuPlotter::<_, PosTableLegacy>::new(
piece_getter.clone(),
Arc::clone(&downloading_semaphore),
plotting_thread_pool_manager.clone(),
record_encoding_concurrency,
Arc::clone(&global_mutex),
kzg.clone(),
erasure_coding.clone(),
None,
));
let modern_plotter = if let Some(modern_plotter) = modern_plotter {
let plotter = if let Some(plotter) = plotter {
info!("CPU plotting for v1 farms was disabled due to detected faster plotting with GPU");

modern_plotter
plotter
} else {
let modern_cpu_plotter = Arc::new(CpuPlotter::<_, PosTable>::new(
let cpu_plotter = Arc::new(CpuPlotter::<_, PosTable>::new(
piece_getter.clone(),
downloading_semaphore,
plotting_thread_pool_manager.clone(),
Expand All @@ -377,7 +367,7 @@ where
erasure_coding.clone(),
None,
));
Arc::new(modern_cpu_plotter)
Arc::new(cpu_plotter)
};

let (farms, plotting_delay_senders) = {
Expand All @@ -401,24 +391,22 @@ where
let max_pieces_in_sector = farmer_app_info.protocol_info.max_pieces_in_sector;
let kzg = kzg.clone();
let erasure_coding = erasure_coding.clone();
let plotter_legacy = Arc::clone(&legacy_cpu_plotter);
let plotter = Arc::clone(&modern_plotter);
let plotter = Arc::clone(&plotter);
let global_mutex = Arc::clone(&global_mutex);
let faster_read_sector_record_chunks_mode_barrier =
Arc::clone(&faster_read_sector_record_chunks_mode_barrier);
let faster_read_sector_record_chunks_mode_concurrency =
Arc::clone(&faster_read_sector_record_chunks_mode_concurrency);

async move {
let farm_fut = SingleDiskFarm::new::<_, PosTableLegacy, PosTable>(
let farm_fut = SingleDiskFarm::new::<_, PosTable>(
SingleDiskFarmOptions {
directory: disk_farm.directory.clone(),
farmer_app_info,
allocated_space: disk_farm.allocated_space,
max_pieces_in_sector,
node_client,
reward_address,
plotter_legacy,
plotter,
kzg,
erasure_coding,
Expand Down
Loading

0 comments on commit 9175fde

Please sign in to comment.