Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions linera-service/src/cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1893,6 +1893,7 @@ async fn run(options: &ClientOptions) -> Result<i32, Error> {
no_build,
docker_image_name,
build_mode,
path,
with_faucet,
faucet_chain,
faucet_port,
Expand All @@ -1916,6 +1917,7 @@ async fn run(options: &ClientOptions) -> Result<i32, Error> {
*faucet_port,
*faucet_amount,
*dual_store,
path,
)
.boxed()
.await?;
Expand Down
3 changes: 3 additions & 0 deletions linera-service/src/cli/net_up_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ pub async fn handle_net_up_kubernetes(
faucet_port: NonZeroU16,
faucet_amount: Amount,
dual_store: bool,
path: &Option<String>,
) -> anyhow::Result<()> {
if num_initial_validators < 1 {
panic!("The local test network must have at least one validator.");
Expand All @@ -140,6 +141,7 @@ pub async fn handle_net_up_kubernetes(
let shutdown_notifier = CancellationToken::new();
tokio::spawn(listen_for_shutdown_signals(shutdown_notifier.clone()));

let path_provider = PathProvider::new(path)?;
let config = LocalKubernetesNetConfig {
network: Network::Grpc,
testing_prng_seed,
Expand All @@ -153,6 +155,7 @@ pub async fn handle_net_up_kubernetes(
build_mode,
policy_config,
dual_store,
path_provider,
};
let (mut net, client) = config.instantiate().await?;
let faucet_service = print_messages_and_create_faucet(
Expand Down
30 changes: 16 additions & 14 deletions linera-service/src/cli_wrappers/local_kubernetes_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use linera_base::{
data_types::Amount,
};
use linera_client::client_options::ResourceControlPolicyConfig;
use tempfile::{tempdir, TempDir};
use tokio::process::Command;
#[cfg(with_testing)]
use {linera_base::command::current_binary_parent, tokio::sync::OnceCell};
Expand Down Expand Up @@ -69,6 +68,7 @@ pub struct LocalKubernetesNetConfig {
pub build_mode: BuildMode,
pub policy_config: ResourceControlPolicyConfig,
pub dual_store: bool,
pub path_provider: PathProvider,
}

/// A wrapper of [`LocalKubernetesNetConfig`] to create a shared local Kubernetes network
Expand All @@ -82,7 +82,6 @@ pub struct LocalKubernetesNet {
network: Network,
testing_prng_seed: Option<u64>,
next_client_id: usize,
tmp_dir: Arc<TempDir>,
binaries: BuildArg,
no_build: bool,
docker_image_name: String,
Expand All @@ -92,6 +91,7 @@ pub struct LocalKubernetesNet {
num_initial_validators: usize,
num_shards: usize,
dual_store: bool,
path_provider: PathProvider,
}

#[cfg(with_testing)]
Expand All @@ -114,6 +114,7 @@ impl SharedLocalKubernetesNetTestingConfig {
binaries = BuildArg::Directory(binaries_dir);
}
}
let path_provider = PathProvider::create_temporary_directory().unwrap();
Self(LocalKubernetesNetConfig {
network,
testing_prng_seed: Some(37),
Expand All @@ -127,6 +128,7 @@ impl SharedLocalKubernetesNetTestingConfig {
build_mode: BuildMode::Release,
policy_config: ResourceControlPolicyConfig::Testnet,
dual_store: false,
path_provider,
})
}
}
Expand Down Expand Up @@ -160,6 +162,7 @@ impl LineraNetConfig for LocalKubernetesNetConfig {
self.num_initial_validators,
self.num_shards,
self.dual_store,
self.path_provider,
)?;

let client = net.make_client().await;
Expand Down Expand Up @@ -276,11 +279,8 @@ impl LineraNet for LocalKubernetesNet {
}

async fn make_client(&mut self) -> ClientWrapper {
let path_provider = PathProvider::TemporaryDirectory {
tmp_dir: self.tmp_dir.clone(),
};
let client = ClientWrapper::new(
path_provider,
self.path_provider.clone(),
self.network,
self.testing_prng_seed,
self.next_client_id,
Expand Down Expand Up @@ -340,12 +340,12 @@ impl LocalKubernetesNet {
num_initial_validators: usize,
num_shards: usize,
dual_store: bool,
path_provider: PathProvider,
) -> Result<Self> {
Ok(Self {
network,
testing_prng_seed,
next_client_id: 0,
tmp_dir: Arc::new(tempdir()?),
binaries,
no_build,
docker_image_name,
Expand All @@ -355,19 +355,23 @@ impl LocalKubernetesNet {
num_initial_validators,
num_shards,
dual_store,
path_provider,
})
}

async fn command_for_binary(&self, name: &'static str) -> Result<Command> {
let path = resolve_binary(name, env!("CARGO_PKG_NAME")).await?;
let mut command = Command::new(path);
command.current_dir(self.tmp_dir.path());
command.current_dir(self.path_provider.path());
Ok(command)
}

fn configuration_string(&self, server_number: usize) -> Result<String> {
let n = server_number;
let path = self.tmp_dir.path().join(format!("validator_{n}.toml"));
let path = self
.path_provider
.path()
.join(format!("validator_{n}.toml"));
let port = 19100 + server_number;
let internal_port = 20100;
let metrics_port = 21100;
Expand Down Expand Up @@ -450,13 +454,11 @@ impl LocalKubernetesNet {
.join("kubernetes")
.join("linera-validator")
.join("working");
fs_err::copy(
self.tmp_dir.path().join("genesis.json"),
base_dir.join("genesis.json"),
)?;
let path = self.path_provider.path();
fs_err::copy(path.join("genesis.json"), base_dir.join("genesis.json"))?;

let kubectl_instance_clone = self.kubectl_instance.clone();
let tmp_dir_path_clone = self.tmp_dir.path().to_path_buf();
let tmp_dir_path_clone = path.to_path_buf();
let num_shards = self.num_shards;

let mut validators_initialization_futures = Vec::new();
Expand Down
Loading