Giter Club home page Giter Club logo

hydradx-node's Introduction

HydraDX node

CROSS-CHAIN LIQUIDITY PROTOCOL BUILT ON SUBSTRATE

Contributions & Code of Conduct

Please follow the contributions guidelines as outlined in docs/CONTRIBUTING.md. We are welcoming and friendly community please follow our Code of Conduct.

Local Development

Follow these steps to prepare a local Substrate development environment ๐Ÿ› ๏ธ

Simple Setup

Install all the required dependencies with a single command (be patient, this can take up to 30 minutes).

curl https://getsubstrate.io -sSf | bash -s -- --fast

Manual Setup

Find manual setup instructions at the Substrate Developer Hub.

Build

Once the development environment is set up, build the node. This command will build the Wasm and native code:

cargo build --release

Run

Chopsticks

The easiest way to run and interact with HydraDX node is to use Chopsticks

npx @acala-network/chopsticks@latest --config=launch-configs/chopsticks/hydradx.yml 

Now you have a test node running at ws://localhost:8000

Local Testnet with Zombienet

Relay chain repository (polkadot) has to be built in ../polkadot Grab zombienet utility used to start network from releases

Start local testnet with 4 relay chain validators and HydraDX as a parachain with 2 collators.

cd ./rococo-local
zombienet spawn config-zombienet.json

Interaction with the node

Go to the polkadot apps at https://polkadot.js.org/apps

Connect to

  • Mainnet: wss://rpc.hydradx.cloud
  • local node: ws://localhost:8000 (if you are using chopsticks)

Testing of storage migrations and runtime upgrades

The try-runtime tool can be used to test storage migrations and runtime upgrades against state from a real chain. Run the following command to test against the state on HydraDX. Don't forget to use a runtime built with try-runtime feature.

try-runtime --runtime ./target/release/wbuild/hydradx-runtime/hydradx_runtime.wasm on-runtime-upgrade --checks all live --uri wss://rpc.hydradx.cloud:443

or against HydraDX testnet on Rococo using --uri wss://rococo-hydradx-rpc.hydration.dev:443

Security

Useful resources:

Bug bounty: https://immunefi.com/bounty/hydradx/

Reponsible disclosure: [email protected]

hydradx-node's People

Contributors

alistair-singh avatar andresilva avatar apopiak avatar bkchr avatar chrisk700 avatar dependabot-preview[bot] avatar dmoka avatar enthusiastmartin avatar fakirayoub avatar gflow33 avatar green-jay avatar jak-pan avatar jareknowotka avatar kukabi avatar kyoshisuki avatar martinfridrich avatar mckrava avatar mikespook avatar mikexing-onf avatar mrq1911 avatar mustermeiszer avatar pmensik avatar roborambo avatar roznovjak avatar senseless avatar unordered-set avatar vgantchev 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

hydradx-node's Issues

Exchange discount trades should pass even if hdx/asset pair does not exists

Sells/Buys with discounts should go through without the discount if the pair hdx/asset does not exists.

Currently sell and buys returns error "CannotApplyDiscount" and if this sells is part of the matched transactions , it can lead to scenarion where only part of the amount is trade ( directtrade )

Weights template format

There is hbs template in the .maintain directory which currently does not follow same formatting guidelines.

Runtime: payment weight in extrinsic base weight

Currently , the extra weight for the payment is set as follows:

pub const ExtrinsicPaymentExtraWeight: Weight = 307_000_000;
pub const ExtrinsicBaseWeight: Weight = frame_support::weights::constants::ExtrinsicBaseWeight::get() + ExtrinsicPaymentExtraWeight::get();

It would be nice if the ExtrinsicPaymentExtraWeight is taken from the weight information localted in the transaction multi payment pallet.

For example, something like this :

pub const ExtrinsicPaymentExtraWeight: Weight = PaymentModule::weights::swap_currency() as Weight;

However, this is const and it is not as straightforward. It might need little Rust and Substrate magic to get it working.

Implement claims pallet

As in #56

We're planning to distribute our tokens on the Ethereum network so that people can participate early on our upcoming ๐Ÿ Snakenet. Stakers will have limited time to acquire xHDX tokens on Ethereum and after this phase, we'll freeze their balances in order to move them to our chain. This is where this pallet comes to play.

  1. Ethereum addresses and their balances have to be imported somehow into the storage
    • up to you, can be solved multiple ways, either runtime upgrade or some sudo extrinsic comes to mind
    • there could be up to 10k addresses
  2. Stakers will be able to claim tokens into their HydraDX wallet
    • they have to prove ownership of the Ethereum wallet by signing a message
    • signature will be sent by using extrinsic without fee (we expect them to have no balance)
    • if the signature is valid, claim balance will be cleared and HDX tokens minted to the account

Helpful resources:

claims site https://claims.polkadot.network/

Prepare chain_spec for stakenet

  • remove alice, bob
  • remove balances except Intergalactic account
  • setup treasury acc
  • setup staking
  • setup initial keys
  • setup initial authorities
  • disable balance transfers
  • setup initial bootnodes

Implement Claims

Claims will be available after freeze of balances on ETH side. We will then transfer addresses with balances info into our stake-net by runtime upgrade as follows:

STORAGE { (ETHADDR): BALANCE }

Simple UI will connect to the ETH network and HydraDX at the same time. The flow will be following:

  1. connect to ETH with metamask || input ETH addres
  2. show claimable balance
  3. connect to polkadot-js || hydradx
  4. sign using metamask || input verification based on sign message generated
  5. claim

We'll use Metamask or Infura on the ETH side. Our open node on HydraDX side.

This will trigger ETH address validation on our side and if successful, removes claimable balance from the initial storage, and mint HDX to an address.

Prepare infrastructure

Boot up 3 validator nodes + preferably in different providers and different locations.

Boot 2 RPC nodes in different locations.

We'll want to do separate backup node in some serious location / provider.

Price-fetch: One time price evaluation with off-chain workers

The general assumption is that the PoS nodes (can) run offchain workers themselves who publish data (e.g. price feeds) as oracles so that this data can be used on-chain.
To make sure that the offchain workers report their data correctly, we can repurpose the stake they have for validating the blocks themselves. In its simplest iteration such a system could work like this:

  1. PoS validators each run an offchain worker that gets and reports data, they include it in a block
  2. The blocks are collected over some time (in the order of minutes) and then compared by an on-chain averaging module
  3. The averaging module calculates the average (or median or mean or modus) and detects outliers in the data
  4. If the outliers are "too far apart" (to be defined), the validator set can execute rules to punish the reporters of this outlying data.
  5. If there are different data source families, it could be viable to see each of them as a separate data source so that an error in the off-chain feed does not punish the well-behaving reporters. Instead a warning can be issued if two or more oracle systems differ too much (e.g. DIA reports a price of 1 and another oracle a price of 2, but all DIA nodes are around 1 and all nodes from the other data provider report around 2, nobody in the reporter crowd should be punished)

credit @kaythxbye @martinfridrich @jak-pan

Ideas | PRs welcome

to do:

  • Better parsing of oracle data #37
  • Include POS in the runtime #39

Upgrade Substrate and ORML

Upgrade Substrate to the specific git revision: b7712fed2c58a898f7706e16861d7109c8f585a5

And ORML to version 0.3.2

Usage of DOLLARS

Make sure DOLLARS and HDX/UNIT s are used correctly. We use them interchangeably but in reality 1 dollar should be roughly 10HDX. We'll need to do changes to chainspec too to use HDX/UNIT instead of DOLLARS.

Exogenous currency fee burning

What I am thinking is that we might want to simplify this sooner than expected since this brings so many questions and probably performance implications. What we wanted to do with tx fees is to burn them instead of accumulating. Similar to EIP1559, but this brings some tokenomics questions which we didn't clear yet.

Right now, we're doing User -> poolSwap (+token,-HDX) -> treasury. We could do just the burn and send on some very basic math really.

Soo... The solution for me is to make it as simple as possible and create new issue that targets this in the omnipool.

Originally posted by @jak-pan in #91 (comment)

Exchange: atomicity and storage transactions

As was mentioned during builder's review session - it would be probably beneficial to spend some effort and investigate use of storage transactions in the exchange pallet's algorithm.

We won't do this as part of the code review changes but will treat this as separate issue ( as this will probably need major refactor ).

Prepare for Roccoco-v1

  • Setup machines that will be running relay chain validator and our collator
  • Prepare parachain runtime #11
  • Prepare scripts or workflows to inject keys, required metadata and setup for running V1
  • Remove Alice,Bob,Charlie... add our own account preferably the one we use on relay chain. Add it to endowed accounts. - @jak-pan << pls test if it works
  • Handle parachain security
  • Test our local setup on remote

Bonus:

  • Get a name for roccoco parachain

we should also strive to be up-to date since heavy development is being done

Transfer to cumulus

Let's transfer or change this to latest cumulus to be able to connect as a parachain.

Let's have a look at this and decide if we're going to do it before or after merging:
paritytech/cumulus#207

Add minimal pool limit, minimal trade limit and pool existential limit

These should be setup so that users cannot abuse the system. We should also have minimal pool creation limit / existential limit because the integer math starts to break at some point. Also we don't want to hold very small pools that are blocking other pools because they are very volatile. (something in range of 100-1000 should be ok for math)

Inspiration here:
https://github.com/galacticcouncil/HydraDX-node/pull/27/files

Some progress was also made in #91

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.