BlockDAG Dashboard v3

logout

Notifications

0
logout

Connect Wallet

Dev Release 28

Greetings BlockDAG Community,

Let's first go through a quick recap of this week!
To start our week, we began by implementing libP2P, where we discovered the processes for identifying nodes and addresses. There were three key discovery mechanisms introduced: bootstrap nodes, mDNS, and Kademlia. Following the identification phase, we moved on to construct connections between nodes. After a successful connection, a sub-stream is established. A few basic implementation algorithms were described in conjunction with libP2P. Additionally, the request-response protocol was investigated and implemented alongside the notification protocol. Finally, synchronizing is required, thus an implementation method and rapid algorithms were developed around this.
Today, we began exploring the mining process and the tactics that surround it. Let's dig into more information about today's research:

Understanding the mining process in BlockDAG

The linear holds transaction records on the blockchain by connecting a series of blocks. That each block is adding a new chain in the linear. Contrastingly, in BlockDAGs, a more sophisticated structure is introduced, where multiple blocks can be mutually referenced, forming a directed complex graph which does no longer need to have a strict linear sequence.
In BlockDAG mining, the primary goal remains the same: towards the validation of transactions and to secure the network.
The DAG formation based on consideration of transaction selections features a big deviation as compared to the linear blockchains. Miners in the BlockDAG network need to take into account parameters like dependency relation between the transactions, graph topology and accord rules. Let's understand a conceptual algorithm of how mining will work in blockchains based on DAG implementation:

  1. Transaction Validation: In a DAG, transactions are not organized into blocks that are added sequentially to a chain. Instead, each transaction directly references and validates two previous transactions. To participate in mining, nodes (or participants) in the network validate transactions by approving two previous transactions through a voting process.
  2. Consensus Mechanism:
  • Proof of Work (PoW) in DAG: Nodes perform a small amount of computational work to validate transactions and reach consensus. However, the main focus is on approving transactions by referencing previous transactions.
  • Other Consensus Mechanisms: Some DAG-based blockchains use unique consensus algorithms like Tangle's "Markov Chain Monte Carlo" (MCMC) or similar voting-based systems to achieve agreement on transaction validity.
  1. Approving Transactions: Miners (or nodes) in a DAG network contribute to the approval of transactions by referencing previous transactions and adding new transactions to the DAG structure. Each approved transaction confirms and strengthens the network, contributing to its security and reliability.
  2. Transaction Confirmation: Transactions in a DAG blockchain are considered confirmed when they are referenced (approved) by subsequent transactions. This confirmation process does not rely on block creation or mining rewards in the traditional sense but instead on the collective validation and approval of transactions by network participants.
  3. Network Growth and Security: As more transactions are added to the DAG, the network grows and becomes more secure. The structure of the DAG allows for parallel processing and potentially higher scalability compared to linear blockchains. Nodes contribute to the network's security by actively participating in the approval of transactions.
  4. Incentives and Rewards: In some DAG-based blockchains, there may still be incentives or rewards for participants (miners) who contribute to the network's operation and security. These incentives will vary and will also include some transaction fees, network token rewards, or other mechanisms to encourage participation and network growth.

In summary, mining in a DAG-based blockchain focuses on transaction approval and consensus through a decentralized voting process rather than traditional block creation and PoW(Proof Of Work) mechanisms. Participants contribute to the network's security and reliability by validating transactions and building on the DAG structure, leveraging its unique properties for scalable and efficient decentralized transactions.

An example algorithm implementation

Here's an example algorithm implementation which can be used to implement the mining process in BlockDAG.
 

  • Initialization:
  • Inputs:
             transactions: List of transactions to be included in the new block.
             previousBlockHash: Hash of the previous block in the blockchain.
  •      difficulty: Mining difficulty level (e.g., number of leading zeros required in the block hash)
     
  • Mining Loop:
             Initialize nonce to 0.
  • Repeat the following steps until a valid block hash is found:
  • Construct Block Data:
  • Create block data containing:
                     index: Index of the new block (incremented from the previous block index).
                     previousBlockHash: Hash of the previous block.
                     transactions: List of transactions.
                     timestamp: Current timestamp.
              nonce: Current nonce value.
  • Calculate Block Hash:
  • Calculate the hash of the block data using a cryptographic hash function (e.g., SHA-256).
  • Check Difficulty:
  • Verify if the calculated block hash meets the required mining difficulty:
                        Convert the hash into a binary string.
                        Count the number of leading zeros in the binary string.
              Compare the count of leading zeros with the specified difficulty.
  • Increment Nonce:
                If the block hash does not meet the difficulty, increment the nonce and repeat the calculation.

     
  • Block Validation:
  • Once a valid block hash is found (i.e., meets the required difficulty), create a new block:
  • Assign the calculated block hash to the hash field of the new block.
  • Create a new block object with the index, previous block hash, transactions, timestamp, nonce, and calculated hash.
     
  • Adding to Blockchain:
  • Add the newly created block to the blockchain by appending it to the list of blocks.

Next steps!

The above mentioned algorithm is just a conceptual explanation, the actually implementation of mining will begin from next week, stay tuned for more technical dive ins!

BlockDAG LogoBlockDAG Logo