MVC Incentived Testnets

MIT 全称 MVC Incentived Testnets,通过测试网活动,MVC社区将为未来数十亿用户构建可无限扩容、高水平去中心化、高性能的Web3区块链。

第一步:安装依赖项

sudo apt-get install -y build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils
sudo apt-get install -y libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev
sudo apt-get install -y libdb-dev libdb++-dev libczmq-dev

安装脚本:

#!/bin/bash
_url=https://github.com/Brochao/space-mining-guide/releases/download
_net_choose=
_latest_version=0.1.0.0
_version=
_node_file=mvc.tar.gz
_miner_file=cpuminer.tar.gz
_node_install_dir=
_node_data_dir=

# check_file_exit(){

# }
ensure() {
    if ! "$@"; then err "command $*" "failed" ; fi
}

say() {
    printf '[ERROR] %s: %s\n' "$1" "$2"
}

err() {
    say "$1" "$2" >&2
    exit 1
}

need_cmd() {
    if ! check_cmd "$1"; then
        err "command not found" "need '$1'"
    fi
}

check_cmd() {
    command -v "$1" > /dev/null 2>&1
}

usage() {
    cat 1>&2 <<EOF
The node installer for metaverchain

USAGE:
    ./install-node.sh [FLAGS] [OPTIONS]

FLAGS:
    -m, --mainnet             install and query mainnet
    -t, --testnet             install and query testnet

OPTIONS:
        --latest              install the newest version of metaversechain
        --version=<x.x.x.x>   install the specific version (--version=0.1.0.0 for example)
EOF
}

main(){
    if [ $# -eq 0 ] || [ $# -gt 2 ] || [ "$1" = -h ] || [ "$1" = -help ] || [ "$1" = ? ];
    then
        usage
        exit 0
    fi

    if [ "$1" != -m ] && [ "$1" != --mainnet ] && [ "$1" != -t ] && [ "$1" != --testnet ];
    then
        err "net choose [$1]" "not support"
    fi

    if [ "$1" = -m ] || [ "$1" = --mainnet ];
    then
        # TODO
        err "net choose [$1]" "mainnet is not supported yet"
        # _net_choose=mainnet
    fi

    if [ "$1" = -t ] || [ "$1" = --testnet ];
    then
        _net_choose=testnet
    fi


    local tmp_str=$2
    tmp_str=${tmp_str%=*}

    if [ "$2" = --latest ];
    then
        _version=$_latest_version
    elif [ $tmp_str = --version ]; 
    then
        tmp_str=$2
        _version=${tmp_str#*=}
        _version=${_version#*v}
    else
    err "version choose [$2]" "invalid"
    fi


    echo you choose $_net_choose with version $_version 
    # echo continue? "(y/n)"
    # read -n 1 choise
    # echo 
    # if [ $choise != y ];
    # then
    #     echo "installation will be quit, please check your choise"
    #     exit 0
    # fi


    need_cmd wget
    need_cmd tar
    need_cmd pwd

    # echo "please input the installation path of mvc node"
    # echo "if not set"
    # echo "current path will be used"
    # read  path
    # _node_install_dir=$path
    
    # if [ -z $_node_install_dir ];
    # then
        _node_install_dir=$(pwd)
    # fi
    echo "the mvc node will be installed to $_node_install_dir"
    # echo "(y/n)"
    # read -n 1 choise
    # if [ $choise != y ];
    # then
    #     echo "installation will be quit, please select another path"
    #     exit 0
    # fi

    # echo "please input the data storage path of mvc node"
    # echo "in which the blocks data/wallet data/logs will be saved"
    # echo "if not set"
    # echo "current path will be used"
    # read  path
    # _node_data_dir=$path
    
    # if [ -z $_node_data_dir ];
    # then
        _node_data_dir=$(pwd)/node_data_dir
    # fi
    echo "the mvc node data will be saved to $_node_data_dir"
    # echo "(y/n)"
    # read -n 1 choise
    # echo 
    # if [ $choise != y ];
    # then
    #     echo "installation will be quit, please select another path"
    #     exit 0
    # fi

     ensure mkdir -p "$_node_install_dir"
     ensure mkdir -p "$_node_data_dir"

    local temp_path=temp-$(date +%s%N)
    mkdir $temp_path
    cd $temp_path
    echo "downloading node file..."
    echo 
    wget -q --show-progress ${_url}/v${_version}/${_node_file} 
    if [ $? != 0 ];
    then
        err "node downloading" "failed"
    fi

    echo "downloading mining file..."
    echo 
    wget -q --show-progress ${_url}/v${_version}/${_miner_file} 
        if [ $? != 0 ];
    then
        err "miner downloading" "failed"
    fi

   tar zxvf mvc.tar.gz -C $_node_install_dir
   tar zxvf cpuminer.tar.gz -C $_node_install_dir

   cd ..
   rm -rf $temp_path



   $_node_install_dir/bin/mvcd -conf=$_node_install_dir/mvc.conf -data_dir=$_node_data_dir

}

main "$@" || exit 1

配置文件mvc.conf:修改mvc.conf中的addnode、rpcuser和rpcpasswd参数

##
## mvcd.conf configuration file. Lines beginning with # are comments.
##

#start in background
daemon=1

#Required Consensus Rules for Genesis
excessiveblocksize=10000000000 #10GB
maxstackmemoryusageconsensus=100000000 #100MB

#Mining
#biggest block size you want to mine
blockmaxsize=4000000000 
blockassembler=journaling

#preload mempool
preload=1

# Index all transactions, prune mode don&t support txindex
txindex=1
reindex=1
reindex-chainstate=1

#Other Sys, ws add
maxmempool=6000
dbcache=1000 

#Other Block, ws add
threadsperblock=6
#prune=196000

#Other Tx Conf:
maxscriptsizepolicy=0
blockmintxfee=0.00000250

# Connect via a SOCKS5 proxy
#proxy=127.0.0.1:9050

# Bind to given address and always listen on it. Use [host]:port notation for IPv6
#bind=<addr>

# Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6
#whitebind=<addr>

##############################################################
##            Quick Primer on addnode vs connect            ##
##  Let's say for instance you use addnode=4.2.2.4          ##
##  addnode will connect you to and tell you about the      ##
##    nodes connected to 4.2.2.4.  In addition it will tell ##
##    the other nodes connected to it that you exist so     ##
##    they can connect to you.                              ##
##  connect will not do the above when you 'connect' to it. ##
##    It will *only* connect you to 4.2.2.4 and no one else.##
##                                                          ##
##  So if you're behind a firewall, or have other problems  ##
##  finding nodes, add some using 'addnode'.                ##
##                                                          ##
##  If you want to stay private, use 'connect' to only      ##
##  connect to "trusted" nodes.                             ##
##                                                          ##
##  If you run multiple nodes on a LAN, there's no need for ##
##  all of them to open lots of connections.  Instead       ##
##  'connect' them all to one node that is port forwarded   ##
##  and has lots of connections.                            ##
##       Thanks goes to [Noodle] on Freenode.               ##
##############################################################

# Use as many addnode= settings as you like to connect to specific peers
addnode=node.mvc.space:29883

# Alternatively use as many connect= settings as you like to connect ONLY to specific peers
#connect=

# Listening mode, enabled by default except when 'connect' is being used
#listen=1

# Maximum number of inbound+outbound connections.
maxconnections=12

#
# JSON-RPC options (for controlling a running Bitcoin/bitcoind process)
#

# server=1 tells bitcoind to accept JSON-RPC commands
server=1

# Bind to given address to listen for JSON-RPC connections. Use [host]:port notation for IPv6.
# This option can be specified multiple times (default: bind to all interfaces)
rpcbind=0.0.0.0

# If no rpcpassword is set, rpc cookie auth is sought. The default `-rpccookiefile` name
# is .cookie and found in the `-datadir` being used for bitcoind. This option is typically used
# when the server and client are run as the same user.
#
# If not, you must set rpcuser and rpcpassword to secure the JSON-RPC api. The first
# method(DEPRECATED) is to set this pair for the server and client:
rpcuser=user

rpcpassword=password

# How many seconds mvc will wait for a complete RPC HTTP request.
# after the HTTP connection is established. 
#rpcclienttimeout=30

# By default, only RPC connections from localhost are allowed.
# Specify as many rpcallowip= settings as you like to allow connections from other hosts,
# either as a single IPv4/IPv6 or with a subnet specification.

# NOTE: opening up the RPC port to hosts outside your local trusted network is NOT RECOMMENDED,
# because the rpcpassword is transmitted over the network unencrypted.

# server=1 is read by mvcd to determine if RPC should be enabled 
rpcallowip=0.0.0.0/0

# Listen for RPC connections on this TCP port:
rpcport=9882

minimumchainwork=0000000000000000000000000000000000000000000000000000000100010001
  1. chmod 777 ./install-node.sh
  2. ./install-node.sh -t –latest

启动节点,注意user:password需修改为mvc.conf中的rpcuser rpcpassword一致

配置cli命令
alias mvc-cli="/home/$USER/mvc/bin/mvc-cli -conf=/home/$USER/mvc/mvc.conf"
快速启动点配置方法

alias mvc-cli="$NODE_DIR/bin/mvc-cli -conf=$NODE_DIR/mvc.conf"

获取采矿地址
mvc-cli getnewaddress "mine"
开始挖矿
/home/$USER/mine/minerd -a sha256d -o 127.0.0.1:9882 -O user:password --coinbase-addr=addr
快速启动节的挖掘方法

$NODE_DIR/minerd -a sha256d -o 127.0.0.1:9882 -O user:password --coinbase-addr=addr