Giter Club home page Giter Club logo

rusty-kaspa's Introduction

Kaspa On Rust

Welcome to the Rust-based implementation of the Kaspa full-node and its ancillary libraries. The contained node release serves as a drop-in replacement to the established Golang node and to date is the recommended node software for the Kaspa network, introducing developers to the possibilities of Rust in the Kaspa network's context.

We invite developers and blockchain enthusiasts to collaborate, test, and optimize our Rust implementation. Each line of code here is an opportunity to contribute to the open-source blockchain movement, shaping a platform designed for scalability and speed without compromising on decentralization.

Your feedback, contributions, and issue reports will be integral to evolving this codebase and continuing its maturity as a reliable node in the Kaspa network.

Installation

Building on Linux
  1. Install general prerequisites

    sudo apt install curl git build-essential libssl-dev pkg-config 
  2. Install Protobuf (required for gRPC)

    sudo apt install protobuf-compiler libprotobuf-dev #Required for gRPC
  3. Install the clang toolchain (required for RocksDB and WASM secp256k1 builds)

    sudo apt-get install clang-format clang-tidy \
    clang-tools clang clangd libc++-dev \
    libc++1 libc++abi-dev libc++abi1 \
    libclang-dev libclang1 liblldb-dev \
    libllvm-ocaml-dev libomp-dev libomp5 \
    lld lldb llvm-dev llvm-runtime \
    llvm python3-clang
  4. Install the rust toolchain

    If you already have rust installed, update it by running: rustup update

  5. Install wasm-pack

    cargo install wasm-pack
  6. Install wasm32 target

    rustup target add wasm32-unknown-unknown
  7. Clone the repo

    git clone https://github.com/kaspanet/rusty-kaspa
    cd rusty-kaspa
Building on Windows
  1. Install Git for Windows or an alternative Git distribution.

  2. Install Protocol Buffers and add the bin directory to your Path

  3. Install 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

    If you already have rust installed, update it by running: rustup update

  5. Install wasm-pack

    cargo install wasm-pack
  6. Install wasm32 target

    rustup target add wasm32-unknown-unknown
  7. Clone the repo

    git clone https://github.com/kaspanet/rusty-kaspa
    cd rusty-kaspa
Building on Mac OS
  1. Install Protobuf (required for gRPC)

    brew install protobuf
  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).

    brew install llvm

    NOTE: Homebrew can use different keg installation locations depending on your configuration. For example:

    • /opt/homebrew/opt/llvm -> /opt/homebrew/Cellar/llvm/16.0.1
    • /usr/local/Cellar/llvm/16.0.1

    To determine the installation location you can use brew list llvm command and then modify the paths below accordingly:

    % brew list llvm
    /usr/local/Cellar/llvm/16.0.1/bin/FileCheck
    /usr/local/Cellar/llvm/16.0.1/bin/UnicodeNameMappingGenerator
    ...

    If you have /opt/homebrew/Cellar, then you should be able to use /opt/homebrew/opt/llvm.

    Add the following to your ~/.zshrc file:

    export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
    export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"
    export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"
    export AR=/opt/homebrew/opt/llvm/bin/llvm-ar

    Reload the ~/.zshrc file

    source ~/.zshrc
  3. Install the rust toolchain

    If you already have rust installed, update it by running: rustup update

  4. Install wasm-pack

    cargo install wasm-pack
  5. Install wasm32 target

    rustup target add wasm32-unknown-unknown
  6. Clone the repo

    git clone https://github.com/kaspanet/rusty-kaspa
    cd rusty-kaspa
Building WASM32 SDK

Rust WebAssembly (WASM) refers to the use of the Rust programming language to write code that can be compiled into WebAssembly, a binary instruction format that runs in web browsers and NodeJs. This allows for easy development using JavaScript and TypeScript programming languages while retaining the benefits of Rust.

WASM SDK components can be built from sources by running: - ./build-release - build a full release package (includes both release and debug builds for web and nodejs targets) - ./build-docs - build TypeScript documentation - ./build-web - release web build - ./build-web-dev - development web build - ./build-nodejs - release nodejs build - ./build-nodejs-dev - development nodejs build

IMPORTANT: do not use dev builds in production. They are significantly larger, slower and include debug symbols.

Requirements

Builds & documentation

Kaspa CLI + Wallet `kaspa-cli` crate provides 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.
cd cli
cargo run --release
Local Web Wallet

Run an http server inside of wallet/wasm/web folder. If you don't have once, you can use the following:

cd wallet/wasm/web
cargo install basic-http-server
basic-http-server

The basic-http-server will serve on port 4000 by default, so open your web browser and load http://localhost:4000

The framework is compatible with all major desktop and mobile browsers.

Running the node

Start a mainnet node

cargo run --release --bin kaspad
# or with UTXO-index enabled (needed when using wallets)
cargo run --release --bin kaspad -- --utxoindex

Start a testnet node

cargo run --release --bin kaspad -- --testnet

Testnet 11

For participation in the 10BPS test network (TN11), see the following detailed guide.

Using a configuration file
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.
  • 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"].

For example:

testnet = true
utxoindex = false
disable-upnp = true
perf-metrics = true
appdir = "some-dir"
netsuffix = 11
addpeer = ["10.0.0.1", "1.2.3.4"]

Pass the --help flag to view all possible arguments

cargo run --release --bin kaspad -- --help
wRPC

wRPC subsystem is disabled by default in kaspad and can be enabled via:

JSON protocol:

--rpclisten-json = <interface:port>
# or use the defaults for current network
--rpclisten-json = default

Borsh protocol:

--rpclisten-borsh = <interface:port>
# or use the defaults for current network
--rpclisten-borsh = default

Sidenote:

Rusty Kaspa integrates an optional wRPC subsystem. wRPC is a high-performance, platform-neutral, Rust-centric, WebSocket-framed RPC implementation that can use Borsh and JSON protocol encoding.

JSON protocol messaging is similar to JSON-RPC 1.0, but differs from the specification due to server-side notifications.

Borsh encoding is meant for inter-process communication. When using Borsh both client and server should be built from the same codebase.

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 the Kaspa WASM framework.

Benchmarking & Testing

Simulation framework (Simpa)

Logging in kaspad and simpa can be filtered 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).

To see the available commands

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.

cargo run --release --bin simpa -- -t=200 -d=2 -b=8 -n=1000
Heap Profiling

Heap-profiling in kaspad and simpa can be done by enabling heap feature and profile using the --features argument

cargo run --bin kaspad --profile heap --features=heap

It will produce {bin-name}-heap.json file in the root of the workdir, that can be inspected by the dhat-viewer

Tests

Run unit and most integration tests

cd rusty-kaspa
cargo test --release
// or install nextest and run

Using nextest

cd rusty-kaspa
cargo nextest run --release
Benchmarks
cd rusty-kaspa
cargo bench
Logging

Logging in kaspad and simpa can be filtered by either:

  1. Defining the environment variable RUST_LOG

  2. Adding the --loglevel argument like in the following example:

    (cargo run --bin kaspad -- --loglevel info,kaspa_rpc_core=trace,kaspa_grpc_core=trace,consensus=trace,kaspa_core=trace) 2>&1 | tee ~/rusty-kaspa.log
    

    In this command we set the loglevel to INFO.

rusty-kaspa's People

Contributors

aspect avatar biryukovmaxim avatar coderofstuff avatar d-stacks avatar eladitzhakian avatar elertan avatar elichai avatar gvbgduh avatar hlxeasy avatar michaelsutton avatar omahs avatar orgr avatar reshmem avatar shaiw avatar someone235 avatar starkbamse avatar supertypo avatar surinder83singh avatar thealan404 avatar tiram88 avatar tmrlvi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rusty-kaspa's Issues

Add the time correctness check before starting a node

In order to make nodes have as precise a time as possible and to increase the number of honest nodes reporting a correct time in their blocks, either:

  • check the local time against any available timeserver and refuse to start unless the diff is more than X seconds; ot
  • periodically check the time in the background and simply have a correction value that's added to the local time reports upon necessity, thus having fixed many possible local time issues both deliberately and unknowingly incurred.

Maybe for this purpose implement a time server into the Kaspa DNS servers functionality, to a) decrease the internet time servers load and 2) to increase the chance of having the source of correct time in the case of time servers being firewalled out.

Probably (for a case when there are multiple nodes behind a firewall for redundancy, most of which are only aware of each other, and only 1 of them have the full internet access) also implement a time server functionality into the nodes p2p protocol as a fallback and last resort option.

\rusty-kaspa\kos\Build.ps1 fails due to invalid wasm-pack command

Describe the bug
Was using the Build.ps1 in the \rusty-kaspa\kos\ directory and noticed the following...

Original with parameters inside the quote - not working:

& "wasm-pack build --dev --target web --out-name kaspa --out-dir app/wasm"

Move the quote to only around wasm-pack and parameters after quote - Working:

& "wasm-pack" build --dev --target web --out-name kaspa --out-dir app/wasm

I think it's because PowerShell treats everything inside the quote as a single command. Parameters should follow the quotes. These quotes will need to change on all wasm-pack commands. The above is just a single example.

To Reproduce
Steps to reproduce the behavior:
1,) install prerequisites from "https://github.com/kaspanet/rusty-kaspa#readme"
2.) Verify that the running of scripts is allowed on your system and if not, use the Set-ExecutionPolicy command to allow them per your system security requirements.
3.) Perform the following from elevated PowerShell Window

git clone https://github.com/kaspanet/rusty-kaspa
cd .\rusty-kaspa\kos
.\build.ps1

  1. See error

Expected behavior
The .\build.ps1 script should begin to build the solution, instead of erroring out due to an invalid command.

Screenshots
image
Desktop (please complete the following information):

  • OS: Windows 10 Pro

Update Rusty-Kaspa Readme to include adding LLVM/bin to Path environment variable to enable Kos build

Describe the bug
When using \rusty-kaspa\kos\Build.ps1, the build errors out as it is not able to find "clang", even though LLVM is installed. I had to add "C:\Program Files\LLVM\bin" directly to the Path environment variable and reboot or the build process couldn't find clang. This is not mentioned in the Readme...it says only to "set LIBCLANG_PATH env var pointing to the bin dir of the llvm installation" and I did already have the LIBCLANG_PATH set. Once I added "C:\Program Files\LLVM\bin" to the "Path" environment variable and rebooted, it was able to find clang and proceed.

To Reproduce
Steps to reproduce the behavior:
Starting from a clean install of Windows, follow the Kaspa Readme to install prerequisites and clone the rusty-kaspa directory.
Navigate down to the rusty-kaspa/kos directory and open an elevated PowerShell window at this location. execute \rusty-kaspa\kos\Build.ps1 after applying the fix discussed in issue "#245"

the script should fail as it cannot find "clang"

Expected behavior
When executing \rusty-kaspa\kos\Build.ps1, it should build successfully.

Desktop (please complete the following information):

  • OS: Windows 10 Pro
  • Kaspad version: [e.g. 0.12.11]

Additional context
Add any other context about the problem here.

Benchmark, and perhaps adopt, `serde_bytes` on all sturct fields of type `Vec<u8>`, or `&'a [u8]`.

https://docs.rs/serde_bytes/latest/serde_bytes/

The above crate promises faster serde Serialization / Deserialization on byte vectors and byte slices, as it claims standard serde is not optimized for variable length sequences already in byte format.

Some examples in our current codebase where this could be included are the fields script inconsensus_core::tx::ScriptPublicKey, paylod in consensus_core::tx::Transaction, signature_script in consensus_core::tx::TransactionInput.

Implement RPC authentication

I would like to transfer the following issue to the rusty-kaspa repo:

Currently, many nodes have RPC ports potentially open to the world
Some manner of authentication should be implemented to mitigate it

Suggested solution: gRPC supports authentication out-of-the-box: https://grpc.io/docs/guides/auth/

Source: kaspanet/kaspad#1893

Only the auth method should probably ideally support wRPC, gRPC and all potential future protocols in a generic manner.

Implement disable_relay_tx

Is your feature request related to a problem? Please describe.
Yes - a user that only wants to use the node as an API does not need to receive tx messages. Not having to deal with txs will reduce mempool use.

Describe the solution you'd like
Implement the disable_relay_tx flag. When enabled, this lets a node's peers that it doesn't want to receive transactions. The peers will not send txs to this node.

Describe alternatives you've considered
N/A

Additional context

One consideration is the issue of starvation: What if a node that wants to receive txs is only connected to peers that have DisableRelayTx=false?

Notes

  • Rust code: in flow_context.rs the line // TODO: disable_relay_tx from config/cmd is where this would go
  • Go code: this was BlockOnly in config, and DisableRelayTx in the rest of the codebase.

Virtual processor - Part 2

  1. Change Block to have Arc<Header> and pass block around w/o an arc
  2. Switch BlueWorkType to Uint192
  3. Consider the DAA window average optimization by Tiram
  4. Remove fee param from Tx output
  5. Remove many Arcs from within Tx structs
  6. Use BlockHashMap/BlockHashSet type defs where ever possible
  7. Add prefix support to logs trace macro and perhaps add debug/info macros
  8. Consider switching from saving the mergeset DAA blocks to saving the complementary set, i.e. the mergeset non-DAA blocks. On average this means moving from saving O(mergeset) to 0
  9. Apply DbWriter as a generalization of Batch writing and use it to cleanup remaining caching.rs code duplications
  10. Add genesis block to config
  11. Take cache sizes from kaspa-go + give it more thought
  12. Rename rust files with a single convention

Kaspa URI scheme and IANA registration

Table of Contents

  1. Monivation
    1.1. Context
    1.2. Wallets
  2. IANA URI Scheme
    2.1. Application
    2.2. Process

Motivation

Context

The Kaspa cryptocurrency project launched in November 2021, and is growing quickly.
It is a community governed OSS project.

Kaspa's value proposition is to fulfil Satoshi Nakamoto's original vision with Bitcoin, to become a peer to peer electronic cash system. Kaspa is powered by a proof of work network of miners that produce 1 block per second, onto a blockDAG governed by the GHOSTDAG consensus engine. It is under the final stages to upgrade the network to 32 blocks per second by rewriting the peer to peer network node in rustlang. This allows Kaspa to scale down confirmation times to several seconds.

The outcome is a currency that is as secure as Bitcoin under similar network hashrate or more secure considering Kaspa doesn't orphan blocks, as decentralized as Bitcoin or more considering the block rewards are much more granular than Bitcoin making solo-mining more viable, and much more usable as a medium of exchange than Bitcoin considering the network can house at least 8,000 transactions each second, and those transactions can get settled on the network with probabilistic finality in a scale of seconds, eliminating long wait times.

As of writing these lines, Kaspa has a $130.8M market cap, a $224.5M fully dilluted market cap, and $2.7M daily volume.

Wallets

Kaspa has several different self-custidy wallets developed by different community members:

  • Kaspa CLI wallet
  • Kaspa PWA web wallet
  • KDX wallet
  • Kaspium iOS and Android wallets

There are projects for adding support of Kaspa by hardware wallets such as Ledger, Tangem, and OneKey.
Finally there are custodial wallets for community memberrs to tip each other on Discord and Telegram.

There is a need to establish a standard scheme for sending Kaspa currency between all wallets.
In order to establish a standard, I propose to register a scheme in accordance with IANA URI Schema RFC 7595 as described in Section 7.2 Registration Process.

IANA URI Scheme

Application

Scheme name:
   kaspa

Status:
   Provisional

Applications/protocols that use this scheme name:
   Transfer of Kaspa coins, marked as $KAS, by Wallets that 
   implement the Kaspa protocols.

Contact:
   Registegin party: Eyal Yablonka <[email protected]>; 
   Eyal Yablonka <[email protected]>
   Scheme creator: Kaspa URI Scheme

Change controller:
    Either the registering party or someone who is verified to 
    represent the scheme creator.  See previous answer.
    E.g.: Kaspa core developers.

References:
   [1] https://github.com/kaspanet/kaspad
   [2] https://kaspawiki.net
   [3] https://discord.gg/kaspa
   [4] https://kaspa.org

Scheme syntax:
   kaspa:<bech32_address>[?[amount=<size>][&][label=<label>][&][message=<message>][&][payload=<payload_hex>]]
   Example:
   kaspa:qpqtq6r0r0v2mwm4txcd756m27lm33azq5f7epyhgl5tyjny5et854lazvrjn?amount=0.12345678&label=label&message=message&payload=1A2B3C4D5E6F


Scheme semantics:
   Send money to a Kaspa address.

Encoding considerations:
   The address is bech32 encoded.
   The payload is hex encoded.
   The labels and message are utf-8 encoded.

Interoperability considerations:
   None.

Security considerations:
   None.

Process

When pre-approved by Kaspa core developers and wallet developers, this proposal should be sent to [email protected]

Existing schemes: https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml
Bitcoin scheme: https://www.iana.org/assignments/uri-schemes/prov/bitcoin
Bitcoin Cash scheme: https://www.iana.org/assignments/uri-schemes/prov/bitcoincash
Registration process: https://www.rfc-editor.org/rfc/rfc7595.html#section-7.2

Implement gRPC message ID support

Overview

The current gRPC server in the Golang implementation operates in FIFO mode (It is my understanding that different types of responses can return out of order, but for the sake of this proposal, let's refer to this as FIFO). This processing mode currently trickles down into rusty-kaspa gRPC implementation.

Wallet instances operating on behalf of different users make multiple requests via RPC, however, if interfacing with a system that operates in a FIFO mode, requests have to be queued, which interferes with parallelism. The solution to this is to establish a dedicated connection for each user "context", however, this results in additional resource consumption in the form of open sockets. In the current JS WebSocket/gRPC proxy implementation, each WebSocket connection results in a dedicated gRPC connection, yielding 2x open sockets.

Proposal

It would be desirable to modify Kaspa gRPC protocol messages to support an id field supplied by the user during the request, carried throughout the RPC call execution, and returned with the response.

Having a dedicated id property for each request would allow a single gRPC connection to post requests on behalf of different clients and match responses with the corresponding requests. This would in turn allow a proxy server to establish a single dedicated connection to rusty-kaspa reducing the number of open sockets and also reducing the CPU load required to handle large amounts of sockets.

Adding this would also significantly simplify the gRPC Matcher that was put together by @tiram88 which would, instead of checking the request queue head and then doing a linear search through pending gRPC requests would be able to maintain a simple HashMap of requests, resolving them by id.

NOTE: This should apply strictly to gRPC .proto messages, not internal RPC message structures (they should be agnostic to RPC channels).

For backward compatibility with the Golang client, it would be ideal if the Golang implementation also supports id propagation. This would allow the Rust gRPC client to interop with Golang via a single socket channel.

Considerations

The FIFO mechanism currently used, imposes what sums up to be the processing queue for each client. This, at expense of multiple sockets, creates a per-client "pacing" mechanism. Removal of this queue requirement by introducing id-based processing can result in heavier processing bursts as this would allow wallets/clients to execute multiple requests in parallel. I don't think this is an issue, but this could result in a different CPU load patterns and should be taken into consideration.

kaspad console log outputs to stdeer instead of stdout

Rusty kaspad (possibly other executables as well) logs to stderr instead of stdout, on Linux at least.

This adds complexity when processing output using command line tools.

Reproduce:
Can easily be reproduced with: ./kaspad | grep kaspad <- all output will be shown instead of only the lines containing kaspad
However, kaspad -h actually outputs to stdout: ./kaspad --help | grep kaspad <- only one line is output.

Fix:
Correct logging facility to always do console output to stdout.

Add step to rusty-kaspa getting started section to install Git for Windows after the "Install the rust toolchain" step

Describe the bug
If a Windows user is starting from a clean system, git for windows will not be present and when a user executes the git command to clone the repo, it will fail

To Reproduce
Steps to reproduce the behavior:
Start from a clean Windows OS, follow the Getting Started section in the readme file exactly "https://github.com/kaspanet/rusty-kaspa#getting-started" and when you try to run "git clone https://github.com/kaspanet/rusty-kaspa" it will fail.

Expected behavior

When starting from a clean install of Windows OS and following the Getting Started section in the readme file exactly "https://github.com/kaspanet/rusty-kaspa#getting-started", executing "git clone https://github.com/kaspanet/rusty-kaspa" should succeed and clone the repo to the local directory.

Perhaps adding a section after the "Install the rust toolchain" step to install "Git for Windows". This would be an ideal place to put this step, as the "Install the rust toolchain" step does allow for the automatic installation of Visual Studio. Git for Windows can be installed using the "Visual Studio Installer". Once Visual Studio is installed, simply navigate to the Windows start menu, locate the "Visual Studio Installer" and open it. Once the Visual Studio Installer menu has appeared, select "Modify". On the next menu, select the tab "Individual Components" and search for "git"
image

Check the check box for "Git for Windows" and install.

Desktop (please complete the following information):

  • OS: Windows 10 Pro
  • Kaspad version: [e.g. 0.12.11]

Bug: Syncing during a pruning point shift idles the node (and probably corrupts the db).

Describe the bug
Syncing during a pruning point shift may result in the node not accepting blocks, idling in an endless progression of ibd header sync.

To Reproduce
Steps to reproduce the behavior:
sync a node and make sure it is in the ibd header syncing stage when a pruning point shift occurs.

Expected behavior
A node that accepts blocks from peers

Desktop (please complete the following information):
OS:

PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

Kaspad:

v. 0.1.0

commit 7f26aa6cac1086e8ac5dc4ed9e1d0f12710d4c89 (HEAD -> prune, origin/prune)
Author: Michael Sutton <[email protected]>
Date:   Mon May 29 18:17:08 2023 +0000

    add lock yield logic to semaphore and rwlock

Additional context
Logs:

2023-05-30 15:11:44.192Z [INFO ] kaspad v0.1.0 is when i restarted
...
2023-05-30 15:12:03.723Z [INFO ] Validating level 225 from the pruning point proof
...
2023-05-30 15:12:34.984Z [INFO ] Validating level 0 from the pruning point proof
2023-05-30 15:12:44.285Z [INFO ] Setting d706324b72daf8aa92f008f22d5a336a58fa333ff6572f99b820e84821d8d971 as the current pruning point
2023-05-30 15:12:44.285Z [INFO ] Building the proof which was just applied (sanity test)
2023-05-30 15:12:44.653Z [INFO ] Proof was locally built successfully
2023-05-30 15:12:44.898Z [INFO ] Starting to process 2644 trusted blocks
2023-05-30 15:12:45.898Z [INFO ] Processed 2471 trusted blocks in the last 1.00s (total 2471)
2023-05-30 15:12:45.937Z [INFO ] Done processing trusted blocks
2023-05-30 15:12:54.475Z [INFO ] Processed 3 blocks and 4184 headers in the last 10.00s (6 transactions; 7387 parent references; 0 UTXO-validated blocks; 2.00 avg txs per block; 34046 avg block mass)
2023-05-30 15:12:58.605Z [INFO ] IBD: Processed 3071 block headers (1%)
...
2023-05-30 15:32:48.207Z [INFO ] IBD: Processed 271508 block headers (100%)
2023-05-30 15:32:48.517Z [INFO ] Processed 0 blocks and 1697 headers in the last 10.00s (0 transactions; 2886 parent references; 0 UTXO-validated blocks; 0.00 avg txs per block; 0 avg block mass)
2023-05-30 15:32:49.355Z [INFO ] Received 99 UTXO set chunks so far, totaling in 99000 UTXOs
...
2023-05-30 15:34:19.916Z [INFO ] Finished receiving the UTXO set. Total UTXOs: 8117830
2023-05-30 15:34:19.917Z [INFO ] Importing the UTXO set of the pruning point d706324b72daf8aa92f008f22d5a336a58fa333ff6572f99b820e84821d8d971
2023-05-30 15:34:58.818Z [INFO ] Resyncing the utxoindex...
2023-05-30 15:35:36.515Z [INFO ] Registering p2p flows for peer 49.0.240.99:45994 for protocol version 5
2023-05-30 15:35:36.515Z [INFO ] P2P Connected to incoming peer 49.0.240.99:45994
2023-05-30 15:36:01.118Z [INFO ] P2P, Router receive loop - incoming stream ended from peer 38.242.139.17:16111
2023-05-30 15:36:04.434Z [INFO ] IBD with peer 38.242.139.17:16111 completed with error: ConnectionClosed
2023-05-30 15:36:04.813Z [INFO ] IBD started with peer 51.91.82.136:50408
2023-05-30 15:36:08.575Z [INFO ] Processed 0 blocks and 424 headers in the last 10.00s (0 transactions; 762 parent references; 0 UTXO-validated blocks; 0.00 avg txs per block; 0 avg block mass)
2023-05-30 15:36:12.375Z [INFO ] IBD: Processed 1025 block headers (74%)
2023-05-30 15:36:15.451Z [INFO ] IBD: Processed 1387 block headers (100%)
...
2023-05-30 15:38:41.209Z [INFO ] IBD: Processed 6 block headers (100%)
2023-05-30 15:38:43.077Z [INFO ] P2P, Router receive loop - incoming stream ended from peer 77.37.202.136:16111
2023-05-30 15:38:43.078Z [INFO ] IBD with peer 77.37.202.136:16111 completed with error: ConnectionClosed
2023-05-30 15:38:43.230Z [INFO ] IBD started with peer 193.198.102.245:16111
2023-05-30 15:38:43.382Z [INFO ] IBD: Processed 1 block headers (100%)
2023-05-30 15:38:45.153Z [INFO ] P2P, Router receive loop - incoming stream ended from peer 193.198.102.245:16111
2023-05-30 15:38:45.154Z [INFO ] IBD with peer 193.198.102.245:16111 completed with error: ConnectionClosed
2023-05-30 15:38:45.349Z [INFO ] IBD started with peer 54.39.129.199:40084
2023-05-30 15:38:45.713Z [INFO ] IBD: Processed 3 block headers (100%)

Note: Buggy Behavior is consistent when restarting the node without the --reset-db flag

Rewrite wish list

An issue for gathering any possible feature wished to be implemented during the rewrite of Kaspa to Rust. This might help guiding the developers to design things in a specific way, even if the actual feature is yet to be implemented.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.