Official mining application for OpenPoll Platform
Purpose: This document holds the very basic necessities that the mining application will need. The mining application supports two different types of mining: (1) mining the OpenPoll main blockchain, and (2) mining multiple different shard blockchains. All miners at the time of initial launch are required to operate full nodes, until a light miner is released. Before understanding the architecture and design of the mining application, you should understand the theory behind the OpenPoll main and shard blockchains. This document describes the software implementation of the mining application, however, it does not describe the higher level theory behind the main blockchain, or individual shard chains.
Mining Application Responsibilities
The mining application has many different responsibilities, but principally, it has the ability to transform a computer into a node running optionally on the main blockchain, or turn a single computer into a node for many shard blockchains.
- The goal of a node mining poll responses (as well as completed poll hashes) is so that they can be locked into an immutable chain of blocks (a blockchain) that is hash enforced and validated by network consensus rules
- Nodes must be able to speak to each other, broadcast their status/data to all nodes they are connected to, begin working on any chain of their choice (whether it be a available poll shard or the main chain), and terminate any completed shard following network consensus
- The network must be decentralized and allow miners to work on whatever they’d like. All miners will be full nodes at the outset.
- Miners should be rewarded for blocks they mine that stay on the best blockchain and respondents should be rewarded for their responses that stay on the best blockchain.
- Both events, the miners being rewarded as well as the respondents being rewarded (at least for the poll shards) will be assessed upon shard termination and incorporation into the main chain where the shard chain will undergo final validation and poll escrow funds will be released to the appropriate parties and transactions will be locked into the main chain
- Miners working one the main chain will be awarded an MCIF (main chain incorporation fee) for every poll in a block they mine on the main chain that stays on the best blockchain.
- Percentage breakdown of poll funding distribution can be found here
Node CLI Commands
Miners must be able to interface with the application and know the state of their operations. Miners must be able to know what pollId’s are available for them to work on, be able to start or drop working on any pollId (or the main chain), and they must be able to know what they have won a mining race and will be rewarded eventually. We can use
[commander](https://www.npmjs.com/package/commander) to take terminal input and let users interface with internal application state that way.
Basic Top-Level Commands To Support
- Displays a list of pollId’s that the miner can work on. By calling fetch, the miner can initialize their mempool and blockchain for that shard (or the main chain if “main” is passed in as the pollId argument).
- Displays the working status of this node. What shards it is mining on (or not mining on), what shards are ready to be mined on (have latest blockchain and mempool imported), what shards aren’t ready to be mined on, etc.
- Fetches the genesis block or best blockchain for this pollId (or main chain), fetch the mempool of the chain, and broadcast that this node is now working on this pollId (or main chain).
- Clears the data associated with the pollId (or mainchain) from LevelDB, broadcasts to all nodes that this node is now not working on on this poll
- Begins mining for the shard associated with the pollId (only if fetch has been called first and all the data is there and node has proper state to begin mini)
- Stops mining for the shard associated with the pollId (or mainchain if “main” passed in)
- Displays the chain associated with the given pollId that this node holds
block <blockIndex> <pollId>
- Displays the block at index blockindex for the given pollId
- Refetch the mempool for this pollId (or main chain mempool if this is for the mainchain)u
- Create a new wallet for the miner given a password. The password is hashed, hash is used to create a wallet secret, secret is used to generate a public and private key pair for the miner (and address is calculated using the keypair). Wallet structure can be found in JSON Formats