Skip to content

Commit

Permalink
Merge branch 'main' into hf/hotfix-kit-s
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-frmr committed Mar 17, 2024
2 parents 10174f7 + af8e298 commit 03b0b56
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 33 deletions.
3 changes: 0 additions & 3 deletions kinode/packages/app_store/app_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ pub enum Resp {
}

fn fetch_logs(eth_provider: &eth::Provider, filter: &eth::Filter) -> Vec<eth::Log> {
#[cfg(not(feature = "simulation-mode"))]
loop {
match eth_provider.get_logs(filter) {
Ok(res) => return res,
Expand All @@ -88,7 +87,6 @@ fn fetch_logs(eth_provider: &eth::Provider, filter: &eth::Filter) -> Vec<eth::Lo

#[allow(unused_variables)]
fn subscribe_to_logs(eth_provider: &eth::Provider, filter: eth::Filter) {
#[cfg(not(feature = "simulation-mode"))]
loop {
match eth_provider.subscribe(1, filter.clone()) {
Ok(()) => break,
Expand All @@ -99,7 +97,6 @@ fn subscribe_to_logs(eth_provider: &eth::Provider, filter: eth::Filter) {
}
}
}
#[cfg(not(feature = "simulation-mode"))]
println!("subscribed to logs successfully");
}

Expand Down
2 changes: 0 additions & 2 deletions kinode/packages/kns_indexer/kns_indexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ sol! {
}

fn subscribe_to_logs(eth_provider: &eth::Provider, from_block: u64, filter: eth::Filter) {
#[cfg(not(feature = "simulation-mode"))]
loop {
match eth_provider.subscribe(1, filter.clone().from_block(from_block)) {
Ok(()) => break,
Expand All @@ -110,7 +109,6 @@ fn subscribe_to_logs(eth_provider: &eth::Provider, from_block: u64, filter: eth:
}
}
}
#[cfg(not(feature = "simulation-mode"))]
println!("subscribed to logs successfully");
}

Expand Down
56 changes: 28 additions & 28 deletions kinode/src/kernel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,6 @@ async fn handle_kernel_request(
return;
}
};
let _ = send_to_terminal
.send(t::Printout {
verbosity: 2,
content: format!("killing process {process_id}"),
})
.await;
process_handle.abort();
process_map.remove(&process_id);
caps_oracle
Expand All @@ -484,6 +478,12 @@ async fn handle_kernel_request(
.await
.expect("event loop: fatal: sender died");
if request.expects_response.is_none() {
let _ = send_to_terminal
.send(t::Printout {
verbosity: 2,
content: format!("killing process {process_id}"),
})
.await;
return;
}
let _ = send_to_terminal
Expand Down Expand Up @@ -716,18 +716,19 @@ pub async fn kernel(
let mut is_debug: bool = false;
let mut reboot_processes: Vec<(t::ProcessId, StartProcessMetadata, Vec<u8>)> = vec![];

// filter out OnExit::None processes from process_map
process_map.retain(|_, persisted| !persisted.on_exit.is_none());

for (process_id, persisted) in &process_map {
// runtime extensions will have a bytes_handle of "", because they have no
// WASM code saved in filesystem.
if persisted.on_exit.is_restart() && !persisted.wasm_bytes_handle.is_empty() {
// read wasm bytes directly from vfs
// start process.
let wasm_bytes = match tokio::fs::read(format!(
"{}/{}",
vfs_path, persisted.wasm_bytes_handle
))
.await
{
if persisted.wasm_bytes_handle.is_empty() {
continue;
}
// read wasm bytes directly from vfs
// start process.
let wasm_bytes =
match tokio::fs::read(format!("{}/{}", vfs_path, persisted.wasm_bytes_handle)).await {
Ok(bytes) => bytes,
Err(e) => {
let _ = send_to_terminal
Expand All @@ -742,20 +743,19 @@ pub async fn kernel(
continue;
}
};
reboot_processes.push((
process_id.clone(),
StartProcessMetadata {
source: t::Address {
node: our.name.clone(),
process: KERNEL_PROCESS_ID.clone(),
},
process_id: process_id.clone(),
persisted: persisted.clone(),
reboot: true,
reboot_processes.push((
process_id.clone(),
StartProcessMetadata {
source: t::Address {
node: our.name.clone(),
process: KERNEL_PROCESS_ID.clone(),
},
wasm_bytes,
));
}
process_id: process_id.clone(),
persisted: persisted.clone(),
reboot: true,
},
wasm_bytes,
));
if let t::OnExit::Requests(requests) = &persisted.on_exit {
// if a persisted process had on-death-requests, we should perform them now
// even in death, a process can only message processes it has capabilities for
Expand Down
3 changes: 3 additions & 0 deletions kinode/src/kernel/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,9 @@ pub async fn make_process_loop(
// the process has completed, time to perform cleanup
//

// update metadata to what was mutated by process in store
let metadata = store.data().process.metadata.to_owned();

let our_kernel = t::Address {
node: metadata.our.node.clone(),
process: KERNEL_PROCESS_ID.clone(),
Expand Down
8 changes: 8 additions & 0 deletions lib/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,14 @@ impl OnExit {
}
}

pub fn is_none(&self) -> bool {
match self {
OnExit::None => true,
OnExit::Restart => false,
OnExit::Requests(_) => false,
}
}

pub fn en_wit(&self) -> wit::OnExit {
match self {
OnExit::None => wit::OnExit::None,
Expand Down

0 comments on commit 03b0b56

Please sign in to comment.