Code Monkey home page Code Monkey logo

xian-core's Introduction

Xian

ABCI application to be used with CometBFT 0.38.7

Installation

Ubuntu 22.04

Follow these steps to set up the environment on Ubuntu 22.04:

  1. Update and prepare the system:

    sudo apt-get update
    sudo apt-get update
  2. Install necessary packages:

    sudo apt-get install pkg-config libhdf5-dev build-essential
  3. Install Python 3.11.8

    Use your preferred way of installing this.

  4. Clone Xian and related repositories:

    git clone https://github.com/xian-network/xian-core.git
    cd xian-core
    git clone https://github.com/xian-network/contracting.git
  5. Set up Python virtual environment and dependencies:

    python3.11 -m venv xian_venv
    source xian_venv/bin/activate
    pip install -e contracting/ -e .
  6. Download, unpack, and initialize CometBFT:

    wget https://github.com/cometbft/cometbft/releases/download/v0.38.7/cometbft_0.38.7_linux_amd64.tar.gz
    tar -xf cometbft_0.38.7_linux_amd64.tar.gz
    rm cometbft_0.38.7_linux_amd64.tar.gz
    ./cometbft init
  7. Configuring your node:

    • For starting your own local network:

      python src/xian/tools/configure.py --moniker "Node" --copy-genesis True --genesis-file-name genesis.json --validator-privkey "cd6cc45ffe7cebf09c6c6025575d50bb42c6c70c07e1dbc5150aaadc98705c2b"

      The --validator-privkey flag should be set to your validator's private key. The example above uses a key from the genesis file for testing purposes so you can start developing directly. --moniker is the node name in the CometBFT network.

    • For joining an existing network:

      python src/xian/tools/configure.py --moniker "Node" --copy-genesis True --genesis-file-name genesis-testnet.json --seed-node "91.108.112.184" --validator-privkey "ENTER YOUR WALLET PRIVATE KEY HERE"

      Use --seed-node to specify the seed node's IP address you want to connect to. --validator-privkey is your validator wallet's private key. Ensure ports 26657 (REST API), 26656 (Node Communication), and 26660 (Prometheus Metrics) are open on your firewall.

  8. Run CometBFT and Xian:

    Run CometBFT:

    ./cometbft node --rpc.laddr tcp://0.0.0.0:26657

    In a new terminal session (remember to activate the environment again with source xian_venv/bin/activate), run Xian:

    python src/xian/xian_abci.py

    Alternatively, use screen or install PM2 to manage processes:

    sudo apt-get install npm
    npm install pm2 -g
    make up # To start
    make down # To stop

Accessing the Application

CometBFT RPC is exposed on localhost:26657. Xian is running inside the container and can be accessed accordingly.

xian-core's People

Contributors

crosschainer avatar endogen avatar davebryson avatar duelingbenjos avatar sbellem avatar kansi avatar duckfev3r avatar dependabot[bot] avatar eckelj avatar 30mb1 avatar gauthamzz avatar vrde avatar ldmberman avatar ritzvik avatar arifengineer avatar tuxxy avatar

Stargazers

 avatar π avatar  avatar Tudor Munteanu avatar Jan Kučera avatar Kelvin Takyi-Bobi avatar Kervin  avatar  avatar

Watchers

 avatar

xian-core's Issues

Parallel Processing

Parallel processing is definitely possible with our stack and worth trying.

Currently the blockchain is capable of processing low 100's of simple transactions per second.

This implementation could be used to significantly increase the throughput of the blockchain, based on the amount of cores available.

How would it work ?

A few modifications would be needed to support this.

1 ) The user's transaction must detail all the values on the blockchain it will be altering. Let's call this a claim.

2 ) The begin_block method would need knowledge of all the transactions from the block it's processing.

3 ) n lightweight contracting processes to run transactions in separate threads, these do not write to disk, but instead return the list of writes to the ABCI app.

Lifecycle of a block

  1. begin_block is called, retrieves all transactions in the block.
  2. Sort transactions :Make two lists, in one - transactions where the claim does not intend to modify any values held by other claims. These can be processed async. The other list contains claims that contain overlapping state modifications.
  3. run the async transactions in other threads async. if the result of the transaction results in writes that differ from the claim, fail it, otherwise it's ok to write it, return tx output to the main process. Add the output to a structure like this. :
{
    # This tx is processed by a side process.
    "tx_1"{
        "parallel": true,
        "success": true,
        "data"{...
        } // this is the tx output to return in the deliver_tx response
    },
    # This tx was was rejected due to invalid claim
    "tx_2"{
        "parallel": true,
        "success": false,
        "data"{...
        } // this is the tx output to return in the deliver_tx response
    },
    # To be process as normal, in sequence at deliver_tx
    "tx_3"{
        "parallel": false
    }
}
  1. The begin_block function completes and the blockchain now iterates through all transactions.
  2. Soft apply all async state results to the db
  3. deliver_tx is called for each transaction, for async txns the appropriate data is returned in the response, as if the transaction was normally. Sync transactions are processed normally, however the claim is still validated against the transaction result.
  4. end_block and commit are called.
  5. all state-changes are hard-applied

Transaction Environment

Transaction environment relates to how we create verifyable, deterministic randomness in smart contracts.

Also related to using the time which comes from the begin_block event. We need to decide how we are replacing the legacy way of creating a block hash, salt etc.

Return Transaction Schema

To get the process_tx logic to work, I commented out a bunch of stuff. Some of this had to do with signature and hashes in the final return object.

We need to determine what we want to include here and what we can permanently do without.

Rename `currency` contract

We should rename the currency contract to something else. Because if we at some point want to interact with another network like Lamden, it might be an issue if their TAU and our XIAN are both the same contract.

Either we name it xian if we are sure about the name or we call it something more abstract.

OpenAPI Spec

Would be more nice I think if we can provide a swagger ui for our API.

Can we still have FIFO?

That said, if the transactions contain some internal value, like an order/nonce/sequence number, the application can reject transactions that are out of order. So if a node receives tx3, then tx1, it can reject tx3 and then accept tx1. The sender can then retry sending tx3, which should probably be rejected until the node has seen tx2.

https://docs.cometbft.com/v0.38/core/mempool

Onboard Endogen

Let's have a discussion about the structure of the project and how we can make it as nice a place to work as possible.

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.