Git Product home page Git Product logo

rust-byron-cardano's Introduction

⚠️ This project is deprecated, and only supports the first version of cardano (Byron). do not use anymore, it is here for historical purpose.

Rust implementation of Cardano primitives, helpers, and related applications

Cardano Rust is a modular toolbox of Cardano’s cryptographic primitives, a library of wallet functions and a future alternative Cardano node implementation written in Rust. It can be used by any third-party to build wallet applications and interact with the Cardano blockchain.

Related repositories

Installation

If this is a new installation: install rust's toolchain.

We support the following states; stable, unstable and nightly.

We also support the wasm32 target.

Building the Library

To build the library, use:

cargo build

Running the tests

To run the tests, use:

cargo test

How to integrate the Rust library in your project

Information will be available soon on crates.io

In the mean time, it is possible to add the project using git submodules:

git submodule add https://github.com/input-output-hk/rust-cardano cardano-deps

And then by adding the following to your Cargo.toml:

[dependencies]
cardano = { path = "cardano-deps/cardano" }

rust-byron-cardano's People

Contributors

alanverbner avatar amias-iohk avatar anviking avatar codesandwich avatar datnv-ibl avatar disassembler avatar dkijania avatar dominikguzei avatar drozdziak1 avatar ecioppettini avatar edolstra avatar etscrivner avatar gguoss avatar jleni avatar mzabaluev avatar nahern avatar nicolasdp avatar qnikst avatar rooooooooob avatar sebastiengllmt avatar sjmackenzie avatar vincenthz avatar vsubhuman 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

rust-byron-cardano's Issues

update the wallet configuration

A wallet has an associated directory with directory name the name of the wallet.
It contains a config file config.yml:

  • blockchain: the associated blockchain/network

And up to 2^31 account files account-<index>.yml containing the account state:

  • alias: account alias for UX, can't be a number to avoid clashing with index, it is optional, in this case user can refer to it via its number;
  • addresses: array of known addresses
  • balance: the account balance

add LOCK file in storage

have ariadne and hermes to consume this to be able to prevent access to same file and corrupting data.

more block validation

Add some further blocks validation (header, body, proofs, etc)

We can see this as multi level validation (each back by their own function):

  1. At the block level: check that the block is consistent with itself:
    • all hashes matches: e.g. body hash matches the one in the header, but other hashes also.
    • transactions semantic are correct: at least 1 input, at least 1 output, input sum matches output sum and fees, check fees according to a fee calculator
    • etc
  2. At the epoch level: check that all the block within an epoch are valid:
    • signature verified
    • slot leaders keys (available in genesis block), matches each block signature.
  3. Overall: check that utxo spent are valid.

spending protocol

  • gather information on how it's done
  • add support for lowlevel protocol

Add installation instructions

Hey, im just installing this on my machine and it would be great if you add the following installation instructions to the readme:

# install rustup
curl https://sh.rustup.rs -sSf | sh
# use nightly version
rustup install nightly
rustup default nightly
# with wasm32 target
rustup target add wasm32-unknown-unknown --toolchain nightly

Only then i can run ./build correctly 😉

Update configuration of hermes

  • we need the configuration to allow
    • port to listen to
    • log level
    • log output
    • allow override via command line
  • we need to be able to serve multiple blockchains
    • support for the exe-common::config;
    • update handlers to serve the different blockchains

by default, we will use the ~/.hermes directory:

.hermes
   |-config.yml
   `-networks
      |-mainnet
      |   |-config.yml
      |   |-blocks
      |   `- ... # all like ariadne here
      `-testnet
          |-config.yml

protocol configuration API

put all the general configuration in a structure and add as parameter for every functions that requires it

fix Tx -> TxId

currently missing a hash in id:

impl Tx { ...
    pub fn id(&self) -> TxId {
}}```

generate cardano address

ability to generate addresses from wallet extended private/public key.

this need the specific hash combination, a CBOR encoder, and replicating the AddrSpendingData structures (and whatever is inside).

WalletLog: have an object to write wallet log of action

enum Log {
    // keep empty for now
}
impl Log {
    fn serialise(&self) -> Vec<u8> { /* ... */ }
    fn deserialise(bytes: &[u8]) -> Result<Self> { /* ... */ }
}

struct LogReader(AppendReader);
impl LogReader {
    pub fn next(&mut self) -> Result<Option<Log>> { /* ... */ }
}

struct LogWriter(AppendWriter);
impl LogWriter {
    pub fn append(&mut self, log: &Log) -> Result<()> { /* ... */ }
}

storage append file

leverage the lock file from #113 to prevent concurrent access between processes

impl abstraction to write an append file based on the model of the pack file.

Writing in the append file

let lock = Lock::lock("path/to/file");
let appender = AppendWriter::open(lock);
appender.append(bytes);

Reading from the append file

let lock = Lock::lock("path/to/file");
let mut appender = AppendReader::open(lock);
while let Some(bytes) = appender.pop() {
    // do something
}

derivation V1

Add derivation for V1 scheme, as per haskell implementation

`ariadne blockchain sync <name>` is broken

As of e84810f

It's a runtime error, so perhaps something changed about on-disk formats. I haven't had a chance to look into it yet, but I will after finishing my other work.

Error for existing blockchain

$ RUST_BACKTRACE=1 ./target/debug/ariadne blockchain sync foo
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Message("missing field `peers`", Some(Pos { marker: Marker { index: 10, line: 2, col: 6 }, path: "." }))', libcore/result.rs:945:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:463
   5: std::panicking::begin_panic_fmt
             at libstd/panicking.rs:350
   6: rust_begin_unwind
             at libstd/panicking.rs:328
   7: core::panicking::panic_fmt
             at libcore/panicking.rs:71
   8: core::result::unwrap_failed
             at /checkout/src/libcore/macros.rs:26
   9: <core::result::Result<T, E>>::unwrap
             at /checkout/src/libcore/result.rs:782
  10: exe_common::config::net::Config::from_file
             at ./exe-common/src/config.rs:227
  11: ariadne::command::blockchain::net_sync_faster
             at wallet-cli/src/command/blockchain/mod.rs:105
  12: <ariadne::command::blockchain::Blockchain as ariadne::command::HasCommand>::run
             at wallet-cli/src/command/blockchain/mod.rs:274
  13: ariadne::main
             at wallet-cli/src/main.rs:43
  14: std::rt::lang_start::{{closure}}
             at /checkout/src/libstd/rt.rs:74
  15: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  16: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  17: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:374
             at libstd/rt.rs:58
  18: std::rt::lang_start
             at /checkout/src/libstd/rt.rs:74
  19: main
  20: __libc_start_main
  21: _start
             at ../sysdeps/x86_64/start.S:120

Error for new blockchain (repro)

$ RUST_BACKTRACE=1 ./target/debug/ariadne blockchain new --template testnet foo2

$ RUST_BACKTRACE=1 ./target/debug/ariadne blockchain sync foo2
Configured genesis   : b365f1be6863b453f12b93e1810909b10c79a95ee44bf53414888513fe172c90
Configured genesis-1 : c6a004d3d178f600cd8caa10abbebe1549bef878f0665aea2903472d5abf7323
latest known epoch 0 hash=Some(HeaderHash(b365f1be6863b453f12b93e1810909b10c79a95ee44bf53414888513fe172c90))
downloading epoch 0 b365f1be6863b453f12b93e1810909b10c79a95ee44bf53414888513fe172c90
 INFO 2018-05-31T16:51:01Z: exe_common::network::hermes: querying uri: http://hermes.dev.iohkdev.io/foo2/epoch/0
 INFO 2018-05-31T16:51:01Z: exe_common::network::hermes: Downloaded EPOCH in 0sec
thread 'main' panicked at 'no last block found, error.', exe-common/src/network/hermes.rs:79:23
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:463
   5: std::panicking::begin_panic
             at /checkout/src/libstd/panicking.rs:397
   6: <exe_common::network::hermes::HermesEndPoint as exe_common::network::api::Api>::fetch_epoch
             at exe-common/src/network/hermes.rs:79
   7: <exe_common::network::peer::Peer as exe_common::network::api::Api>::fetch_epoch
             at exe-common/src/network/peer.rs:44
   8: ariadne::command::blockchain::net_sync_faster
             at wallet-cli/src/command/blockchain/mod.rs:132
   9: <ariadne::command::blockchain::Blockchain as ariadne::command::HasCommand>::run
             at wallet-cli/src/command/blockchain/mod.rs:274
  10: ariadne::main
             at wallet-cli/src/main.rs:43
  11: std::rt::lang_start::{{closure}}
             at /checkout/src/libstd/rt.rs:74
  12: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  13: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  14: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:374
             at libstd/rt.rs:58
  15: std::rt::lang_start
             at /checkout/src/libstd/rt.rs:74
  16: main
  17: __libc_start_main
  18: _start
             at ../sysdeps/x86_64/start.S:120

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.