mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-11-22 03:04:35 +03:00
first pass: handle multiple wit versions, normalize all version values to u32
This commit is contained in:
parent
eec1581632
commit
15c86f55be
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@ target/
|
||||
wit/
|
||||
**/target/
|
||||
**/wit/
|
||||
**/wit-*/
|
||||
**/*.wasm
|
||||
.vscode
|
||||
.app-signing
|
||||
|
@ -831,7 +831,7 @@ pub fn handle_install(
|
||||
.body(serde_json::to_vec(&kt::KernelCommand::InitializeProcess {
|
||||
id: parsed_new_process_id.clone(),
|
||||
wasm_bytes_handle: wasm_path,
|
||||
wit_version: None,
|
||||
wit_version: None, // TODO get from manifest!!!
|
||||
on_exit: entry.on_exit.clone(),
|
||||
initial_capabilities: HashSet::new(),
|
||||
public: entry.public,
|
||||
|
@ -231,7 +231,7 @@ fn handle_run(our: &Address, process: &ProcessId, args: String) -> anyhow::Resul
|
||||
.body(serde_json::to_vec(&kt::KernelCommand::InitializeProcess {
|
||||
id: parsed_new_process_id.clone(),
|
||||
wasm_bytes_handle: wasm_path.clone(),
|
||||
wit_version: None,
|
||||
wit_version: None, // update this with new versions if desired
|
||||
on_exit: kt::OnExit::None,
|
||||
initial_capabilities: HashSet::new(),
|
||||
public: entry.public,
|
||||
@ -297,10 +297,9 @@ fn handle_run(our: &Address, process: &ProcessId, args: String) -> anyhow::Resul
|
||||
print_to_terminal(
|
||||
3,
|
||||
&format!(
|
||||
"{}: Process {{\n wasm_bytes_handle: {},\n wit_version: {},\n on_exit: {:?},\n public: {}\n capabilities: {}\n}}",
|
||||
"{}: Process {{\n wasm_bytes_handle: {},\n on_exit: {:?},\n public: {}\n capabilities: {}\n}}",
|
||||
parsed_new_process_id.clone(),
|
||||
wasm_path.clone(),
|
||||
"None",
|
||||
kt::OnExit::None,
|
||||
entry.public,
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ mod standard_host;
|
||||
|
||||
const PROCESS_CHANNEL_CAPACITY: usize = 100;
|
||||
|
||||
const DEFAULT_WIT_VERSION: u32 = 0;
|
||||
pub const LATEST_WIT_VERSION: u32 = 0;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct StartProcessMetadata {
|
||||
@ -606,10 +606,7 @@ async fn start_process(
|
||||
process: id.clone(),
|
||||
},
|
||||
wasm_bytes_handle: process_metadata.persisted.wasm_bytes_handle.clone(),
|
||||
wit_version: process_metadata
|
||||
.persisted
|
||||
.wit_version
|
||||
.unwrap_or(DEFAULT_WIT_VERSION),
|
||||
wit_version: process_metadata.persisted.wit_version,
|
||||
on_exit: process_metadata.persisted.on_exit.clone(),
|
||||
public: process_metadata.persisted.public,
|
||||
};
|
||||
|
@ -734,7 +734,7 @@ pub async fn make_process_loop(
|
||||
body: serde_json::to_vec(&t::KernelCommand::InitializeProcess {
|
||||
id: metadata.our.process.clone(),
|
||||
wasm_bytes_handle: metadata.wasm_bytes_handle,
|
||||
wit_version: Some(metadata.wit_version),
|
||||
wit_version: metadata.wit_version,
|
||||
on_exit: metadata.on_exit,
|
||||
initial_capabilities,
|
||||
public: metadata.public,
|
||||
|
@ -267,7 +267,7 @@ impl StandardHost for process::ProcessWasi {
|
||||
body: serde_json::to_vec(&t::KernelCommand::InitializeProcess {
|
||||
id: new_process_id.clone(),
|
||||
wasm_bytes_handle: wasm_path,
|
||||
wit_version: Some(self.process.metadata.wit_version),
|
||||
wit_version: self.process.metadata.wit_version,
|
||||
on_exit: t::OnExit::de_wit(on_exit),
|
||||
initial_capabilities: request_capabilities
|
||||
.iter()
|
||||
|
@ -358,7 +358,7 @@ async fn bootstrap(
|
||||
.entry(ProcessId::new(Some("kernel"), "distro", "sys"))
|
||||
.or_insert(PersistedProcess {
|
||||
wasm_bytes_handle: "".into(),
|
||||
wit_version: None,
|
||||
wit_version: Some(crate::kernel::LATEST_WIT_VERSION),
|
||||
on_exit: OnExit::Restart,
|
||||
capabilities: runtime_caps.clone(),
|
||||
public: false,
|
||||
@ -368,7 +368,7 @@ async fn bootstrap(
|
||||
.entry(ProcessId::new(Some("net"), "distro", "sys"))
|
||||
.or_insert(PersistedProcess {
|
||||
wasm_bytes_handle: "".into(),
|
||||
wit_version: None,
|
||||
wit_version: Some(crate::kernel::LATEST_WIT_VERSION),
|
||||
on_exit: OnExit::Restart,
|
||||
capabilities: runtime_caps.clone(),
|
||||
public: false,
|
||||
@ -379,7 +379,7 @@ async fn bootstrap(
|
||||
.entry(runtime_module.0)
|
||||
.or_insert(PersistedProcess {
|
||||
wasm_bytes_handle: "".into(),
|
||||
wit_version: None,
|
||||
wit_version: Some(crate::kernel::LATEST_WIT_VERSION),
|
||||
on_exit: OnExit::Restart,
|
||||
capabilities: runtime_caps.clone(),
|
||||
public: runtime_module.3,
|
||||
|
19
lib/build.rs
19
lib/build.rs
@ -1,6 +1,9 @@
|
||||
const KINODE_WIT_URL: &str =
|
||||
const KINODE_WIT_0_7_0_URL: &str =
|
||||
"https://raw.githubusercontent.com/kinode-dao/kinode-wit/aa2c8b11c9171b949d1991c32f58591c0e881f85/kinode.wit";
|
||||
|
||||
const KINODE_WIT_0_8_0_URL: &str =
|
||||
"https://raw.githubusercontent.com/kinode-dao/kinode-wit/v0.8/kinode.wit";
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
if std::env::var("SKIP_BUILD_SCRIPT").is_ok() {
|
||||
println!("Skipping build script");
|
||||
@ -9,11 +12,21 @@ fn main() -> anyhow::Result<()> {
|
||||
|
||||
let pwd = std::env::current_dir()?;
|
||||
|
||||
let wit_file = pwd.join("wit").join("kinode.wit");
|
||||
let wit_file = pwd.join("wit-v0.7.0").join("kinode.wit");
|
||||
|
||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||
rt.block_on(async {
|
||||
kit::build::download_file(KINODE_WIT_URL, &wit_file)
|
||||
kit::build::download_file(KINODE_WIT_0_7_0_URL, &wit_file)
|
||||
.await
|
||||
.map_err(|e| anyhow::anyhow!("{:?}", e))?;
|
||||
Ok::<(), anyhow::Error>(())
|
||||
})?;
|
||||
|
||||
let wit_file = pwd.join("wit-v0.8.0").join("kinode.wit");
|
||||
|
||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||
rt.block_on(async {
|
||||
kit::build::download_file(KINODE_WIT_0_8_0_URL, &wit_file)
|
||||
.await
|
||||
.map_err(|e| anyhow::anyhow!("{:?}", e))?;
|
||||
Ok(())
|
||||
|
@ -838,7 +838,8 @@ pub struct UnencryptedIdentity {
|
||||
pub struct ProcessMetadata {
|
||||
pub our: Address,
|
||||
pub wasm_bytes_handle: String,
|
||||
pub wit_version: u32,
|
||||
/// if None, use the oldest version: 0.7.0
|
||||
pub wit_version: Option<u32>,
|
||||
pub on_exit: OnExit,
|
||||
pub public: bool,
|
||||
}
|
||||
@ -1019,7 +1020,7 @@ impl std::fmt::Display for PersistedProcess {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"Process {{\n wasm_bytes_handle: {},\n wit_version: {},\n on_exit: {:?},\n public: {}\n capabilities: {}\n}}",
|
||||
"Process {{\n wasm_bytes_handle: {},\n wit_version: {:?},\n on_exit: {:?},\n public: {}\n capabilities: {}\n}}",
|
||||
{
|
||||
if &self.wasm_bytes_handle == "" {
|
||||
"(none, this is a runtime process)"
|
||||
@ -1027,7 +1028,7 @@ impl std::fmt::Display for PersistedProcess {
|
||||
&self.wasm_bytes_handle
|
||||
}
|
||||
},
|
||||
self.wit_version.unwrap_or_default(),
|
||||
self.wit_version,
|
||||
self.on_exit,
|
||||
self.public,
|
||||
{
|
||||
@ -1081,7 +1082,7 @@ pub struct Erc721Properties {
|
||||
pub code_hashes: HashMap<String, String>,
|
||||
pub license: Option<String>,
|
||||
pub screenshots: Option<Vec<String>>,
|
||||
pub wit_version: Option<(u32, u32, u32)>,
|
||||
pub wit_version: Option<u32>,
|
||||
}
|
||||
|
||||
/// the type that gets deserialized from each entry in the array in `manifest.json`
|
||||
|
@ -13,7 +13,17 @@ pub use kinode::process;
|
||||
pub use kinode::process::standard as wit;
|
||||
|
||||
wasmtime::component::bindgen!({
|
||||
path: "wit",
|
||||
path: "wit-v0.7.0",
|
||||
world: "process",
|
||||
async: true,
|
||||
});
|
||||
|
||||
pub mod v0 {
|
||||
pub use kinode::process;
|
||||
pub use kinode::process::standard as wit;
|
||||
wasmtime::component::bindgen!({
|
||||
path: "wit-v0.8.0",
|
||||
world: "process-v0",
|
||||
async: true,
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user