Skip to content

Commit

Permalink
Merge pull request #390 from kinode-dao/develop
Browse files Browse the repository at this point in the history
Develop 0.8.1
  • Loading branch information
dr-frmr authored Jun 11, 2024
2 parents 577ca64 + f2eb9d1 commit 3719ab3
Show file tree
Hide file tree
Showing 19 changed files with 85 additions and 55 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/release_candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ jobs:
- name: build and deploy kinode
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
host: ${{ secrets.SSH_API_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_ED25519KEY }}
key: ${{ secrets.SSH_API_ED25519KEY }}
port: ${{ secrets.SSH_PORT }}
command_timeout: 60m
script: |
cd ~
./build-kinode.sh
curl -X PUT http://localhost:8000/monitor/build-kinode
6 changes: 3 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "kinode_lib"
authors = ["KinodeDAO"]
version = "0.8.0"
version = "0.8.1"
edition = "2021"
description = "A general-purpose sovereign cloud computing platform"
homepage = "https://kinode.org"
Expand Down
2 changes: 1 addition & 1 deletion kinode/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "kinode"
authors = ["KinodeDAO"]
version = "0.8.0"
version = "0.8.1"
edition = "2021"
description = "A general-purpose sovereign cloud computing platform"
homepage = "https://kinode.org"
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion kinode/packages/app_store/pkg/ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport"
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1.00001, viewport-fit=cover" />
<script type="module" crossorigin src="/main:app_store:sys/assets/index-I5kjLT9f.js"></script>
<script type="module" crossorigin src="/main:app_store:sys/assets/index-I7H8IZID.js"></script>
<link rel="stylesheet" crossorigin href="/main:app_store:sys/assets/index-fGthT1qI.css">
</head>

Expand Down
4 changes: 2 additions & 2 deletions kinode/packages/app_store/ui/src/components/InstallButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function InstallButton({ app, isIcon = false, ...props }: Install
const { installApp, getCaps, getMyApp, getMyApps } =
useAppsStore();
const [showModal, setShowModal] = useState(false);
const [caps, setCaps] = useState<string[]>([]);
const [caps, setCaps] = useState<any[]>([]);
const [installing, setInstalling] = useState("");

const onClick = useCallback(async (e: React.MouseEvent<HTMLButtonElement>) => {
Expand Down Expand Up @@ -83,7 +83,7 @@ export default function InstallButton({ app, isIcon = false, ...props }: Install
</h5>
<ul className="flex flex-col items-start">
{caps.map((cap) => (
<li key={cap}>{cap}</li>
<li>{JSON.stringify(cap)}</li>
))}
</ul>
<button type="button" onClick={install}>
Expand Down
4 changes: 2 additions & 2 deletions kinode/packages/app_store/ui/src/types/Apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export interface PackageManifest {
process_wasm_path: string
on_exit: string
request_networking: boolean
request_capabilities: string[]
grant_capabilities: string[]
request_capabilities: any[]
grant_capabilities: any[]
public: boolean
}

Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion kinode/packages/homepage/pkg/ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport"
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1.00001, viewport-fit=cover" />
<script type="module" crossorigin src="/assets/index-BVEbM5H5.js"></script>
<script type="module" crossorigin src="/assets/index-emIdaXB4.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BS5LP50I.css">
</head>

Expand Down
2 changes: 1 addition & 1 deletion kinode/packages/homepage/ui/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport"
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1.00001, viewport-fit=cover" />
<script type="module" crossorigin src="/assets/index-BVEbM5H5.js"></script>
<script type="module" crossorigin src="/assets/index-emIdaXB4.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BS5LP50I.css">
</head>

Expand Down
2 changes: 1 addition & 1 deletion kinode/packages/homepage/ui/src/pages/Homepage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function Homepage() {
{isHosted && <img
src={valetIcon}
className='!w-12 !h-12 !p-1 button icon object-cover'
onClick={() => window.location.href = `https://${our.replace('.os', '')}.hosting.kinode.net/`}
onClick={() => window.location.href = `https://valet.kinode.org/`}
/>}
<span>{our}</span>
<span className='bg-white/10 rounded p-1'>v{version}</span>
Expand Down
55 changes: 34 additions & 21 deletions kinode/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,19 @@ async fn main() {
mpsc::channel(TERMINAL_CHANNEL_CAPACITY);

let our_ip = find_public_ip().await;
let (ws_tcp_handle, ws_flag_used) = setup_networking(ws_networking_port).await;
let (ws_tcp_handle, ws_flag_used) = setup_networking("ws", ws_networking_port).await;
#[cfg(not(feature = "simulation-mode"))]
let (tcp_tcp_handle, tcp_flag_used) = setup_networking(tcp_networking_port).await;
let (tcp_tcp_handle, tcp_flag_used) = setup_networking("tcp", tcp_networking_port).await;

#[cfg(feature = "simulation-mode")]
let (our, encoded_keyfile, decoded_keyfile) = simulate_node(
fake_node_name.cloned(),
password.cloned(),
home_directory_path,
(ws_tcp_handle, ws_flag_used),
(
ws_tcp_handle.expect("need ws networking for simulation mode"),
ws_flag_used,
),
// NOTE: fakenodes only using WS protocol at the moment
fakechain_port,
)
Expand Down Expand Up @@ -499,19 +502,26 @@ async fn set_http_server_port(set_port: Option<&u16>) -> u16 {
/// If a specific port is provided, it attempts to bind to it directly.
/// If no port is provided, it searches for the first available port between 9000 and 65535.
/// Returns a tuple containing the TcpListener and a boolean indicating if a specific port was used.
async fn setup_networking(networking_port: Option<&u16>) -> (tokio::net::TcpListener, bool) {
async fn setup_networking(
protocol: &str,
networking_port: Option<&u16>,
) -> (Option<tokio::net::TcpListener>, bool) {
if let Some(&0) = networking_port {
return (None, true);
}
match networking_port {
Some(port) => {
let listener = http::utils::find_open_port(*port, port + 1)
.await
.expect("port selected with flag could not be bound");
(listener, true)
(Some(listener), true)
}
None => {
let listener = http::utils::find_open_port(9000, 65535)
let min_port = if protocol == "ws" { 9000 } else { 10000 };
let listener = http::utils::find_open_port(min_port, 65535)
.await
.expect("no ports found in range 9000-65535 for kinode networking");
(listener, false)
(Some(listener), false)
}
}
}
Expand Down Expand Up @@ -709,8 +719,8 @@ async fn find_public_ip() -> std::net::Ipv4Addr {
async fn serve_register_fe(
home_directory_path: &str,
our_ip: String,
ws_networking: (tokio::net::TcpListener, bool),
tcp_networking: (tokio::net::TcpListener, bool),
ws_networking: (Option<tokio::net::TcpListener>, bool),
tcp_networking: (Option<tokio::net::TcpListener>, bool),
http_server_port: u16,
maybe_rpc: Option<String>,
) -> (Identity, Vec<u8>, Keyfile) {
Expand All @@ -726,8 +736,8 @@ async fn serve_register_fe(
tx,
kill_rx,
our_ip,
ws_networking,
tcp_networking,
(ws_networking.0.as_ref(), ws_networking.1),
(tcp_networking.0.as_ref(), tcp_networking.1),
http_server_port,
disk_keyfile,
maybe_rpc) => {
Expand All @@ -747,15 +757,18 @@ async fn serve_register_fe(

let _ = kill_tx.send(true);

drop(ws_networking.0);
drop(tcp_networking.0);

(our, encoded_keyfile, decoded_keyfile)
}

#[cfg(not(feature = "simulation-mode"))]
async fn login_with_password(
home_directory_path: &str,
our_ip: String,
ws_networking: (tokio::net::TcpListener, bool),
tcp_networking: (tokio::net::TcpListener, bool),
ws_networking: (Option<tokio::net::TcpListener>, bool),
tcp_networking: (Option<tokio::net::TcpListener>, bool),
maybe_rpc: Option<String>,
password: &str,
) -> (Identity, Vec<u8>, Keyfile) {
Expand Down Expand Up @@ -795,14 +808,14 @@ async fn login_with_password(
&mut our,
kns_address,
provider,
(
ws_networking.0.local_addr().unwrap().port(),
ws_networking.1,
),
(
tcp_networking.0.local_addr().unwrap().port(),
tcp_networking.1,
),
match ws_networking.0 {
Some(listener) => (listener.local_addr().unwrap().port(), ws_networking.1),
None => (0, ws_networking.1),
},
match tcp_networking.0 {
Some(listener) => (listener.local_addr().unwrap().port(), tcp_networking.1),
None => (0, tcp_networking.1),
},
)
.await
.expect("information used to boot does not match information onchain");
Expand Down
4 changes: 2 additions & 2 deletions kinode/src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ pub async fn networking(
"net: fatal error: need at least one networking protocol"
));
}
if ports.contains_key(WS_PROTOCOL) {
if ext.our.ws_routing().is_some() {
tasks.spawn(ws::receiver(ext.clone(), net_data.clone()));
}
if ports.contains_key(TCP_PROTOCOL) {
if ext.our.tcp_routing().is_some() {
tasks.spawn(tcp::receiver(ext.clone(), net_data.clone()));
}
}
Expand Down
5 changes: 4 additions & 1 deletion kinode/src/net/tcp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ pub struct PeerConnection {
}

pub async fn receiver(ext: IdentityExt, data: NetData) -> anyhow::Result<()> {
let tcp_port = ext.our.get_protocol_port(TCP_PROTOCOL).unwrap();
let tcp_port = ext
.our
.get_protocol_port(TCP_PROTOCOL)
.expect("tcp port not found");
let tcp = match TcpListener::bind(format!("0.0.0.0:{tcp_port}")).await {
Ok(tcp) => tcp,
Err(_e) => {
Expand Down
5 changes: 4 additions & 1 deletion kinode/src/net/ws/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ pub struct PeerConnection {
pub type WebSocket = WebSocketStream<MaybeTlsStream<tokio::net::TcpStream>>;

pub async fn receiver(ext: IdentityExt, data: NetData) -> Result<()> {
let ws_port = ext.our.get_protocol_port(WS_PROTOCOL).unwrap();
let ws_port = ext
.our
.get_protocol_port(WS_PROTOCOL)
.expect("ws port not found");
let ws = match TcpListener::bind(format!("0.0.0.0:{ws_port}")).await {
Ok(ws) => ws,
Err(_e) => {
Expand Down
27 changes: 19 additions & 8 deletions kinode/src/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ pub async fn register(
tx: RegistrationSender,
kill_rx: oneshot::Receiver<bool>,
ip: String,
ws_networking: (tokio::net::TcpListener, bool),
tcp_networking: (tokio::net::TcpListener, bool),
ws_networking: (Option<&tokio::net::TcpListener>, bool),
tcp_networking: (Option<&tokio::net::TcpListener>, bool),
http_port: u16,
keyfile: Option<Vec<u8>>,
maybe_rpc: Option<String>,
Expand All @@ -54,11 +54,25 @@ pub async fn register(
let net_keypair = Arc::new(serialized_networking_keypair.as_ref().to_vec());
let tx = Arc::new(tx);

let ws_port = ws_networking.0.local_addr().unwrap().port();
let ws_port = match ws_networking.0 {
Some(listener) => listener.local_addr().unwrap().port(),
None => 0,
};
let ws_flag_used = ws_networking.1;
let tcp_port = tcp_networking.0.local_addr().unwrap().port();
let tcp_port = match tcp_networking.0 {
Some(listener) => listener.local_addr().unwrap().port(),
None => 0,
};
let tcp_flag_used = tcp_networking.1;

let mut ports_map = std::collections::BTreeMap::new();
if ws_port != 0 {
ports_map.insert("ws".to_string(), ws_port);
}
if tcp_port != 0 {
ports_map.insert("tcp".to_string(), tcp_port);
}

// This is a **temporary** identity, passed to the UI.
// If it is confirmed through a /boot or /confirm-change-network-keys,
// then it will be used to replace the current identity.
Expand All @@ -67,10 +81,7 @@ pub async fn register(
name: "".to_string(),
routing: NodeRouting::Both {
ip: ip.clone(),
ports: std::collections::BTreeMap::from([
("ws".to_string(), ws_port),
("tcp".to_string(), tcp_port),
]),
ports: ports_map,
routers: vec![
"default-router-1.os".into(),
"default-router-2.os".into(),
Expand Down
2 changes: 1 addition & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "lib"
authors = ["KinodeDAO"]
version = "0.8.0"
version = "0.8.1"
edition = "2021"
description = "A general-purpose sovereign cloud computing platform"
homepage = "https://kinode.org"
Expand Down
3 changes: 2 additions & 1 deletion scripts/build-release.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def main():
for feature in features:
build_and_move(feature, tmp_dir, architecture, os_name)

print(f"Build and move process completed.\nFind release in {tmp_dir}.")
linked_dir = f"\033]8;;file://{tmp_dir}\033\\{tmp_dir}\033]8;;\033\\"
print(f"Build and move process completed.\nFind release in {linked_dir}.")

if __name__ == "__main__":
main()
Expand Down

0 comments on commit 3719ab3

Please sign in to comment.