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(system-service-deployer): introduce new system service deployment system [fixes NET-487] #1623

Merged
merged 27 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
75 changes: 75 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ members = [
"script-storage",
"spell-storage",
"particle-execution",
"crates/system-service-deployer"
kmd-fl marked this conversation as resolved.
Show resolved Hide resolved
]
exclude = [
"particle-node/tests/tetraplets",
Expand Down Expand Up @@ -87,6 +88,7 @@ connection-pool = { path = "connection-pool" }
script-storage = { path = "script-storage" }
spell-storage = { path = "spell-storage" }
particle-execution = { path = "particle-execution" }
system-service-deployer = { path = "crates/system-service-deployer" }

# spell
fluence-spell-dtos = "=0.5.11"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test:
cargo test --release

server:
RUST_LOG="info,tide=off,tracing=off,avm_server=off,run-console=debug" \
RUST_LOG="info,tide=off,tracing=off,avm_server=off,run-console=debug,system_service_deployer=debug,sorcerer::spell_builtins=debug,sorcerer=debug" \
cargo run --release -p particle-node

server-debug:
Expand Down
20 changes: 20 additions & 0 deletions crates/server-config/src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,23 @@ pub fn default_max_builtin_metrics_storage_size() -> usize {
pub fn default_allowed_binaries() -> Vec<String> {
vec!["/usr/bin/curl".to_string(), "/usr/bin/ipfs".to_string()]
}

pub fn default_ipfs_multiaddr() -> String {
"/dns4/ipfs.fluence.dev/tcp/5001".to_string()
}

pub fn default_spell_period_sec() -> u32 {
121
kmd-fl marked this conversation as resolved.
Show resolved Hide resolved
}

pub fn default_deal_network_api_endpoint() -> String {
"https://testnet.aurora.dev".to_string()
}

pub fn default_deal_contract_address_hex() -> String {
"0xb497e025D3095A197E30Ca84DEc36a637E649868".to_string()
}

pub fn default_deal_contract_block_hex() -> String {
"0x75f3fbc".to_string()
kmd-fl marked this conversation as resolved.
Show resolved Hide resolved
}
2 changes: 2 additions & 0 deletions crates/server-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ mod network_config;
mod node_config;
mod resolved_config;
mod services_config;
mod system_services_config;

pub use defaults::{builtins_base_dir, *};
pub use resolved_config::load_config;
Expand All @@ -54,3 +55,4 @@ pub use resolved_config::LogFormat;
pub use resolved_config::TracingConfig;
pub use resolved_config::{ResolvedConfig, UnresolvedConfig};
pub use services_config::ServicesConfig;
pub use system_services_config::{AquaIpfsConfig, DeciderConfig, SystemServicesConfig};
7 changes: 7 additions & 0 deletions crates/server-config/src/node_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use fs_utils::to_abs_path;
use particle_protocol::ProtocolConfig;

use crate::keys::{decode_key, decode_secret_key, load_key};
use crate::system_services_config::SystemServicesConfig;
use crate::{BootstrapConfig, KademliaConfig};

use super::defaults::*;
Expand Down Expand Up @@ -140,6 +141,9 @@ pub struct UnresolvedNodeConfig {

#[serde(default = "default_allowed_binaries")]
pub allowed_binaries: Vec<String>,

#[serde(default)]
pub system_services_config: SystemServicesConfig,
}

impl UnresolvedNodeConfig {
Expand Down Expand Up @@ -192,6 +196,7 @@ impl UnresolvedNodeConfig {
transport_config: self.transport_config,
listen_config: self.listen_config,
allowed_binaries: self.allowed_binaries,
system_services_config: self.system_services_config,
};

Ok(result)
Expand Down Expand Up @@ -275,6 +280,8 @@ pub struct NodeConfig {
pub management_peer_id: PeerId,

pub allowed_binaries: Vec<String>,

pub system_services_config: SystemServicesConfig,
}

#[derive(Clone, Deserialize, Serialize, Derivative, Copy)]
Expand Down
73 changes: 73 additions & 0 deletions crates/server-config/src/system_services_config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright 2023 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

use super::defaults::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Serialize, Deserialize, Debug, Default)]
pub struct SystemServicesConfig {
#[serde(default)]
pub aqua_ipfs: AquaIpfsConfig,
#[serde(default)]
pub decider: DeciderConfig,
}

#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct AquaIpfsConfig {
#[serde(default = "default_ipfs_multiaddr")]
pub external_api_multiaddr: String,
#[serde(default = "default_ipfs_multiaddr")]
pub local_api_multiaddr: String,
}

impl Default for AquaIpfsConfig {
fn default() -> Self {
Self {
external_api_multiaddr: default_ipfs_multiaddr(),
local_api_multiaddr: default_ipfs_multiaddr(),
}
}
}

#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct DeciderConfig {
#[serde(default = "default_spell_period_sec")]
pub decider_period_sec: u32,
#[serde(default = "default_spell_period_sec")]
pub worker_period_sec: u32,
#[serde(default = "default_ipfs_multiaddr")]
pub worker_ipfs_multiaddr: String,
// FIXME: I think these fields should not have default values, but it's only for now
kmd-fl marked this conversation as resolved.
Show resolved Hide resolved
#[serde(default = "default_deal_network_api_endpoint")]
pub network_api_endpoint: String,
#[serde(default = "default_deal_contract_address_hex")]
pub contract_address_hex: String,
#[serde(default = "default_deal_contract_block_hex")]
pub contract_block_hex: String,
}

impl Default for DeciderConfig {
fn default() -> Self {
Self {
decider_period_sec: default_spell_period_sec(),
worker_period_sec: default_spell_period_sec(),
worker_ipfs_multiaddr: default_ipfs_multiaddr(),
network_api_endpoint: default_deal_network_api_endpoint(),
contract_address_hex: default_deal_contract_address_hex(),
contract_block_hex: default_deal_contract_block_hex(),
}
}
}
33 changes: 33 additions & 0 deletions crates/system-service-deployer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "system-service-deployer"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
aqua-ipfs-distro-test = "=0.5.12-1"
decider-distro-test = "=0.4.8-3"
registry-distro-test = "=0.8.4-2"
trust-graph-distro-test = "=0.4.1-3"

maplit = { workspace = true }
toml = { workspace = true }
fluence-app-service = { workspace = true }
particle-modules = { workspace = true }
particle-services = { workspace = true }
eyre = {workspace = true}
libp2p = { workspace = true }
service-modules = { workspace = true }
log = { workspace = true }
serde_json = { workspace = true }
serde = { workspace = true }
fluence-spell-dtos = { workspace = true }
sorcerer = { workspace = true }
particle-execution = { workspace = true }
particle-args = { workspace = true }
spell-storage = { workspace = true }
spell-event-bus = { workspace = true }
now-millis = { workspace = true }
server-config = { workspace = true }

Loading
Loading