├── .dockerignore
├── run.sh
├── clean-chain.sh
├── .gitignore
├── .editorconfig
├── init-wasm.sh
├── docker
├── docker-compose.yml
├── build.sh
└── Dockerfile
├── src
├── error.rs
├── main.rs
├── cli.rs
├── service.rs
└── chain_spec.rs
├── Cargo.toml
├── README.md
├── banner.svg
└── LICENSE
/.dockerignore:
--------------------------------------------------------------------------------
1 | **/target/
--------------------------------------------------------------------------------
/run.sh:
--------------------------------------------------------------------------------
1 | cargo run -- --dev
2 |
--------------------------------------------------------------------------------
/clean-chain.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | cargo run -- purge-chain --dev
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Generated by Cargo
2 | # will have compiled files and executables
3 | **/target/
4 |
5 | # These are backup files generated by rustfmt
6 | **/*.rs.bk
7 |
8 | # JetBrains IDEs
9 | .idea
10 |
11 | dappforce-subsocial-runtime
12 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 | [*]
3 | indent_style=tab
4 | indent_size=tab
5 | tab_width=4
6 | end_of_line=lf
7 | charset=utf-8
8 | trim_trailing_whitespace=true
9 | max_line_length=120
10 | insert_final_newline=true
11 |
12 | [*.yml]
13 | indent_style=space
14 | indent_size=2
15 | tab_width=8
16 | end_of_line=lf
17 |
--------------------------------------------------------------------------------
/init-wasm.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 |
5 | echo "*** Initializing WASM build environment"
6 |
7 | if [ -z $CI_PROJECT_NAME ] ; then
8 | rustup update nightly
9 | rustup update stable
10 | fi
11 |
12 | rustup target add wasm32-unknown-unknown --toolchain nightly
13 |
14 | # Install wasm-gc. It's useful for stripping slimming down wasm binaries.
15 | command -v wasm-gc || \
16 | cargo +nightly install --git https://github.com/alexcrichton/wasm-gc --force
17 |
--------------------------------------------------------------------------------
/docker/docker-compose.yml:
--------------------------------------------------------------------------------
1 | # docker-compose.yml
2 | version: "3"
3 | services:
4 | subsocial-substrate:
5 | build:
6 | context: ..
7 | dockerfile: ./docker/Dockerfile
8 | image: dappforce/subsocial-node:latest
9 | container_name: subsocial_substrate_node
10 | network_mode: "host"
11 | ports:
12 | - "9944:9944"
13 | restart: on-failure
14 | volumes:
15 | - chain_data:/data
16 | command: ./subsocial-node --dev --ws-external
17 |
18 | volumes:
19 | chain_data:
20 | driver: local
21 |
--------------------------------------------------------------------------------
/docker/build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -e
3 |
4 | pushd .
5 |
6 | # The following line ensure we run from the project root
7 | PROJECT_ROOT=`git rev-parse --show-toplevel`
8 | cd $PROJECT_ROOT
9 |
10 | # Find the current version from Cargo.toml
11 | VERSION=`grep "^version" ./Cargo.toml | egrep -o "([0-9\.]+)"`
12 | GITUSER=dappforce
13 | GITREPO=subsocial-node
14 |
15 | # Build the image
16 | echo "Building ${GITUSER}/${GITREPO}:latest docker image, hang on!"
17 | time docker build -f ./docker/Dockerfile -t ${GITUSER}/${GITREPO}:latest .
18 |
19 | # Show the list of available images for this repo
20 | echo "Image is ready"
21 | docker images | grep ${GITREPO}
22 |
23 | echo -e "\nIf you just built version ${VERSION}, you may want to update your tag:"
24 | echo " $ docker tag ${GITUSER}/${GITREPO}:$VERSION ${GITUSER}/${GITREPO}:${VERSION}"
25 |
26 | popd
--------------------------------------------------------------------------------
/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM rust:slim as builder
2 |
3 | ENV TERM xterm
4 |
5 | RUN apt-get update && apt-get upgrade -y && apt-get install -y cmake pkg-config libssl-dev clang
6 |
7 | WORKDIR /dappforce-subsocial-node
8 | COPY init-wasm.sh .
9 | COPY build-runtime.sh .
10 | COPY Cargo.toml .
11 | COPY Cargo.lock .
12 | COPY dappforce-subsocial-runtime/ dappforce-subsocial-runtime/
13 |
14 | RUN ./init-wasm.sh
15 | RUN ./build-runtime.sh
16 |
17 | COPY src/ src/
18 | COPY build.rs .
19 |
20 | RUN cargo build
21 |
22 | FROM rust:slim
23 |
24 | COPY --from=builder /dappforce-subsocial-node/target/debug/subsocial-node .
25 |
26 | RUN mv /usr/share/ca* /tmp && \
27 | rm -rf /usr/share/* && \
28 | mv /tmp/ca-certificates /usr/share && \
29 | mkdir -p /root/.local/share/subsocial-node && \
30 | ln -s /root/.local/share/subsocial-node /data
31 |
32 | RUN rm -rf /usr/bin /usr/sbin
33 |
34 |
35 | EXPOSE 30333 9933 9944
36 | VOLUME ["/data"]
37 |
38 | CMD ["./subsocial-node"]
--------------------------------------------------------------------------------
/src/error.rs:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Joystream Contributors
2 | // This file is part of Joystream node.
3 |
4 | // Joystream node is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 |
9 | // Joystream node is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 |
14 | // You should have received a copy of the GNU General Public License
15 | // along with Joystream node. If not, see .
16 |
17 | //! Initialization errors.
18 |
19 | use client;
20 |
21 | error_chain! {
22 | foreign_links {
23 | Io(::std::io::Error) #[doc="IO error"];
24 | Cli(::clap::Error) #[doc="CLI error"];
25 | }
26 | links {
27 | Client(client::error::Error, client::error::ErrorKind) #[doc="Client error"];
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main.rs:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Joystream Contributors
2 | // This file is part of Joystream node.
3 |
4 | // Joystream node is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 |
9 | // Joystream node is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 |
14 | // You should have received a copy of the GNU General Public License
15 | // along with Joystream node. If not, see .
16 |
17 | //! Substrate Node Template CLI library.
18 |
19 | #![warn(missing_docs)]
20 | #![warn(unused_extern_crates)]
21 |
22 | mod chain_spec;
23 | mod cli;
24 | mod service;
25 |
26 | pub use substrate_cli::{error, IntoExit, VersionInfo};
27 |
28 | fn run() -> cli::error::Result<()> {
29 | let version = VersionInfo {
30 | name: "Subsocial Node",
31 | commit: env!("VERGEN_SHA_SHORT"),
32 | version: env!("CARGO_PKG_VERSION"),
33 | executable_name: "subsocial-node",
34 | author: "Dappforce",
35 | description: "Dappforce Subsocial Substrate node",
36 | support_url: "http://dappforce.io",
37 | };
38 | cli::run(::std::env::args(), cli::Exit, version)
39 | }
40 |
41 | error_chain::quick_main!(run);
42 |
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [[bin]]
2 | name = 'subsocial-node'
3 | path = 'src/main.rs'
4 |
5 | [package]
6 | authors = ['Dappforce']
7 | build = 'build.rs'
8 | edition = '2018'
9 | name = 'subsocial-node'
10 | version = '1.0.0'
11 |
12 | [dependencies]
13 | error-chain = '0.12'
14 | exit-future = '0.1'
15 | futures = '0.1'
16 | hex-literal = '0.1'
17 | log = '0.4'
18 | parity-codec = '3.2'
19 | parking_lot = '0.7.1'
20 | tokio = '0.1'
21 | trie-root = '0.12.0'
22 |
23 | [dependencies.basic-authorship]
24 | git = 'https://github.com/joystream/substrate.git'
25 | package = 'substrate-basic-authorship'
26 | rev = '6dfc3e8b057bb00322136251a0f10305fbb1ad8f'
27 |
28 | [dependencies.consensus]
29 | git = 'https://github.com/joystream/substrate.git'
30 | package = 'substrate-consensus-aura'
31 | rev = '6dfc3e8b057bb00322136251a0f10305fbb1ad8f'
32 |
33 | [dependencies.ctrlc]
34 | features = ['termination']
35 | version = '3.0'
36 |
37 | [dependencies.inherents]
38 | git = 'https://github.com/joystream/substrate.git'
39 | package = 'substrate-inherents'
40 | rev = '6dfc3e8b057bb00322136251a0f10305fbb1ad8f'
41 |
42 | [dependencies.network]
43 | git = 'https://github.com/joystream/substrate.git'
44 | package = 'substrate-network'
45 | rev = '6dfc3e8b057bb00322136251a0f10305fbb1ad8f'
46 |
47 | [dependencies.subsocial-runtime]
48 | path = 'dappforce-subsocial-runtime'
49 |
50 | [dependencies.primitives]
51 | git = 'https://github.com/joystream/substrate.git'
52 | package = 'substrate-primitives'
53 | rev = '6dfc3e8b057bb00322136251a0f10305fbb1ad8f'
54 |
55 | [dependencies.sr-io]
56 | git = 'https://github.com/joystream/substrate.git'
57 | rev = '6dfc3e8b057bb00322136251a0f10305fbb1ad8f'
58 |
59 | [dependencies.substrate-cli]
60 | git = 'https://github.com/joystream/substrate.git'
61 | rev = '6dfc3e8b057bb00322136251a0f10305fbb1ad8f'
62 |
63 | [dependencies.substrate-client]
64 | git = 'https://github.com/joystream/substrate.git'
65 | rev = '6dfc3e8b057bb00322136251a0f10305fbb1ad8f'
66 |
67 | [dependencies.substrate-executor]
68 | git = 'https://github.com/joystream/substrate.git'
69 | rev = '6dfc3e8b057bb00322136251a0f10305fbb1ad8f'
70 |
71 | [dependencies.substrate-service]
72 | git = 'https://github.com/joystream/substrate.git'
73 | rev = '6dfc3e8b057bb00322136251a0f10305fbb1ad8f'
74 |
75 | [dependencies.transaction-pool]
76 | git = 'https://github.com/joystream/substrate.git'
77 | package = 'substrate-transaction-pool'
78 | rev = '6dfc3e8b057bb00322136251a0f10305fbb1ad8f'
79 |
80 | [dependencies.substrate-telemetry]
81 | git = 'https://github.com/joystream/substrate.git'
82 | package = 'substrate-telemetry'
83 | rev = '6dfc3e8b057bb00322136251a0f10305fbb1ad8f'
84 |
85 | [dependencies.grandpa]
86 | git = 'https://github.com/joystream/substrate.git'
87 | package = 'substrate-finality-grandpa'
88 | rev = '6dfc3e8b057bb00322136251a0f10305fbb1ad8f'
89 |
90 | [profile.release]
91 | panic = 'unwind'
92 |
93 | [build-dependencies]
94 | vergen = '3'
95 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Subsocial Node for Substrate v1 by [DappForce](https://github.com/dappforce)
2 |
3 | ⚠️ Note that Subsocial development has moved to a new repo: [dappforce-subsocial-node](https://github.com/dappforce/dappforce-subsocial-node) and now it's based on Substrate v2. That's why we archieved this current repo where Subsocial is implemented on top of [Substrate v1 (April 12, 2019)](https://github.com/paritytech/substrate/commit/6dfc3e8b057bb00322136251a0f10305fbb1ad8f).
4 |
5 | ## What is Subsocial?
6 |
7 | Subsocial is a set of Substrate pallets with web UI that allows anyone to launch their own decentralized censorship-resistant social network aka community. Every community can be a separate Substrate chain and connect with other communities via a Polkadot-based relay chain.
8 |
9 | You can think of this as decentralized versions of Reddit, Stack Exchange or Medium, where subreddits or communities of Stack Exchange or blogs on Medium run on their own chain. At the same time, users of these decentralized communities should be able to share their reputation or transfer coins and other values from one community to another via Polkadot relay chain.
10 |
11 | To learn more about Subsocial, please visit [Subsocial Network](http://subsocial.network).
12 |
13 | ## Supported by Web3 Foundation
14 |
15 |
16 |
17 | Subsocial is a recipient of the technical grant from Web3 Foundation. We have successfully delivered all three milestones described in Subsocial's grant application. [Official announcement](https://medium.com/web3foundation/web3-foundation-grants-wave-3-recipients-6426e77f1230).
18 |
19 | ## Building from source
20 |
21 | ### Initial setup
22 | If you want to build from source you will need the Rust [toolchain](https://rustup.rs/), openssl and llvm/libclang.
23 |
24 | ```bash
25 | git clone git@github.com:dappforce/dappforce-subsocial-node.git
26 | ```
27 |
28 | Initialise the WASM build environment:
29 |
30 | ```bash
31 | cd dappforce-subsocial-node/
32 | ./init-wasm.sh
33 | ```
34 |
35 | ### Building
36 | Clone the SubSocial runtime into the dappforce-subsocial-runtime directory:
37 |
38 | ```bash
39 | git clone git@github.com:dappforce/dappforce-subsocial-runtime.git
40 | ```
41 |
42 | Build the WASM runtime library:
43 | ```bash
44 | ./build-runtime.sh
45 | ```
46 |
47 | Build the node (native code):
48 | ```bash
49 | cargo build --release
50 | ```
51 |
52 | ### Running a public node
53 | Run the node and connect to the public testnet
54 | ```bash
55 | cargo run --release
56 | ```
57 |
58 | ### Installing a release build
59 | This will install the executable `subsocial-node` to your `~/.cargo/bin` folder, which you would normally have in your `$PATH` environment.
60 |
61 | ```bash
62 | cargo install --path ./
63 | ```
64 |
65 | Now you can run
66 |
67 | ```bash
68 | subsocial-node
69 | ```
70 |
71 | ## Building from Docker
72 |
73 | ### Easiest start
74 | To start Subsocial Full Node separately (you should have docker-compose):
75 |
76 | ```
77 | cd docker/
78 | docker-compose up -d
79 | ```
80 |
81 | ### Start with your own parameters
82 |
83 | ```
84 | docker run -p 9944:9944 dappforce/subsocial-node:latest ./subsocial-node [flags] [options]
85 | ```
86 | * Don't forget `--ws-external` flag, if you want your node to be visible no only within the container.
87 |
88 | ### Build your own image
89 | If you want to build docker image from your local repository (it takes a while...), in your shell:
90 |
91 | ```
92 | cd docker/
93 | ./build
94 | ```
95 |
96 | ### Start all parts of Subsocial at once with [Subsocial Starter](https://github.com/dappforce/dappforce-subsocial-starter).
97 |
98 | ## Development
99 |
100 | ### Running a local development node
101 |
102 | ```bash
103 | cargo run --release -- --dev
104 | ```
105 |
106 | ### Cleaning development chain data
107 | When making changes to the runtime library remember to purge the chain after rebuilding the node to test the new runtime.
108 |
109 | ```bash
110 | cargo run --release -- purge-chain --dev
111 | ```
112 |
113 | ## License
114 |
115 | Subsocial is [GPL 3.0](./LICENSE) licensed.
116 |
--------------------------------------------------------------------------------
/src/cli.rs:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Joystream Contributors
2 | // This file is part of Joystream node.
3 |
4 | // Joystream node is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 |
9 | // Joystream node is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 |
14 | // You should have received a copy of the GNU General Public License
15 | // along with Joystream node. If not, see .
16 |
17 | use crate::chain_spec;
18 | use crate::service;
19 | use futures::{future, sync::oneshot, Future};
20 | use log::info;
21 | use std::cell::RefCell;
22 | use std::ops::Deref;
23 | pub use substrate_cli::{error, IntoExit, VersionInfo};
24 | use substrate_cli::{informant, parse_and_execute, NoCustom};
25 | use substrate_service::{Roles as ServiceRoles, ServiceFactory};
26 | use tokio::runtime::Runtime;
27 |
28 | /// Parse command line arguments into service configuration.
29 | pub fn run(args: I, exit: E, version: VersionInfo) -> error::Result<()>
30 | where
31 | I: IntoIterator- ,
32 | T: Into + Clone,
33 | E: IntoExit,
34 | {
35 | parse_and_execute::(
36 | load_spec,
37 | &version,
38 | "subsocial-node",
39 | args,
40 | exit,
41 | |exit, _custom_args, config| {
42 | info!("{}", version.name);
43 | info!(" version {}", config.full_version());
44 | info!(" by {}, 2019", version.author);
45 | info!("Chain specification: {}", config.chain_spec.name());
46 | info!("Node name: {}", config.name);
47 | info!("Roles: {:?}", config.roles);
48 | let runtime = Runtime::new().map_err(|e| format!("{:?}", e))?;
49 | let executor = runtime.executor();
50 | match config.roles {
51 | ServiceRoles::LIGHT => run_until_exit(
52 | runtime,
53 | service::Factory::new_light(config, executor)
54 | .map_err(|e| format!("{:?}", e))?,
55 | exit,
56 | ),
57 | _ => run_until_exit(
58 | runtime,
59 | service::Factory::new_full(config, executor).map_err(|e| format!("{:?}", e))?,
60 | exit,
61 | ),
62 | }
63 | .map_err(|e| format!("{:?}", e))
64 | },
65 | )
66 | .map_err(Into::into)
67 | .map(|_| ())
68 | }
69 |
70 | fn load_spec(id: &str) -> Result