DECA Docs

The DECA Project Documentation

Introduction

A general DECA protocol specification and some example use cases.

Requirements

There are some requirements you need to fulfill to be able to work with DECA docs.

  • Rust >= 1.66
  • curl >= 7.88.1
  • cargo >= 1.72.0
  • mdBook >= v0.4.34
  • git >= 2.39.2

NOTE: These are the recommended versions since they were tested in the development environment.

Installation.

The easiest way to get both Rust and Cargo's latest versions is by using the rustup script, which also means that you have to use the curl command.

1. Git Installation.

The first step is to install git on you Unix system. To do that, you only need to run the following command:

$ sudo apt install git

2. Curl Installation.

You have to repeat the same proccess to install curl, use the apt command:

 $ sudo apt install curl

Once you have curl installed you can go ahead and continue with the Rust and Cargo installations.

3. Rust and Cargo Installation.

To install Rust and Cargo on your Unix System you have to download the rustup installer script using the following command on the terminal:

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

By using the previous command you will get the latest Rust and Cargo's versions.

Suggestion: You can make sure the installation was succesfull by using the following command:

$ rustc --version

It tells you the version of Rust that was installed.

NOTE: Some important considerations when installing Rust:

  • When you install Rust, it will be installed only for the current user, in other words, the installation is not system-wide.

  • It is not required to be root or sudo to be able to install Rust.

Once you have completed your Rust and Cargo installations, you can now continue with the mdBook installation.

4. MdBook Installation.

DECA Docs uses mdBook as a way to create books with Markdown. Since mdBook is a command line tool, it is ideal for creating tutorials, API documentations, course materials, amongst other useful things.

You can follow the instructions bellow to download mdBook.

First, you have to use the following command to build and install mdBook:

$ cargo install mdbook

The command will automatically download mdBook, build it and install it in Cargo's global binary directory.

Once installed, the next step is to get the DECA Docs repository. Follow the instructions below to get it.

Clone the DECA Documentation repository.

After you have succesfully compleated all installations, you can now access the docummentation repository and contribute to the resources. Run the next command on the terminal:

$ git clone https://git.decentralizedscience.org/DECA/docs.git
  • This command lets you copy the DECA Docs repository to your local machine.
  • It also means that you can pull down a full copy of all the repository data that it has at that point in time, including all versions of every file and folder for the project.

Once the repository has been cloned, you can have access to it by entering the following command on your terminal:

$ cd docs/

This command will lead you to the directory where you can find the DECA Docs README.md.

The last step is to run the server using the following command:

$ mdbook serve 

You can view the page on any browser using the following link http://127.0.0.1:3000

NOTE: If you want to access remotely use the mdbook serve -n 0.0.0.0 which means any IP address can access the DECA Docs project.

Contribute (Usage)

ToDo

Contract

Developers

License

Copyright (C) DECENTRALIZED CLIMATE FOUNDATION A.C.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU
Free Documentation License". 

References

  1. Rust, "Learn Rust", https://www.rust-lang.org/tools/install, 2023-08-31.

  2. A.Prakash, "How to install Rust and Cargo", https://itsfoss.com/install-rust-cargo-ubuntu-linux/, 2023-03-26.

  3. The Cargo Book, "Installation", https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/share/doc/rust/html/cargo/getting-started/installation.html#build-and-install-cargo-from-source, 2023-08-31.

  4. Docs GitHub, "Cloning a repository", https://docs.github.com/es/repositories/creating-and-managing-repositories/cloning-a-repository, 2023-08-31.

  5. mdBook Docummentation, "Introduction", https://rust-lang.github.io/mdBook/#:~:text=mdBook%20is%20a%20command%20line,easily%20navigable%20and%20customizable%20presentation.&text=This%20guide%20is%20an%20example%20of%20what%20mdBook%20produces., 2023-08-31.

DECA's IPFS Nodes Setup Guide

The following guide is on how to setup an IPFS node for DECA Protocol Requirements if you want to contribute and provide some infrastructure. This guide is based on Debian 12.1, improvements to our documentation are welcome.

IPFS Instalation

  1. Download the Linux Kubo binary from dist.ipfs.tech.

    $ wget https://dist.ipfs.tech/kubo/v0.22.0/kubo_v0.22.0_linux-amd64.tar.gz
    
  2. Untargz the file:

    $ tar -xvzf kubo_v0.22.0_linux-amd64.tar.gz
    > x kubo/LICENSE
    > x kubo/LICENSE-APACHE
    > x kubo/LICENSE-MIT
    > x kubo/README.md
    > x kubo/install.sh
    > x kubo/ipfs
    
  3. Move into the go-ipfs folder and run the install script:

    $ cd kubo
    
    $ sudo bash install.sh
    
    > Moved ./ipfs to /usr/local/bin
    
  4. Test that IPFS has installed correctly:

    ipfs --version
    
    > ipfs version 0.22.0
    

Setup ipfs service for deca

First time config setup for a server:

   ipfs init --profile server

This removes local discovery requests

Enable Public Gateway

Modify the GateWay section with the IP Address 0.0.0.0 :

 "Addresses": {
 "API": "/ip4/127.0.0.1/tcp/5001",
 "Announce": [],
 "AppendAnnounce": [],
 "Gateway": "/ip4/0.0.0.0/tcp/8080",

Enable WebSocket on port 4004

Add swarm address in the config (specifically the ws line):

    "Swarm": [
      "/ip4/0.0.0.0/tcp/4001",
      "/ip4/0.0.0.0/tcp/4004/ws",
      "/ip6/::/tcp/4001",
      "/ip4/0.0.0.0/udp/4001/quic",
      "/ip6/::/udp/4001/quic"
    ]

Enable Circuit Relay V2

Enable Swarm.RelayService with the following command:

   ipfs config --json Swarm.RelayService.Enabled true

and

   ipfs config --json Swarm.RelayClient.Enabled true

Enable Public Gateway

To enable the public gateway setting your Gateway section should look as the following:

  "Gateway": {
    "APICommands": [],
    "DeserializedResponses": null,
    "HTTPHeaders": {},
    "NoDNSLink": false,
    "NoFetch": false,
    "PathPrefixes": [],
    "PublicGateways":{
      "devteam": {
        "UseSubdomains": false,
        "Paths": [
          "/ipfs",
          "/ipns"
        ]
      }
    },
    "RootRedirect": ""
  },

Set IPFS as a daemon

Copy the following lines after the sudo vim... command, modify user and path to ipfs so that it matches with your system and user that runs ipfs:

 $ sudo vim /etc/systemd/system/ipfs.service

[Unit]
Description=IPFS Daemon
After=network.target

[Service]
Type=notify
ExecStart=/usr/local/bin/ipfs daemon --enable-gc=true --migrate=true
ExecStop=/usr/local/bin/ipfs shutdown
User=nodemaster
Restart=on-failure
LimitNOFILE=10240
KillSignal=SIGINT

[Install]
WantedBy=multi-user.target

NOTE: in this example user that runs ipfs is nodemaster, also the ipfs location is at /usr/local/bin/ipfs if you don't know the path, try $ whereis ipfs

Enable the service

 $ sudo systemctl daemon-reload
 $ sudo systemctl enable ipfs.service
 $ sudo systemctl start ipfs.service
 $ sudo systemctl status ipfs.service

NOTE: service must be set as active (running), if not please verify the preview steps

Set IPFS as a daemon and Nginx Reverse Proxy

Nginx Reverse Proxy for a public gateway and websocket

NOTE: websocket is required for the Orbitdb which hold search.deca.eco our carbon credits distributed database

The Gateway setup: Change the server name for your own domain name:

server {
    listen 80;
    server_name gateway.decentralizescience.org;

    location / {
        proxy_pass http://localhost:8080;
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        allow all;
    }
}

Note: Remember to enable the service and get ssl with certbot

The enabling Secure WebSocket with nginx:

NOTE: Change the server name for your own domain name.

server {
    listen 80; 
    server_name ipfs.decentralizedscience.org;

    location / {
        proxy_pass http://127.0.0.1:4004;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

NOTE: Remember to enable the service and get ssl with certbot

Testing

Verify Secure WebSocket connection

Doing an IPFS ping

ipfs ping /dns4/gateway.decentralizedscience.org/443/wss/p2p/12D3KooWQzickgUJ1N9dNZMJpNnFUCHmhndTVgexXnt6dQhPFcEE

PING 12D3KooWQzickgUJ1N9dNZMJpNnFUCHmhndTVgexXnt6dQhPFcEE.
Pong received: time=161.27 ms
Pong received: time=161.13 ms
Pong received: time=161.55 ms

Doing a swarm connect

ipfs swarm connect /dns4/gateway.decentralizedscience.org/443/wss/p2p/12D3KooWQzickgUJ1N9dNZMJpNnFUCHmhndTVgexXnt6dQhPFcEE

connect 12D3KooWQzickgUJ1N9dNZMJpNnFUCHmhndTVgexXnt6dQhPFcEE success

check the IPFS public Gateway:

Browse by adding /ipns/docs.deca.eco/ to your gateway address:

You should see the IPFS official web3 website

Example: https://gateway.decentralizedscience.org/ipns/docs.deca.eco/

License

GPLV3. ?

Contact.

Developers

ToDo/Proposal

References

  1. Install IPFS Kubo
  2. Hosting a public IPFS gateway
  3. file transfer
  4. circuit relay
  5. understanding circuit relay
  6. experimental features