Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reward miners #9

Open
robinmonjo opened this issue Oct 8, 2017 · 0 comments
Open

Reward miners #9

robinmonjo opened this issue Oct 8, 2017 · 0 comments

Comments

@robinmonjo
Copy link
Owner

robinmonjo commented Oct 8, 2017

How does it works in Bitcoin

In the Bitcoin blockchain, a block is mined every ~10 minutes. This block can contains from 0 to N transactions. The only limit is that at the end, the block is no more than 1Mb. What's interesting here is that even if there is no transaction a block will still be mined and a "coinbase" transaction (a transaction that generates bitcoin) get generated every ~10 minutes.

Miners also collect transactions fees, and that's a way for people to ensure their transactions will be incorporated into the blockchain quickly if they set a high transaction fee

What's going on with coincoin ?

Currently coincoin has a really naive approach to mining:

  1. A transaction comes in
  2. Miner compete to mine the block
  3. First miner to come up with the proof-of-work add the block to the chain

Miners do not have any rewards and the only way to inject tokens into the blockchain is to use the Token.free_tokens/1 API.

How to reward miners in coincoin ?

For simplicity reasons, I will ignore transaction fees:

  • miners always spend their time mining the next block even if no transactions are in their pool
  • when they start mining a new block:
    1. they generate a new coinbase transaction for themselves
    2. compute the merkle root of all the transactions in their pool (+ the coinbase transaction)
    3. start to compute the nonce

Implications

  • a block no longer contains only one transaction, and will contains 1 coinbase transaction + 0 or N transactions
  • a block contains a merkle_root field which is used to compute the block hash
  • The Token.Ledger module must change to loop over transactions (no more one transaction per block)
  • coinbase transactions must be validated (amount ...)
  • difficulty must be a full part of the protocol and not just a config. Ideally, coincoin will be configured with an average time to mine a block and a block mining reward amount, and miners will re-adapt the difficulty based on this and the time it took to mine X blocks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant