Compilation and deployment of eosio

1. Explanation of terms

  1. The creation node (BIOS) is used to create the initial block and load the basic contract for other nodes to connect synchronously.

  2. The miner node (BP) is mainly used for the production of synchronous blocks, and the cost incurred in calculating the contract belongs to the miner account.

  3. The query node does not generate blocks, synchronizes block information, and provides block information query function.

  4. The private key is used for signature operation. The private key can generate a unique corresponding public key.

  5. The public key is used to verify the signature of the private key.

  6. When the private key is generated and saved in the wallet, the private key list will be read from the wallet for signature.

  7. The bandwidth is divided into cpu bandwidth and net bandwidth. Each execution of the contract will consume a certain bandwidth (deducted from the account).

  8. A section of executable code in the chain is bound to the account, and each account can only bind one contract.

  9. Account stores user information, including balance, bandwidth, contract (if any), etc.

  10. Total votes total votes = total number of currencies issued.

  11. The voters pledged money to vote for the miners. When the number of votes of the miners is more than 15% of the total votes, the genesis node stops producing blocks and transfers them to the miners' production blocks.

    The so-called miner node and query node are only used to distinguish whether to produce different configurations of blocks.

2. Node code compilation and program installation

Note: later compilation depends on git, so make sure that. Git of the code root directory is complete and Git is installed in the system. Take ubuntu system as an example, and other system steps are similar.

  1. Install GIT first, ignore this step if already installed

    sudo apt update && sudo apt install git -y
    
  2. Clone the latest code from GIT

    git clone https://github.com/eosio/eos --recursive --depth 1
    
  3. Auto compile with eosio build.sh

    The script will check the system dependency library and install it automatically. Please pay attention to the administrator permission prompt. If the download of dependency library is interrupted, please check the network status and execute it again.

    cd eosio
    export LOCAL_CMAKE_FLAGS="-DEOSIO_ROOT_KEY=EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV -DCORE_SYMBOL_NAME=EOS"
    ./script/eosio_build.sh
    

    The formal environment can use the local cmake flags environment variable to specify the root public key eosio root key and the system currency symbol core symbol name

  4. Packaging and installation

    If the compilation is successful, the ASCII drawing prompt of 'EOSIO' will appear. Please perform the following operations to install the program into the system. If there is a compilation error, please submit the error prompt to the relevant personnel for check and solution.

     cd build/packages
     bash ./generate_package.sh [brew|deb|rpm]
     ls
    
     #ubuntu
     sudo dpkg -i eosio-v1.7.3.deb
    
     #redhat
     sudo yum install eosio-v1.7.3.rpm
     #perhaps
     sudo rpm -ivh eosio-v1.7.3.rpm
    

    Parameter Description:

    • brew mac system
    • deb ubuntu system
    • rpm redhat system
  5. Recompile If there is any code modification or version update, please close the currently running wallet and node programs, clear the programs installed in the system, and then compile.

    pkill -2 keosd nodeos
    #ubuntu
    sudo apt remove eosio
    #redhat
    sudo yum remove eosio
    

3. Default profile directory

Linux: ~/.local/share/eosio/nodeos/config Mac: ~/Library/Application Support/eosio/nodeos/config

4. Create default wallet and public private key

  1. Start wallet service

    keosd --unlock-timeout 3600 # Wallet relocks in 3600 seconds
    
  2. Create Wallet

    Please save the output wallet code. It will be used the next time you open the wallet.

    cleos wallet create -n default
    
    #Open wallet
    cleos wallet open -n default
    
  3. Create public private key

    cleos create key
    
  4. Import the private key generated in the previous step into the wallet

    cleos wallet import -n default --private-key [private key]
    

5. General configuration

Parameter name Example Explain
agent-name The name of the node identifying itself in p2p network "eosio bios"
producer-name Miner's account name "eosio"
signature-provider Miner's public key and private key for signature EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV<br>=KEY:5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
p2p-server-address p2p service listening address, default listening 0.0.0.0:9876 "0.0.0.0:9876"
http-server-address The http server listens for the address. If you do not want to provide http service, you can leave the address blank, and the non http service will not start. Note that if not filled in, the default address will be 127.0.0.1:8888 "127.0.0.1:8888"
enable-stale-production Start the production block immediately after startup. If it is not a BIOS node, fill in false here. true
p2p-peer-address The p2p synchronization address of other nodes is used to synchronize data. This parameter can have multiple nodes, that is, to connect to multiple nodes. "192.168.0.2:9876"

6. Configuration of Genesis node

6.1. Start parameter configuration

  1. To create a public and private key for the eosio system account, see 4. Create wallet and public private key

  2. Modify the initial key of genesis.json to the public key generated in the previous step

  3. Start the node and fill in the public and private keys generated in step 1

     nodeos --agent-name "eosio bios" --producer-name "eosio" \
         --signature-provider [public key]=KEY:[private key] \
         --plugin eosio::chain_plugin --plugin eosio::chain_api_plugin \
         --p2p-server-address "0.0.0.0:9876" --http-server-address "127.0.0.1:8888" --enable-stale-production
    

6.2. Deployment system contract

  1. Download compile contract compiler

     git clone https://github.com/eosio/eosio.cdt.git --recursive --depth 1
     cd eosio.cdt
     ./build.sh
     sudo ./install.sh
    
  2. Download compilation contract

     git clone https://github.com/eosio/eosio.contracts.git --depth 1
     cd eosio.contracts
     ./build.sh
    
  3. Create system account

    The OwnerKey is the same as the ActiveKey, see 6.1 generated public key

    cleos create account eosio eosio.token [OwnerKey] [ActiveKey] -p eosio 
    cleos create account eosio eosio.msig [OwnerKey] [ActiveKey] -p eosio 
    cleos create account eosio eosio.bpay [OwnerKey] [ActiveKey] -p eosio 
    cleos create account eosio eosio.names [OwnerKey] [ActiveKey] -p eosio 
    cleos create account eosio eosio.ram [OwnerKey] [ActiveKey] -p eosio 
    cleos create account eosio eosio.ramfee [OwnerKey] [ActiveKey] -p eosio 
    cleos create account eosio eosio.saving [OwnerKey] [ActiveKey] -p eosio 
    cleos create account eosio eosio.stake [OwnerKey] [ActiveKey] -p eosio 
    cleos create account eosio eosio.vpay [OwnerKey] [ActiveKey] -p eosio 
    

    If the root public key is specified with the local cmake flags parameter, it must be the same here.

  4. To deploy a currency contract, please confirm to execute it in the root directory of the contract code. See 6.2.2 download and compile contract

    cleos set contract eosio.token build/eosio.token -p eosio.token
    cleos set contract eosio.msig build/eosio.msig -p eosio.msig
    
  5. Create currency

    cleos push action eosio.token create '["eosio", "1000000000000.0000 EOS", 0, 0, 0]' -p eosio.token
    cleos push action eosio.token issue '["eosio", "1000000000000.0000 EOS", "issue"]' -p eosio
    

    If the system currency symbol is specified using the local cmake flags parameter, it must be the same here.

  6. To deploy the system contract, please confirm to execute it in the contract code root directory. See 6.2.2 download and compile contract

    cleos set contract eosio build/eosio.system -p eosio
    cleos push action eosio init '[0, "4,EOS"]' -p eosio@active
    cleos push action eosio setpriv '["eosio.msig", 1]' -p eosio@active
    

7. Miner node configuration

1. Register miner account

  1. For public and private keys to create a miner account, see 4. Create wallet and public private key

  2. Create miner account

    cleos system newaccount --stake-net [quantity] --stake-cpu [quantity] --buy-ram-kbytes 8192 \
        [creater] [name] [OwnerKey] [ActiveKey] -p [creater]
    # Parameter description
    # Creator account of the creator miner account.
    # Name the name of the miner's account.
    # quantity purchases bandwidth resources and deducts them from the creator's account.
    # OwnerKey is the same as ActiveKey, the public key of the miner account, that is, the public key generated in the previous step.
    
    # Example
    cleos system newaccount --stake-net "50.0000 EOS" --stake-cpu "50.0000 EOS" --buy-ram-kbytes 8888888 eosio eosnewbpa \
    EOS7n1U9Z2NQeVEvQZYjHCedNXRVWshmmuGH2j3r6bD4c8fH4U8QL EOS7n1U9Z2NQeVEvQZYjHCedNXRVWshmmuGH2j3r6bD4c8fH4U8QL -p eosio
    
  3. Transfer to miner account

    cleos transfer [from] [recipient] [amount] [momo]
    # Parameter description
    # from transfer account No
    # recipient receiving transfer account
    # amount
    # momo notes
    
    # Example
    cleos transfer eosio eosnewbpa "9000000000.0000 EOS" "trans to eosnewbpa"
    
  4. Registered as a miner

    cleos system regproducer [name] [ActiveKey] [url]
    # Parameter description
    # name miner account
    # ActiveKey public key of miner account
    # url miner's website
    
    #Example
    cleos system regproducer eosnewbpa  EOS7n1U9Z2NQeVEvQZYjHCedNXRVWshmmuGH2j3r6bD4c8fH4U8QL https://192.168.0.57:8888
    
  5. Mortgage corresponding resources

    cleos system delegatebw [name] [name] [stake_net_quantity] [stake_cpu_quantity]
    # Parameter description
    # name miner account
    # The network bandwidth resources mortgaged by make net quantity
    # The CPU bandwidth resources mortgaged by "make" CPU "quantity
    
    # Example
    cleos system delegatebw eosnewbpa eosnewbpa '4400000000.0000 EOS' '4400000000.0000 EOS'
    
  6. Vote for yourself

    cleos system voteproducer prods [voter] [producers] -p [voter]
    # Parameter description
    # voter miner account
    # Network bandwidth resources mortgaged by producers
    
    #Example
    cleos system voteproducer prods eosnewbpa eosnewbpa
    

2. Start parameter configuration

  1. To create a public and private key for the eosio system account, see Creating wallets and public and private keys

  2. Modify the initial key of genesis.json to generate the public key for the BIOS

  3. Start the node and fill in the public and private keys generated in step 1

    Suppose that bios node 192.168.0.56:9876 and BP node 192.168.0.58:9876 are known.

    nodeos --agent-name "eosnewbpa" --producer-name "eosnewbpa" \
        --signature-provider [public key]=KEY:[private key] \
        --p2p-server-address "0.0.0.0:9876" --http-server-address "127.0.0.1:8888" \
        --p2p-peer-address "192.168.0.56:9876" --p2p-peer-address "192.168.0.58:9876"
    

8. Query node configuration

The query node configuration is similar to the miner node configuration, except that it is not registered as a miner, and the query node is often used for data query. It is recommended to open the Mongo DB plugin plug-in. Mongo DB plugin is a plug-in for saving block transaction information to mongodb.

Suppose that the bios node 192.168.0.56:9876, BP node 192.168.0.57:9876 and 192.168.0.58:9876 are known, and the mongo_db_plugin plug-in is enabled for all three nodes.

nodeos --agent-name "eosnewbpb" --producer-name "eosnewbpb" \
  --signature-provider [public key]=KEY:[private key] \
  --p2p-server-address "0.0.0.0:9876" --http-server-address "127.0.0.1:8888" \
  --p2p-peer-address "192.168.0.56:9876" --p2p-peer-address "192.168.0.57:9876" --p2p-peer-address "192.168.0.58:9876" \
  --plugin eosio::mongo_db_plugin --mongodb-uri mongodb://127.0.0.1:27017/EOSIO

9. recommendations

  1. From the perspective of security, do not disclose the private key to others. After knowing the private key of the account, you can manipulate the account at will.

  2. If you use a private key generated by a mnemonic, use a more complex mnemonic.

  3. Many of the parameters passed in above are for demonstration. If it is formally deployed, it is recommended to use the configuration file.

  4. It is recommended to use SIGINT signal to shut down the node and prevent the program from generating dirty data.

    pkill -2 keosd nodeos
    
  5. If dirty data is generated, use the -- replay blockchain parameter or the -- delete all blocks parameter to start the node and resynchronize the data.

  6. Before starting the node, please confirm that the time and time zone are correct, and the offset of time will affect the block data verification.

    sudo mv /etc/localtime  /etc/localtime.bak
    sudo ln -s /usr/share/zoneinfo/UTC /etc/localtime
    # Update system time with ntpdate
    sudo apt install ntpdate ntp -y # yum install ntpdate ntp -y
    sudo timedatectl set-timezone UTC
    sudo ntpdate -u time.windows.com
    sudo hwclock --systohc # Write hardware
    # Start ntpd service
    sudo systemctl enable ntp # systemctl enable ntpd
    sudo systemctl start ntp # systemctl start ntpd
    

Tags: Blockchain sudo git RPM Ubuntu

Posted on Thu, 09 Jan 2020 13:14:45 -0500 by ethan.whitt