Showing posts with label decentralized. Show all posts
Showing posts with label decentralized. Show all posts

2015-12-01

P2Pool and low power miners

Recently, we got a new insight into 21 Inc's plans for its mining computer / chips - allowing the device to connect and mine on any pool, and ultimately - mining on a P2Pool-like network to further "redecentralize Bitcoin". This got me thinking about whether P2Pool would actually be compatible with a potential large swarms of low-power devices mining together. Lets see how it might work.

What is P2Pool?


P2Pool is an interesting idea that came about around 2011 to address the growing centralization of Bitcoin mining in mining pools. Instead of connecting to a centralized pool, a miner would instead join the P2Pool decentralized network and start mining there. The block reward would be split between peers based on how many "shares" they contributed to the decentralized network - essentially creating a decentralized "Pay Per Last N Shares" mining pool.

What is very interesting about P2Pool is that it allows for the decentralization of mining - anyone can join the network and contribute, you are free to mine for any valid block as long as you respect the mining reward distribution and all in all it once again allowed smaller miners to mine for Bitcoin blocks without relying (or giving power to) any centralized third party.

However, P2Pool is not without its disadvantages.

It is reportedly underperforming / being "unlucky", indicating that it might be experiencing a higher rate of orphaned blocks. This could be due to traditional mining pools optimizing their new block discovery time (I heard someone mentioning a dedicated communication network for the mining pools, but I can't find a source for that claim currently), while P2Pool might be reliant on the Bitcoin network itself, which can take a few extra seconds to populate.

P2Pool coinbase transactions are pretty big in comparison to the traditional mining pools' transactions. This means the blocks themselves can process a few fewer transactions, and there is a practical limit to how many outputs one can reasonably fit into a transaction to pay for the last N mining shares.

Mining at a traditional pool uses about 20MB per day, or 600MB per month. In comparison, P2Pool puts a much higher burden on the data transfers at about 38GB per month before we start taking the resources used up by BitcoinQT which you also have to run.

All in all, if you are mining on a computer with a good internet connection, a reasonably powerful set of miners attached and you don't mind earning a few percent less than you otherwise could, then P2Pool is not a bad choice.

However, what if you are dealing with mobile devices equipped with low-power mining chips?

21 Bitcoin Computer with P2Pool


Looking at the limitations of P2Pool and what 21 Inc is aiming to do with their mining computer, there are a few problems that stand out.

Currently, P2Pool pays its miners directly in the block coinbase, while 21 Inc prefers to buffer the balances at its shared wallet before letting you withdraw the mined dust to a wallet. If the 21 Bitcoin Computer was instead to be paid directly with the coinbase, you might quickly run out of block space. Looking at some sample P2Pool coinbases (1, 2), we can see about 200-250 outputs being included on average, taking up about 8kB of space. This roughly puts an upper cap of 32'000 outputs on a transaction before a whole block is filled with only the coinbase. Equally divided, every output would receive about 78125 satoshis, worth about 27 cents (at  current 356 USD/BTC exchange rate). This would represent about two days of mining for one of the 21 Bitcoin Computers.

32k computers mining a block every two days is fairly incompatible with 21 Inc's vision of "buffered pool mining" (quick way of mining coins to use for transaction) and putting a mining chip into every gadget.

Based on the amount of unique entities you want on the Bitcoin network, we can start extrapolating how often they could get paid on average. Sticking with the 32k outputs per block, we would have 4'608'000 daily outputs. If we looked at the sales of only iPhones in Q4 2015 (48.05M), we would require over 10 days worth of blocks to credit each of those devices individually. This is all before those transactions are again spent, before taking into account all the other smartphones, quarters and every other potential device one could think of in the Internet of Things world. All in all, Bitcoin couldn't handle this level of spam even if the blocks were increased.

Looking at the mobile data plans of a company like AT&T, 40GB/month would cost one about $300, or about $10 per day. The data price for P2Pool alone is 37 times more than the 21 Bitcoin Computer would earn. Mining at a pool would cost somewhere between $20-$30 worth of a data plan, making the data only twice more expensive than the bits one would earn before taking electricity costs into consideration.

Optimizing for your needs


All in all, it would appear that with mining, like with project management, you have three variables:

  • Centralization vs decentralization
  • Low vs high variance
  • Whether small devices can efficiently mine or not
But we can only pick two of them. Decentralized low variance mining but not good for small miners? That's P2Pool. Centralized low variance mining for any device? Centralized pools. Decentralized mining for any device but with high variance? Solo mining.


Possible solutions?


While with the current technology it might be rather impossible to achieve what 21 Inc is aiming to achieve in full, there are some ways one could compromise while still achieving some of the desired outcomes.

First of all, one could try creating an intermediate solution between a fully decentralized P2Pool and a completely centralized mining pool. Perhaps we could see a lot of new, smaller mining pools popping up based on carrier, manufacturer, geography, etc. that the devices could connect to and contribute the mining power to instead. This would allow the balances to be stored on shared wallets and used accordingly, perhaps aggregated into bigger payments or some off-chain settlement between those nodes (and oh god, we're coming back to the tired 2013-era block size debate and ways of settling without bloating the blockchain...).

We could focus on creating bigger mining devices that would power our mobile wallets. This device could stay at home and mine coins using the standard P2Pool protocol, rather than having a miner in every device. This would probably just get us back to the buy vs mine debate once more though. We could even do without all the physical mining and purchase some virtual mining contracts instead... Moreover, the situation is no different than what one can currently do with the existing mining hardware and since we don't seem to be doing that en masse suggest we wouldn't do it in the future either.

Lastly, we could just ignore the variance and mining profitability altogether and just starting to waste money for the benefit of the Bitcoin network. While this might sound crazy, it might not be that far-fetched of a plan. Chip manufacturers would probably make more money than the chips could ever mine, so they could just fork over some money to pay the mining rewards in a Pay-Per-Share scheme. Mining would still go to secure the network, perhaps in an inefficient way, and we might just end up with the entire Bitcoin mining ecosystem being generally unprofitable to mine in. Since the cost of mining would be distributed between potentially many millions of people, the individual burden might be small in comparison. However, this entire idea would best be suited to an entirely separate post I might do at some other time.

Conclusions


All in all, P2Pool currently is rather incompatible with low-power miners, especially if data bandwidth and profitability is an issue. If there is some way to solve the the underlying problems with how P2Pool operates to address those issues, I would love to hear more, but I doubt we'll see any concrete informations on the subject any time soon.

2015-06-28

Bitcoin vs Blockchain

In the recent months there has been a lot of buzz in the financial world about the "blockchain technology". It seems that everyone from Overstock to NASDAQ are getting into the game, but the Bitcoin name is uttered less and less often. The consensus is that the blockchain technology is interesting, but Bitcoin is not. On the flip side, the Bitcoin community appears to detest the notion countering that the blockchain cannot exist without Bitcoin. Lets analyse this topic and figure out what is going on...

What is a blockchain?


There appears to be some confusion among some people as to what the blockchain is. The technology bears some resemblance to a database and git in particular. The general consensus appears to be that a blockchain:
  • Is a database consisting of atomic transaction records
  • It is write-only (barring a 51% attack)
  • It is immutable (transactions cannot be changed, again barring a 51% attack)
  • Commits to the blockchain come in a form of a block
  • Commits have an unambiguous sequence (every block refers to a previous block)
  • The blockchain protocol enforces some rules as to how each transaction is handled (through a protocol and smart contracts)
  • The blockchain protocol has a way of resolving forks in the chain (for example, longest chain)
  • At any time, the blockchain is in a predictable, unambiguous state (given by the current block)
Beyond those, there is some disagreement as to whether or not some features are needed:
  • Does a blockchain need a native currency?
  • Do blocks need to be mined?
  • Is a blockchain controlled by a single entity still a blockchain, or just a database?
Lets explore some of the disagreements and possible misconceptions in greater detail.

"You can't have a blockchain without Bitcoin"


If we're talking in a literal sense, that statement is obviously false - there is nothing in Bitcoin that imbues its blockchain with some special properties unobtainable by say, Litecoin or Dogecoin. However, if we're talking in a more broad sense about blockchains without native coins that provide an incentive for the miners to be creating more blocks, things get a bit more complicated.

In a traditional blockchain like Bitcoin, the native currency is not only used to incentivise the miners, but also to prevent spam. It is quite an elegant solution - anyone wishing to send a payment won't mind spending less than a penny to get their transaction included in a block, but someone flooding the network with spam transactions will feel the burden of the fees compounding on them.

A blockchain without an internal currency loses both the incentive for the miners to create new blocks and prevent spam through the use of fees. While this would probably cripple any decentralized blockchain, it might not be the case with more centralized blockchains (we'll discuss them in detail later on).

The miners can be subsidized in other fashion, or even ran for free by the businesses that rely on the network. This is the case with Ripple's validators - most of them are run by Ripple Labs, since they have a strong stake to keep the network running, but one could imagine a more decentralized network with validators being run by the various gateways on the network. Since the validators earn money in some other way (running gateways, providing other services, etc.), it makes sense to keep the servers running.

If we're talking about blockchains without fees, Hyperledger and Eris come to mind. While those solutions don't appear to be suitable for decentralized networks, they make sense if we're talking about a finite number of known servers communicating with one another. In this scenario, similar to a private network, you don't expect spam or DOS attacks to be an issue - all the parties are known and they have no motivation to attack the network. Moreover, if the users of the network are known, they can be punished if they try to break the network - either by having their access revoked, or possibly by some legal actions being taken against them. 

So all in all, it looks like decentralized networks do need a token to run their blockchain, while more centralized solutions can get by without them through other means.

"Centralized blockchain is just a database"


While in the previous section we touched on the economics of running a centralized blockchain, here we will be discussing what is the point of running a centralized blockchain in the first place.

There are many reasons to connect to a decentralized blockchain like Bitcoin - you can transact with anyone in the world, nobody can ban you from the network and all your transactions are forever stored and distributed among many computers all around the world. However, there are also some needs that can't be achieved in a public ledger - protection of private data, instant transaction speed, dealing with only known parties, etc. All of those are features needed by some companies - perhaps they need to follow strict KYC rules on all clients, or they are dealing with sensitive financial information that need to be kept private. One way or the other - there are some valid reasons to run a private blockchain.

Given all that, what advantages and disadvantages are there to using a blockchain over a database?

There are certainly many disadvantages - since the blockchain is a new technology, it might not be as optimized as a database. If we're talking about a distributed network, there is also a lot of delay when the data is transmitted, not to mention the block creation time itself.

There are also some advantages to a blockchain over a database:
  • The entire status of the system can be summarized in a single hash (latest blockchain hash)
  • Every full node in the system is synchronized with the rest of the network and will reach consistency with it
  • Every transaction is authorized by a private key, meaning every action and actor can be held accountable
  • Every block can be similarly authorized by a known entity / private key, meaning that any "51% attacks" can be traced and punished externally
  • There is certainty for whether or not a transaction committed successfully to the blockchain and what is its outcome (especially if we're talking about more complex systems like Ripple or Ethereum)
While there might be little use for a blockchain technology if it's used by a single entity, it certainly bring up a lot of benefits if we're considering multiple parties using the blockchain technology to conduct business:
  • All transactions on the network can be legally binding as per agreement (especially if we're talking about making business decisions using smart contracts or tracking debt using a Ripple-like ledger)
  • There is no confusion as to the current state of the network - everyone will be on the same page once fully synchronized
  • Given the block creators are trusted entities (in a model similar to BitShares or Eris), or everyone using the network is also a block creator (in an ideal consensus mechanism), there is a strong disincentive to attack the network through a 51%-esque attack (block creators can be legally liable for doing such a thing)
  • Audits of the network are unambiguous, since all transactions are public (provided the auditor has access to the full blockchain)

Centralized versus decentralized blockchains


While centralized blockchains have their uses, there are certainly some advantages to using a decentralized blockchain (Bitcoin or otherwise).

First of all, anything that happens on a large, decentralized blockchain such as Bitcoin can be verified to have happened at the given time. Centralized blockchains can be re-written or forged if all the involved parties collude, while a decentralized blockchain is much harder to corrupt. This is why we see companies like Factom using the Bitcoin blockchain for timestamping - the record is public and provably immutable. Any private blockchain wishing to prove their records were not altered would similarly have to use the Bitcoin blockchain and embed the block hashes into it to prove the data was not altered later down the line.

Secondly, it may be much easier for multiple companies to agree to use a decentralized network as a middleware, rather than them agreeing to use a proprietary blockchain. This is especially true if we would be talking about companies dealing with entities they don't know or don't trust. Using a decentralized network allows you to tap into its network effect - you're not only connected to a few parties, but to potentially everyone in the world.

Conclusions


All in all, there are advantages and disadvantages to both using centralized and decentralized blockchains. Every one of them is a tool of its own, and some might be more suitable for problems than others. While the Bitcoin network certainly has a lot of value on its own, it's not a silver bullet solution to all problems and use cases. Blockchain without Bitcoin is certainly possible, but even in the world filled with centralized blockchains, Bitcoin has a place of its own.