Giter Site home page Giter Site logo

polkadex-substrate / polkadex Goto Github PK

View Code? Open in Web Editor NEW
284.0 26.0 92.0 43.61 MB

An Orderbook-based Decentralized Exchange using the Substrate Blockchain Framework.

Home Page: https://www.polkadex.trade

License: GNU General Public License v3.0

Shell 0.99% Rust 98.91% JavaScript 0.04% Dockerfile 0.05%
decentralized-exchanges trading-features substrate frequency-trading liquidity traders substrate-blockchain-framework market interoperability

polkadex's Introduction

Logo

What is Polkadex? ๐Ÿš€

Polkadex is a Open Source, Decentralized Exchange Platform made using Substrate Blockchain Framework that provides traders with the centralized user experience.

Why did we do this? ๐ŸŽ

There are many decentralized exchanges/protocols available in the market for traders but they still prefer to use centralized solutions for their convenience and ease of use knowing very well that their funds are at risk. This is because decentralized solutions are still not user friendly to an average trader. Some of them also have no proper decentralization and also got hacked in the process. We cannot call an exchange decentralized if it can lose or freeze customer funds.

The problems faced by decentralized exchanges are:

  • Inadequate UI/UX experience.
  • Low liquidity
  • Lack of advanced trading features, high-frequency trading, and bots.
  • Lack of proper decentralization and interoperability.

To solve the above problems, our goal is to build a fully decentralized, peer-peer, cryptocurrency exchange for the Defi ecosystem in Substrate. The project envisages the creation of a fully decentralized platform for exchanging tokens in a peer-peer, trustless environment, that enables high-frequency trading, high-liquidity, and lightning-fast transaction speed for supporting Defi applications.

In order to address the first problem, we needed to enable features that attract users into the exchange which includes a fast, responsive UI and trading features. It is mainly to attract day traders and retail investors who prefer centralized exchanges due to convenience and speed of execution. The block time of 3s given by the Babe/Grandpa consensus algorithm allows transaction speeds of up to 400/s under test conditions which is more than sufficient to compete with any centralized solutions in the market today. Please check our analysis here. Since Substrate allows the modular implementation of the consensus algorithm, we think a platform like a Substrate will support the future growth of the exchange by changing consensus to accommodate more transactions per second as better ones emerge.

Secondly, the lack of liquidity is addressed by enabling,

  1. High-frequency trading using feeless transactions.
  2. APIs that enable trading/AMM bots to observe market changes and submit trades.
  3. Advanced trading features like stop limit, market limit, Stop loss, Fill/Kill, Post only, TWAP, etc.

Thirdly, proper decentralization and Interoperability are achieved by having a parachain in Polkadot that brings in liquidity from other blockchains and also using ChainBridge protocol that connects directly to the Ethereum network. Hence, traders have two different mechanisms to bring in liquidity.

The value we provide to the Substrate community is,

  1. They can build custom UI/UX to connect to our network and create their own custom exchange experience.
  2. Traders can contribute their own custom trading algorithms by making use of market data provided by our full nodes.
  3. They get a decentralized trading platform to trade Polkadot & Ethereum tokens.
  4. This will be one of the first Decentralized exchanges to have High-Frequency Trading bot support using APIs directly from full nodes. Web3 Grants

Build the Polkadex Node ๐Ÿ’ƒ

To build Polkadex, you will need a proper Substrate development environment. If you need a refresher setting up your Substrate environment, see Substrate's Getting Started Guide.

Note that cloning master might result in an unstable build. If you want a stable version, check out the latest releases.

# Fetch the code
git clone https://github.com/Polkadex-Substrate/Polkadex.git
cd Polkadex

# Build the node (The first build will be long (~30min))
cargo build --release

If a cargo not found error shows up in the terminal, manually add Rust to your system path (or restart your system):

source $HOME/.cargo/env

Then, you will want to run the node in dev mode using the following command:

./target/release/polkadex-node --dev

For people not familiar with Substrate, the --dev flag is a way to run a Substrate-based node in a single node developer configuration for testing purposes. You can learn more about --dev in this Substrate tutorial.

When running a node via the binary file, data is stored in a local directory typically located in ~/.local/shared/polkadex-node/chains/development/db. If you want to start a fresh instance of the node, you can either delete the content of the folder, or run the following command inside the polkadex folder:

./target/release/node-polkadex purge-chain --dev

This will remove the data folder, note that all chain data is now lost.

Run a local network (two nodes)

  • Install subkey, jq
curl https://getsubstrate.io -sSf | bash -s --
brew install jq
  • Generate node key using subkey
Alice_Node_Key=$(subkey generate --scheme Ed25519 --output-type Json | jq -r '.secretSeed')
  • Run Alice's node
# Purge any chain data from previous runs
./target/release/polkadex-node purge-chain --base-path /tmp/alice --chain local

# Start Alice's node
./target/release/polkadex-node --base-path /tmp/alice \
  --chain local \
  --alice \
  --port 30333 \
  --ws-port 9945 \
  --rpc-port 9933 \
  --node-key $Alice_Node_Key \
  --telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' \
  --validator
2021-06-30 08:12:38 Polkadex Node    
2021-06-30 08:12:38 โœŒ๏ธ  version 3.0.0-6426a73b-x86_64-macos    
2021-06-30 08:12:38 โค๏ธ  by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2021    
2021-06-30 08:12:38 ๐Ÿ“‹ Chain specification: Local Testnet    
2021-06-30 08:12:38 ๐Ÿท Node name: Alice    
2021-06-30 08:12:38 ๐Ÿ‘ค Role: AUTHORITY    
2021-06-30 08:12:38 ๐Ÿ’พ Database: RocksDb at /tmp/alice/chains/local_testnet/db    
2021-06-30 08:12:38 โ›“  Native runtime: node-polkadex-265 (node-polkadex-1.tx2.au10)    
2021-06-30 08:12:39 ๐Ÿ”จ Initializing Genesis block/state (state: 0xbe0aโ€ฆ5ef3, header-hash: 0xa55fโ€ฆ7888)    
2021-06-30 08:12:39 ๐Ÿ‘ด Loading GRANDPA authority set from genesis on what appears to be first startup.    
2021-06-30 08:12:39 โฑ  Loaded block-time = 3s from genesis on first-launch    
2021-06-30 08:12:39 ๐Ÿ‘ถ Creating empty BABE epoch changes on what appears to be first startup.    
2021-06-30 08:12:39 Using default protocol ID "sup" because none is configured in the chain specs    
2021-06-30 08:12:39 ๐Ÿท Local node identity is: 12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp    
2021-06-30 08:12:39 ๐Ÿ“ฆ Highest known block at #0    
2021-06-30 08:12:39 ใ€ฝ๏ธ Prometheus server started at 127.0.0.1:9615    
2021-06-30 08:12:39 Listening for new connections on 127.0.0.1:9945.    
2021-06-30 08:12:39 ๐Ÿ‘ถ Starting BABE Authorship worker    
2021-06-30 08:12:44 ๐Ÿ’ค Idle (0 peers), best: #0 (0xa55fโ€ฆ7888), finalized #0 (0xa55fโ€ฆ7888), โฌ‡ 0 โฌ† 0    
2021-06-30 08:12:49 ๐Ÿ’ค Idle (0 peers), best: #0 (0xa55fโ€ฆ7888), finalized #0 (0xa55fโ€ฆ7888), โฌ‡ 0 โฌ† 0    
2021-06-30 08:12:54 ๐Ÿ’ค Idle (0 peers), best: #0 (0xa55fโ€ฆ7888), finalized #0 (0xa55fโ€ฆ7888), โฌ‡ 0 โฌ† 0

Local node identity is: 12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp shows the Peer ID that Bob will need when booting from Alice's node. This value was determined by the --node-key that was used to start Alice's node.

Now that Alice's node is up and running, Bob can join the network by bootstrapping from her node.

./target/release/polkadex-node purge-chain --base-path /tmp/bob --chain local
./target/release/polkadex-node \
  --base-path /tmp/bob \
  --chain local \
  --bob \
  --port 30334 \
  --ws-port 9946 \
  --rpc-port 9934 \
  --telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' \
  --validator \
  --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp

If all is going well, after a few seconds, the nodes should peer together and start producing blocks. You should see some lines like the following in the console that started Alice node.

2021-06-30 08:16:52 Polkadex Node    
2021-06-30 08:16:52 โœŒ๏ธ  version 3.0.0-6426a73b-x86_64-macos    
2021-06-30 08:16:52 โค๏ธ  by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2021    
2021-06-30 08:16:52 ๐Ÿ“‹ Chain specification: Local Testnet    
2021-06-30 08:16:52 ๐Ÿท Node name: Bob    
2021-06-30 08:16:52 ๐Ÿ‘ค Role: AUTHORITY    
2021-06-30 08:16:52 ๐Ÿ’พ Database: RocksDb at /tmp/bob/chains/local_testnet/db    
2021-06-30 08:16:52 โ›“  Native runtime: node-polkadex-265 (node-polkadex-1.tx2.au10)    
2021-06-30 08:16:52 ๐Ÿ”จ Initializing Genesis block/state (state: 0xbe0aโ€ฆ5ef3, header-hash: 0xa55fโ€ฆ7888)    
2021-06-30 08:16:52 ๐Ÿ‘ด Loading GRANDPA authority set from genesis on what appears to be first startup.    
2021-06-30 08:16:52 โฑ  Loaded block-time = 3s from genesis on first-launch    
2021-06-30 08:16:52 ๐Ÿ‘ถ Creating empty BABE epoch changes on what appears to be first startup.    
2021-06-30 08:16:52 Using default protocol ID "sup" because none is configured in the chain specs    
2021-06-30 08:16:52 ๐Ÿท Local node identity is: 12D3KooWRHDuuHg5ZQcJhvVDKud9XkFz2Dcs2GQKF9KKuTD6quq7    
2021-06-30 08:16:53 ๐Ÿ“ฆ Highest known block at #0    
2021-06-30 08:16:53 Listening for new connections on 127.0.0.1:9946.    
2021-06-30 08:16:53 ๐Ÿ‘ถ Starting BABE Authorship worker    
2021-06-30 08:16:53 ๐Ÿ” Discovered new external address for our node: /ip4/127.0.0.1/tcp/30334/p2p/12D3KooWRHDuuHg5ZQcJhvVDKud9XkFz2Dcs2GQKF9KKuTD6quq7    
2021-06-30 08:16:53 ๐Ÿ” Discovered new external address for our node: /ip4/192.168.1.37/tcp/30334/p2p/12D3KooWRHDuuHg5ZQcJhvVDKud9XkFz2Dcs2GQKF9KKuTD6quq7    
2021-06-30 08:16:53 Creating inherent data providers took more time than we had left for the slot.    
2021-06-30 08:16:54 ๐Ÿ™Œ Starting consensus session on top of parent 0xa55fa19cc37ca1f8d93bc06ca1f6fee767f18200516d9e349938601a3fe97888    
2021-06-30 08:16:54 ๐ŸŽ Prepared block for proposing at 1 [hash: 0x2959db5e42a7192434d3699d335e5d920da73409963e3081ad43afd93a8cdb4b; parent_hash: 0xa55fโ€ฆ7888; extrinsics (1): [0x4431โ€ฆ4eff]]    
2021-06-30 08:16:54 ๐Ÿ”– Pre-sealed block for proposal at 1. Hash now 0x5263ed1cbf1b4edbc887cc87786471819cd0614d8aeaff3a898c0c3ffda245c2, previously 0x2959db5e42a7192434d3699d335e5d920da73409963e3081ad43afd93a8cdb4b.    
2021-06-30 08:16:54 ๐Ÿ‘ถ New epoch 0 launching at block 0x5263โ€ฆ45c2 (block slot 541685138 >= start slot 541685138).    
2021-06-30 08:16:54 ๐Ÿ‘ถ Next epoch starts at slot 541685338    
2021-06-30 08:16:54 โœจ Imported #1 (0x5263โ€ฆ45c2)    
2021-06-30 08:16:57 ๐Ÿ™Œ Starting consensus session on top of parent 0x5263ed1cbf1b4edbc887cc87786471819cd0614d8aeaff3a898c0c3ffda245c2    
2021-06-30 08:16:57 ๐ŸŽ Prepared block for proposing at 2 [hash: 0x0c513e39a88bcb03d113a18ed824bcbaab03881e9dcdeedbe12e71955dcfe05d; parent_hash: 0x5263โ€ฆ45c2; extrinsics (1): [0xf06aโ€ฆbf04]]    
2021-06-30 08:16:57 ๐Ÿ”– Pre-sealed block for proposal at 2. Hash now 0x4293ecd46db852f5add54a24acfcd1ea12f6c26d5470b61736d7cf0e039e3e39, previously 0x0c513e39a88bcb03d113a18ed824bcbaab03881e9dcdeedbe12e71955dcfe05d.    
2021-06-30 08:16:57 โœจ Imported #2 (0x4293โ€ฆ3e39)    
2021-06-30 08:16:58 ๐Ÿ’ค Idle (1 peers), best: #2 (0x4293โ€ฆ3e39), finalized #0 (0xa55fโ€ฆ7888), โฌ‡ 1.7kiB/s โฌ† 1.9kiB/s 

Using docker

The following commands will setup a local polkadex network made of 2 nodes. It's using the node key (0000000000000000000000000000000000000000000000000000000000000001). But you should generate your own node key using the subkey as the above.

docker build . -t polkadex-node
docker-compose -f 2nodes.yml up --force-recreate

Connecting Polkadot JS Apps to a Local Polkadex Node

The development node is a Substrate-based node, so you can interact with it using standard Substrate tools. The two provided RPC endpoints are:

  • HTTP: http://127.0.0.1:9933
  • WS: ws://127.0.0.1:9944

Start by connecting to it with Polkadot JS Apps. Open a browser to: https://polkadot.js.org/apps/#/explorer. This will open Polkadot JS Apps, which automatically connects to Polkadot MainNet.

Click on the top left corner to open the menu to configure the networks, and then navigate down to open the Development sub-menu. In there, you will want to toggle the "Local Node" option, which points Polkadot JS Apps to ws://127.0.0.1:9944. Next, select the Switch button, and the site should connect to your Polkadex development node.

How to run a validator

Here is a guide Run a validator (Polkadex)

Contribute ๐Ÿ˜

We would love to work with anyone who can contribute their work and improve this project. The details will be shared soon.

License ๐Ÿ“œ

Licensed Under GPLv3

polkadex's People

Contributors

35359595 avatar arrudagates avatar ayushmishra2005 avatar dimitriolock avatar felixfaisal avatar frankli-dev avatar gabaod avatar gauthamastro avatar jaxter03 avatar jaymansfield avatar mambisi avatar mt-gareth avatar nakul1010 avatar nuel77 avatar pdexpab avatar petrovma avatar pranayagaram avatar rimbi avatar serhii-temchenko avatar simonsso avatar visiondream3 avatar zktony 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

polkadex's Issues

Remove Generic Asset and Old engine pallet

Is your feature request related to a problem? Please describe.
As we have completely removed Generic Assets and the Old Polkadex engine in these PRs #77 and #72. We can remove the pallets generic asset and polkadex from the pallets folder

Implement Pre-Checks in Transaction Pool to Invalidate Transactions

Is your feature request related to a problem? Please describe.
We are doing a lot of checks in the engine pallet like

  1. Bounds of Price*Quantity
  2. Bounds of Price and Quantity
  3. Checking available balance
  4. Checking if trading_pair exists
  5. Checking OrderType
  6. Checking TradeType
  7. Pre-Checks for batch orders

It wastes block time.

Describe the solution you'd like
We need to implement it in SignedExtension and validate the transactions in the transaction pool's ready pool before reaching the block construction. In this way only, valid transactions are included for block construction.

References
SignedExtension
Knowledgebase
Example implementation

Add Cargo commands in Github pipeline

Is your feature request related to a problem? Please describe.
As a part of #42 , we enabled Cargo to build testnet/mainnet as features. We should add same commands in github pipeline to make sure both features are compiling succsessfully

Describe the solution you'd like
Add below commands in github pipeline:

cargo build --manifest-path bin/polkadex/Cargo.toml --features mainnet

cargo build --manifest-path bin/polkadex/Cargo.toml --features testnet

Balance transfers are messed up!!

I am not getting the expected Free balance in tests after placing BidLimit orders that consume more than 1 price level. The state of the order book is correct, but the balance results are not correct

Change Node and Chain Name

Is your feature request related to a problem? Please describe.
The current Chain and Node names are Substrate defaults and should be changed to "Polkadex Node" and "Polkadex Testnet" for node name and chain name.

Install Governance Pallets

Describe the solution you'd like
Install Council and Treasury pallets from FRAME.

Additional context
Refer to Slack and Whitepaper for more details

Install all Custom Polkadex Pallets.

Is your feature request related to a problem? Please describe.
Install all Custom Polkadex Pallets into Testnet Runtime.

Describe the solution you'd like
Integrate Following Pallets into Polkadex Testnet:-

  • Polkadex_custom_asset Pallet.
  • Polkadex_engine Pallet.
  • Polkadex_uniswap_Pallet.
  • Polkadex_identity_Pallet.

Extend Github Actions to run cargo test for each pallets

Is your feature request related to a problem? Please describe.
The Github actions are building the whole project as one and testing it. Instead, it would be better to have cargo test workflows for each pallet.

Describe the solution you'd like
Different cargo test workflows for each pallet, mainnet, and testnet separately

Modify Market Data's storage from StorageDoubleMap to StorageMap

Is your feature request related to a problem? Please describe.
The Current implementation of market data wastes space on-chain and also, it is harder to retrieve data on the frontend side. if we make MarketData a StorageMap then we can retrieve historic data using range([from,to]) and also by just getting the Blockhash for historic block using api.rpc.chain.getBlockHash()

Describe the solution you'd like
Convert the storage from a DoubleMap to a StorageMap

Describe alternatives you've considered
The current solution solve it in an elegant clean way, other alternatives are not required

Additional context
Not applicable

Unit tests failing for swap and custom-assets

Describe the bug
The cargo test command is failing on the develop branch due to an error in unit testing in pallets uniswap and custom-assets.

To Reproduce
Steps to reproduce the behavior:

  1. Cargo test on develop branch

Expected behavior
Expected all tests to pass

Screenshots
Not applicable

Additional context
Error Logs

error[E0277]: the trait bound `mock::Test: pallet_idenity::Trait` is not satisfied
  --> pallets/polkadex-uniswap/src/mock.rs:54:6
   |
54 | impl Trait for Test {
   |      ^^^^^ the trait `pallet_idenity::Trait` is not implemented for `mock::Test`

error[E0277]: the trait bound `mock::Test: pallet_idenity::Trait` is not satisfied
  --> pallets/polkadex-custom-assets/src/mock.rs:76:6
   |
76 | impl Trait for Test {
   |      ^^^^^ the trait `pallet_idenity::Trait` is not implemented for `mock::Test`
   |
  ::: pallets/polkadex-custom-assets/src/lib.rs:31:40
   |
31 | pub trait Trait: frame_system::Trait + pallet_idenity::Trait {
   |                                        --------------------- required by this bound in `Trait`

error: could not compile `pallet-idenity`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error[E0277]: the trait bound `mock::Test: pallet_idenity::Trait` is not satisfied
  --> pallets/polkadex-uniswap/src/mock.rs:63:6
   |
63 | impl polkadex_custom_assets::Trait for Test{
   |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `pallet_idenity::Trait` is not implemented for `mock::Test`
   |
  ::: /mnt/c/Users/Gautham/Desktop/Work/Polkadex/pallets/polkadex-custom-assets/src/lib.rs:31:40
   |
31 | pub trait Trait: frame_system::Trait + pallet_idenity::Trait {
   |                                        --------------------- required by this bound in `polkadex_custom_assets::Trait`

error[E0277]: the trait bound `mock::TestRuntime: pallet_idenity::Trait` is not satisfied
  --> pallets/polkadex-engine/src/mock.rs:57:6
   |
57 | impl Trait for TestRuntime {
   |      ^^^^^ the trait `pallet_idenity::Trait` is not implemented for `mock::TestRuntime`

error[E0277]: the trait bound `mock::TestRuntime: pallet_idenity::Trait` is not satisfied
  --> pallets/polkadex-engine/src/mock.rs:69:6
   |
69 | impl polkadex_custom_assets::Trait for TestRuntime {
   |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `pallet_idenity::Trait` is not implemented for `mock::TestRuntime`
   |
  ::: /mnt/c/Users/Gautham/Desktop/Work/Polkadex/pallets/polkadex-custom-assets/src/lib.rs:31:40
   |
31 | pub trait Trait: frame_system::Trait + pallet_idenity::Trait {
   |                                        --------------------- required by this bound in `polkadex_custom_assets::Trait`

error[E0277]: the trait bound `mock::TestRuntime: pallet_idenity::Trait` is not satisfied
  --> pallets/polkadex-engine/src/mock.rs:79:6
   |
79 | impl polkadex_swap_engine::Trait for TestRuntime {
   |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `pallet_idenity::Trait` is not implemented for `mock::TestRuntime`
   

Wont build - ubuntu 20.04

please help

root@ubuntu-s-1vcpu-1gb-polkadex:~/Polkadex# cargo build --release
Compiling node-polkadex-runtime v2.0.0-rc6 (/root/Polkadex/runtime)
Compiling node-polkadex v2.0.0-rc6 (/root/Polkadex/node)
error: could not compile node-polkadex

Caused by:
process didn't exit successfully: rustc --crate-name node_polkadex --edition=2018 node/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C metadata=276300912b27e3ac -C extra-filename=-276300912b27e3ac --out-dir /root/Polkadex/target/release/deps -L dependency=/root/Polkadex/target/release/deps --extern jsonrpc_core=/root/Polkadex/target/release/deps/libjsonrpc_core-9b0b0492c96f271b.rmeta --extern jsonrpc_core_client=/root/Polkadex/target/release/deps/libjsonrpc_core_client-603a0c90edc1f736.rmeta --extern jsonrpc_derive=/root/Polkadex/target/release/deps/libjsonrpc_derive-f4487a8f83370a07.so --extern node_polkadex_runtime=/root/Polkadex/target/release/deps/libnode_polkadex_runtime-2b4b7f159fb3a3b6.rmeta --extern pallet_transaction_payment_rpc=/root/Polkadex/target/release/deps/libpallet_transaction_payment_rpc-9571780298b0097c.rmeta --extern rpc=/root/Polkadex/target/release/deps/librpc-d4277266da7a6c28.rmeta --extern runtime_api=/root/Polkadex/target/release/deps/libruntime_api-f154747cca61e4ad.rmeta --extern sc_basic_authorship=/root/Polkadex/target/release/deps/libsc_basic_authorship-8bff4cca6753195d.rmeta --extern sc_cli=/root/Polkadex/target/release/deps/libsc_cli-5f946e43d367d576.rmeta --extern sc_client_api=/root/Polkadex/target/release/deps/libsc_client_api-97175913e7850850.rmeta --extern sc_consensus=/root/Polkadex/target/release/deps/libsc_consensus-6ce14f90ffe97330.rmeta --extern sc_consensus_babe=/root/Polkadex/target/release/deps/libsc_consensus_babe-e63846dc67e4b858.rmeta --extern sc_executor=/root/Polkadex/target/release/deps/libsc_executor-dca1c4963320bee5.rmeta --extern sc_finality_grandpa=/root/Polkadex/target/release/deps/libsc_finality_grandpa-90fe0e5b86f2c5f0.rmeta --extern sc_rpc=/root/Polkadex/target/release/deps/libsc_rpc-f193b9368bdcbffd.rmeta --extern sc_rpc_api=/root/Polkadex/target/release/deps/libsc_rpc_api-a5bf96f7b482689f.rmeta --extern sc_service=/root/Polkadex/target/release/deps/libsc_service-22ea5f9d9278674d.rmeta --extern sc_transaction_pool=/root/Polkadex/target/release/deps/libsc_transaction_pool-3cf652806ace7654.rmeta --extern sp_api=/root/Polkadex/target/release/deps/libsp_api-c5fa8a76061b02c9.rmeta --extern sp_block_builder=/root/Polkadex/target/release/deps/libsp_block_builder-386d012d05ba4d95.rmeta --extern sp_blockchain=/root/Polkadex/target/release/deps/libsp_blockchain-bc367ed12e740e05.rmeta --extern sp_consensus=/root/Polkadex/target/release/deps/libsp_consensus-c684c93b78b31b5a.rmeta --extern sp_consensus_babe=/root/Polkadex/target/release/deps/libsp_consensus_babe-0eee42cae05b4bde.rmeta --extern sp_core=/root/Polkadex/target/release/deps/libsp_core-6c35f85790f0f226.rmeta --extern sp_finality_grandpa=/root/Polkadex/target/release/deps/libsp_finality_grandpa-8a92cb7367a22be7.rmeta --extern sp_inherents=/root/Polkadex/target/release/deps/libsp_inherents-4d842d058ef3183a.rmeta --extern sp_runtime=/root/Polkadex/target/release/deps/libsp_runtime-d2cbe6284c68a828.rmeta --extern sp_transaction_pool=/root/Polkadex/target/release/deps/libsp_transaction_pool-d4ca49994cc2f87b.rmeta --extern structopt=/root/Polkadex/target/release/deps/libstructopt-d07791ba3397a584.rmeta --extern substrate_frame_rpc_system=/root/Polkadex/target/release/deps/libsubstrate_frame_rpc_system-d36bb9cf78d899bb.rmeta -L native=/root/Polkadex/target/release/build/ring-562b25fb7dbe1699/out -L native=/root/Polkadex/target/release/build/libz-sys-68b6c7804e5ae034/out/build -L native=/root/Polkadex/target/release/build/zstd-sys-9bb7b935c7dbcd10/out -L native=/root/Polkadex/target/release/build/wasmtime-runtime-afcdc8d0320438a5/out -L native=/root/Polkadex/target/release/build/librocksdb-sys-6e30ee65f7cd0b83/out -L native=/root/Polkadex/target/release/build/librocksdb-sys-6e30ee65f7cd0b83/out (signal: 9, SIGKILL: kill)
root@ubuntu-s-1vcpu-1gb-polkadex:~/Polkadex#

CI/CD Integration

Proposed Architecture

Untitled Diagram

Workflows Checklist

Workflow 1

  • Install Dependencies.
  • Check Code Formatting.
  • Run Automated Tests.
  • Upload Code coverage as an Artifact.
  • Cache Dependencies.

Workflow 2

  • Install Dependencies.
  • Check Code Formatting.
  • Run Automated Tests.
  • Build Project.
  • Upload Build as Artifact.
  • Cache Dependency.

Workflow 3

  • Install Dependencies.
  • Check Code Formatting.
  • Run Automated Tests.
  • Upload Code coverage as an Artifact.
  • Cache Dependencies.
  • Check Copyright & License

Workflow 4

  • Install Dependencies.
  • Check Code Formatting.
  • Run Automated Tests.
  • Upload Code coverage as an Artifact.
  • Build Project.
  • Upload Build as an Artifact.
  • Create a Release.
  • Upload Coverage to Codecov.

Unit Tests failing in identity pallet

Describe the bug
The Unit tests of Polkadex Identity pallets are failing

To Reproduce
Steps to reproduce the behavior:

  1. git checkout develop
  2. cargo build -> It fails

Expected behavior
Identity pallet should compile fine and tests should be passing

Additional context
Error Logs

error[E0308]: mismatched types
   --> pallets/polkadex-identity-pallet/src/test.rs:147:57
    |
147 |         assert_eq!(TemplateModule::check_account_status(accountid_trader), Judgement::Freeze);
    |                                                         ^^^^^^^^^^^^^^^^
    |                                                         |
    |                                                         expected `&u64`, found `u64`
    |                                                         help: consider borrowing here: `&accountid_trader`
    ```

Enable Transient Storage for Engine

Is your feature request related to a problem? Please describe.
Enabling Transient storage will help us to keep the commonly used storage items in RAM instead of reading and writing it frequently to disk.
This is much needed for Polkadex Engine to improve fetching of the order book and linked list. and also in the case of CustomAssetsPallet

Describe the solution you'd like
Refer this

Additional context
This feature can help us increase the speed of execution and minimize DB access.

Extrinsic Invalid on Load testing

The issue is related to paritytech/substrate#6261.

INFO tokio-runtime-worker sc_basic_authorship::basic_authorship:๐Ÿ™Œ Starting consensus session on top of parent 0xf45f96accce6a194bd7a15e33e722afcaea88f72d31c1ed00a5fb9444fde49c2
2020-11-29 06:05:48.006   WARN tokio-runtime-worker txpool:[0xd665a5c84f82492cc450c97008462285bd43e204aaff88b9ee42f43bc039e317] Extrinsic invalid
2020-11-29 06:05:48.006   WARN tokio-runtime-worker txpool:[0x7d7bce56d9f2989554269960b085a9c366cb9f2da0225b0ac444d70e3b5eae62] Extrinsic invalid
2020-11-29 06:05:48.006   WARN tokio-runtime-worker txpool:[0x594e2b44c45c632ce6922ec9d46871adf05e0bbf5cf73cf094ba154a51943ee0] Extrinsic invalid

logs

Remove Balances Pallet

Is your feature request related to a problem? Please describe.
Balances pallet is a relic from the Substrate node template, and we are not using it anymore in Polkadex.

Describe the solution you'd like
We have to remove the balances pallet and replace all instances of that with NativeAssetCurrency of Polkadex Custom Assets

Additional context
Give importance to transaction payment pallet, staking, treasury, and any other module dealing with balances pallet and native currency

Get Randomness from BABE for engine and custom-assets

Is your feature request related to a problem? Please describe.
Currently, we use a strictly increasing counter (i.e. nonce) for generating the order id in the polkadex engine and the asset id in the custom-assets pallet. This is not exactly random and it is a security concern.

Describe the solution you'd like
The Randomness can be retrieved from BABE using babe-randomness pallet.

Treasury Funds Management and Genesis Configuration

Is your feature request related to a problem? Please describe.
Currently, there is no genesis configuration.

Describe the solution you'd like
We need to implement the genesis configuration by referring to whitepaper

Implement testnet/mainet as features in cargo

Is your feature request related to a problem? Please describe.
The current configuration compiles the whole repo, which is unnecessary in most cases. We need to have a selection flag while compiling to compile the required ones selectively.

Describe the solution you'd like
If it is possible to make the testnet and mainnet as features, then we use cargo build --features=mainnet for compiling packages only related to mainnet and similarly for testnet

Describe alternatives you've considered
Let me know other alternatives in the comments

CC: @ayushmishra2005 @ksr30

Benchmark Polkadex Engine

Polkadex Engine is not yet benchmarked, weights are not set. It can be done once other features and functions of Polkadex are included.

Pallet Collective Genesis

Is your feature request related to a problem? Please describe.
Genesis is not implemented

Describe the solution you'd like
We need to implement genesis taking into account treasury pallet and economics from whitepaper

Remove 'from_fraction()' from Polkadex_Swap

Describe the bug
We can not use from_fraction when building with Runtime. It's only appropriate to use it with the test. We have to replace it with something else.

#[cfg(any(feature = "std", test))]
pub fn from_fraction(x: f64) -> Self {
Self((x * (<Self as FixedPointNumber>::DIV as f64)) as $inner_type)

To Reproduce
Clone and compile :- feature/runtime-upgradation branch

Additional context
Error :-

  error[E0599]: no function or associated item named `from_fraction` found for struct `FixedU128` in the current scope
    --> /home/knoldus/Desktop/rust/polkadex-project/Polkadex/pallets/polkadex-uniswap/src/lib.rs:45:39
     |
  45 |         SwappingFee: FixedU128 = FixedU128::from_fraction(0.003);
     |                                             ^^^^^^^^^^^^^ function or associated item not found in `FixedU128`

  error[E0599]: no function or associated item named `from_fraction` found for struct `FixedU128` in the current scope
     --> /home/knoldus/Desktop/rust/polkadex-project/Polkadex/pallets/polkadex-uniswap/src/lib.rs:307:50
      |
  307 |             let fee_term: FixedU128 = FixedU128::from_fraction(1.0).saturating_sub(swap_fee);
      |                                                  ^^^^^^^^^^^^^ function or associated item not found in `FixedU128`

  error[E0599]: no function or associated item named `from_fraction` found for struct `FixedU128` in the current scope
     --> /home/knoldus/Desktop/rust/polkadex-project/Polkadex/pallets/polkadex-uniswap/src/lib.rs:330:50
      |
  330 |             let fee_term: FixedU128 = FixedU128::from_fraction(1.0).saturating_sub(swap_fee);
      |                                                  ^^^^^^^^^^^^^ function or associated item not found in `FixedU128`

FIFO in Transaction Pool

Is your feature request related to a problem? Please describe.
We have to modify the Transaction Pool in Polkadex Node to make it FIFO and doesn't consider a higher transaction fee for prioritizing transactions

Describe the solution you'd like
I suggest that we replace the current transaction fee-based prioritizing model that comes as default in Substrate to a First in First Out Model by creating a list of transactions the way it is received by the node and process it in the same order.

Describe alternatives you've considered
Not anything specific in mind.

Save Cache in Github Actions

Is your feature request related to a problem? Please describe.
The git actions currently don't store the complied components as a cache between runs; it is spending too much time compiling due to this.

Describe the solution you'd like
If we store the cache and recompile only those updated packages, it can improve compile times.

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.