Showing posts with label P2Pool. Show all posts
Showing posts with label P2Pool. Show all posts

Monday, December 7, 2015

Irrational Bitcoin mining

Irrational Bitcoin mining

Last week we discussed the economics of P2Pool mining with low-powered miners. One of the more interesting comments I came across while doing some research for the topic talked about the possibility of companies like 21 Inc creating a scenario where the Bitcoin mining becomes completely unprofitable for anyone that has to pay their electricity bills. Lets examine how this scenario might impact Bitcoin.

Creating irrational miners


In game theory, one generally assumes that every player in the scenario behaves rationally, that is to say - they are motivated by maximizing their own profits. In the Bitcoin mining world, every large-scale miner is rational - they care about their bottom line and profits. If it is profitable to mine, they mine, if not, they either switch to more efficient hardware (CPU->GPU->FPGA->ASIC->better ASICs), don't turn on their miners (minimizing losses), or outright buy bitcoins from the market (if they aim to accumulate bitcoins).

Since the Bitcoin difficulty is self-correcting, eventually the market weeds out the most inefficient miners until mining becomes profitable again. All in all, it's a strange mix between the tragedy of commons and an arms race that makes Bitcoin more and more resilient to attacks (a potential attacker would have to incest more money into the attack than everyone else combined).

However, earning money from mining is only one motivator a potential miner might have. Just like Google indirectly benefits from laying down Google Fiber that gets more people onto the Internet where Google can monetize them with ads, Bitcoin companies might devote some of their resources to mining even at a loss. For example, SatoshiDice might want to have its own mining pool to push through all of its pending transactions that some other pools might consider to be spam. Big exchanges would similarly want to make sure all of their deposits and withdrawals are processed faster than its competitors, etc. Lastly, companies might want to mine just to make sure the Bitcoin network is more decentralized.

And now, with companies like 21 Inc pushing for inclusion of their mining chips into various devices, we might see an emergence of essentially botnets of low-powered miners contributing their hashing power to their creators.

Botnet mining


Botnet mining bitcoins isn't really all that new. We had some mining viruses bundled with torrents, esports server code, or even embedded in websites through WebGL. However, since nowadays mining with anything short of a dedicated ASIC chip is worth less than the coding time required to run it. However, if we start embedding small ASIC chips into devices, things might get more interesting...

It would be possible for hardware manufacturers to include physical bundleware / crapware into their products similar to how phones nowadays come with pre-installed bloatware. Like 21 Inc's investor slides suggest, those mining chips would probably come with pre-defined address they will be always mining a portion of their income to, creating a revenue stream for the chip or phone manufacturers, or perhaps network operators or the like. I would also suspect that for some amount of time most of those chips would be locked in to a specific pool (similar to carrier-locking), which means most of the value of the chip will probably be extracted in a controlled fashion.

All in all, what would this boil down to? Most likely, the people that purchase the device with a bundled miner that would mine for a specified pool say, when the device is plugged in or charged. Maybe if we're lucky, those devices would mine on something like P2Pool, but that has its own problems. The customers might not notice their devices eat up a few extra dollars of electricity and could break down faster after the warranty is over. They would get some dust balances to use in the Internet of Things, but that wouldn't matter much in comparison to some other implications.

The Bitcoin difficulty could be pushed up over time, accelerating its already fast growth. Traditional for-profit miners would have harder and harder time competing in the market against the botnet. If the miners would really be pushed into every device, they would probably be unable to compete shy of plugging new chips in straight from the factory for mining before consumer electronics devices would go through the process of production-shipping-sale-mining. ASIC manufacturers would probably start offering their own mining chips and compete to build their own botnets of devices with bundled miners. Perhaps there would be some market for second-hand mining chips - the manufacturers would first mine with a fresh batch of chips to get in on the lower initial difficulty (possibly under the pretext of "stress testing"), then when it becomes unprofitable, the chips would be sold to consumers, a bit like what Butterfly Labs was doing, only on a bigger scale.

At that point, we would probably see traditional Bitcoin mining pools be replaced with pools owned by chip / hardware manufacturers or network operators. While the talk of "redecentralizing Bitcoin" is all well and good, when push comes to shove I doubt final consumers would be mining through P2Pool if the profits could instead be directed through some big corporation's pocket. Providing the cost of running such a pool would be small, you could still squeeze in a bit of money out of your consumers by making them pay for the electricity used in mining.

Getting your bitcoins for cheap / free might be undesirable, if you subscribe to the labour theory of value (a good is worth about as much as it costs to produce it). While a mining pool today might be more careful with its hard earned coins - selling them for as much as possible, waiting to sell if the price dips, etc. - a botnet mining pool might not care as much. They might also not care as much about various Bitcoin issues - they might not vote on various BIPs, not care if their software provider creates a pool that censors some transactions, create empty blocks, be easier to sell their mining power to "double-spend-as-a-service" pools, etc. If the mining is forced onto the users, they can't vote with their feet unless they are willing to unplug their electronics completely.

Conclusions


While the current state of largely centralized mining pools might be a potential Sword of Damocles hanging over the Bitcoin network, they have a strong incentive not to attack the network:

If a greedy attacker is able to assemble more CPU power than all the honest nodes, he would have to choose between using it to defraud people by stealing back his payments, or using it to generate new coins. He ought to find it more profitable to play by the rules, such rules that favour him with more new coins than everyone else combined, than to undermine the system and the validity of his own wealth.

Giving the mining power to everyone through a P2Pool-like solution might be seen as similar to low information voters - a lot of them would not know what to do.

If embedded mining chips become more widespread, we could see them disrupting the current mining status-quo, but I ultimately doubt the new mining pools would be much more decentralized than the current ones. They would also have less incentives to care about the Bitcoin network - it's not their main business.

Only time will tell how this will play out.

Tuesday, December 1, 2015

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.