Skip to content
Snippets Groups Projects
Commit 3761ec6e authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

Add beginner walkthrough documentation (!111)

* review tuxmain

* Apply 1 suggestion(s) to 1 file(s)

* review

* remove release mode for autocompletion

* add zsh autocomplete

* improve walkthrough

fix typos
add formatting
add conclusion

* add beginner walkthrough documentation
parent 21b10749
No related branches found
No related tags found
1 merge request!111Add beginner walkthrough documentation
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
- [manual](./docs/api/manual.md) - [manual](./docs/api/manual.md)
- [runtime-calls](./docs/api/runtime-calls.md) the calls you can submit through the RPC API - [runtime-calls](./docs/api/runtime-calls.md) the calls you can submit through the RPC API
- [dev](./docs/dev/) - [dev](./docs/dev/)
- [beginner-walkthrough](./docs/dev/beginner-walkthrough.md)
- [git-conventions](./docs/dev/git-conventions.md) - [git-conventions](./docs/dev/git-conventions.md)
- [launch-a-live-network](./docs/dev/launch-a-live-network.md) - [launch-a-live-network](./docs/dev/launch-a-live-network.md)
- [setup](./docs/dev/setup.md) - [setup](./docs/dev/setup.md)
...@@ -102,6 +103,8 @@ docker run -it -p9944:9944 --name duniter-v2s \ ...@@ -102,6 +103,8 @@ docker run -it -p9944:9944 --name duniter-v2s \
## Contribute ## Contribute
If you are beginner in Rust and need a well guided tutorial, follow the [beginner walkthrough](./docs/dev/beginner-walkthrough.md).
Before any contribution, please read carefully the [CONTRIBUTING](./CONTRIBUTING.md) file and our [git conventions](./docs/dev/git-conventions.md). Before any contribution, please read carefully the [CONTRIBUTING](./CONTRIBUTING.md) file and our [git conventions](./docs/dev/git-conventions.md).
### Setup your dev environment ### Setup your dev environment
......
# Beginner walkthrough
This is a beginner tutorial for those who do not have a previous experience with Rust ecosystem or need guidance to get familiar with Duniter v2s project. You'll need a development machine with an internet connection, at least **20 GB of free storage**, and **an hour or two** depending on your computing power.
This walkthrough is based on the following video (french), don't hesitate to record an english voicecover if you feel so.
[![preview](https://tube.p2p.legal/lazy-static/previews/654006dc-66c0-4e37-a32f-b7b5a1c13213.jpg)](https://tube.p2p.legal/w/n4TXxQ4SqxzpHPY4TNMXFu)
> video walkthrough on peertube https://tube.p2p.legal/w/n4TXxQ4SqxzpHPY4TNMXFu
## Requirements
If you are on a debian based system, you can install the required packages with:
```bash
sudo apt install cmake pkg-config libssl-dev git build-essential clang libclang-dev curl
```
Else, look at the corresponding section in the [system setup documentation](./setup.md).
Rust recommended installation method is through the rustup script that you can run with:
```bash
curl https://sh.rustup.rs -sSf | sh
```
If you reopen your terminal, it will give you access to the `rustup`, `rustc` and `cargo` commands. You can then install the required Rust toolchains with:
```bash
rustup default stable
rustup update nightly
rustup update stable
rustup target add wasm32-unknown-unknown --toolchain nightly
```
This can take about **2 minutes**.
## Build project
After cloning wherever you want the `duniter-v2s` repo with:
```bash
git clone https://git.duniter.org/nodes/rust/duniter-v2s.git
```
you can go to the root folder and build the substrate client and default runtime with:
```bash
cargo build
```
This will take about **2 minutes** to download dependencies plus between 5 and **15 minutes** to build in debug mode depending on the power of your processor. At this point, you built the *substrate client* (a kind of "shell" in which lies the runtime) and the default *runtime* itself. You can run a local blockchain with:
```bash
cargo run -- --dev --tmp # here, --dev means --chain=dev which selects the gdev runtime
```
When you see the logs, the blockchain is running and you can connect to it with polkadotjs app: [https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:9944](https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944). You should see blocks being added every 6 seconds. You can use Alice, Bob, etc test accounts to submit extrinsics.
## Autocompletion
When using Duniter commands, you will benefit a lot from commands autocompletion. This can be achieved by following [autocompletion documentation](../user/autocompletion.md) for you shell. If you use bash the commands are:
```bash
# create local dir to store completion script
mkdir -p ~/.local/share/duniter
# export the bash completion file
cargo run -- completion --generator bash > ~/.local/share/duniter/completion.bash
# add the following line to your ~/.bashrc to automatically load completion on startup
[[ -f $HOME/.local/share/duniter/completion.bash ]] && source $HOME/.local/share/duniter/completion.bash
```
You will then benefit from completion using `<Tab>` key and `*`.
## End-to-end tests using cucumber
Cucumber end2end tests are a good way to dive in Duniter's business procedure. They work by spawning a local blockchain and submitting extrinsics to it. You can build and run the cucumber tests by running:
```bash
cargo cucumber
```
which should take about **4 minutes** to build and run the tests. A highly detailed documentation about the end2end tests is available [in the dedicated folder](../../end2end-tests/README.md), you will learn how to read and modify the tests.
## Get in touch with us
Wether you are stuck and need help or have sucessfully completed this tutorial, don't hesitate to get in touch with us on the Duniter forum! If you found this walkthrough useful, please 🙏 let us know on the [walkthrough topic](https://forum.duniter.org/t/contribuer-a-duniter-tutoriel-video/9770) on the forum 😊.
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
One can generate autocompletion for its favorite shell using the following option: One can generate autocompletion for its favorite shell using the following option:
```sh ```sh
cargo run --release -- completion --generator <GENERATOR> cargo run -- completion --generator <GENERATOR>
``` ```
Where `GENERATOR` can be any of `bash`, `elvish`, `fish`, `powershell` and `zsh`. Where `GENERATOR` can be any of `bash`, `elvish`, `fish`, `powershell` and `zsh`.
...@@ -14,7 +14,7 @@ First, get the completion file in a known place: ...@@ -14,7 +14,7 @@ First, get the completion file in a known place:
```sh ```sh
mkdir -p ~/.local/share/duniter mkdir -p ~/.local/share/duniter
cargo run --release -- completion --generator bash > ~/.local/share/duniter/completion.bash cargo run -- completion --generator bash > ~/.local/share/duniter/completion.bash
``` ```
You can now manually source the file when needed: You can now manually source the file when needed:
...@@ -30,3 +30,17 @@ Or you can automatically source it at `bash` startup by adding this to your `~/. ...@@ -30,3 +30,17 @@ Or you can automatically source it at `bash` startup by adding this to your `~/.
``` ```
You can now enjoy semantic completion of the `./target/release/duniter` command using `<Tab>` key. You can now enjoy semantic completion of the `./target/release/duniter` command using `<Tab>` key.
## Zsh
Zsh equivalent
```sh
# make directory to store completion
mkdir -p ~/.zsh/completion
# write the completion script
cargo run -- completion --generator zsh > ~/.zsh/completion/_duniter.zsh
# add the following lines to your ~/.zshrc
fpath+=(~/.zsh/completion)
compinit # might slow down terminal startup
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment