Skip to content
Merged
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
90 changes: 36 additions & 54 deletions src/boot_fake_node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn extract_zip(archive_path: &Path) -> Result<()> {
}

#[instrument(level = "trace", skip_all)]
pub fn compile_runtime(path: &Path, release: bool, is_simulation_mode: bool) -> Result<()> {
fn compile_runtime(path: &Path, release: bool, is_simulation_mode: bool) -> Result<()> {
info!("Compiling Hyperdrive...");

// build the packages
Expand Down Expand Up @@ -174,10 +174,7 @@ pub fn get_platform_runtime_name(is_simulation_mode: bool) -> Result<String> {
}

#[instrument(level = "trace", skip_all)]
pub async fn get_runtime_binary(
version: &str,
is_simulation_mode: bool,
) -> Result<(PathBuf, String)> {
async fn get_runtime_binary(version: &str, is_simulation_mode: bool) -> Result<PathBuf> {
let zip_name = get_platform_runtime_name(is_simulation_mode)?;

let version = if version != "latest" {
Expand Down Expand Up @@ -214,7 +211,36 @@ pub async fn get_runtime_binary(
get_runtime_binary_inner(&version, &zip_name, &runtime_dir).await?;
}

Ok((runtime_path, version))
Ok(runtime_path)
}

#[instrument(level = "trace", skip_all)]
pub async fn get_or_build_runtime_binary(
version: &str,
is_simulation_mode: bool,
runtime_path: Option<PathBuf>,
is_release: bool,
) -> Result<PathBuf> {
let runtime_path = match runtime_path {
None => get_runtime_binary(&version, is_simulation_mode).await?,
Some(runtime_path) => {
if !runtime_path.exists() {
return Err(eyre!("--runtime-path {:?} does not exist.", runtime_path));
}
let runtime_path = if runtime_path.is_dir() {
// Compile the runtime binary
compile_runtime(&runtime_path, is_release, is_simulation_mode)?;
runtime_path
.join("target")
.join(if is_release { "release" } else { "debug" })
.join("hyperdrive")
} else {
runtime_path
};
runtime_path
}
};
Ok(runtime_path)
}

#[instrument(level = "trace", skip_all)]
Expand Down Expand Up @@ -425,46 +451,8 @@ pub async fn execute(
verbosity: u8,
mut args: Vec<String>,
) -> Result<()> {
println!("a");
let detached = false; // TODO: to argument?
// TODO: factor out with run_tests?
let (runtime_path, version) = match runtime_path {
None => get_runtime_binary(&version, true).await?,
Some(runtime_path) => {
println!("b");
if !runtime_path.exists() {
return Err(eyre!("--runtime-path {:?} does not exist.", runtime_path));
}
let runtime_path = if runtime_path.is_dir() {
// Compile the runtime binary
compile_runtime(&runtime_path, release, true)?;
runtime_path
.join("target")
.join(if release { "release" } else { "debug" })
.join("hyperdrive")
} else {
runtime_path
};
let Some((output, _)) = build::run_command(
Command::new("bash").args(["-c", &format!("{} --version", runtime_path.display())]),
false,
)?
else {
return Err(eyre!("couldn't get Hyperdrive version"));
};
let version = output
.split('\n')
.nth(0)
//.rev()
//.nth(1)
.unwrap()
.split(' ')
.last()
.unwrap();
(runtime_path, version.to_string())
}
};
let version = version.strip_prefix("v").unwrap_or_else(|| &version);
let runtime_path = get_or_build_runtime_binary(&version, true, runtime_path, release).await?;

let mut task_handles = Vec::new();

Expand Down Expand Up @@ -495,18 +483,12 @@ pub async fn execute(
let _cleanup_context = CleanupContext::new(send_to_cleanup_for_cleanup);

if !fake_node_name.contains(".") {
fake_node_name.push_str(".dev");
fake_node_name.push_str(".os");
}

// boot fakechain
let version = version.parse()?;
let anvil_process = chain::start_chain(
fakechain_port,
recv_kill_in_start_chain,
Some(version),
false,
)
.await?;
let anvil_process =
chain::start_chain(fakechain_port, recv_kill_in_start_chain, false, false).await?;

if let Some(rpc) = rpc {
args.extend_from_slice(&["--rpc".into(), rpc.into()]);
Expand Down
27 changes: 3 additions & 24 deletions src/boot_real_node/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::path::PathBuf;
use std::sync::Arc;

use color_eyre::eyre::{eyre, Result};
use color_eyre::eyre::Result;
use tokio::sync::Mutex;
use tracing::instrument;

use crate::boot_fake_node::{compile_runtime, get_runtime_binary, run_runtime};
use crate::boot_fake_node::{get_or_build_runtime_binary, run_runtime};
use crate::run_tests::cleanup::{cleanup, cleanup_on_signal};
use crate::run_tests::types::*;

Expand All @@ -22,28 +22,7 @@ pub async fn execute(
mut args: Vec<String>,
) -> Result<()> {
let detached = false; // TODO: to argument?
// TODO: factor out with run_tests?
let runtime_path = match runtime_path {
None => {
let (runtime_path, _) = get_runtime_binary(&version, false).await?;
runtime_path
}
Some(runtime_path) => {
if !runtime_path.exists() {
return Err(eyre!("--runtime-path {:?} does not exist.", runtime_path));
}
if runtime_path.is_dir() {
// Compile the runtime binary
compile_runtime(&runtime_path, release, false)?;
runtime_path
.join("target")
.join(if release { "release" } else { "debug" })
.join("hyperdrive")
} else {
runtime_path
}
}
};
let runtime_path = get_or_build_runtime_binary(&version, false, runtime_path, release).await?;

let mut task_handles = Vec::new();

Expand Down
1 change: 1 addition & 0 deletions src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ async fn compile_rust_wasm_process(

// Build the module using Cargo
let mut args = vec![
"+stable",
"build",
"--release",
"--no-default-features",
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/chain/bytecode/deploy-hyperaccount-minter.txt

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/chain/bytecode/deploykinoaccountminter.txt

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/chain/bytecode/hypermap.txt

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/chain/bytecode/kimap.txt

This file was deleted.

1 change: 1 addition & 0 deletions src/chain/bytecode/mint-os.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0x51945447000000000000000000000000000000000044c6b8cb4d8f0f889a3e47664eaeda0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000104094cefed000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000e01dcbd3ed5f709874a1ea7a25677de18c8661c900000000000000000000000000000000000000000000000000000000000000026f7300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000048129fc1c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1 change: 0 additions & 1 deletion src/chain/kinostate/008922d51.json

This file was deleted.

1 change: 0 additions & 1 deletion src/chain/kinostate/c3069a5.json

This file was deleted.

Loading