Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): Introduce ephemeral and persistent storage [fixes NET-759 NET-760] #2091

Merged
merged 53 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
64cd25a
feat(cores): cpu_range set
gurinderu Feb 7, 2024
3db09d2
feat(cores): core manager
gurinderu Feb 7, 2024
5cb2d4f
small improvements
gurinderu Feb 7, 2024
38ad1cc
small improvements
gurinderu Feb 7, 2024
7919443
small improvements
gurinderu Feb 7, 2024
e49b39e
small improvements
gurinderu Feb 7, 2024
a4615f8
small improvements
gurinderu Feb 7, 2024
521f51c
small improvements
gurinderu Feb 7, 2024
511283a
small improvements
gurinderu Feb 9, 2024
a305cdc
small improvements
gurinderu Feb 14, 2024
aa762f5
pin system threads
gurinderu Feb 15, 2024
2631064
pin worker threads
gurinderu Feb 15, 2024
0c83ebe
Fixes
gurinderu Feb 16, 2024
b46d809
Review fixes
gurinderu Feb 17, 2024
ab2a111
Review fixes
gurinderu Feb 17, 2024
a0d9c14
Review fixes
gurinderu Feb 17, 2024
87c162f
Review fixes
gurinderu Feb 17, 2024
ad5b08a
Review fixes
gurinderu Feb 17, 2024
a94f9ea
Review fixes
gurinderu Feb 17, 2024
ac29233
Review fixes
gurinderu Feb 17, 2024
2a0f414
Review fixes
gurinderu Feb 17, 2024
50bc707
use CUID
gurinderu Feb 19, 2024
cf56e80
feat(config): Introduce ephemeral and persistent storage
gurinderu Feb 20, 2024
76707d3
fix
gurinderu Feb 20, 2024
92ed7e7
fix
gurinderu Feb 20, 2024
ff66e95
fix
gurinderu Feb 20, 2024
4e0fa00
change layout + inject persistent dirs into services
gurinderu Feb 21, 2024
4f5b165
fix test
gurinderu Feb 21, 2024
f460be5
Expose applied config in CreatedSwarm
gurinderu Feb 21, 2024
3588d1f
rename stepper
gurinderu Feb 21, 2024
0dca554
fix
gurinderu Feb 21, 2024
d8faecc
fix fd in core manager
gurinderu Feb 22, 2024
110f582
fix fd in core manager
gurinderu Feb 22, 2024
11774a4
fix fd in core manager
gurinderu Feb 22, 2024
2273627
update spell
gurinderu Feb 22, 2024
b9f9037
update spell
gurinderu Feb 22, 2024
c86d210
shutdown workers runtime at shutdown signal
gurinderu Feb 22, 2024
d89b0e3
fix
gurinderu Feb 23, 2024
4da2cbc
fluence-spell-dtos update
gurinderu Feb 22, 2024
0b2ef54
fluence-spell-dtos update
gurinderu Feb 22, 2024
d242556
fix
gurinderu Feb 23, 2024
e677009
fix
gurinderu Feb 23, 2024
8fbec0e
fix
gurinderu Feb 23, 2024
b46c33a
fix
gurinderu Feb 23, 2024
e8ca4a2
fix
gurinderu Feb 23, 2024
e472b53
fix
gurinderu Feb 23, 2024
7f1f757
fix
gurinderu Feb 23, 2024
3f418a9
fix
gurinderu Feb 23, 2024
09aa8aa
fix
gurinderu Feb 23, 2024
3a1544e
update fluence-spell-dtos
gurinderu Feb 23, 2024
6bde1de
make injecttion async
gurinderu Feb 23, 2024
e0c1067
fix(deps): decider 0.6.7
folex Feb 23, 2024
399c474
fixes
gurinderu Feb 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
230 changes: 152 additions & 78 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ types = { path = "crates/types" }
core-manager = { path = "crates/core-manager" }

# spell
fluence-spell-dtos = "=0.7.3"
fluence-spell-distro = "=0.7.3"
fluence-spell-dtos = "=0.7.4"
fluence-spell-distro = "=0.7.4"

# marine
fluence-app-service = { version = "0.33.0" }
fluence-app-service = "0.35.0"
marine-utils = "0.5.1"
marine-it-parser = "0.15.1"
marine-it-parser = "0.16.0"

# avm
avm-server = "=0.35.0"
Expand Down
8 changes: 2 additions & 6 deletions crates/core-manager/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,8 @@ impl CoreManagerFunctions for PersistentCoreManager {
drop(lock);
let toml = toml::to_string_pretty(&persistent_state)
.map_err(|err| PersistError::SerializationError { err })?;
let exists = self.file_path.exists();
let mut file = if exists {
File::open(self.file_path.clone()).map_err(|err| PersistError::IoError { err })?
} else {
File::create(self.file_path.clone()).map_err(|err| PersistError::IoError { err })?
};
let mut file =
File::create(self.file_path.clone()).map_err(|err| PersistError::IoError { err })?;
file.write(toml.as_bytes())
.map_err(|err| PersistError::IoError { err })?;
Ok(())
Expand Down
53 changes: 42 additions & 11 deletions crates/created-swarm/src/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ use futures::stream::iter;
use nox::{Connectivity, Node};
use particle_protocol::ProtocolConfig;
use server_config::{
system_services_config, BootstrapConfig, ChainListenerConfig, UnresolvedConfig,
persistent_dir, system_services_config, BootstrapConfig, ChainListenerConfig, ResolvedConfig,
UnresolvedConfig,
};
use tempfile::TempDir;
use test_constants::{EXECUTION_TIMEOUT, TRANSPORT_TIMEOUT};
Expand All @@ -52,12 +53,14 @@ const HEALTH_CHECK_POLLING_INTERVAL: Duration = Duration::from_millis(100);

// default bound on the number of computations it can perform simultaneously
const DEFAULT_PARALLELISM: usize = 2;

#[allow(clippy::upper_case_acronyms)]
type AVM = aquamarine::AVMRunner;

#[derive(Derivative)]
#[derivative(Debug)]
pub struct CreatedSwarm {
pub config: ResolvedConfig,
pub peer_id: PeerId,
pub multiaddr: Multiaddr,
// tmp dir, must be cleaned
Expand Down Expand Up @@ -157,7 +160,17 @@ where
F: (FnMut(
Vec<Multiaddr>,
Multiaddr,
) -> BoxFuture<'static, (PeerId, Box<Node<RT>>, KeyPair, SwarmConfig, Span)>)
) -> BoxFuture<
'static,
(
PeerId,
Box<Node<RT>>,
KeyPair,
SwarmConfig,
ResolvedConfig,
Span,
),
>)
+ 'static
+ Send,
M: (FnMut() -> Multiaddr) + 'static + Send,
Expand All @@ -175,7 +188,8 @@ where
let bootstraps = bootstraps(addrs);
let create_node_future = create_node(bootstraps, addr.clone());
async move {
let (peer_id, node, management_keypair, config, span) = create_node_future.await;
let (peer_id, node, management_keypair, input_config, resolved_config, span) =
create_node_future.await;
let connectivity = node.connectivity.clone();
let aquamarine_api = node.aquamarine_api.clone();
let started_node = node
Expand All @@ -187,9 +201,10 @@ where
.http_listen_addr
.expect("could not take http listen addr");
CreatedSwarm {
config: resolved_config,
peer_id,
multiaddr: config.listen_on,
tmp_dir: config.tmp_dir.clone(),
multiaddr: input_config.listen_on,
tmp_dir: input_config.tmp_dir.clone(),
management_keypair,
exit_outlet: started_node.exit_outlet,
connectivity,
Expand Down Expand Up @@ -306,7 +321,8 @@ pub fn aqua_vm_config(
peer_id, tmp_dir, ..
} = vm_config;

let air_interpreter = air_interpreter_path(&tmp_dir);
let persistent_dir = persistent_dir(&tmp_dir);
let air_interpreter = air_interpreter_path(&persistent_dir);
write_default_air_interpreter(&air_interpreter).expect("write air interpreter");

VmConfig::new(peer_id, air_interpreter, None)
Expand All @@ -315,7 +331,14 @@ pub fn aqua_vm_config(
pub async fn create_swarm_with_runtime<RT: AquaRuntime>(
config: SwarmConfig,
vm_config: impl Fn(BaseVmConfig) -> RT::Config,
) -> (PeerId, Box<Node<RT>>, KeyPair, SwarmConfig, Span) {
) -> (
PeerId,
Box<Node<RT>>,
KeyPair,
SwarmConfig,
ResolvedConfig,
Span,
) {
use serde_json::json;

let format = match &config.keypair {
Expand All @@ -332,7 +355,7 @@ pub async fn create_swarm_with_runtime<RT: AquaRuntime>(
let node_listen_span = tracing::info_span!(parent: &parent_span, "config");
let node_creation_span = tracing::info_span!(parent: &parent_span, "config");

let (node, management_kp) = config_apply_span.in_scope(||{
let (node, management_kp, resolved_config) = config_apply_span.in_scope(|| {
let tmp_dir = config.tmp_dir.path().to_path_buf();

let node_config = json!({
Expand Down Expand Up @@ -419,15 +442,15 @@ pub async fn create_swarm_with_runtime<RT: AquaRuntime>(
.extend(config.extend_system_services.clone());
let core_manager = Arc::new(DummyCoreManager::default().into());
let node = Node::new(
resolved,
resolved.clone(),
core_manager,
vm_config,
data_store_config,
"some version",
"some version",
system_service_distros,
);
(node, management_kp)
(node, management_kp, resolved)
});

let mut node = node
Expand All @@ -442,13 +465,21 @@ pub async fn create_swarm_with_runtime<RT: AquaRuntime>(
node,
management_kp,
config,
resolved_config,
parent_span.clone(),
)
})
}

pub async fn create_swarm(
config: SwarmConfig,
) -> (PeerId, Box<Node<AVMRunner>>, KeyPair, SwarmConfig, Span) {
) -> (
PeerId,
Box<Node<AVMRunner>>,
KeyPair,
SwarmConfig,
ResolvedConfig,
Span,
) {
create_swarm_with_runtime(config, aqua_vm_config).await
}
Loading
Loading