diff --git a/Cargo.lock b/Cargo.lock index 5f1db767a7f44..9cb5e757fca89 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2952,6 +2952,104 @@ dependencies = [ "libc", ] +[[package]] +name = "mangata-node" +version = "2.0.0" +dependencies = [ + "frame-benchmarking", + "frame-benchmarking-cli", + "frame-support", + "frame-system", + "jsonrpc-core", + "mangata-runtime", + "pallet-assets", + "pallet-authority-discovery", + "pallet-balances", + "pallet-grandpa", + "pallet-staking", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc", + "sc-authority-discovery", + "sc-basic-authorship", + "sc-chain-spec", + "sc-cli", + "sc-client-api", + "sc-client-db", + "sc-consensus", + "sc-consensus-babe", + "sc-executor", + "sc-finality-grandpa", + "sc-network", + "sc-offchain", + "sc-rpc", + "sc-rpc-api", + "sc-service", + "sc-telemetry", + "sc-tracing", + "sc-transaction-pool", + "sp-api", + "sp-authority-discovery", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-core", + "sp-finality-grandpa", + "sp-finality-tracker", + "sp-inherents", + "sp-io", + "sp-keyring", + "sp-runtime", + "sp-timestamp", + "sp-transaction-pool", + "structopt", + "substrate-build-script-utils", + "substrate-frame-rpc-system", +] + +[[package]] +name = "mangata-runtime" +version = "2.0.0" +dependencies = [ + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "hex-literal", + "pallet-assets", + "pallet-authorship", + "pallet-babe", + "pallet-balances", + "pallet-grandpa", + "pallet-offences", + "pallet-randomness-collective-flip", + "pallet-session", + "pallet-staking", + "pallet-staking-reward-curve", + "pallet-sudo", + "pallet-template", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-xyk", + "parity-scale-codec", + "serde", + "sp-api", + "sp-block-builder", + "sp-consensus-babe", + "sp-core", + "sp-inherents", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder-runner", +] + [[package]] name = "matchers" version = "0.0.1" @@ -3232,104 +3330,6 @@ dependencies = [ "void", ] -[[package]] -name = "node-template" -version = "2.0.0" -dependencies = [ - "frame-benchmarking", - "frame-benchmarking-cli", - "frame-support", - "frame-system", - "jsonrpc-core", - "node-template-runtime", - "pallet-assets", - "pallet-authority-discovery", - "pallet-balances", - "pallet-grandpa", - "pallet-staking", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc", - "sc-authority-discovery", - "sc-basic-authorship", - "sc-chain-spec", - "sc-cli", - "sc-client-api", - "sc-client-db", - "sc-consensus", - "sc-consensus-babe", - "sc-executor", - "sc-finality-grandpa", - "sc-network", - "sc-offchain", - "sc-rpc", - "sc-rpc-api", - "sc-service", - "sc-telemetry", - "sc-tracing", - "sc-transaction-pool", - "sp-api", - "sp-authority-discovery", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-core", - "sp-finality-grandpa", - "sp-finality-tracker", - "sp-inherents", - "sp-io", - "sp-keyring", - "sp-runtime", - "sp-timestamp", - "sp-transaction-pool", - "structopt", - "substrate-build-script-utils", - "substrate-frame-rpc-system", -] - -[[package]] -name = "node-template-runtime" -version = "2.0.0" -dependencies = [ - "frame-benchmarking", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "hex-literal", - "pallet-assets", - "pallet-authorship", - "pallet-babe", - "pallet-balances", - "pallet-grandpa", - "pallet-offences", - "pallet-randomness-collective-flip", - "pallet-session", - "pallet-staking", - "pallet-staking-reward-curve", - "pallet-sudo", - "pallet-template", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-xyk", - "parity-scale-codec", - "serde", - "sp-api", - "sp-block-builder", - "sp-consensus-babe", - "sp-core", - "sp-inherents", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder-runner", -] - [[package]] name = "nodrop" version = "0.1.14" diff --git a/Cargo.toml b/Cargo.toml index 23b94c592f58e..0fa037f28473e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ panic = 'unwind' [workspace] members = [ 'node', - 'pallets/template', + 'pallets/xyk', 'runtime', ] diff --git a/README.md b/README.md index 8d4689e537164..cfc64bc4085d3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ -# Substrate Node Template +# Mangata node +##The fair DEX +The most reliable decentralized exchange (DEX) - capable of working across multiple blockchains using interoperability. The exchange is using an innovative consensus algorithm that solves frontrunning problems and makes all participants equal. + +Our mission is to bring fair and equal rules for exchange participants, fix volatile fees of trading and reuse exchange assets to maximize gains. Our goal is to create the number one Go-To protocol for traders and liquidity providers of digital currencies online. + +The design of our blockchain guarantees low fixed-fees that provides greater predictability of trading costs. +Assets on the exchange will serve multiple purposes- at the first iteration, they are the block producer’s stake and exchange liquidity at the same time, and more comes later. -A new FRAME-based Substrate node, ready for hacking :rocket: ## Local Development @@ -20,156 +26,39 @@ curl https://getsubstrate.io -sSf | bash -s -- --fast Find manual setup instructions at the [Substrate Developer Hub](https://substrate.dev/docs/en/knowledgebase/getting-started/#manual-installation). -### Build +## Build -Once the development environment is set up, build the node template. This command will build the -[Wasm](https://substrate.dev/docs/en/knowledgebase/advanced/executor#wasm-execution) and -[native](https://substrate.dev/docs/en/knowledgebase/advanced/executor#native-execution) code: +### Local target ```bash cargo build --release ``` -## Run - -### Single Node Development Chain - -Purge any existing dev chain state: +### Docker container ```bash -./target/release/node-template purge-chain --dev +./scripts/build-manga-node-docker-image.sh ``` -Start a dev chain: +## Run -```bash -./target/release/node-template --dev -``` +### Single Node Development Chain -Or, start a dev chain with detailed logging: +Purge any existing dev chain state: ```bash -RUST_LOG=debug RUST_BACKTRACE=1 ./target/release/node-template -lruntime=debug --dev +./target/release/mangata-node purge-chain --dev ``` -### Multi-Node Local Testnet - -If you want to see the multi-node consensus algorithm in action, refer to -[our Start a Private Network tutorial](https://substrate.dev/docs/en/tutorials/start-a-private-network/). - -## Template Structure - -A Substrate project such as this consists of a number of components that are spread across a few -directories. - -### Node - -A blockchain node is an application that allows users to participate in a blockchain network. -Substrate-based blockchain nodes expose a number of capabilities: - -- Networking: Substrate nodes use the [`libp2p`](https://libp2p.io/) networking stack to allow the - nodes in the network to communicate with one another. -- Consensus: Blockchains must have a way to come to - [consensus](https://substrate.dev/docs/en/knowledgebase/advanced/consensus) on the state of the - network. Substrate makes it possible to supply custom consensus engines and also ships with - several consensus mechanisms that have been built on top of - [Web3 Foundation research](https://research.web3.foundation/en/latest/polkadot/NPoS/index.html). -- RPC Server: A remote procedure call (RPC) server is used to interact with Substrate nodes. - -There are several files in the `node` directory - take special note of the following: - -- [`chain_spec.rs`](./node/src/chain_spec.rs): A - [chain specification](https://substrate.dev/docs/en/knowledgebase/integrate/chain-spec) is a - source code file that defines a Substrate chain's initial (genesis) state. Chain specifications - are useful for development and testing, and critical when architecting the launch of a - production chain. Take note of the `development_config` and `testnet_genesis` functions, which - are used to define the genesis state for the local development chain configuration. These - functions identify some - [well-known accounts](https://substrate.dev/docs/en/knowledgebase/integrate/subkey#well-known-keys) - and use them to configure the blockchain's initial state. -- [`service.rs`](./node/src/service.rs): This file defines the node implementation. Take note of - the libraries that this file imports and the names of the functions it invokes. In particular, - there are references to consensus-related topics, such as the - [longest chain rule](https://substrate.dev/docs/en/knowledgebase/advanced/consensus#longest-chain-rule), - the [Aura](https://substrate.dev/docs/en/knowledgebase/advanced/consensus#aura) block authoring - mechanism and the - [GRANDPA](https://substrate.dev/docs/en/knowledgebase/advanced/consensus#grandpa) finality - gadget. - -After the node has been [built](#build), refer to the embedded documentation to learn more about the -capabilities and configuration parameters that it exposes: - -```shell -./target/release/node-template --help -``` - -### Runtime - -In Substrate, the terms -"[runtime](https://substrate.dev/docs/en/knowledgebase/getting-started/glossary#runtime)" and -"[state transition function](https://substrate.dev/docs/en/knowledgebase/getting-started/glossary#stf-state-transition-function)" -are analogous - they refer to the core logic of the blockchain that is responsible for validating -blocks and executing the state changes they define. The Substrate project in this repository uses -the [FRAME](https://substrate.dev/docs/en/knowledgebase/runtime/frame) framework to construct a -blockchain runtime. FRAME allows runtime developers to declare domain-specific logic in modules -called "pallets". At the heart of FRAME is a helpful -[macro language](https://substrate.dev/docs/en/knowledgebase/runtime/macros) that makes it easy to -create pallets and flexibly compose them to create blockchains that can address -[a variety of needs](https://www.substrate.io/substrate-users/). - -Review the [FRAME runtime implementation](./runtime/src/lib.rs) included in this template and note -the following: - -- This file configures several pallets to include in the runtime. Each pallet configuration is - defined by a code block that begins with `impl $PALLET_NAME::Trait for Runtime`. -- The pallets are composed into a single runtime by way of the - [`construct_runtime!`](https://crates.parity.io/frame_support/macro.construct_runtime.html) - macro, which is part of the core - [FRAME Support](https://substrate.dev/docs/en/knowledgebase/runtime/frame#support-library) - library. - -### Pallets - -The runtime in this project is constructed using many FRAME pallets that ship with the -[core Substrate repository](https://github.com/paritytech/substrate/tree/master/frame) and a -template pallet that is [defined in the `pallets`](./pallets/template/src/lib.rs) directory. - -A FRAME pallet is compromised of a number of blockchain primitives: - -- Storage: FRAME defines a rich set of powerful - [storage abstractions](https://substrate.dev/docs/en/knowledgebase/runtime/storage) that makes - it easy to use Substrate's efficient key-value database to manage the evolving state of a - blockchain. -- Dispatchables: FRAME pallets define special types of functions that can be invoked (dispatched) - from outside of the runtime in order to update its state. -- Events: Substrate uses [events](https://substrate.dev/docs/en/knowledgebase/runtime/events) to - notify users of important changes in the runtime. -- Errors: When a dispatchable fails, it returns an error. -- Trait: The `Trait` configuration interface is used to define the types and parameters upon which - a FRAME pallet depends. - -### Run in Docker - -First, install [Docker](https://docs.docker.com/get-docker/) and -[Docker Compose](https://docs.docker.com/compose/install/). - -Then run the following command to start a single node development chain. +Start a dev chain: ```bash -./scripts/docker_run.sh +./target/release/mangata-node --dev ``` -This command will firstly compile your code, and then start a local development network. You can -also replace the default command (`cargo build --release && ./target/release/node-template --dev --ws-external`) -by appending your own. A few useful ones are as follow. +### Two-Nodes Dockerized Testnet ```bash -# Run Substrate node without re-compiling -./scripts/docker_run.sh ./target/release/node-template --dev --ws-external - -# Purge the local dev chain -./scripts/docker_run.sh ./target/release/node-template purge-chain --dev - -# Check whether the code is compilable -./scripts/docker_run.sh cargo check +cd ./devops +docker-compose up ``` diff --git a/devops/dockerfiles/node-and-runtime/Dockerfile b/devops/dockerfiles/node-and-runtime/Dockerfile index 183b5297b6435..dbdbb1e56858c 100644 --- a/devops/dockerfiles/node-and-runtime/Dockerfile +++ b/devops/dockerfiles/node-and-runtime/Dockerfile @@ -8,8 +8,8 @@ RUN WASM_BUILD_TOOLCHAIN=nightly-2020-05-23 cargo build --release FROM debian:stretch LABEL description="mangata node" WORKDIR /mangata -COPY --from=builder /mangata/target/release/node-template /mangata/node -COPY --from=builder /mangata/target/release/wbuild/node-template-runtime/node_template_runtime.compact.wasm /mangata/runtime.compact.wasm +COPY --from=builder /mangata/target/release/mangata-node /mangata/node +COPY --from=builder /mangata/target/release/wbuild/mangata-runtime/mangata_runtime.compact.wasm /mangata/runtime.compact.wasm RUN /mangata/node --version diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index bc1922f47d963..0000000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,17 +0,0 @@ -version: "3.2" - -services: - dev: - container_name: node-template - image: paritytech/ci-linux:production - working_dir: /var/www/node-template - ports: - - "9944:9944" - environment: - - CARGO_HOME=/var/www/node-template/.cargo - volumes: - - .:/var/www/node-template - - type: bind - source: ./.local - target: /root/.local - command: bash -c "cargo build --release && ./target/release/node-template --dev --ws-external" diff --git a/node/Cargo.toml b/node/Cargo.toml index 28f3449843788..7a36eb6271fca 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -1,16 +1,15 @@ [package] authors = ['Substrate DevHub '] build = 'build.rs' -description = 'A fresh FRAME-based Substrate node, ready for hacking.' +description = 'The fair DEX' edition = '2018' homepage = 'https://substrate.dev' license = 'Unlicense' -name = 'node-template' -repository = 'https://github.com/substrate-developer-hub/substrate-node-template/' +name = 'mangata-node' version = '2.0.0' [[bin]] -name = 'node-template' +name = 'mangata-node' [package.metadata.docs.rs] targets = ['x86_64-unknown-linux-gnu'] @@ -23,7 +22,7 @@ jsonrpc-core = '15.0.0' structopt = '0.3.8' # local dependencies -node-template-runtime = { path = '../runtime', version = '2.0.0' } +mangata-runtime = { path = '../runtime', version = '2.0.0' } # Substrate dependencies frame-benchmarking = '2.0.0' @@ -77,4 +76,4 @@ pallet-assets = { default-features = false, version = '2.0.0', path = '../pallet [features] default = [] -runtime-benchmarks = ['node-template-runtime/runtime-benchmarks'] +runtime-benchmarks = ['mangata-runtime/runtime-benchmarks'] diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 4e62dd4917ae4..3417210ab7379 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -1,5 +1,5 @@ use sp_core::{Pair, Public, sr25519}; -use node_template_runtime::{ +use mangata_runtime::{ AccountId, BabeConfig, BalancesConfig, GenesisConfig, GrandpaConfig, SessionConfig, SudoConfig, SystemConfig, WASM_BINARY, Signature, StakerStatus, StakingConfig, SessionKeys }; diff --git a/node/src/command.rs b/node/src/command.rs index 2efca03837108..a0580d307d9a7 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -19,7 +19,7 @@ use crate::{chain_spec, service}; use crate::cli::{Cli, Subcommand}; use sc_cli::{SubstrateCli, RuntimeVersion, Role, ChainSpec}; use sc_service::PartialComponents; -use node_template_runtime::Block; +use mangata_runtime::Block; impl SubstrateCli for Cli { fn impl_name() -> String { @@ -57,7 +57,7 @@ impl SubstrateCli for Cli { } fn native_runtime_version(_: &Box) -> &'static RuntimeVersion { - &node_template_runtime::VERSION + &mangata_runtime::VERSION } } diff --git a/node/src/rpc.rs b/node/src/rpc.rs index c1f0e0a8457bc..78b86df03f413 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -7,7 +7,7 @@ use std::sync::Arc; -use node_template_runtime::{opaque::Block, AccountId, Balance, Index}; +use mangata_runtime::{opaque::Block, AccountId, Balance, Index}; use sp_api::ProvideRuntimeApi; use sp_blockchain::{Error as BlockChainError, HeaderMetadata, HeaderBackend}; use sp_block_builder::BlockBuilder; diff --git a/node/src/service.rs b/node/src/service.rs index 345963b65e944..4ae1f1e5d3097 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use std::time::Duration; use sc_client_api::{ExecutorProvider, RemoteBackend}; -use node_template_runtime::{self, opaque::Block, RuntimeApi}; +use mangata_runtime::{self, opaque::Block, RuntimeApi}; use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; use sp_inherents::InherentDataProviders; use sc_executor::native_executor_instance; @@ -14,8 +14,8 @@ use sc_finality_grandpa::{FinalityProofProvider as GrandpaFinalityProofProvider, // Our native executor instance. native_executor_instance!( pub Executor, - node_template_runtime::api::dispatch, - node_template_runtime::native_version, + mangata_runtime::api::dispatch, + mangata_runtime::native_version, frame_benchmarking::benchmarking::HostFunctions, ); diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 5dadda2171c8e..24babd29670ed 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -3,8 +3,7 @@ authors = ['Substrate DevHub '] edition = '2018' homepage = 'https://substrate.dev' license = 'Unlicense' -name = 'node-template-runtime' -repository = 'https://github.com/substrate-developer-hub/substrate-node-template/' +name = 'mangata-runtime' version = '2.0.0' [package.metadata.docs.rs]