Giter VIP home page Giter VIP logo

avrio-rs's Introduction

Avrio

Master branch: Travis CI Development branch: Travis CI Codacy Badge

This is the offical implemention of the avrio protocol. It is written in rust. It's protocol is subject to frequent change and as such no documention exists (however it is in the works) It is currently not ready for usage. For more details please join our discord

Table of Contents

How to compile

Build optimization

The following instructions use the --release flag. This means that cargo will optimize the code while compiling. It takes considerably longer to compile but makes the executables much faster. If you want to compile faster or if you are debugging the code, remove the release tag and the bins will end up in target/debug rather than target/release. Please note that using these debug bins will result in a considerably lower vote and hence lower reward. On slower machines, using debug may cause you to receive vote below the minimum (meaning you get banned for an epoch). For this reason, we do not recommend that you remove the ---release tag unless needed.

Linux

Prerequisites

Rust makes abundant use of Rust's syntax extensions and other advanced, unstable features. Because of this, you will need to use a nightly version of Rust. If you already have a working installation of the latest Rust nightly, feel free to skip to the next section.

To install a nightly version of Rust, we recommend using rustup. Install rustup by following the instructions on its website. Once rustup is installed, configure Rust nightly as your default toolchain by running the command:

rustup default nightly

If you prefer you can use per-directory overrides to use the nightly version only for avrio by running the following command in the directory:

rustup override set nightly

โš  Warning: Avrio requires the latest version of Rust nightly.

If avrio suddenly stops building, ensure you're using the latest version of Rust nightly and avrio by updating your toolchain and dependencies with:

rustup update && cargo update

You will also need the following packages: Boost, OpenSSL Cargo (or rustc) and git.

Ubuntu
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update
sudo apt-get install -y build-essential g++-8 gcc-8 git libboost-all-dev libssl-dev cmake libclang-dev clang
git clone -b master --single-branch https://github.com/avrio-project/avrio-rs/
cd avrio-rs
cargo build --release

After the completion, the binaries will be in the target/release folder.

cd target
./avrio-daemon
Generic Linux

Ensure you have the dependencies listed above.

git clone -b master --single-branch https://github.com/avrio-project/avrio-rs/
cd avrio-rs
cargo build --release

After the completion, the binaries will be in the target/release folder.

cd target
./avrio-daemon

Windows

Compiling on native windows is currently impossible due to a fff 0.3 assembly bug. Please use MinGw to compile.

File structure

Each aspect of the code is split up into libraries (e.g. database, blockchain, p2p). Libraries are further split into modules (e.g., transaction is a module part of the core library; genesis is a module part of the blockchain lib). If you want to use one of these libs in your code then please add the following to your Cargo.toml and clone this repo into your extern folder for the blockchain library avrio_<lib_name> = { path: "extern/<lib_name>" } e.g. avrio_p2p = { path: "extern/p2p" } The executables can be found in the bin folder, the testnet executables are in bin/testnet.

Contributing

Pull requests are welcomed. If you can help with the code, please fork the repo, make your changes to the forked repo and then open a PR into the development branch. Please NEVER open a PR into the master branch. Any PRs into the master branch without prior authorization will be closed.

Contributors

A huge thank you to everyone who has controbuted to the avrio codebase:

avrio-rs's People

Contributors

arielh25 avatar kruciferx avatar leahcornelius avatar richreggio avatar thedevminertv avatar

Stargazers

 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

avrio-rs's Issues

Catch up syncing is broken

Description

When you sync not from scratch, EG when you turn on your node and it has missed blocks, the peer you are syncing on fails to get your top block hash and due to a soon-to-be-fixed issue freezes the sync process till you time out

Expected Behavior

The peer should return every block (in chunks of 218) above your top block

Actual Behavior

The peer fails to read your block from the disk and so does nothing

Possible Fix

Check if blocks are being saved properly, when you don't share the top block with a peer work retroactively until you find the top common block (then the peer rewinds to this block)

Steps to Reproduce

  1. Start two nodes, connect them
  2. Once they are connected open a wallet and create some blocks
  3. Disconnect the node the wallet is NOT connected to
  4. Create some more blocks
  5. Turn the node back on, let it try and sync
  6. It fails

Your Environment

  • Avrio Version used: 0.1.0 alpha
  • Rust toolchain name and version (e.g. Rust nightly 1.0.3): rustc 1.53.0-nightly (2e495d2e8 2021-04-08)
  • Computer specs (eg 3 core, 3gb ram with a 100gb ssd): 4 core, 4gb ram, 50gb ssd, 500gb spinner (I think, is a vps)
  • Operating System and version: Ubuntu 18
  • Any changes to the code? (eg custom additions): N/A

Write api docs

Description

We currently do not have a finished plan as to the format of the docs and hence we are making it up as we go along. We have this: https://github.com/avrio-project/avrio-docs but it needs finishing

If anyone has some time on their hands proposing some format would be great.

Current DAG structure critical issue

Currently a block is added to both the receiver and sender's blockchain. This works provided the sender and the receiver have exactly the same block height. If they do not then there will be two blocks at certain heights. To solve this a block can be one of two types:

  • Send
  • Receive
    Send blocks are made by the sender and are put straight into the mempool after being validated. Once they have at least 2/3 signatures from the committee then the block is sent to the committee dealing with the receiver. The receiving committee then forms a receive block with the exact same data as the send block. Unlike send blocks, receiver blocks do not have to be signed by the wallet. The are created by the committee that deals with that chain and to be valid must reference a block that is in the mempool. If a node receives a receive block it first looks in the mempool for the block that the receive block references. If it does not have it then it asks the node it got the receiving block from to sen the corresponding send block. If the send block is valid and all fields of the receive block other than hash, timestamp, height, type or signatures are the same and the node signatures are valid then it accepts both blocks. If a node does not respond with a send block related to the receive block then the node simply ignores the block.
    [POLL]
    Should we add the receive block without a parent (the send block) to the mempool, tell me what you think on this one as i cant decide.

Some edits that need to be done:

  • Never enact a send block, you only enact receive blocks
  • Do not save a send block until we see a (valid) receive block, until then add it to the mempool and wait
  • Periodically ask peers for a receive block relating to the send block, if after 3 hours we have not got one purge the block from the mempool until we next see it.
  • Add the following parameters to block:
  • block_type: Custom enum?
  • send_block_hash: Option
  • anything else?

Im going to make a separate branch and work on this, if anyone want to help out that would be great. Ill be adding code documentation as i go along as well as fixing any warnings

SYncing needs to account for block chunks

The current syncing code was implemented before the concept of block chunks. A better syncing approach would be to ditch inventories and instead just follow:

  • Download a list of shards, choose which you will be syncing (Full or just a select amount like the one your wallet is in)

  • For each shard you are not syncing:

    • Download the shards balance delta list and enact
  • For each shard you are syncing:

    • Download a list of block chunks
    • Download each block chunk
    • For each block chunk:
    • Validate, if valid:
      • Download each block in the chunk and enact
    • Once done, compute each chain contained in the shard's digest
  • Compute network digest and check it is up to date

  • Sync your mempool with pending blocks & chunks

Advantages:

  • We can eliminate the concept of inventories entirely which will save disk space, p2p bandwidth and memory as well as logistically simplify syncing
  • Targeted syncing for fullnodes can be easily implemented (when you only catch up with the shards assigned to your committee)
  • Should solve #33 in the process

Potential problems

  • When syncing select shards you will need to also catch up on the balance of shards you're not downloading. I will describe the concept of balance delta lists in a new issue soon however they do require a moderate rework of the accounting system to allow you to tentatively semi enact balance changes in a RAM copy of the account list to allow you to perform validation operations on it. This shouldn't be too hard to implement, but making a well-performing version of this may take some time

Can't sync after build

[2022-11-11][22:47:54][avrio_daemon][INFO] Avrio Daemon Testnet v0.1.0 (alpha)
[2022-11-11][22:47:54][avrio_daemon][WARN] Warning, this software is not stable
[2022-11-11][22:47:54][avrio_config][TRACE] Reading config from disk
[2022-11-11][22:47:54][avrio_database][TRACE] GD: master from tree chaindigest
[2022-11-11][22:47:54][avrio_database][DEBUG] Opened DB tree chaindigest
[2022-11-11][22:47:54][avrio_database][TRACE] Some bytes (len=44)
[2022-11-11][22:47:54][avrio_daemon][INFO] Launching API server
[2022-11-11][22:47:54][avrio_daemon][INFO] Starting mempool
[2022-11-11][22:47:54][avrio_daemon][INFO] Avrio Daemon successfully launched
[2022-11-11][22:47:54][avrio_database][TRACE] GD: master from tree chaindigest
[2022-11-11][22:47:54][avrio_database][DEBUG] Opened DB tree chaindigest
[2022-11-11][22:47:54][avrio_database][TRACE] Some bytes (len=44)
[2022-11-11][22:47:54][avrio_daemon][INFO] State digest: ************************************************************
[2022-11-11][22:47:54][avrio_daemon][INFO] Launching P2p server on 0.0.0.0:56789
[2022-11-11][22:47:54][avrio_database][TRACE] GD: white from tree peers
[2022-11-11][22:47:54][avrio_database][DEBUG] Opened DB tree peers
[2022-11-11][22:47:54][avrio_database][TRACE] No bytes
[2022-11-11][22:47:54][avrio_daemon][INFO] P2P identity=***********************************************************
[2022-11-11][22:47:54][avrio_daemon][TRACE] Adding seednode with addr=192.168.1.218:56789 to peerlist
[2022-11-11][22:47:54][avrio_daemon][DEBUG] Connecting to: 192.168.1.218:56789
[2022-11-11][22:47:54][avrio_p2p::core][INFO] Connecting to 192.168.1.218:56789
[2022-11-11][22:47:54][avrio_p2p::server][INFO] P2P Server bound to 0.0.0.0:56789
[2022-11-11][22:47:59][avrio_daemon][WARN] Failed to connect to 192.168.1.218::56789, returned error Err(Error { kind: TimedOut, message: "connection timed out" })
[2022-11-11][22:47:59][avrio_database][TRACE] GD: white from tree peers
[2022-11-11][22:47:59][avrio_database][DEBUG] Opened DB tree peers
[2022-11-11][22:47:59][avrio_database][TRACE] No bytes
[2022-11-11][22:47:59][avrio_p2p::helper][TRACE] Got not chain digests
[2022-11-11][22:47:59][avrio_daemon][INFO] Starting sync (this will take some time)
[2022-11-11][22:47:59][avrio_database][TRACE] GD: topepoch from tree epochdata
[2022-11-11][22:47:59][avrio_database][DEBUG] Opened DB tree epochdata
[2022-11-11][22:47:59][avrio_database][TRACE] Some bytes (len=1)
[2022-11-11][22:47:59][avrio_database][TRACE] GD: 0 from tree epochdata
[2022-11-11][22:47:59][avrio_database][DEBUG] Opened DB tree epochdata
[2022-11-11][22:47:59][avrio_database][TRACE] Some bytes (len=280)
[2022-11-11][22:47:59][avrio_database][TRACE] GD: count from tree candidates
[2022-11-11][22:47:59][avrio_database][DEBUG] Opened DB tree candidates
[2022-11-11][22:47:59][avrio_database][TRACE] No bytes
[2022-11-11][22:47:59][avrio_daemon][ERROR] Syncing failed

192.168.1.218 is a private ipv4 cannot be reached from here, is there anywhere i can connect to sync?!

Thanks

Refactor the code

The current code is messy and hard to understand. After we have a working testnet we should focus on rewriting in more standard and commented form anything we edit. At least adding comments.

Description

I am currently helping two users go through the code so they can begin to help developing. For all of us it is hard work as my code is poorley documented. This should be fixed, the code should be well documented (functions and LoC) and follow rust standards. An example is the new p2p code.

Possible Fix

WE should go through and slowly refactor or at least comment and explain each function

Fix Rust code warnings

As many people notice when first compiling avrio-rs, it has ALOT of warnings. These are mostly just incorrect camel case naming and unused muts but these need fixing as it is a pain to the eyes to see 1k warnings about naming conventions scroll down the screen. If someone has the time it would be great if they could go through and fix these warnings. Please base the fixes off the development or the master branch. If you rename a variable make sure you update all references to it before opening the PR as we will not merge it until it compiles. Please ensure all PRs reference this issue, are opened into the development branch and are named appropriately. You do not have to follow our commit format ([LIBNAME] commit) as it will be squashed and merged.

Thanks for your help!

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.