Giter Club home page Giter Club logo

cudos-node's Introduction

POC 1 - Create Cosmos Chain with BFT, Wallets and preconfigured accounts

Prerequirements

Starport: https://github.com/tendermint/starport/releases (linux only)
or
make (different ways to install it depending on OS)

Requirements

This project uses the default blog project from starport. It's purpose is to prove POC 1 requirements, such as:

  • Ability to launch a "vanilla" Cosmos blockchain and create a closed public test environment.
  • Ability of the network to support Tendermint BFT with Ethereum type of wallets.
  • The network should start with ~20 accounts/validators that have pre-configured vested balance in the genesis block.

Links:

Ability to launch a "vanilla" Cosmos blockchain and create a closed public test environment.

Launching a vanilla Cosmos blockchain is possible by starting this project using methods below.

Ability of the network to support Tendermint BFT with Ethereum type of wallets

The network supports Tendermint BFT by default. The wallets private keys are generated using secp256k1 also by default. The retionale of using Ethereum type of wallets is to ensure that the users will be able to import their ethereum wallets into cudos blockchain using theirs seed phase. After the import the users will expect to see that their balance from ethereum blockchain is transferred to cudos. Although the cryptography is the same it is used in a slightly different manner so a converted is developed. Its usage is described below. It can convert ethereum public key to cudos wallet address. Using cudos wallet address a wallet can be pre-funded with required tokes so when a user import his wallet, using his seed, the balance will be correct.

Creating accounts/validators with preconfigured vested balance in the genesis block

There are three ways to add preconfigured accounts with/without vested balance in the genesis block.

  1. Modifying genesis.json after the blockchian is initialized, but before it is first started. This is not recommented method.
  2. Using config.yml. This method works if the blockchain is initialized with starport utility.
  3. Using commands from the binary itself. This method works if the blockchain is manually initialized without startport utility.



Manual build

Build the blockchian binary into $GOPATH directory using "cudos-noded" name. All these steps are combined into init.sh/init.cmd

make

Initialize the blockchain.

cudos-noded init cudos-node --chain-id=cudos-node

Creating accounts. Each account can have vesting balance as well.

cudos-noded keys add validator01 --keyring-backend test --vesting-amount 500stake --vesting-end-time 1617615300

Add balance in the genesis block to an account.

cudos-noded add-genesis-account $MY_VALIDATOR_ADDRESS 100000000000stake

Add validator

cudos-noded gentx validator01 100000000stake --chain-id cudos-node --keyring-backend test

Collect genesis transaction and start the blockchain

cudos-noded collect-gentxs
cudos-noded start



Starport build

Configure accounts and validators in config.yml after that just start the blockchain

starport serve



Docker build

  1. Build persistent-node cd ./docker docker-compose -f ./persistent-node.yml -p cudos-network-persistent-node up --build

  2. After node starts copy its it and paste it into full-node.yml Peer node looks like: P2P Node ID ID=de14a2005d220171c7133efb31b3f3e1d7ba776a file=/root/.blog/config/node_key.json module=p2p

  3. Run full-node cd ./docker docker-compose -f ./full-node.yml -p cudos-network-full-node up --build




Converting ethereum public keys to cosmos wallet address

Run the converter and pass a ethereum public key as argument.

go run ./converter 0x03139bb3b92e99d034ee38674a0e29c4aad83dd09b3fa465a265da310f9948fbe6

Example ethereum mnemonic: battle erosion opinion city birth modify scale hood caught menu risk rather
Example ethereum public key (32 bytes, compressed form): 0x03139bb3b92e99d034ee38674a0e29c4aad83dd09b3fa465a265da310f9948fbe6

This mnemonic could be imported into cudos blockchain in order to verify that resulting account access will be the same as generated from the converter.

cudos-noded keys add ruser02 --recover --hd-path="m/44'/60'/0'/0/0"



Usefull commands

Send currency

cudos-noded tx bank send $VALIDATOR_ADDRESS $RECIPIENT 51000000stake --chain-id=cudos-network --keyring-backend test

Check balances

cudos-noded query bank balances $RECIPIENT --chain-id=cudos-network

Create validator

cudos-noded tx staking create-validator --amount=1000stake \
--from=validator02 \
--pubkey=$(cudos-noded tendermint show-validator) \
--moniker=cudos-node-01 \
--chain-id=cudos-network \
--commission-rate="0.10" \
--commission-max-rate="0.20" \
--commission-max-change-rate="0.01" \
--min-self-delegation="1" \
--gas="auto" \
--gas-prices="0.025cudos" \
--gas-adjustment="1.80" \
--keyring-backend test



Reset the blockchain

All data of the blockchain is store at ~/.blog folder. By deleting it the entire blockchain is completely reset and it must be initialized again.

Static compile

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo -ldflags '-extldflags "-static"' ./cmd/cudos-noded/

export CGO_LDFLAGS="-lpthread -ldl" go build -v -a -tags netgo,osusergo -ldflags='-lpthread -extldflags "-lpthread -static"' ./cmd/cudos-noded/

cudos-node's People

Contributors

kstoykov avatar v-staykov avatar

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.