diff --git a/Cargo.lock b/Cargo.lock index 4505e78707..34fcff383f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2994,7 +2994,7 @@ dependencies = [ [[package]] name = "extension-storage" -version = "1.2.4-rc.1" +version = "1.2.4-rc.2" dependencies = [ "bip39", "console_error_panic_hook", @@ -5568,7 +5568,7 @@ dependencies = [ [[package]] name = "mix-fetch-wasm" -version = "1.2.4-rc.1" +version = "1.2.4-rc.2" dependencies = [ "async-trait", "futures", @@ -6270,7 +6270,7 @@ dependencies = [ [[package]] name = "nym-client-wasm" -version = "1.2.4-rc.1" +version = "1.2.4-rc.2" dependencies = [ "anyhow", "futures", @@ -6972,7 +6972,7 @@ dependencies = [ [[package]] name = "nym-node-tester-wasm" -version = "1.2.4-rc.1" +version = "1.2.4-rc.2" dependencies = [ "futures", "js-sys", diff --git a/common/wireguard/src/platform/linux/tun_device.rs b/common/wireguard/src/platform/linux/tun_device.rs index 022e07462b..d0596f81c8 100644 --- a/common/wireguard/src/platform/linux/tun_device.rs +++ b/common/wireguard/src/platform/linux/tun_device.rs @@ -134,13 +134,15 @@ impl TunDevice { nat_table.nat_table.insert(src_addr, tag); } - self.tun - .write_all(&packet) - .await - .tap_err(|err| { - log::error!("iface: write error: {err}"); - }) - .ok(); + tokio::time::timeout( + std::time::Duration::from_millis(1000), + self.tun.write_all(&packet), + ) + .await + .tap_err(|err| { + log::error!("iface: write error: {err}"); + }) + .ok(); } // Receive reponse packets from the wild internet @@ -163,14 +165,25 @@ impl TunDevice { match self.routing_mode { // This is how wireguard does it, by consulting the AllowedIPs table. RoutingMode::AllowedIps(ref peers_by_ip) => { - let peers = peers_by_ip.peers_by_ip.as_ref().lock().await; + let Ok(peers) = tokio::time::timeout( + std::time::Duration::from_millis(1000), + peers_by_ip.peers_by_ip.as_ref().lock(), + ) + .await + else { + log::error!("Failed to lock peer"); + return; + }; + if let Some(peer_tx) = peers.longest_match(dst_addr).map(|(_, tx)| tx) { log::info!("Forward packet to wg tunnel"); - peer_tx - .send(Event::Ip(packet.to_vec().into())) - .await - .tap_err(|err| log::error!("{err}")) - .ok(); + tokio::time::timeout( + std::time::Duration::from_millis(1000), + peer_tx.send(Event::Ip(packet.to_vec().into())), + ) + .await + .tap_err(|err| log::error!("Failed to forward packet to wg tunnel: {err}")) + .ok(); return; } } @@ -179,11 +192,13 @@ impl TunDevice { RoutingMode::Nat(ref nat_table) => { if let Some(tag) = nat_table.nat_table.get(&dst_addr) { log::info!("Forward packet with tag: {tag}"); - self.tun_task_response_tx - .send((*tag, packet.to_vec())) - .await - .tap_err(|err| log::error!("{err}")) - .ok(); + tokio::time::timeout( + std::time::Duration::from_millis(1000), + self.tun_task_response_tx.send((*tag, packet.to_vec())), + ) + .await + .tap_err(|err| log::error!("Failed to foward packet with tag: {err}")) + .ok(); return; } } @@ -201,20 +216,32 @@ impl TunDevice { len = self.tun.read(&mut buf) => match len { Ok(len) => { let packet = &buf[..len]; - self.handle_tun_read(packet).await; + tokio::time::timeout( + std::time::Duration::from_millis(1000), + self.handle_tun_read(packet) + ) + .await + .tap_err(|_err| log::error!("Failed: handle_tun_read timeout")) + .ok(); }, Err(err) => { log::info!("iface: read error: {err}"); - break; + // break; } }, // Writing to the TUN device Some(data) = self.tun_task_rx.recv() => { - self.handle_tun_write(data).await; + tokio::time::timeout( + std::time::Duration::from_millis(1000), + self.handle_tun_write(data) + ) + .await + .tap_err(|_err| log::error!("Failed: handle_tun_write timeout")) + .ok(); } } } - log::info!("TUN device shutting down"); + // log::info!("TUN device shutting down"); } pub fn start(self) { diff --git a/documentation/dev-portal/src/shipyard/guidelines.md b/documentation/dev-portal/src/shipyard/guidelines.md index ac8a7b18a8..1f4a901f7a 100644 --- a/documentation/dev-portal/src/shipyard/guidelines.md +++ b/documentation/dev-portal/src/shipyard/guidelines.md @@ -10,3 +10,6 @@ We expect to see the following for submissions: - If a UI-based solution: - How to run it locally? We are happy to also accept staging deployments as part of the submission (e.g. via Vercel) but this does not replace being able to run it locally. - Please make sure that your application works on commonly reproducible system environments (e.g. if you’re developing on Artix Linux please check for the necessary dependencies for more common-place OSes such as Debian, or Arch). If you are developing on Windows please make sure that it works on non-Windows machines also. Where possible please try to include build and install instructions for a variety of OSes. + +## How to submit? +Please follow the instructions [here](https://github.com/nymtech/nym/discussions/4143). \ No newline at end of file diff --git a/documentation/docs/src/introduction.md b/documentation/docs/src/introduction.md index c9b4c4a7d5..f3fcdccb62 100644 --- a/documentation/docs/src/introduction.md +++ b/documentation/docs/src/introduction.md @@ -1,12 +1,12 @@ # Introduction -This is Nym's technical documentation, containing information and setup guides about the various pieces of Nym software such as different mixnet infrastructure nodes, application clients, and existing applications like the desktop wallet and mixnet explorer. +This is Nym's technical documentation, containing information and setup guides about the various pieces of Nym software such as different Mixnet infrastructure nodes, application clients, and existing applications like the desktop wallet and Mixnet explorer. -If you are new to Nym and want to learn about the mixnet, explore kickstart options and demos, learn how to integrate with the network, and follow developer tutorials check out the [Developer Portal](https://nymtech.net/developers/) where you can find also our [FAQ section](https://nymtech.net/developers/faq/general-faq.md). +If you are new to Nym and want to learn about the Mixnet, explore kickstart options and demos, learn how to integrate with the network, and follow developer tutorials check out the [Developer Portal](https://nymtech.net/developers/) where you can find also our [FAQ section](https://nymtech.net/developers/faq/general-faq.html). -If you are looking for information and setup guides for the various pieces of Nym mixnet infrastructure (mix nodes, gateways and network requesters) and Nyx blockchain validators see the **new [Operators Guides](https://nymtech.net/operators)** book. +If you are looking for information and setup guides for the various pieces of Nym Mixnet infrastructure (Mix Nodes, Gateways and Network Requesters) and Nyx blockchain validators see the **new [Operators Guides](https://nymtech.net/operators)** book. -If you're specically looking for TypeScript/JavaScript related information such as SDKs to build your own tools, step-by-step tutorials, live playgrounds and more - make sure to check out the **new [TS SDK Handbook](https://sdk.nymtech.net/)** ! +If you're specifically looking for TypeScript/JavaScript related information such as SDKs to build your own tools, step-by-step tutorials, live playgrounds and more - make sure to check out the **new [TS SDK Handbook](https://sdk.nymtech.net/)** ! ## Popular pages **Network Architecture:** diff --git a/documentation/operators/src/faq/mixnodes-faq.md b/documentation/operators/src/faq/mixnodes-faq.md index c6b81bb3f0..c20d4d26cf 100644 --- a/documentation/operators/src/faq/mixnodes-faq.md +++ b/documentation/operators/src/faq/mixnodes-faq.md @@ -44,6 +44,14 @@ Nope, anyone can run a Mix Node. Purely reliant on the node's reputation (self s ### What's the difference between NYM and NYX? ---> +### Why some Nyx blockchain operations take one hour and others are instant? + +This is based on the definition in [Nym's CosmWasm](https://github.com/nymtech/nym/tree/develop/common/cosmwasm-smart-contracts) smart contracts code. + +Whatever is defined as [a pending epoch event](https://github.com/nymtech/nym/blob/b07627d57e075b6de35b4b1a84927578c3172811/common/cosmwasm-smart-contracts/mixnet-contract/src/pending_events.rs#L35-L103) will get resolved at the end of the current epoch. + +And whatever is defined as [a pending interval event](https://github.com/nymtech/nym/blob/b07627d57e075b6de35b4b1a84927578c3172811/common/cosmwasm-smart-contracts/mixnet-contract/src/pending_events.rs#L145-L172) will get resolved at the end of the current interval. + ### Can I run a validator? We are currently working towards building up a closed set of reputable validators. You can ask us for coins to get in, but please don't be offended if we say no - validators are part of our system's core security and we are starting out with people we already know or who have a solid reputation. diff --git a/documentation/operators/src/faq/smoosh-faq.md b/documentation/operators/src/faq/smoosh-faq.md index cb58eb5bc4..1c9232cb1a 100644 --- a/documentation/operators/src/faq/smoosh-faq.md +++ b/documentation/operators/src/faq/smoosh-faq.md @@ -4,7 +4,8 @@ > -- Harry Halpin, Nym CEO
-This page refer to the changes which are planned to take place over Q3 and Q4 2023. As this is a transition period in the beginning (Q3 2023) the [Mix Nodes FAQ page](./mixnodes-faq.md) holds more answers to the current setup as project Smoosh refers to the eventual setup. As project Smoosh gets progressively implemented the answers on this page will become to be more relevant to the current state and eventually this FAQ page will be merged with the still relevant parts of the main Mix Nodes FAQ page. + +This page refer to the changes which are planned to take place over Q3 and Q4 2023. As this is a transition period in the beginning (Q3 2023) the [Mix Nodes FAQ page](mixnodes-faq.md) holds more answers to the current setup as project Smoosh refers to the eventual setup. As project Smoosh gets progressively implemented the answers on this page will become to be more relevant to the current state and eventually this FAQ page will be merged with the still relevant parts of the main Mix Nodes FAQ page. If any questions are not answered or it's not clear for you in which stage project Smoosh is right now, please reach out in Node Operators [Matrix room](https://matrix.to/#/#operators:nymtech.chat). diff --git a/documentation/operators/src/introduction.md b/documentation/operators/src/introduction.md index e12497a791..5d1df7d880 100644 --- a/documentation/operators/src/introduction.md +++ b/documentation/operators/src/introduction.md @@ -1,6 +1,6 @@ # Introduction -This is Nym's Operators guide, containing information and setup guides for the various pieces of Nym mixnet infrastructure (mix node, gateway and network requester) and Nyx blockchain validators. +This is Nym's Operators guide, containing information and setup guides for the various pieces of Nym Mixnet infrastructure (Mix Node, Gateway and Network Requester) and Nyx blockchain validators. If you are new to Nym and want to learn about the mixnet, explore kickstart options and demos, learn how to integrate with the network, and follow developer tutorials check out the [Developer Portal](https://nymtech.net/developers/). diff --git a/documentation/operators/src/legal/exit-gateway.md b/documentation/operators/src/legal/exit-gateway.md index 8d0ac54682..cc1e6bb81b 100644 --- a/documentation/operators/src/legal/exit-gateway.md +++ b/documentation/operators/src/legal/exit-gateway.md @@ -8,7 +8,7 @@ This page is a part of Nym Community Legal Forum and its content is composed by This document presents an initiative to further support Nym’s mission of allowing privacy for everyone everywhere. This would be achieved with the support of Nym node operators operating Gateways and opening these to any online service. Such setup needs a **clear policy**, one which will remain the **same for all operators** running Nym nodes. The [proposed **Exit policy**](https://nymtech.net/.wellknown/network-requester/exit-policy.txt) is a combination of two existing safeguards: [Tor Null ‘deny’ list](https://tornull.org/) and [Tor reduced policy](https://tornull.org/tor-reduced-reduced-exit-policy.php). -All the technical changes on the side of Nym nodes - ***Project Smoosh** - are described in the [FAQ section](../faq/smoosh-faq.md). +All the technical changes on the side of Nym nodes - ***Project Smoosh*** - are described in the [FAQ section](../faq/smoosh-faq.md). ```admonish warning Nym core team cannot provide comprehensive legal advice across all jurisdictions. Knowledge and experience with the legalities are being built up with the help of our counsel and with you, the community of Nym node operators. We encourage Nym node operators to join the operator channels ([Element](https://matrix.to/#/#operators:nymtech.chat), [Discord](https://discord.com/invite/nym), [Telegram](https://t.me/nymchan_help_chat)) to share best practices and experiences. @@ -96,7 +96,7 @@ Note that Tor states: * Top 3 advice - Have an abuse response letter - Run relay from a location that is not home - - Read through the legal resources that Tor-supportive lawyers put together: https://www.eff.org/pages/legal-faq-tor-relay-operators or https://www.noisebridge.net/wiki/Noisebridge_Tor/FBI + - Read through the legal resources that Tor-supportive lawyers put together: [www.eff.org/pages/legal-faq-tor-relay-operators](https://www.eff.org/pages/legal-faq-tor-relay-operators) or [www.noisebridge.net/wiki/Noisebridge_Tor/FBI](https://www.noisebridge.net/wiki/Noisebridge_Tor/FBI) * Consult a lawyer / local digital rights association / the EFF prior to operating an exit relay, especially in a place where exit relay operators have been harassed or not operating before. Note that Tor DOES NOT provide legal advice for specific countries. It only provides general advice (itself or in partnership), eventually skewed towards [US audiences](https://www.eff.org/pages/legal-faq-tor-relay-operators). diff --git a/documentation/operators/src/nodes/gateway-setup.md b/documentation/operators/src/nodes/gateway-setup.md index 76aeae2aa9..1f2fe52927 100644 --- a/documentation/operators/src/nodes/gateway-setup.md +++ b/documentation/operators/src/nodes/gateway-setup.md @@ -16,7 +16,7 @@ As a result of [Project Smoosh](../faq/smoosh-faq.md), the current version of `n ## Preliminary steps -Make sure you do the preparation listed in the [preliminary steps page](../preliminary-steps.md) before setting up your gateway. +Make sure you do the preparation listed in the [preliminary steps page](../preliminary-steps.md) before setting up your Gateway. ## Gateway setup @@ -225,19 +225,22 @@ It will look something like this (as `` we used `supergateway`): >>> attempting to sign 2Mf8xYytgEeyJke9LA7TjhHoGQWNBEfgHZtTyy2krFJfGHSiqy7FLgTnauSkQepCZTqKN5Yfi34JQCuog9k6FGA2EjsdpNGAWHZiuUGDipyJ6UksNKRxnFKhYW7ri4MRduyZwbR98y5fQMLAwHne1Tjm9cXYCn8McfigNt77WAYwBk5bRRKmC34BJMmWcAxphcLES2v9RdSR68tkHSpy2C8STfdmAQs3tZg8bJS5Qa8pQdqx14TnfQAPLk3QYCynfUJvgcQTrg29aqCasceGRpKdQ3Tbn81MLXAGAs7JLBbiMEAhCezAr2kEN8kET1q54zXtKz6znTPgeTZoSbP8rzf4k2JKHZYWrHYF9JriXepuZTnyxAKAxvGFPBk8Z6KAQi33NRQkwd7MPyttatHna6kG9x7knffV6ebGzgRBf7NV27LurH8x4L1uUXwm1v1UYCA1WSBQ9Pp2JW69k5v5v7G9gBy8RUcZnMbeL26Qqb8WkuGcmuHhaFfoqSfV7PRHPpPT4M8uRqUyR4bjUtSJJM1yh6QSeZk9BEazzoJqPeYeGoiFDZ3LMj2jesbJweQR4caaYuRczK92UGSSqu9zBKmE45a >>> decoding the message... >>> message to sign: {"nonce":0,"algorithm":"ed25519","message_type":"gateway-bonding","content":{"sender":"n1ewmme88q22l8syvgshqma02jv0vqrug9zq9dy8","proxy":null,"funds":[{"denom":"unym","amount":"100000000"}],"data":{"gateway":{"host":"62.240.134.189","mix_port":1789,"clients_port":9000,"location":"62.240.134.189","sphinx_key":"FKbuN7mPdoCG9jA3CkAfXxC5X4rHhqeMVtmfRtJ3cFZd","identity_key":"3RoAhR8gEdfBETMjm2vbMFzKddxXDdE9ygBAnJHWqSzD","version":"1.1.13"}}}} +>>> The base58-encoded signature is: +2SPDjLjX4b6XEtkgG7yD8Znsb1xycL1edFvRK4JcVnPsM9k6HXEUUeVS6rswRiYxoj1bMgiRKyPDwiksiuyxu8Xi ``` ~~~ * Copy the resulting signature: -``` ->>> The base58-encoded signature is: +```sh +# >>> The base58-encoded signature is: 2SPDjLjX4b6XEtkgG7yD8Znsb1xycL1edFvRK4JcVnPsM9k6HXEUUeVS6rswRiYxoj1bMgiRKyPDwiksiuyxu8Xi ``` * And paste it into the wallet nodal, press `Next` and confirm the transaction. -![Paste Signature](../images/wallet-screenshots/wallet-gateway-sign.png) +![Paste Signature](../images/wallet-screenshots/wallet-gateway-sign.png) +*This image is just an example, copy-paste your own base58-encoded signature* * Your Gateway is now bonded. diff --git a/documentation/operators/src/nodes/mix-node-setup.md b/documentation/operators/src/nodes/mix-node-setup.md index 0644d44452..21516a091f 100644 --- a/documentation/operators/src/nodes/mix-node-setup.md +++ b/documentation/operators/src/nodes/mix-node-setup.md @@ -121,7 +121,7 @@ To initialise, run and bond your Mix Node are the minimum steps to do in order f - [Describe your Mix Node](./mix-node-setup.md#node-description-optional) - [Configure your firewall](./maintenance.md#configure-your-firewall) - [Automate your Mix Node](./maintenance.md#vps-setup-and-automation) -- Set the [ulimit](./maintenance.md#set-the-ulimit-via-systemd-service-file) In case you haven't automated with [systemd](./maintenance.md#set-the-ulimit-on-non-systemd-based-distributions) +- Set the [ulimit](./maintenance.md#set-the-ulimit-via-systemd-service-file), in case you haven't automated with [systemd](./maintenance.md#set-the-ulimit-on-non-systemd-based-distributions) ### Bond via the Desktop wallet (recommended) @@ -141,33 +141,22 @@ It will look something like this: ~~~admonish example collapsible=true title="Console output" ``` -./nym-mixnode sign --id upgrade_test --contract-msg 22Z9wt4PyiBCbMiErxj5bBa4VCCFsjNawZ1KnLyMeV9pMUQGyksRVANbXHjWndMUaXNRnAuEVJW6UCxpRJwZe788hDt4sicsrv7iAXRajEq19cWPVybbUqgeo76wbXbCbRdg1FvVKgYZGZZp8D72p5zWhKSBRD44qgCrqzfV1SkiFEhsvcLUvZATdLRocAUL75KmWivyRiQjCE1XYEWyRH9yvRYn4TymWwrKVDtEB63zhHjATN4QEi2E5qSrSbBcmmqatXsKakbgSbQoLsYygcHx7tkwbQ2HDYzeiKP1t16Rhcjn6Ftc2FuXUNnTcibk2LQ1hiqu3FAq31bHUbzn2wiaPfm4RgqTwGM4eqnjBofwR3251wQSxbYwKUYwGsrkweRcoPuEaovApR9R19oJ7GVG5BrKmFwZWX3XFVuECe8vt1x9MY7DbQ3xhAapsHhThUmzN6JPPU4qbQ3PdMt3YVWy6oRhap97ma2dPMBaidebfgLJizpRU3Yu7mtb6E8vgi5Xnehrgtd35gitoJqJUY5sB1p6TDPd6vk3MVU1zqusrke7Lvrud4xKfCLqp672Bj9eGb2wPwow643CpHuMkhigfSWsv9jDq13d75EGTEiprC2UmWTzCJWHrDH7ka68DZJ5XXAW67DBewu7KUm1jrJkNs55vS83SWwm5RjzQLVhscdtCH1Bamec6uZoFBNVzjs21o7ax2WHDghJpGMxFi6dmdMCZpqn618t4 - - _ __ _ _ _ __ ___ - | '_ \| | | | '_ \ _ \ - | | | | |_| | | | | | | - |_| |_|\__, |_| |_| |_| - |___/ - - (nym-mixnode - version v1.1.29) - - ->>> attempting to sign 22Z9wt4PyiBCbMiErxj5bBa4VCCFsjNawZ1KnLyMeV9pMUQGyksRVANbXHjWndMUaXNRnAuEVJW6UCxpRJwZe788hDt4sicsrv7iAXRajEq19cWPVybbUqgeo76wbXbCbRdg1FvVKgYZGZZp8D72p5zWhKSBRD44qgCrqzfV1SkiFEhsvcLUvZATdLRocAUL75KmWivyRiQjCE1XYEWyRH9yvRYn4TymWwrKVDtEB63zhHjATN4QEi2E5qSrSbBcmmqatXsKakbgSbQoLsYygcHx7tkwbQ2HDYzeiKP1t16Rhcjn6Ftc2FuXUNnTcibk2LQ1hiqu3FAq31bHUbzn2wiaPfm4RgqTwGM4eqnjBofwR3251wQSxbYwKUYwGsrkweRcoPuEaovApR9R19oJ7GVG5BrKmFwZWX3XFVuECe8vt1x9MY7DbQ3xhAapsHhThUmzN6JPPU4qbQ3PdMt3YVWy6oRhap97ma2dPMBaidebfgLJizpRU3Yu7mtb6E8vgi5Xnehrgtd35gitoJqJUY5sB1p6TDPd6vk3MVU1zqusrke7Lvrud4xKfCLqp672Bj9eGb2wPwow643CpHuMkhigfSWsv9jDq13d75EGTEiprC2UmWTzCJWHrDH7ka68DZJ5XXAW67DBewu7KUm1jrJkNs55vS83SWwm5RjzQLVhscdtCH1Bamec6uZoFBNVzjs21o7ax2WHDghJpGMxFi6dmdMCZpqn618t4 ->>> decoding the message... ->>> message to sign: {"nonce":0,"algorithm":"ed25519","message_type":"mixnode-bonding","content":{"sender":"n1eufxdlgt0puwrwptgjfqne8pj4nhy2u5ft62uq","proxy":null,"funds":[{"denom":"unym","amount":"100000000"}],"data":{"mix_node":{"host":"62.240.134.189","mix_port":1789,"verloc_port":1790,"http_api_port":8000,"sphinx_key":"CfZSy1jRfrfiVi9JYexjFWPqWkKoY72t7NdpWaq37K8Z","identity_key":"DhmUYedPZvhP9MMwXdNpPaqCxxTQgjAg78s2nqtTTiNF","version":"1.1.14"},"cost_params":{"profit_margin_percent":"0.1","interval_operating_cost":{"denom":"unym","amount":"40000000"}}}}} + + ``` ~~~ * Copy the resulting signature: -``` ->>> The base58-encoded signature is: -2GbKcZVKFdpi3sR9xoJWzwPuGdj3bvd7yDtDYVoKfbTWdpjqAeU8KS5bSftD5giVLJC3gZiCg2kmEjNG5jkdjKUt +```sh +# >>> The base58-encoded signature is: +2bbDJSmSo9r9qdamTNygY297nQTVRyQaxXURuomVcRd7EvG9oEC8uW8fvZZYnDeeC9iWyG9mAbX2K8rWEAxZBro1 ``` * And paste it into the wallet nodal, press `Next` and confirm the transaction. -![Paste Signature](../images/wallet-screenshots/wallet-sign.png) +![Paste Signature](../images/wallet-screenshots/wallet-sign.png) +*This image is just an example, copy-paste your own base58-encoded signature* * Your node will now be bonded and ready to mix at the beginning of the next epoch (at most 1 hour). @@ -200,7 +189,8 @@ Change directory by `cd ///` and run the following on th ~~~admonish example collapsible=true title="Console output" ``` - + + ``` ~~~ @@ -234,7 +224,8 @@ Change directory by `cd ///` and run the following on th ~~~admonish example collapsible=true title="Console output" ``` - + + ``` ~~~ @@ -260,7 +251,7 @@ To get the node owner signature, use: If wanting to leave, run the same initial command as above, followed by: Using `nym-cli`: - + ``` ./nym-cli cosmwasm execute '{"leave_family": {"signature": "","family_head": "","owner_signautre": ""}}' --mnemonic ``` @@ -287,8 +278,6 @@ There are also 2 community explorers which have been created by [Nodes Guru](htt For more details see [Troubleshooting FAQ](../nodes/troubleshooting.md) - - ## Maintenance For Mix Node upgrade, firewall setup, port configuration, API endpoints, VPS suggestions, automation and more, see the [maintenance page](./maintenance.md) diff --git a/documentation/operators/src/nodes/validator-setup.md b/documentation/operators/src/nodes/validator-setup.md index ca35c0b2b9..53f979019f 100644 --- a/documentation/operators/src/nodes/validator-setup.md +++ b/documentation/operators/src/nodes/validator-setup.md @@ -1,12 +1,12 @@ # Validators -> Nym has two main codebases: +> Nym has two main codebases: > - the [Nym platform](https://github.com/nymtech/nym), written in Rust. This contains all of our code except for the validators. -> - the [Nym validators](https://github.com/nymtech/nyxd), written in Go. +> - the [Nym validators](https://github.com/nymtech/nyxd), written in Go & maintained as a no-modification fork of [wasmd](https://github.com/CosmWasm/wasmd) -The validator is built using [Cosmos SDK](https://cosmos.network) and [Tendermint](https://tendermint.com), with a [CosmWasm](https://cosmwasm.com) smart contract controlling the directory service, node bonding, and delegated mixnet staking. +The validator is a Go application which implements it's functionalities using [Cosmos SDK](https://v1.cosmos.network/sdk). The underlying state-replication engine is powered by [CometBFT](https://cometbft.com/), where the consensus mechanism is based on the [Tendermint Consensus Algorithm](https://arxiv.org/abs/1807.04938). Finally, a [CosmWasm](https://cosmwasm.com) smart contract module controls crucial mixnet functionalities like decentralised directory service, node bonding, and delegated mixnet staking. -> We are currently working towards building up a closed set of reputable validators. You can ask us for coins to get in, but please don't be offended if we say no - validators are part of our system's core security and we are starting out with people we already know or who have a solid reputation. +> We are currently running mainnet with a closed set of reputable validators. To ensure decentralisation of Nyx chain, we are working on a mechanism to onboard new validators to the network. To join the waitlist, please drop an email to `validators [at] nymtech.net` with details of your setup, experience and any other relevent information ## Building your validator @@ -33,9 +33,9 @@ pacman -S git gcc jq `Go` can be installed via the following commands (taken from the [Go Download and install page](https://go.dev/doc/install)): ``` -# First remove any existing old Go installation and extract the archive you just downloaded into /usr/local: +# First remove any existing old Go installation and extract the archive you just downloaded into /usr/local: # You may need to run the command as root or through sudo -rm -rf /usr/local/go && tar -C /usr/local -xzf go1.20.6.linux-amd64.tar.gz +rm -rf /usr/local/go && tar -C /usr/local -xzf go1.20.10.linux-amd64.tar.gz # Add /usr/local/go/bin to the PATH environment variable export PATH=$PATH:/usr/local/go/bin @@ -47,16 +47,12 @@ Verify `Go` is installed with: ``` go version # Should return something like: -go version go1.20.4 linux/amd64 +go version go1.20.10 linux/amd64 ``` ### Download a precompiled validator binary You can find pre-compiled binaries for Ubuntu `22.04` and `20.04` [here](https://github.com/nymtech/nyxd/releases). -```admonish caution title="" -There are seperate releases for Mainnet and the Sandbox testnet - make sure to download the correct binary to avoid `bech32Prefix` mismatches. -``` - ### Manually compiling your validator binary The codebase for the Nyx validators can be found [here](https://github.com/nymtech/nyxd). @@ -64,15 +60,13 @@ The validator binary can be compiled by running the following commands: ``` git clone https://github.com/nymtech/nyxd.git cd nyxd + +# Make sure to check releases for the latest version information git checkout release/ -# Mainnet +# Build the binaries make build - -# Sandbox testnet -BECH32_PREFIX=nymt make build ``` - At this point, you will have a copy of the `nyxd` binary in your `build/` directory. Test that it's compiled properly by running: ``` @@ -83,50 +77,49 @@ You should see a similar help menu printed to you: ~~~admonish example collapsible=true title="Console output" ``` -Wasm Daemon (server) +Nyx Daemon (server) Usage: nyxd [command] Available Commands: - add-genesis-account Add a genesis account to genesis.json - add-wasm-genesis-message Wasm genesis subcommands - collect-gentxs Collect genesis txs and output a genesis.json file - config Create or query an application CLI configuration file - debug Tool for helping with debugging your application - export Export state to JSON - gentx Generate a genesis tx carrying a self delegation - help Help about any command - init Initialize private validator, p2p, genesis, and application configuration files - keys Manage your application's keys - query Querying subcommands - rollback rollback cosmos-sdk and tendermint state by one height - start Run the full node - status Query remote node for status - tendermint Tendermint subcommands - tx Transactions subcommands - validate-genesis validates the genesis file at the default location or at the location passed as an arg - version Print the application binary version information + completion Generate the autocompletion script for the specified shell + config Create or query an application CLI configuration file + debug Tool for helping with debugging your application + export Export state to JSON + genesis Application's genesis-related subcommands + help Help about any command + init Initialize private validator, p2p, genesis, and application configuration files + keys Manage your application's keys + prune Prune app history states by keeping the recent heights and deleting old heights + query Querying subcommands + rollback rollback cosmos-sdk and tendermint state by one height + rosetta spin up a rosetta server + start Run the full node + status Query remote node for status + tendermint Tendermint subcommands + testnet subcommands for starting or configuring local testnets + tx Transactions subcommands + version Print the application binary version information Flags: -h, --help help for nyxd - --home string directory for config and data (default "/home/willow/.nyxd") + --home string directory for config and data --log_format string The logging format (json|plain) (default "plain") --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) (default "info") --trace print out full stack trace on errors Use "nyxd [command] --help" for more information about a command. - ``` ~~~ ### Linking `nyxd` to `libwasmvm.so` -`libwasmvm.so` is the wasm virtual machine which is needed to execute smart contracts in `v0.26.1`. This file is renamed in `libwasmvm.x86_64.so` in `v0.31.1`. +`libwasmvm.so` is the wasm virtual machine which is needed to execute smart contracts in `v0.26.1`. This file is renamed in `libwasmvm.x86_64.so` in `v0.31.1` and above. If you downloaded your `nyxd` binary from Github, you will have seen this file when un-`tar`-ing the `.tar.gz` file from the releases page. -If you are seeing an error concerning this file when trying to run `nyxd`, then you need to move the `libwasmvm.so` file to correct location. +If you are seeing an error concerning this file when trying to run `nyxd`, then you need to move the `libwasmvm.x86_64.so` file to correct location. Simply `cp` or `mv` that file to `/lib/x86_64-linux-gnu/` and re-run `nyxd`. @@ -152,40 +145,39 @@ This should return the regular help menu: ~~~admonish example collapsible=true title="Console output" ``` -Wasm Daemon (server) +Nyx Daemon (server) Usage: nyxd [command] Available Commands: - add-genesis-account Add a genesis account to genesis.json - add-wasm-genesis-message Wasm genesis subcommands - collect-gentxs Collect genesis txs and output a genesis.json file - config Create or query an application CLI configuration file - debug Tool for helping with debugging your application - export Export state to JSON - gentx Generate a genesis tx carrying a self delegation - help Help about any command - init Initialize private validator, p2p, genesis, and application configuration files - keys Manage your application's keys - query Querying subcommands - rollback rollback cosmos-sdk and tendermint state by one height - start Run the full node - status Query remote node for status - tendermint Tendermint subcommands - tx Transactions subcommands - validate-genesis validates the genesis file at the default location or at the location passed as an arg - version Print the application binary version information + completion Generate the autocompletion script for the specified shell + config Create or query an application CLI configuration file + debug Tool for helping with debugging your application + export Export state to JSON + genesis Application's genesis-related subcommands + help Help about any command + init Initialize private validator, p2p, genesis, and application configuration files + keys Manage your application's keys + prune Prune app history states by keeping the recent heights and deleting old heights + query Querying subcommands + rollback rollback cosmos-sdk and tendermint state by one height + rosetta spin up a rosetta server + start Run the full node + status Query remote node for status + tendermint Tendermint subcommands + testnet subcommands for starting or configuring local testnets + tx Transactions subcommands + version Print the application binary version information Flags: -h, --help help for nyxd - --home string directory for config and data (default "/home/willow/.nyxd") + --home string directory for config and data --log_format string The logging format (json|plain) (default "plain") --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) (default "info") --trace print out full stack trace on errors Use "nyxd [command] --help" for more information about a command. - ``` ~~~ @@ -224,7 +216,7 @@ You can use the following command to download them for the correct network: wget -O $HOME/.nyxd/config/genesis.json https://nymtech.net/genesis/genesis.json # Sandbox testnet -wget -O $HOME/.nyxd/config/genesis.json https://sandbox-validator1.nymtech.net/snapshots/genesis.json +wget -O $HOME/.nyxd/config/genesis.json https://sandbox-validator1.nymtech.net/snapshots/genesis.json | jq '.result.genesis' ``` ### `config.toml` configuration @@ -234,21 +226,18 @@ Edit the following config options in `$HOME/.nyxd/config/config.toml` to match t ``` # Mainnet persistent_peers = "ee03a6777fb76a2efd0106c3769daaa064a3fcb5@51.79.21.187:26656" -create_empty_blocks = false laddr = "tcp://0.0.0.0:26656" ``` ``` # Sandbox testnet cors_allowed_origins = ["*"] -persistent_peers = "8421c0a3d90d490e27e8061f2abcb1276c8358b6@sandbox-validator1.nymtech.net:26666" -create_empty_blocks = false +persistent_peers = "26f7782aff699457c8e6dd9a845e5054c9b0707e@sandbox-validator1.nymtech.net:26666" laddr = "tcp://0.0.0.0:26656" ``` -These affect the following: +These affect the following: * `persistent_peers = "@.nymtech.net:26666"` allows your validator to start pulling blocks from other validators. **The main sandbox validator listens on `26666` instead of the default `26656` for debugging**. It is recommended you do not change your port from `26656`. -* `create_empty_blocks = false` will save space * `laddr = "tcp://0.0.0.0:26656"` is in your p2p configuration options Optionally, if you want to enable [Prometheus](https://prometheus.io/) metrics then the following must also match in the `config.toml`: @@ -270,11 +259,11 @@ In the file `$HOME/nyxd/config/app.toml`, set the following values: ``` # Mainnet minimum-gas-prices = "0.025unym,0.025unyx" -enable = true in the `[api]` section to get the API server running ``` + ``` # Sandbox Testnet -minimum-gas-prices = "0.025unymt,0.025unyxt" +minimum-gas-prices = "0.025unym,0.025unyx" enable = true` in the `[api]` section to get the API server running ``` @@ -285,9 +274,13 @@ You'll need an admin account to be in charge of your validator. Set that up with nyxd keys add nyxd-admin ``` -This will add keys for your administrator account to your system's keychain and log your name, address, public key, and mnemonic. As the instructions say, remember to **write down your mnemonic**. +```admonish tip title="Key Backends" +Cosmos SDK offers multiple backends for securing your keys. Please refer to the Cosmos SDK [docs on available keyring backends](https://docs.cosmos.network/main/user/run-node/keyring#available-backends-for-the-keyring) to learn more +``` -You can get the admin account's address with: +While using the default settings, this will add keys for your account to your system's keychain and log your name, address, public key, and mnemonic. As the instructions say, remember to **write down your mnemonic**. + +You can get the current account address with: ``` nyxd keys show nyxd-admin -a @@ -297,10 +290,6 @@ Type in your keychain **password**, not the mnemonic, when asked. ## Starting your validator -```admonish caution title="" -If you are running a Sandbox testnet validator, please skip the `validate-genesis` command: it will fail due to the size of the genesis file as this is a fork of an existing chain state. -``` - Everything should now be ready to go. You've got the validator set up, all changes made in `config.toml` and `app.toml`, the Nym genesis file copied into place (replacing the initial auto-generated one). Now let's validate the whole setup: ``` @@ -313,7 +302,7 @@ If this check passes, you should receive the following output: File at /path/to/genesis.json is a valid genesis file ``` -> If this test did not pass, check that you have replaced the contents of `//.nymd/config/genesis.json` with that of the correct genesis file. +> If this test did not pass, check that you have replaced the contents of `//.nyxd/config/genesis.json` with that of the correct genesis file. ### Open firewall ports @@ -323,14 +312,18 @@ Before starting the validator, we will need to open the firewall ports: # if ufw is not already installed: sudo apt install ufw sudo ufw enable -sudo ufw allow 1317,26656,26660,22,80,443/tcp + +# Customise according to your port bindings. This is only for reference +# 26656 : p2p gossip port +# 26660: If prometheus is enabled +# 22 : Default SSH port +sudo ufw allow 26656,26660,22 + # to check everything worked sudo ufw status ``` -Ports `22`, `80`, and `443` are for ssh, http, and https connections respectively. The rest of the ports are documented [here](https://docs.cosmos.network/main/core/grpc_rest). - -For more information about your validator's port configuration, check the [validator port reference table](./maintenance.md#ports) below. +For more information about your validator's port configuration, check the [validator port reference table](./maintenance.md#ports) below. These can be customised in `app.toml` and `config.toml` files. > If you are planning to use [Cockpit](https://cockpit-project.org/) on your validator server then you will have defined a different `grpc` port in your `config.toml` above: remember to open this port as well. @@ -376,8 +369,7 @@ Once your validator has synced and you have received tokens, you can join consen ``` # Mainnet nyxd tx staking create-validator - --amount=10000000unyx - --fees=0unyx + --amount=<10000000unyx> --pubkey=$(/home///nyxd/binaries/nyxd tendermint show-validator) --moniker="" --chain-id=nyx @@ -387,14 +379,14 @@ nyxd tx staking create-validator --min-self-delegation="1" --gas="auto" --gas-adjustment=1.15 - --from="KEYRING_NAME" - --node https://rpc-1.nyx.nodes.guru:443 + --gas-prices=0.025unyx + --from=<"KEYRING_NAME"> + --node=https://rpc.nymtech.net:443 ``` ``` # Sandbox Testnet nyxd tx staking create-validator - --amount=10000000unyxt - --fees=5000unyxt + --amount=<10000000unyx> --pubkey=$(/home///nym/binaries/nyxd tendermint show-validator) --moniker="" --chain-id=sandbox @@ -404,13 +396,13 @@ nyxd tx staking create-validator --min-self-delegation="1" --gas="auto" --gas-adjustment=1.15 - --from="KEYRING_NAME" + --gas-prices=0.025unyx + --from=<"KEYRING_NAME"> --node https://sandbox-validator1.nymtech.net:443 ``` -You'll need either `unyxt` tokens on Sandbox, or `unyx` tokens on mainnet to perform this command. +You'll need Nyx tokens on mainnet / sandbox to perform the above tasks. -> We are currently working towards building up a closed set of reputable validators. You can ask us for coins to get in, but please don't be offended if we say no - validators are part of our system's core security and we are starting out with people we already know or who have a solid reputation. If you want to edit some details for your node you will use a command like this: @@ -424,8 +416,8 @@ nyxd tx staking edit-validator --identity="" --gas="auto" --gas-adjustment=1.15 + --gas-prices=0.025unyx --from="KEYRING_NAME" - --fees 2000unyx ``` ``` # Sandbox testnet @@ -437,8 +429,8 @@ nyxd tx staking edit-validator --identity="" --gas="auto" --gas-adjustment=1.15 + --gas-prices=0.025unyx --from="KEYRING_NAME" - --fees 2000unyxt ``` With above command you can specify the `gpg` key last numbers (as used in `keybase`) as well as validator details and your email for security contact. @@ -446,9 +438,6 @@ With above command you can specify the `gpg` key last numbers (as used in `keyba ### Automating your validator with systemd You will most likely want to automate your validator restarting if your server reboots. Checkout the [maintenance page](./maintenance.md#systemd) with a quick tutorial. -### Installing and configuring nginx for HTTPS - -If you want to set up a reverse proxying on the validator server to improve security and performance, using [nginx](https://www.nginx.com/resources/glossary/nginx/#:~:text=NGINX%20is%20open%20source%20software,%2C%20media%20streaming%2C%20and%20more.&text=In%20addition%20to%20its%20HTTP,%2C%20TCP%2C%20and%20UDP%20servers.), follow the manual on the [maintenance page](./maintenance.md#setup). ### Setting the ulimit @@ -466,7 +455,7 @@ nyxd tx slashing unjail --chain-id=nyx --gas=auto --gas-adjustment=1.4 - --fees=7000unyx + --gas-prices=0.025unyx ``` ``` # Sandbox Testnet @@ -476,7 +465,7 @@ nyxd tx slashing unjail --chain-id=sandbox --gas=auto --gas-adjustment=1.4 - --fees=7000unyxt + --gas-prices=0.025unyx ``` ### Upgrading your validator @@ -496,7 +485,7 @@ If the `/dev/sda` partition is almost full, try pruning some of the `.gz` syslog You can check your current balances with: ``` -nymd query bank balances ${ADDRESS} +nyxd query bank balances ${ADDRESS} ``` For example, on the Sandbox testnet this would return: @@ -504,7 +493,7 @@ For example, on the Sandbox testnet this would return: ```yaml balances: - amount: "919376" -denom: unymt +denom: unym pagination: next_key: null total: "0" @@ -516,22 +505,21 @@ You can, of course, stake back the available balance to your validator with the ``` # Mainnet -nyxd tx staking delegate VALOPERADDRESS AMOUNTunym +nyxd tx staking delegate VALOPERADDRESS AMOUNTunyx --from="KEYRING_NAME" --keyring-backend=os --chain-id=nyx --gas="auto" --gas-adjustment=1.15 - --fees 5000unyx -``` -``` + --gas-prices=0.025unyx + # Sandbox Testnet -nyxd tx staking delegate VALOPERADDRESS AMOUNTunymt +nyxd tx staking delegate VALOPERADDRESS AMOUNTunyx --from="KEYRING_NAME" --keyring-backend=os --chain-id=sandbox --gas="auto" --gas-adjustment=1.15 - --fees 5000unyxt + --gas-prices=0.025unyx ``` diff --git a/nym-api/tests/yarn.lock b/nym-api/tests/yarn.lock index 7b0be55103..6176c8abb6 100644 --- a/nym-api/tests/yarn.lock +++ b/nym-api/tests/yarn.lock @@ -941,8 +941,9 @@ axios@^0.27.2: resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972" integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ== dependencies: - follow-redirects "^1.14.9" + follow-redirects "^1.15.0" form-data "^4.0.0" + proxy-from-env "^1.1.0" babel-jest@^28.1.3: version "28.1.3" @@ -2545,6 +2546,11 @@ prompts@^2.0.1: kleur "^3.0.3" sisteransi "^1.0.5" +proxy-from-env@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + punycode@^2.1.0: version "2.3.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" diff --git a/nym-browser-extension/storage/Cargo.toml b/nym-browser-extension/storage/Cargo.toml index 02661e3284..037386774c 100644 --- a/nym-browser-extension/storage/Cargo.toml +++ b/nym-browser-extension/storage/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "extension-storage" -version = "1.2.4-rc.1" +version = "1.2.4-rc.2" edition = "2021" license = "Apache-2.0" repository = "https://github.com/nymtech/nym" diff --git a/nym-wallet/package.json b/nym-wallet/package.json index 5a011cdee1..f0d1b31155 100644 --- a/nym-wallet/package.json +++ b/nym-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/nym-wallet-app", - "version": "1.2.12-rc.1", + "version": "1.2.12-rc.2", "license": "MIT", "main": "index.js", "scripts": { diff --git a/sdk/typescript/codegen/contract-clients/package.json b/sdk/typescript/codegen/contract-clients/package.json index 99f6bf253a..b4f91a948b 100644 --- a/sdk/typescript/codegen/contract-clients/package.json +++ b/sdk/typescript/codegen/contract-clients/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/contract-clients", - "version": "1.2.4-rc.1", + "version": "1.2.4-rc.2", "description": "A client for all Nym smart contracts", "license": "Apache-2.0", "author": "Nym Technologies SA", diff --git a/sdk/typescript/docs/package.json b/sdk/typescript/docs/package.json index 2d877b8888..f4c99e0a38 100644 --- a/sdk/typescript/docs/package.json +++ b/sdk/typescript/docs/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/ts-sdk-docs", - "version": "1.2.4-rc.1", + "version": "1.2.4-rc.2", "description": "Nym Typescript SDK Docs", "license": "Apache-2.0", "author": "Nym Technologies SA", @@ -28,9 +28,9 @@ "@mui/icons-material": "^5.14.9", "@mui/lab": "^5.0.0-alpha.145", "@mui/material": "^5.14.8", - "@nymproject/contract-clients": ">=1.2.4-rc.1 || ^1", - "@nymproject/mix-fetch-full-fat": ">=1.2.4-rc.1 || ^1", - "@nymproject/sdk-full-fat": ">=1.2.4-rc.1 || ^1", + "@nymproject/contract-clients": ">=1.2.4-rc.2 || ^1", + "@nymproject/mix-fetch-full-fat": ">=1.2.4-rc.2 || ^1", + "@nymproject/sdk-full-fat": ">=1.2.4-rc.2 || ^1", "chain-registry": "^1.19.0", "cosmjs-types": "^0.8.0", "next": "^13.4.19", @@ -50,4 +50,4 @@ "typescript": "^4.9.3" }, "private": false -} \ No newline at end of file +} diff --git a/sdk/typescript/examples/chat-app/parcel/package.json b/sdk/typescript/examples/chat-app/parcel/package.json index 5902778256..0f9dbebffd 100644 --- a/sdk/typescript/examples/chat-app/parcel/package.json +++ b/sdk/typescript/examples/chat-app/parcel/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/sdk-example-plain-html-parcel", - "version": "1.0.4-rc.1", + "version": "1.0.4-rc.2", "description": "An example project that uses WASM and plain HTML bundled with Parcel v2", "license": "Apache-2.0", "scripts": { diff --git a/sdk/typescript/examples/chat-app/plain-html/package.json b/sdk/typescript/examples/chat-app/plain-html/package.json index 907de17a93..4d3915855c 100644 --- a/sdk/typescript/examples/chat-app/plain-html/package.json +++ b/sdk/typescript/examples/chat-app/plain-html/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/sdk-example-plain-html", - "version": "1.0.4-rc.1", + "version": "1.0.4-rc.2", "description": "An example project that uses WASM and plain HTML", "license": "Apache-2.0", "scripts": { diff --git a/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/package.json b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/package.json index 076ad4ebf3..6deb168308 100644 --- a/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/package.json +++ b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/sdk-example-react-webpack-wasm", - "version": "1.0.4-rc.1", + "version": "1.0.4-rc.2", "description": "An example project that uses WASM, React, Webpack, Typescript and the Nym theme + components library", "license": "Apache-2.0", "scripts": { diff --git a/sdk/typescript/examples/chrome-extension/package.json b/sdk/typescript/examples/chrome-extension/package.json index 167863bd7c..4a3759680a 100644 --- a/sdk/typescript/examples/chrome-extension/package.json +++ b/sdk/typescript/examples/chrome-extension/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/sdk-example-chrome-extension", - "version": "1.0.4-rc.1", + "version": "1.0.4-rc.2", "description": "This is an example of how Nym can be used within the context of a Chrome extension.", "license": "ISC", "author": "", diff --git a/sdk/typescript/examples/firefox-extension/package.json b/sdk/typescript/examples/firefox-extension/package.json index 8204cf7e13..9ca8a5111b 100644 --- a/sdk/typescript/examples/firefox-extension/package.json +++ b/sdk/typescript/examples/firefox-extension/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/sdk-example-firefox-extension", - "version": "1.0.4-rc.1", + "version": "1.0.4-rc.2", "description": "This is an example of how Nym can be used within the context of a Firefox extension.", "license": "ISC", "author": "", diff --git a/sdk/typescript/examples/mix-fetch/browser/package.json b/sdk/typescript/examples/mix-fetch/browser/package.json index 69efa51b2f..c5e4ffbdcd 100644 --- a/sdk/typescript/examples/mix-fetch/browser/package.json +++ b/sdk/typescript/examples/mix-fetch/browser/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/mix-fetch-example-parcel", - "version": "1.0.4-rc.1", + "version": "1.0.4-rc.2", "license": "Apache-2.0", "scripts": { "build": "parcel build --no-cache --no-content-hash", diff --git a/sdk/typescript/examples/node-tester/parcel/package.json b/sdk/typescript/examples/node-tester/parcel/package.json index 311361410d..12dc69acf7 100644 --- a/sdk/typescript/examples/node-tester/parcel/package.json +++ b/sdk/typescript/examples/node-tester/parcel/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/sdk-example-node-tester-plain-html-parcel", - "version": "1.0.4-rc.1", + "version": "1.0.4-rc.2", "description": "An example project that uses WASM and plain HTML bundled with Parcel v2", "license": "Apache-2.0", "scripts": { diff --git a/sdk/typescript/examples/node-tester/plain-html/package.json b/sdk/typescript/examples/node-tester/plain-html/package.json index 8e9c645e1c..4fe5e3b7be 100644 --- a/sdk/typescript/examples/node-tester/plain-html/package.json +++ b/sdk/typescript/examples/node-tester/plain-html/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/sdk-example-node-tester-plain-html", - "version": "1.0.4-rc.1", + "version": "1.0.4-rc.2", "description": "An example project that uses WASM node tester and plain HTML", "license": "Apache-2.0", "scripts": { diff --git a/sdk/typescript/examples/node-tester/react/package.json b/sdk/typescript/examples/node-tester/react/package.json index e391f87d5a..db804c92fa 100644 --- a/sdk/typescript/examples/node-tester/react/package.json +++ b/sdk/typescript/examples/node-tester/react/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/sdk-example-node-tester-react", - "version": "1.0.4-rc.1", + "version": "1.0.4-rc.2", "description": "An example project that uses WASM node tester and React", "license": "Apache-2.0", "scripts": { diff --git a/sdk/typescript/packages/mix-fetch-node/package.json b/sdk/typescript/packages/mix-fetch-node/package.json index 07f345c9c8..3367b87244 100644 --- a/sdk/typescript/packages/mix-fetch-node/package.json +++ b/sdk/typescript/packages/mix-fetch-node/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/mix-fetch-node", - "version": "1.2.4-rc.1", + "version": "1.2.4-rc.2", "description": "This package is a drop-in replacement for `fetch` in NodeJS to send HTTP requests over the Nym Mixnet.", "license": "Apache-2.0", "author": "Nym Technologies SA", @@ -28,7 +28,7 @@ "tsc": "tsc --noEmit true" }, "dependencies": { - "@nymproject/mix-fetch-wasm-node": ">=1.2.4-rc.1 || ^1", + "@nymproject/mix-fetch-wasm-node": ">=1.2.4-rc.2 || ^1", "comlink": "^4.3.1", "fake-indexeddb": "^5.0.0", "node-fetch": "^3.3.2", @@ -68,4 +68,4 @@ }, "private": false, "types": "./dist/cjs/index.d.ts" -} \ No newline at end of file +} diff --git a/sdk/typescript/packages/mix-fetch/internal-dev/package.json b/sdk/typescript/packages/mix-fetch/internal-dev/package.json index ffee8a5c7c..8c97273244 100644 --- a/sdk/typescript/packages/mix-fetch/internal-dev/package.json +++ b/sdk/typescript/packages/mix-fetch/internal-dev/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/mix-fetch-tester-webpack", - "version": "1.0.4-rc.1", + "version": "1.0.4-rc.2", "license": "Apache-2.0", "scripts": { "build": "webpack build --progress --config webpack.prod.js", diff --git a/sdk/typescript/packages/mix-fetch/internal-dev/parcel/package.json b/sdk/typescript/packages/mix-fetch/internal-dev/parcel/package.json index 4a92c88588..1aa9dc375d 100644 --- a/sdk/typescript/packages/mix-fetch/internal-dev/parcel/package.json +++ b/sdk/typescript/packages/mix-fetch/internal-dev/parcel/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/mix-fetch-tester-parcel", - "version": "1.0.4-rc.1", + "version": "1.0.4-rc.2", "license": "Apache-2.0", "scripts": { "build": "npx parcel build --no-cache --no-content-hash", diff --git a/sdk/typescript/packages/mix-fetch/package.json b/sdk/typescript/packages/mix-fetch/package.json index d0b060a186..381ea96372 100644 --- a/sdk/typescript/packages/mix-fetch/package.json +++ b/sdk/typescript/packages/mix-fetch/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/mix-fetch", - "version": "1.2.4-rc.1", + "version": "1.2.4-rc.2", "description": "This package is a drop-in replacement for `fetch` to send HTTP requests over the Nym Mixnet.", "license": "Apache-2.0", "author": "Nym Technologies SA", @@ -34,7 +34,7 @@ "tsc": "tsc --noEmit true" }, "dependencies": { - "@nymproject/mix-fetch-wasm": ">=1.2.4-rc.1 || ^1", + "@nymproject/mix-fetch-wasm": ">=1.2.4-rc.2 || ^1", "comlink": "^4.3.1" }, "devDependencies": { @@ -82,4 +82,4 @@ "private": false, "type": "module", "types": "./dist/esm/index.d.ts" -} \ No newline at end of file +} diff --git a/sdk/typescript/packages/node-tester/package.json b/sdk/typescript/packages/node-tester/package.json index bb585756be..eb377423bd 100644 --- a/sdk/typescript/packages/node-tester/package.json +++ b/sdk/typescript/packages/node-tester/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/node-tester", - "version": "1.2.4-rc.1", + "version": "1.2.4-rc.2", "description": "This package provides a tester that can send test packets to mixnode that is part of the Nym Mixnet.", "license": "Apache-2.0", "author": "Nym Technologies SA", @@ -25,7 +25,7 @@ "tsc": "tsc --noEmit true" }, "dependencies": { - "@nymproject/nym-node-tester-wasm": ">=1.2.4-rc.1 || ^1", + "@nymproject/nym-node-tester-wasm": ">=1.2.4-rc.2 || ^1", "comlink": "^4.3.1" }, "devDependencies": { @@ -71,4 +71,4 @@ "private": false, "type": "module", "types": "./dist/esm/index.d.ts" -} \ No newline at end of file +} diff --git a/sdk/typescript/packages/nodejs-client/package.json b/sdk/typescript/packages/nodejs-client/package.json index cc73204f02..e8df393fc4 100644 --- a/sdk/typescript/packages/nodejs-client/package.json +++ b/sdk/typescript/packages/nodejs-client/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/nodejs-client", - "version": "1.2.4-rc.1", + "version": "1.2.4-rc.2", "license": "Apache-2.0", "author": "Nym Technologies SA", "files": [ @@ -25,7 +25,7 @@ "tsc": "tsc --noEmit true" }, "dependencies": { - "@nymproject/nym-client-wasm-node": ">=1.2.4-rc.1 || ^1", + "@nymproject/nym-client-wasm-node": ">=1.2.4-rc.2 || ^1", "comlink": "^4.3.1", "fake-indexeddb": "^4.0.2", "rollup-plugin-polyfill": "^4.2.0", @@ -66,4 +66,4 @@ }, "private": false, "types": "./dist/index.d.ts" -} \ No newline at end of file +} diff --git a/sdk/typescript/packages/sdk-react/package.json b/sdk/typescript/packages/sdk-react/package.json index 3d5077c292..6a163d7269 100644 --- a/sdk/typescript/packages/sdk-react/package.json +++ b/sdk/typescript/packages/sdk-react/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/sdk-react", - "version": "1.2.4-rc.1", + "version": "1.2.4-rc.2", "license": "Apache-2.0", "author": "Nym Technologies SA", "files": [ diff --git a/sdk/typescript/packages/sdk/package.json b/sdk/typescript/packages/sdk/package.json index 5a54835cf4..fabc99574a 100644 --- a/sdk/typescript/packages/sdk/package.json +++ b/sdk/typescript/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/sdk", - "version": "1.2.4-rc.1", + "version": "1.2.4-rc.2", "license": "Apache-2.0", "author": "Nym Technologies SA", "files": [ @@ -31,7 +31,7 @@ "tsc": "tsc --noEmit true" }, "dependencies": { - "@nymproject/nym-client-wasm": ">=1.2.4-rc.1 || ^1", + "@nymproject/nym-client-wasm": ">=1.2.4-rc.2 || ^1", "comlink": "^4.3.1" }, "devDependencies": { @@ -81,4 +81,4 @@ "private": false, "type": "module", "types": "./dist/esm/index.d.ts" -} \ No newline at end of file +} diff --git a/tools/internal/sdk-version-bump/src/helpers.rs b/tools/internal/sdk-version-bump/src/helpers.rs index 55d293d798..62f069929b 100644 --- a/tools/internal/sdk-version-bump/src/helpers.rs +++ b/tools/internal/sdk-version-bump/src/helpers.rs @@ -44,7 +44,7 @@ pub(crate) trait ReleasePackage: Sized { Ok(()) } - fn update_nym_dependencies(&mut self, _: &HashSet) -> anyhow::Result<()> { + fn update_nym_dependencies(&mut self, _: &HashSet, _: bool) -> anyhow::Result<()> { Ok(()) } } @@ -57,28 +57,29 @@ pub(crate) trait VersionBumpExt: Sized { fn try_remove_prerelease(&self) -> anyhow::Result; } +pub(crate) fn try_bump_raw_prerelease(raw: &str) -> anyhow::Result { + // ugh that's disgusting + let (rc_prefix, pre_version) = raw + .split_once('.') + .context("the prerelease version does not contain a valid rc.X suffix")?; + + let parsed_version: u32 = pre_version.parse()?; + let updated_version = parsed_version + 1; + + Ok(format!("{rc_prefix}.{updated_version}").parse()?) +} + impl VersionBumpExt for Version { fn try_bump_prerelease(&self) -> anyhow::Result { if self.pre.is_empty() { bail!("the current version ({self}) does not have pre-release data set - are you sure you followed the release process correctly?") } - // ugh that's disgusting - let (rc_prefix, pre_version) = self - .pre - .as_str() - .split_once('.') - .context("the prerelease version does not contain a valid rc.X suffix")?; - - let parsed_version: u32 = pre_version.parse()?; - let updated_version = parsed_version + 1; - - let pre = format!("{rc_prefix}.{updated_version}").parse()?; Ok(Version { major: self.major, minor: self.minor, patch: self.patch, - pre, + pre: try_bump_raw_prerelease(&self.pre.as_str())?, build: self.build.clone(), }) } diff --git a/tools/internal/sdk-version-bump/src/json.rs b/tools/internal/sdk-version-bump/src/json.rs index 79b89e9d8d..5c6816bf7c 100644 --- a/tools/internal/sdk-version-bump/src/json.rs +++ b/tools/internal/sdk-version-bump/src/json.rs @@ -1,6 +1,7 @@ // Copyright 2023 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 +use crate::helpers::try_bump_raw_prerelease; use crate::json_types::DepsSet; use crate::{json_types, ReleasePackage}; use anyhow::{bail, Context}; @@ -14,10 +15,18 @@ pub struct PackageJson { inner: json_types::Package, } -fn update_dependencies(deps: &mut DepsSet, names: &HashSet) -> anyhow::Result<()> { +fn update_dependencies( + deps: &mut DepsSet, + names: &HashSet, + pre_release: bool, +) -> anyhow::Result<()> { for (package, version) in deps.iter_mut() { if names.contains(package) { - let updated = try_bump_minor_version_req(version)?; + let updated = if pre_release { + try_bump_prerelease_version_req(version)? + } else { + try_bump_minor_version_req(version)? + }; println!("\t\t>>> updating '{package}' from {version} to {updated}"); *version = updated @@ -52,21 +61,25 @@ impl ReleasePackage for PackageJson { self.inner.version = version.to_string() } - fn update_nym_dependencies(&mut self, names: &HashSet) -> anyhow::Result<()> { + fn update_nym_dependencies( + &mut self, + names: &HashSet, + pre_release: bool, + ) -> anyhow::Result<()> { println!("\t>>> updating @nymproject dependencies..."); - update_dependencies(&mut self.inner.dependencies, names)?; + update_dependencies(&mut self.inner.dependencies, names, pre_release)?; println!("\t>>> updating @nymproject peerDependencies..."); - update_dependencies(&mut self.inner.peer_dependencies, names)?; + update_dependencies(&mut self.inner.peer_dependencies, names, pre_release)?; println!("\t>>> updating @nymproject devDependencies..."); - update_dependencies(&mut self.inner.dev_dependencies, names)?; + update_dependencies(&mut self.inner.dev_dependencies, names, pre_release)?; println!("\t>>> updating @nymproject optionalDependencies..."); - update_dependencies(&mut self.inner.optional_dependencies, names)?; + update_dependencies(&mut self.inner.optional_dependencies, names, pre_release)?; println!("\t>>> updating @nymproject bundledDependencies..."); - update_dependencies(&mut self.inner.bundled_dependencies, names)?; + update_dependencies(&mut self.inner.bundled_dependencies, names, pre_release)?; Ok(()) } @@ -101,9 +114,9 @@ pub(crate) fn find_package_path(dir: &Path) -> anyhow::Result { // expected structure: `>=X.Y.Z-rc.W || ^X` fn try_bump_minor_version_req(raw_req: &str) -> anyhow::Result { - let (req, major) = raw_req - .split_once("||") - .context("invalid version requirement")?; + let (req, major) = raw_req.split_once("||").context(format!( + "'{raw_req}' is not a valid semver version requirement - we expect '`>=X.Y.Z-rc.W || ^X`'" + ))?; let parsed_req = VersionReq::parse(req)?; let parsed_major = VersionReq::parse(major)?; if parsed_req.comparators.len() != 1 { @@ -123,6 +136,30 @@ fn try_bump_minor_version_req(raw_req: &str) -> anyhow::Result { Ok(format!("{updated} || {parsed_major}")) } +// expected structure: `>=X.Y.Z-rc.W || ^X` +fn try_bump_prerelease_version_req(raw_req: &str) -> anyhow::Result { + let (req, major) = raw_req.split_once("||").context(format!( + "'{raw_req}' is not a valid semver version requirement - we expect '`>=X.Y.Z-rc.W || ^X`'" + ))?; + let parsed_req = VersionReq::parse(req)?; + let parsed_major = VersionReq::parse(major)?; + if parsed_req.comparators.len() != 1 { + bail!("wrong number of version requirements present in {parsed_req}") + } + + let updated = VersionReq { + comparators: vec![Comparator { + op: parsed_req.comparators[0].op, + major: parsed_req.comparators[0].major, + minor: parsed_req.comparators[0].minor, + patch: parsed_req.comparators[0].patch, + pre: try_bump_raw_prerelease(parsed_req.comparators[0].pre.as_str())?, + }], + }; + + Ok(format!("{updated} || {parsed_major}")) +} + #[cfg(test)] mod tests { use super::*; diff --git a/tools/internal/sdk-version-bump/src/main.rs b/tools/internal/sdk-version-bump/src/main.rs index ae6590e03e..cf77ba6be0 100644 --- a/tools/internal/sdk-version-bump/src/main.rs +++ b/tools/internal/sdk-version-bump/src/main.rs @@ -5,7 +5,7 @@ use crate::cargo::CargoPackage; use crate::helpers::ReleasePackage; use crate::json::PackageJson; use clap::{Parser, Subcommand}; -use std::collections::HashSet; +use std::collections::{HashMap, HashSet}; use std::env; use std::path::{Path, PathBuf}; @@ -18,6 +18,48 @@ fn default_root() -> PathBuf { env::current_dir().unwrap() } +struct Summary { + cargo_results: HashMap>, + + json_results: HashMap>, +} + +impl Summary { + fn new( + cargo_results: HashMap>, + json_results: HashMap>, + ) -> Self { + Summary { + cargo_results, + json_results, + } + } + + fn print(&self) { + let cargo_ok = self.cargo_results.values().filter(|p| p.is_ok()).count(); + let json_ok = self.json_results.values().filter(|p| p.is_ok()).count(); + + println!("SUMMARY"); + println!("inspected {} cargo packages", self.cargo_results.len()); + println!("updated {cargo_ok} cargo packages"); + for (package, res) in &self.cargo_results { + if let Err(err) = res { + println!( + "\t>>> ❌ FAILURE: cargo package '{package}' failed to get updated: {err}" + ); + } + } + + println!("inspected {} json packages", self.json_results.len()); + println!("updated {json_ok} json packages"); + for (package, res) in &self.json_results { + if let Err(err) = res { + println!("\t>>> ❌ FAILURE: json package '{package}' failed to get updated: {err}"); + } + } + } +} + #[derive(Parser)] struct Args { #[arg(default_value=default_root().into_os_string())] @@ -36,12 +78,13 @@ enum Commands { /// It will also update the `@nymproject/...` dependencies from `">=X.Y.Z-rc.0 || ^X"` to `">=X.Y.(Z+1)-rc.0 || ^X"` BumpVersion { #[arg(long)] - /// If enabled, the packages will only have their rc version bumped and the dependencies won't get updated at all + /// If enabled, the packages will only have their rc version bumped and the dependencies + /// will get updated from `">=X.Y.Z-rc.W || ^X"` to `">=X.Y.Z-rc.(W+1) || ^X"` pre_release: bool, }, } -fn remove_suffix(root: &Path, path: impl AsRef) { +fn remove_suffix(root: &Path, path: impl AsRef) -> anyhow::Result<()> { let path = root.join(path); println!( ">>> [{}] UPDATING PACKAGE {}: ", @@ -51,8 +94,10 @@ fn remove_suffix(root: &Path, path: impl AsRef) { if let Err(err) = { remove_suffix_inner::(path) } { println!("\t>>> ❌ FAILURE: {err}"); + Err(err) } else { println!("\t>>> ✅ SUCCESS"); + Ok(()) } } @@ -70,7 +115,7 @@ fn bump_version( path: impl AsRef, dependencies_to_update: &HashSet, pre_release: bool, -) { +) -> anyhow::Result<()> { let path = root.join(path); println!( ">>> [{}] UPDATING PACKAGE {}: ", @@ -79,8 +124,10 @@ fn bump_version( ); if let Err(err) = { bump_version_inner::(path, dependencies_to_update, pre_release) } { println!("\t>>> ❌ FAILURE: {err}"); + Err(err) } else { println!("\t>>> ✅ SUCCESS"); + Ok(()) } } @@ -93,9 +140,7 @@ fn bump_version_inner( let mut package = Pkg::open(path)?; package.bump_version(pre_release)?; - if !pre_release { - package.update_nym_dependencies(dependencies_to_update)?; - } + package.update_nym_dependencies(dependencies_to_update, pre_release)?; println!("\t>>> saving the package file..."); package.save_changes() @@ -132,34 +177,46 @@ impl InternalPackages { self.internal_js_dependencies.insert(name.into()); } - pub fn remove_suffix(&self) { + pub fn remove_suffix(&self) -> Summary { + let mut cargo_results = HashMap::new(); for cargo_package in &self.cargo { - remove_suffix::(&self.root, cargo_package); + let res = remove_suffix::(&self.root, cargo_package); + cargo_results.insert(cargo_package.clone(), res); } + let mut json_results = HashMap::new(); for package_json in &self.json { - remove_suffix::(&self.root, package_json); + let res = remove_suffix::(&self.root, package_json); + json_results.insert(package_json.clone(), res); } + + Summary::new(cargo_results, json_results) } - pub fn bump_version(&self, pre_release: bool) { + pub fn bump_version(&self, pre_release: bool) -> Summary { + let mut cargo_results = HashMap::new(); for cargo_package in &self.cargo { - bump_version::( + let res = bump_version::( &self.root, cargo_package, &Default::default(), pre_release, ); + cargo_results.insert(cargo_package.clone(), res); } + let mut json_results = HashMap::new(); for package_json in &self.json { - bump_version::( + let res = bump_version::( &self.root, package_json, &self.internal_js_dependencies, pre_release, ); + json_results.insert(package_json.clone(), res); } + + Summary::new(cargo_results, json_results) } } @@ -226,10 +283,12 @@ fn main() -> anyhow::Result<()> { let args = Args::parse(); let packages = initialise_internal_packages(args.root); - match args.command { + let summary = match args.command { Commands::RemoveSuffix => packages.remove_suffix(), Commands::BumpVersion { pre_release } => packages.bump_version(pre_release), - } + }; + + summary.print(); Ok(()) } diff --git a/wasm/client/Cargo.toml b/wasm/client/Cargo.toml index 1dcaa740b1..6961325d61 100644 --- a/wasm/client/Cargo.toml +++ b/wasm/client/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "nym-client-wasm" authors = ["Dave Hrycyszyn ", "Jedrzej Stuczynski "] -version = "1.2.4-rc.1" +version = "1.2.4-rc.2" edition = "2021" keywords = ["nym", "sphinx", "wasm", "webassembly", "privacy", "client"] license = "Apache-2.0" diff --git a/wasm/mix-fetch/Cargo.toml b/wasm/mix-fetch/Cargo.toml index 641650a958..298335d6b5 100644 --- a/wasm/mix-fetch/Cargo.toml +++ b/wasm/mix-fetch/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "mix-fetch-wasm" authors = ["Jedrzej Stuczynski "] -version = "1.2.4-rc.1" +version = "1.2.4-rc.2" edition = "2021" keywords = ["nym", "fetch", "wasm", "webassembly", "privacy"] license = "Apache-2.0" diff --git a/wasm/mix-fetch/go-mix-conn/internal/jstypes/conv/request.go b/wasm/mix-fetch/go-mix-conn/internal/jstypes/conv/request.go index 883ce82724..19792dbc06 100644 --- a/wasm/mix-fetch/go-mix-conn/internal/jstypes/conv/request.go +++ b/wasm/mix-fetch/go-mix-conn/internal/jstypes/conv/request.go @@ -195,7 +195,7 @@ func parseHeaders(headers js.Value, reqOpts types.RequestOptions, method string) // 3.1.1 origin := jstypes.Origin() - serializedOrigin := &origin + serializedOrigin := origin // Reference: https://fetch.spec.whatwg.org/#origin-header // TODO: 3.1.2: check response tainting // 3.1.3 @@ -224,7 +224,7 @@ func parseBody(request *js.Value) (io.Reader, error) { jsBody := request.Get(fieldRequestBody) var bodyReader io.Reader - if jsBody.InstanceOf(js.Global().Get("ReadableStream")) && jsBody.Get("getReader").Type() == js.TypeFunction { + if jsBody.InstanceOf(js.Global().Get("ReadableStream")) && jsBody.Get("getReader").Type() == js.TypeFunction { // Check to see if getReader is a function log.Debug("stream body - getReader") bodyReader = external.NewStreamReader(jsBody.Call("getReader")) diff --git a/wasm/mix-fetch/go-mix-conn/internal/jstypes/globals.go b/wasm/mix-fetch/go-mix-conn/internal/jstypes/globals.go index 51dda48c8e..86e7ee3e0e 100644 --- a/wasm/mix-fetch/go-mix-conn/internal/jstypes/globals.go +++ b/wasm/mix-fetch/go-mix-conn/internal/jstypes/globals.go @@ -20,20 +20,26 @@ var ( Headers = js.Global().Get("Headers") ) -func Origin() string { +func Origin() *string { // nodejs doesn't have origin location := js.Global().Get("location") if !location.IsUndefined() && !location.IsNull() { - return location.Get("origin").String() + origin := location.Get("origin").String() + return &origin } else { - return "" + return nil } } func OriginUrl() *url.URL { - originUrl, originErr := url.Parse(Origin()) - if originErr != nil { - panic(fmt.Sprintf("could not obtain origin: %s", originErr)) + origin := Origin() + if origin == nil { + return nil + } else { + originUrl, originErr := url.Parse(*origin) + if originErr != nil { + panic(fmt.Sprintf("could not obtain origin: %s", originErr)) + } + return originUrl } - return originUrl } diff --git a/wasm/mix-fetch/go-mix-conn/internal/mixfetch/mixfetch.go b/wasm/mix-fetch/go-mix-conn/internal/mixfetch/mixfetch.go index 3dbc4c077f..7725be27b6 100644 --- a/wasm/mix-fetch/go-mix-conn/internal/mixfetch/mixfetch.go +++ b/wasm/mix-fetch/go-mix-conn/internal/mixfetch/mixfetch.go @@ -92,7 +92,7 @@ func mainFetchChecks(req *conv.ParsedRequest) error { return nil } if req.Options.Mode == jstypes.ModeSameOrigin { - return errors.New(fmt.Sprintf("MixFetch API cannot load %s. Request mode is \"%s\" but the URL's origin is not same as the request origin %s.", req.Request.URL.String(), jstypes.ModeSameOrigin, jstypes.Origin)) + return errors.New(fmt.Sprintf("MixFetch API cannot load %s. Request mode is \"%s\" but the URL's origin is not same as the request origin %v.", req.Request.URL.String(), jstypes.ModeSameOrigin, jstypes.Origin())) } if req.Options.Mode == jstypes.ModeNoCors { if req.Options.Redirect != jstypes.RequestRedirectFollow { @@ -241,8 +241,17 @@ func doCorsCheck(reqOpts *types.RequestOptions, resp *http.Response) error { // 4.9.4 // TODO: presumably this needs to better account for the wildcard? - if jstypes.Origin() != originHeader { - return errors.New(fmt.Sprintf("\"%s\" does not match the origin \"%s\" on \"%s\" remote header", jstypes.Origin, originHeader, jstypes.HeaderAllowOrigin)) + + // if origin is null it means 4.9.2 would have failed anyway + origin := jstypes.Origin() + if origin == nil { + // TODO: won't this essentially fail all node requests? + return errors.New("the local origin is null") + } + + // safety: it's fine to dereference the pointer here as we've just checked if it's null + if *origin != originHeader { + return errors.New(fmt.Sprintf("\"%v\" does not match the origin \"%s\" on \"%s\" remote header", jstypes.Origin(), originHeader, jstypes.HeaderAllowOrigin)) } // 4.9.5 diff --git a/wasm/node-tester/Cargo.toml b/wasm/node-tester/Cargo.toml index d435a0e728..6a3d8126e7 100644 --- a/wasm/node-tester/Cargo.toml +++ b/wasm/node-tester/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "nym-node-tester-wasm" authors = ["Jedrzej Stuczynski "] -version = "1.2.4-rc.1" +version = "1.2.4-rc.2" edition = "2021" keywords = ["nym", "sphinx", "webassembly", "privacy", "tester"] license = "Apache-2.0" diff --git a/yarn.lock b/yarn.lock index b970212657..39b126860b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6159,9 +6159,9 @@ axios@^0.21.1, axios@^0.21.2: follow-redirects "^1.14.0" axios@^1.0.0, axios@^1.3.3: - version "1.5.1" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.5.1.tgz#11fbaa11fc35f431193a9564109c88c1f27b585f" - integrity sha512-Q28iYCWzNHjAm+yEAot5QaAMxhMghWLFVf7rRdwhUI+c2jix2DUXjAHXVi+s1ibs3mjPO/cCgbA++3BjD0vP/A== + version "1.6.0" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.0.tgz#f1e5292f26b2fd5c2e66876adc5b06cdbd7d2102" + integrity sha512-EZ1DYihju9pwVB+jg67ogm+Tmqc6JmhamRN6I4Zt8DfZu5lbcQGw3ozH9lFejSJgs/ibaef3A9PMXPLeefFGJg== dependencies: follow-redirects "^1.15.0" form-data "^4.0.0"