Experimental report on blockchain technology and Application

Experimental report on blockchain technology and application (Experiment 1)

About the author

  • Author introduction

    ๐ŸŠ Blog home page: Author URI
    ๐ŸŠ Introduction: high quality creators in the field of cloud computing ๐Ÿ†, The it story of the school's official account Creator ๐ŸŽ“, At school, he participated in many computer related provincial and national competitions and won a series of honors. Obtain a series of certifications such as Huawei senior engineer and red hat engineer.

    ๐ŸŠ Pay attention to me: resume template, learning materials, document download and technical support can privately trust me!
    Let life be like a burning fire that cannot be extinguished until death

1, Experimental purpose

  • Experimental purpose

    # Master the basic principle of bitcoin client BitcoinCore
    # Master the installation and configuration methods of bitcoin client BitcoinCore
    

2, Introduction to experimental principle

  • Introduction to experiment

    # bitcoin Core is a node client officially developed by bitcoin. It provides the comprehensive functions required to become a full node, and provides a friendly tool for the development, testing and actual operation of bitcoin, including three main programs.
    
    (1) bitcoin-qt: It encapsulates the complete bitcoin full node and provides a GUI The wallet program can realize the visualization of transaction data. A console is provided in the help menu of the wallet to publish multiple classes RPC Command, more friendly to ordinary users.
    (2) bitcoind: It provides a lightweight encapsulated bitcoin full node, which can be released to it after deployment RPC Commands interact with them, which is more friendly to developers.
    (3) bitcoin-cli: Provides node wide sending through the command line RPC Command function, generally used with bitcoind Cooperate with commissioning.
    
    With the help of the regression test network established earlier, it can be used bitcoin-cli Publish to related nodes RPC Commands interact with the test chain. Open a new command line and enter the following command to view the usage of the tool.
    bitcoin-cli โ€“h
     In each use bitcoin-cli You also need to use "-datadir=<dir>"Mark the path of the configuration file, and then accept the information to be sent RPC Command. For example, for nodes alice๏ผŒIf we want to query the node information connected to it in its perspective, we should enter:
    bitcoin-cli โ€“datadir=%appdata%\bitocin\alic\ getpeerinfo
    

3, Experimental environment

  • Experimental environment

    # Experimental environment
     This experiment is in PC It can be carried out on the machine, and the operating system can be Windows10 or Linux. Attention, in Linux The deployment method of the experiment in the system is similar or even more convenient, which increases the-daemon command(Background operation)Support.
    
    # Here we use the windows platform for demonstration
    windows 10 professional edition
    

4, Basic concepts of blockchain

4.1 introduction to blockchain

  • In November 2008, Japanese American Nakamoto, the developer and founder of bitcoin, published a bitcoin white paper and put forward the concept of blockchain
  • Blockchain is a distributed shared ledger technology, which records the process of asset transfer and transaction data, and has the similar function of database
  • It is a point-to-point relationship, which is decentralized and distributed in essence. It mainly includes two stages: 1.0 and 2.0
  • Characteristics of blockchain: decentralization, tamper proof, loss proof and easy traceability
  • Key technologies of blockchain:
    • Consensus mechanism:
      • Pow: proof of workload
      • PoS: proof of interest
      • DPoS: Certificate of appointment interest
      • PBFT: practical Byzantine fault tolerance algorithm
    • Smart contract:
    • Safety technology:
      • Hash algorithm
      • Asymmetric encryption algorithm (RSA, ECC)
    • Database storage:
    • Networking technology:
  • Other mainstream block chain platforms: Ethernet, super books, Corda, Wutong chain

4.2 introduction to bitcoin

  • Bitcoin is the most successful and important application of blockchain
  • Bitcoin is a digital cryptocurrency based on cryptography and economic game. It is also the first virtual currency system tested by large-scale and long-term operation in history.
  • Algorithm processing flow: the process of mining and bookkeeping
  • Bitcoin official website: Official website

5, Experimental environment deployment

5.1 description of experimental environment

  • Use environment

    operating systemSoftware version
    windows 10 professionalbitcoin-core-0.15.2
  • Software download address: bitcoin-core-0.15.2

5.2 software installation

  • Installation introduction

    # Install it normally here. If you have nothing to explain, you can install disk C or other disks.
    # Pay attention to whether the host computer turns off the firewall
    

5.3 configuring environment variables

  • Open the path of your installation, and then copy the path
  • Click this computer, right-click properties, advanced system settings, environment variables, find the PATH in the system variable (S), and enter it later; Your installation PATH, such as:; D:\bitcoin\daemon
  • Or refer to the following figure to configure environment variables.

5.4 win+R, enter cmd and press enter to enter the command line

  • Enter the command line

5.5 enter bitcoin - version to test whether the installation is successful

  • bitcoind -version

5.6 open and create a notepad, enter regtest=1 and save xx.conf

  • 1. Check the bitcoin installation directory first

  • 2. try to open the above path, create a new file bitcoin.conf, edit through the text editor, add "regtest=1" in the first line of the file, save the CMD command line and run the bitcoind command to observe the changes of the daemon folder.

  • # A regtest directory is added, and the file is the same as the bitcoin directory file
    

5.7 create three nodes, run at the same time and communicate

5.7.1 introduction to configuration file xx.conf

  • Relevant parameters:

    # regtest=1
     Start the key command of the regression test network. If it is omitted, it will automatically connect to the main network and start synchronization up to GB Block data for.
    # port=XXXX
     This command is used to configure the network port used for node connection. Under regression test, it defaults to 18444. If multiple nodes are set to run at the same time, different ports need to be customized to avoid conflicts with the existing services of the system.
    # Connect = < IP: Port > and addnode = < IP: Port >
    Both are means of manually adding known nodes. The difference is: connect After the command is configured, the node will only receive data from the configured specific address, reject the connection of other nodes, and addnode The command has no such restrictions. Addnode Imperative IP In the regression test, the address is generally set as the default loopback address of the system, i.e. 127.0.0.1. 
    # server=0/1
     This command is used to configure whether the node is a service node, that is, whether to accept RPC Command, the default value is 1, so there is no additional configuration.
    # rpcport=XXXX
     This command configures RPC The listening port for the command. Similarly, if multiple nodes are set to run at the same time, different ports need to be customized to avoid conflicts with the existing services of the system.
    # rpcuser=XXXXhe rpcpassword=XXX
     This command is used to set RPC The access user name and password are safe to use RPC Required commands for command. Even nodes do not want their clients to inexplicably accept other people's commands, thus losing all tokens in their wallets.
    Cooperate with the above commands to establish three nodes in the regression test network: alice,bob,network๏ผŒAnd make them connected to each other for interaction.
    
    

5.7.2 configuration file prepared for the experiment at this time

  • 1. Prepare experiment catalogue and documents

  • alice.conf content

    regtest=1
    port=22222
    rpcport=18332
    addnode=127.0.0.1:22224
    addnode=127.0.0.1:22226
                                 
    
  • bob.conf file content

    regtest=1
    port=22224
    rpcport=18334
    addnode=127.0.0.1:22222
    addnode=127.0.0.1:22226                       
    
  • network file content

    regtest=1
    port=22226
    rpcport=18336
    addnode=127.0.0.1:22222
    addnode=127.0.0.1:22224                          
    
  • 2. Delete the previous bitcoin directory and copy the file directory to the installation directory (C:\Users\hbs\AppData\Roaming)

5.7.3 call cmd three times and run the following commands respectively

  • 1. Run alice node

    # bitcoind -conf=%APPDATA%\Bitcoin\alice.conf -datadir=%APPDATA%\Bitcoin\alice
    
  • 2. Run bob node

    # bitcoind -conf=%APPDATA%\Bitcoin\bob.conf -datadir=%APPDATA%\Bitcoin\bob
    
  • 3. Run the network node

    # bitcoind -conf=%APPDATA%\Bitcoin\network.conf -datadir=%APPDATA%\Bitcoin\network
    

At this point, we open any directory (alice, bob, network) under C:\Users\hbs\AppData\Roaming\bitcoin \ directory. There is a regtest directory with the same class content

5.7.4 view the information that three nodes are connected normally

  • Open a directory randomly and check debug

summary

It is not difficult to build the initial environment. We only need to do the installation steps, and then our experiment is completed. Writing is not easy and supports originality. Readers are welcome to praise and collect

Blockchain technology and application experiment report Experiment 2

Dream as a horse, live up to youth, fleeting years laugh, the future can be expected!
                     - Dusk

Tags: Blockchain

Posted on Fri, 24 Sep 2021 09:37:07 -0400 by Smiffy