How to setup a second producer in Koinos Blockchain

in #koinoslast year

As you probably know Koinos Blockchain works with microservices. The principal microservices are:

  • Chain microservice: The core of the blockchain. The smart contracts reside here and the validation of blocks and transactions.
  • P2P microservice: Makes the connection with the network to receive or transmit new blocks.
  • Block store microservice: Stores the history of the blocks.
  • Mempool microservice: Stores pending transactions to be inserted in a block.
  • Block producer microservice: Creates new blocks by taking the transactions from the mempool.

This architecture gives modularity and allows a better management of the nodes. For instance, the ability to setup several blockproducers in a single node.

In this post I will explain how to setup 2 different producers. The process is very simple.

You maybe wondering, why do you need to setup 2 producers? well, the introduction of Fogata and new mining pools opened the door for existing block producers to convert their nodes in mining pools. However, if they don't want to shutdown the current producer they can setup a second producer and link it to the pool.

1. Update the docker-compose.yaml

docker-compose.yaml contains the selection and configuration of the different microservices. Open it and add a new microservice for the second producer:

...
    p2p:
      image: koinos/koinos-p2p:${P2P_TAG:-latest}
      depends_on:
         - amqp
         - block_store
         - chain
         - config
      volumes:
         - "${BASEDIR}:/koinos"
      ports:
         - "${P2P_INTERFACE:-0.0.0.0}:8888:8888"
      command: --basedir=/koinos

   block_producer:
      image: koinos/koinos-block-producer:${BLOCK_PRODUCER_TAG:-latest}
      profiles: ["block_producer", "all"]
      depends_on:
         - amqp
         - mempool
         - chain
         - config
      volumes:
         - "${BASEDIR}:/koinos"
      command: --basedir=/koinos

   block_producer_2:
      image: koinos/koinos-block-producer:${BLOCK_PRODUCER_TAG:-latest}
      profiles: ["block_producer", "all"]
      depends_on:
         - amqp
         - mempool
         - chain
         - config
      volumes:
         - "${BASEDIR}_2:/koinos"
      command: --basedir=/koinos

   jsonrpc:
      image: koinos/koinos-jsonrpc:${JSONRPC_TAG:-latest}
      profiles: ["jsonrpc", "api", "all"]
      depends_on:
         - amqp
         - config
      volumes:
         - "${BASEDIR}:/koinos"
      ports:
         - "${JSONRPC_INTERFACE:-0.0.0.0}:8080:8080"
      command: --basedir=/koinos
...

2. Start docker-compose

Stop your node and run again docker compose to launch the new microservice:

docker-compose --profile block_producer up

3. Get the public key of the new producer

After the containers are started it should create a new folder called ~/.koinos_2 as defined in the docker compose (so ~/.koinos is for the first producer and ~/.koinos_2 for the second one). Open the folder ~/.koinos_2/block_producer and copy the new generated public key. This is the public key that needs to be registered in the PoB contract.

4. Update config.yml

Now open ~/.koinos_2/config.yml and set in producer the address of the new producer (like the pool address in fogata).

5. Restart the node

Restart the node to take the changes from the config.yml file. You should see messages from the microservices of both block producers.

Final note

Remember that you have to register the new public key in the PoB contract. If you are using Fogata you can do it through fogata.io.

Sort:  

Congratulations @jga! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You received more than 10000 upvotes.
Your next target is to reach 15000 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out our last posts:

Our Hive Power Delegations to the January PUM Winners
Feedback from the February Hive Power Up Day
Hive Power Up Month Challenge - January 2023 Winners List
The Hive Gamification Proposal
Support the HiveBuzz project. Vote for our proposal!