Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/gamma-dev' into pskb-wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
KaffinPX committed Oct 26, 2024
2 parents 9a017a1 + c54e83d commit 33a1a0e
Show file tree
Hide file tree
Showing 49 changed files with 1,428 additions and 1,194 deletions.
1,383 changes: 554 additions & 829 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ bincode = { version = "1.3.3", default-features = false }
blake2b_simd = "1.0.2"
borsh = { version = "1.5.1", features = ["derive", "rc"] }
bs58 = { version = "0.5.0", features = ["check"], default-features = false }
bytes = "1.7.1"
cc = "1.0.83"
cfb-mode = "0.8.2"
cfg-if = "1.0.0"
Expand Down Expand Up @@ -188,6 +189,8 @@ hex-literal = "0.4.1"
hexplay = "0.3.0"
hmac = { version = "0.12.1", default-features = false }
home = "0.5.5"
http-body = "1.0.1"
http-body-util = "0.1.2"
igd-next = { version = "0.14.2", features = ["aio_tokio"] }
indexmap = "2.1.0"
intertrait = "0.2.2"
Expand All @@ -211,8 +214,7 @@ parking_lot = "0.12.1"
paste = "1.0.14"
pbkdf2 = "0.12.2"
portable-atomic = { version = "1.5.1", features = ["float"] }
prost = "0.12.1"
# prost = "0.13.1"
prost = "0.13.2"
rand = "0.8.5"
rand_chacha = "0.3.1"
rand_core = { version = "0.6.4", features = ["std"] }
Expand All @@ -222,6 +224,7 @@ regex = "1.10.2"
ripemd = { version = "0.1.3", default-features = false }
rlimit = "0.10.1"
rocksdb = "0.22.0"
rv = "0.16.4"
secp256k1 = { version = "0.29.0", features = [
"global-context",
"rand-std",
Expand All @@ -241,8 +244,6 @@ sha3 = "0.10.8"
slugify-rs = "0.0.3"
smallvec = { version = "1.11.1", features = ["serde"] }
sorted-insert = "0.2.3"
statest = "0.2.2"
statrs = "0.13.0" # TODO "0.16.0"
subtle = { version = "2.5.0", default-features = false }
sysinfo = "0.31.2"
tempfile = "3.8.1"
Expand All @@ -251,8 +252,8 @@ thiserror = "1.0.50"
tokio = { version = "1.33.0", features = ["sync", "rt-multi-thread"] }
tokio-stream = "0.1.14"
toml = "0.8.8"
tonic = { version = "0.10.2", features = ["tls-webpki-roots", "gzip", "transport"] }
tonic-build = { version = "0.10.2", features = ["prost"] }
tonic = { version = "0.12.3", features = ["tls-webpki-roots", "gzip", "transport"] }
tonic-build = { version = "0.12.3", features = ["prost"] }
triggered = "0.1.2"
uuid = { version = "1.5.0", features = ["v4", "fast-rng", "serde"] }
wasm-bindgen = { version = "0.2.93", features = ["serde-serialize"] }
Expand All @@ -262,12 +263,11 @@ web-sys = "0.3.70"
xxhash-rust = { version = "0.8.7", features = ["xxh3"] }
zeroize = { version = "1.6.0", default-features = false, features = ["alloc"] }
pin-project-lite = "0.2.13"
tower-http = { version = "0.4.4", features = [
tower-http = { version = "0.5.2", features = [
"map-response-body",
"map-request-body",
] }
tower = "0.4.7"
hyper = "0.14.27"
tower = "0.5.1"
chrono = "0.4.31"
indexed_db_futures = "0.5.0"
# workflow dependencies that are not a part of core libraries
Expand Down
93 changes: 48 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ The default branch of this repository is `master` and new contributions are cons
## Installation
<details>
<summary>Building on Linux</summary>

1. Install general prerequisites

```bash
sudo apt install curl git build-essential libssl-dev pkg-config
sudo apt install curl git build-essential libssl-dev pkg-config
```

2. Install Protobuf (required for gRPC)

```bash
sudo apt install protobuf-compiler libprotobuf-dev #Required for gRPC
```
Expand All @@ -36,16 +36,16 @@ The default branch of this repository is `master` and new contributions are cons
llvm python3-clang
```
3. Install the [rust toolchain](https://rustup.rs/)
If you already have rust installed, update it by running: `rustup update`

If you already have rust installed, update it by running: `rustup update`
4. Install wasm-pack
```bash
cargo install wasm-pack
```
4. Install wasm32 target
```bash
rustup target add wasm32-unknown-unknown
```
```
5. Clone the repo
```bash
git clone https://github.com/kaspanet/rusty-kaspa
Expand All @@ -55,52 +55,52 @@ The default branch of this repository is `master` and new contributions are cons



<details>
<details>
<summary>Building on Windows</summary>


1. [Install Git for Windows](https://gitforwindows.org/) or an alternative Git distribution.

2. Install [Protocol Buffers](https://github.com/protocolbuffers/protobuf/releases/download/v21.10/protoc-21.10-win64.zip) and add the `bin` directory to your `Path`


3. Install [LLVM-15.0.6-win64.exe](https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.6/LLVM-15.0.6-win64.exe)

Add the `bin` directory of the LLVM installation (`C:\Program Files\LLVM\bin`) to PATH

set `LIBCLANG_PATH` environment variable to point to the `bin` directory as well

**IMPORTANT:** Due to C++ dependency configuration issues, LLVM `AR` installation on Windows may not function correctly when switching between WASM and native C++ code compilation (native `RocksDB+secp256k1` vs WASM32 builds of `secp256k1`). Unfortunately, manually setting `AR` environment variable also confuses C++ build toolchain (it should not be set for native but should be set for WASM32 targets). Currently, the best way to address this, is as follows: after installing LLVM on Windows, go to the target `bin` installation directory and copy or rename `LLVM_AR.exe` to `AR.exe`.

4. Install the [rust toolchain](https://rustup.rs/)
If you already have rust installed, update it by running: `rustup update`

If you already have rust installed, update it by running: `rustup update`
5. Install wasm-pack
```bash
cargo install wasm-pack
```
6. Install wasm32 target
```bash
rustup target add wasm32-unknown-unknown
```
```
7. Clone the repo
```bash
git clone https://github.com/kaspanet/rusty-kaspa
cd rusty-kaspa
```
</details>
</details>


<details>
<details>
<summary>Building on Mac OS</summary>


1. Install Protobuf (required for gRPC)
```bash
brew install protobuf
```
2. Install llvm.
2. Install llvm.

The default XCode installation of `llvm` does not support WASM build targets.
To build WASM on MacOS you need to install `llvm` from homebrew (at the time of writing, the llvm version for MacOS is 16.0.1).
```bash
Expand Down Expand Up @@ -133,23 +133,23 @@ To build WASM on MacOS you need to install `llvm` from homebrew (at the time of
source ~/.zshrc
```
3. Install the [rust toolchain](https://rustup.rs/)
If you already have rust installed, update it by running: `rustup update`

If you already have rust installed, update it by running: `rustup update`
4. Install wasm-pack
```bash
cargo install wasm-pack
```
4. Install wasm32 target
```bash
rustup target add wasm32-unknown-unknown
```
```
5. Clone the repo
```bash
git clone https://github.com/kaspanet/rusty-kaspa
cd rusty-kaspa
```

</details>
</details>

<details>

Expand Down Expand Up @@ -184,7 +184,8 @@ To build WASM on MacOS you need to install `llvm` from homebrew (at the time of
<summary>
Kaspa CLI + Wallet
</summary>
`kaspa-cli` crate provides cli-driven RPC interface to the node and a

`kaspa-cli` crate provides a cli-driven RPC interface to the node and a
terminal interface to the Rusty Kaspa Wallet runtime. These wallets are
compatible with WASM SDK Wallet API and Kaspa NG projects.

Expand Down Expand Up @@ -235,7 +236,7 @@ cargo run --release --bin kaspad -- --testnet
```
**Testnet 11**
For participation in the 10BPS test network (TN11), see the following detailed [guide](docs/testnet11.md).
<details>
Expand All @@ -249,7 +250,7 @@ cargo run --release --bin kaspad -- --configfile /path/to/configfile.toml
# or
cargo run --release --bin kaspad -- -C /path/to/configfile.toml
```
- The config file should be a list of \<CLI argument\> = \<value\> separated by newlines.
- The config file should be a list of \<CLI argument\> = \<value\> separated by newlines.
- Whitespace around the `=` is fine, `arg=value` and `arg = value` are both parsed correctly.
- Values with special characters like `.` or `=` will require quoting the value i.e \<CLI argument\> = "\<value\>".
- Arguments with multiple values should be surrounded with brackets like `addpeer = ["10.0.0.1", "1.2.3.4"]`.
Expand Down Expand Up @@ -297,17 +298,17 @@ wRPC
**Sidenote:**
Rusty Kaspa integrates an optional wRPC
subsystem. wRPC is a high-performance, platform-neutral, Rust-centric, WebSocket-framed RPC
subsystem. wRPC is a high-performance, platform-neutral, Rust-centric, WebSocket-framed RPC
implementation that can use [Borsh](https://borsh.io/) and JSON protocol encoding.
JSON protocol messaging
is similar to JSON-RPC 1.0, but differs from the specification due to server-side
JSON protocol messaging
is similar to JSON-RPC 1.0, but differs from the specification due to server-side
notifications.
[Borsh](https://borsh.io/) encoding is meant for inter-process communication. When using [Borsh](https://borsh.io/)
both client and server should be built from the same codebase.
both client and server should be built from the same codebase.
JSON protocol is based on
JSON protocol is based on
Kaspa data structures and is data-structure-version agnostic. You can connect to the
JSON endpoint using any WebSocket library. Built-in RPC clients for JavaScript and
TypeScript capable of running in web browsers and Node.js are available as a part of
Expand All @@ -316,27 +317,21 @@ wRPC
</details>
<details>
## Benchmarking & Testing
<details>
<details>
<summary>Simulation framework (Simpa)</summary>
Logging in `kaspad` and `simpa` can be [filtered](https://docs.rs/env_logger/0.10.0/env_logger/#filtering-results) by either:
The current codebase supports a full in-process network simulation, building an actual DAG over virtual time with virtual delay and benchmarking validation time (following the simulation generation).
The current codebase supports a full in-process network simulation, building an actual DAG over virtual time with virtual delay and benchmarking validation time (following the simulation generation).
To see the available commands
```bash
```bash
cargo run --release --bin simpa -- --help
```
```
The following command will run a simulation to produce 1000 blocks with communication delay of 2 seconds and 8 BPS (blocks per second) while attempting to fill each block with up to 200 transactions.
The following command will run a simulation to produce 1000 blocks with communication delay of 2 seconds and 8 BPS (blocks per second) while attempting to fill each block with up to 200 transactions.
```bash
cargo run --release --bin simpa -- -t=200 -d=2 -b=8 -n=1000
Expand All @@ -347,7 +342,7 @@ cargo run --release --bin simpa -- -t=200 -d=2 -b=8 -n=1000
<details>
<details>
<summary>Heap Profiling</summary>
Expand All @@ -362,7 +357,7 @@ It will produce `{bin-name}-heap.json` file in the root of the workdir, that can
</details>
<details>
<details>
<summary>Tests</summary>
Expand All @@ -384,12 +379,21 @@ cd rusty-kaspa
cargo nextest run --release
```
</details>
<details>
<summary>Lints</summary>
```bash
cd rusty-kaspa
./check
```
</details>
<details>
<details>
<summary>Benchmarks</summary>
Expand All @@ -400,7 +404,7 @@ cargo bench
</details>
<details>
<details>
<summary>Logging</summary>
Expand All @@ -415,4 +419,3 @@ Logging in `kaspad` and `simpa` can be [filtered](https://docs.rs/env_logger/0.1
In this command we set the `loglevel` to `INFO`.
</details>
4 changes: 2 additions & 2 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ mod panic_handler {
fn stack(error: &Error) -> String;
}

pub fn process(info: &std::panic::PanicInfo) -> String {
pub fn process(info: &std::panic::PanicHookInfo) -> String {
let mut msg = info.to_string();

// Add the error stack to our message.
Expand Down Expand Up @@ -1053,7 +1053,7 @@ mod panic_handler {
impl KaspaCli {
pub fn init_panic_hook(self: &Arc<Self>) {
let this = self.clone();
let handler = move |info: &std::panic::PanicInfo| {
let handler = move |info: &std::panic::PanicHookInfo| {
let msg = panic_handler::process(info);
this.term().writeln(msg.crlf());
panic_handler::console_error(msg);
Expand Down
2 changes: 1 addition & 1 deletion cli/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub fn try_parse_required_nonzero_kaspa_as_sompi_u64<S: ToString + Display>(kasp
let sompi_amount = kaspa_amount
.to_string()
.parse::<f64>()
.map_err(|_| Error::custom(format!("Supplied Kasapa amount is not valid: '{kaspa_amount}'")))?
.map_err(|_| Error::custom(format!("Supplied Kaspa amount is not valid: '{kaspa_amount}'")))?
* SOMPI_PER_KASPA as f64;
if sompi_amount < 0.0 {
Err(Error::custom("Supplied Kaspa amount is not valid: '{kaspa_amount}'"))
Expand Down
3 changes: 1 addition & 2 deletions components/addressmanager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ thiserror.workspace = true
tokio.workspace = true

[dev-dependencies]
statrs.workspace = true
statest.workspace = true
rv.workspace = true
Loading

0 comments on commit 33a1a0e

Please sign in to comment.