Now we're gonna talk about mining pools. So what is a mining pool? Well, let's look at the economics of being a small miner. So say, you're an individual who spent $6,000 of your hard-earned money to buy a nice, shiny, new Bitcoin mining rig. Now, you expect that you'll find a block in about 14 months with this fancy new rig. And remember that a block is worth about $15,000 at today's prices. So if you advertise that, you could say that the expected revenue of this box is about $1,000 per month. And now maybe, once you factor in electricity and your other costs of operating it, if you actually got a check in the mail every month for $1,000, that would make it worth it for you to buy this $6,000 mining rig. But remember that mining is a random process. You don't know when you're gonna find the next block. It's a completely random search, and you could find your next block at any time. So, if we look at the distribution of how many blocks you're likely to find in the first year with that hypothetical 1 terahertz box, the variance is pretty high because the expected number of blocks you're gonna find is so low. So if we just look at the distribution and this is a Poisson distribution, there's over a 40% chance that you won't find any blocks in the first year. In which case you might really be in trouble if you haven't earned any revenue in an entire year of running that $6,000 box that costs a lot of electricity to run. There's about a 36% chance that you'll find one block in the first year, in which case maybe you're barely scraping by. And then there's a slightly smaller chance that you'll find two or more blocks, in which case you'll really be making a profit with this thing. So again, on expectation, you might be just doing okay enough to make a return on your money. But there's a big chance that you'll make nothing at all. So that means that for a small miner, mining is essentially a big game of roulette. Now historically, when small business people faced a lot of risk and they wanted to lower the risk, they got together and formed mutual insurance companies. So farmers would get together and agree that if any individual farmer's barn burned down, they would share profits with that farmer so that farmer wouldn't go bankrupt. And the question is, can we have a mutual insurance model that works for small Bitcoin miners? So that's what a mining pool is. Now the goal of a mining pool is that a group of miners will get together, form a pool. And they'll all attempt to mine a block, which pays that coinbase, the newly minted coins to the same recipient. That recipient is going to be called the pool manager. So no matter who actually finds the block, the pool manager will control the rewards. And then the pool manager will take that revenue and distribute it to all of the participants in the pool based on how much work each participant actually output. Of course, the pool manager will also probably take some kind of cut for their service of managing the pool. So this sounds like a great idea. You can see why it would be attractive to Bitcoin miners to join a pool to lower their variance. But how does the pool manager know how much work each of the members of the pool is actually performing? Obviously, the pool manager doesn't wanna just take everybody's word for it, because everybody would say that they're performing more work than they actually did. So there's a really powerful idea which is that miners can prove probabilistically how much work they're doing by outputting shares. And shares are blocks that are almost valid. So whereas it's pretty rare to find an actually valid block that starts with all 66 required zeros at the beginning of the output hash. There will be a lot more almost blocks that start with a lot of zeros but not quite the 66 necessary to make it a valid block. So a common choice might be, say, 40 bits or maybe 50 bits depending on what size the pool is designed for. Now if miners participating in the pool send in a bunch of these near-valid blocks, the rate at which you're finding those near-valid blocks should give the pool manager a very good statistical idea of who's doing how much work. And the other nice property of this is that there's no way to fake it. Because of the properties of the hash function, there's no way to find almost blocks without also finding actual blocks at the expected rate. So how does this whole setup look? So to start with in each round after the previous block is discovered, the pool manager which will be collecting transactions and assembling a block, will tell all of the participants, here's the next block that we're all gonna work on. So, [COUGH] they'll assemble the block cutter. They'll assemble a Merkle tree of transactions to be included in that block. And in particular, they'll make sure to put into that Merkle root of transactions, the coinbase transaction which creates new coins and assigns ownership to the pool itself. And now this block header will be sent to all of the participants in the pool, and this is what they're asked to work on. And they have to prove that they've been working on it by sending in shares showing that they've been hashing this block. Now once that gets sent out, all of the miners go about and do their work. And they'll all slowly find almost valid blocks or shares, until finally one of the miners hopefully in the pool finds a valid block that will then be published. Now after this happens, all of the participants will send in all of the shares that they found to the pool manager, which should be pretty efficient for the pool manager to verify our valid shares that they found. And then the pool manager will take all of the revenue earned from that block that was published and distribute it back to the participants based on how much work they actually did. Now notice that this miner all the way on the right here who did happen to find the block actually receives less revenue than that miner on the left there who didn't find the ultimately valid block. But they did find more shares. So there's no bonus for this miner on the right here that they actually found a valid share. They would have been better off if they just mined as an individual because they would have gotten to keep all of the revenue from that block. But of course, for the miner on the left, they're sure going to be glad that they joined this pool because they would have gotten nothing if they had just mined on their own cuz they happened to not find a valid block. So there are a bunch of variations on this model of exactly how you determine based on shares submitted, how much money each miner should get in mining rewards. So a couple of common ones, there's the pay-per-share model where the pool manager just announces, I'll pay a flat fee for every share above a certain difficulty that you're willing to send me based on this block. In some ways that's the best for miners, because that's a guarantee. Every time they find a share, they'll get a certain amount of money. The pool manager is essentially absorbing all of the risk in that scheme. Of course as a result, usually with pay-per-share you pay the highest transaction fee to the pool manager. Another way to do it is a proportional model, where instead of paying a flat fee per share, the amount per share depends on whether or not the pool actually found a valid block. So every time a valid block is found, the rewards from that block are distributed to the members proportional to how much work they actually did. So in this case, the miners still bear some risk, proportional to the risk of the pool in general. So if the pool is large enough, the variance of how often the pool finds blocks will be fairly low. Proportional can still be a good approach. And it will provide lower risk for the pool manager. And it gets around a problem that's inherent to pay per share, which is that with pay per share, the miners actually don't have any motivation to send in valid blocks. They don't have any motivation not to, but miners have the option when they find a valid block of just keeping it a secret. Now they're hurting the pool by doing that, so this is purely an act of vandalism. But they have no real motivation since they get a flat reward per share to actually send in the valid blocks. Whereas with a proportional scheme, the miners certainly want to send in the valid blocks cuz that triggers revenue coming back to them. And a final variation that I think is interesting and was popular for a while, is that the pool owner actually collects no fee, but miners can't receive any revenue out until their balance is over one Bitcoin. So basically this means that new entrants to the pool don't make any money for a while. And then they make money at an even rate without paying any fee to the mining pool manager. So essentially once you're established in a pool with this approach, it's a great place to be, but they're harder to break into. So this has become pretty advanced now. There are quite a few protocols to run mining pools. And it's even been suggested that these mining pool protocols should be standardized as part of Bitcoin itself. So just like there's a Bitcoin protocol for running the peer-to-peer network, these protocols are an API for communicating from the pool manager to all of the members. When to work on a new block, what that block should be, and for the miners to send back to the pool manager the shares that they're finding. Another reason why this is so important is that some mining hardware actually supports these protocols at the hardware level. Now this makes it very simple to buy a piece of mining hardware, plug it into the wall, both the electricity and your network connection. Choose a pool, and then it will start immediately getting instructions from the pool, mining and converting your electricity hopefully into money. So mining pools first started around 2010, actually way back in the graphics card era of Bitcoin mining, which is several generations ago. And they were instantly very popular for obvious reasons cuz they lowered the variance for the participating miners. So by 2014, the vast majority of all miners are mining through pools. Very few miners mine on their own anymore. And a very interesting thing happened in June of this year, where the largest pool called GHash.io got so big it actually had over 50% of the entire capacity of the Bitcoin network. Now this is something that people had feared for a long time, but essentially GHash offered such a good deal to all the participating miners that everybody wanted to join. Now since then GHash has gone down a little bit, partly by design. They've made their fees a little bit less attractive to try to get smaller. But you can see in this pie chart of the largest mining pools, they still have about a third of the power. And it's basically only two mining pools today that control about half of the power in the network. And then there's a nice smattering of other pools thrown in there. So, are mining pools a good thing? Well, the advantages of mining pools are that they make mining more predictable for the participants. And they make it much easier for smaller miners to get involved in the game. Whereas the variance would simply make mining infeasible for economic reasons if you didn't have mining pools, you can operate a much smaller mining rig profitably if you're part of a pool. Another advantage of mining pools is that since there's one essential pool manager who's sitting on the network and assembling blocks. It actually makes it easier to upgrade the network, because by upgrading the software that the mining pool manager is running, that effectively updates the software that all of the pool members are running. The disadvantages of the mining pools of course, is that this leads to centralization. It's an open question how much power the operators of a large mining pool actually have. Of course, miners are fairly free in theory to move between pools as much as they like. If you're making profit on one pool, you'll likely make very similar profit in another pool because the fees that they pay out have converged. They all offer about the same deal today. But in practice, miners don't switch very often simply because they're lazy, and it's easier to keep using the pool that they've already signed up for. Another disadvantage of mining pools is that it lowers the population of people actually running a fully validated Bitcoin node. So previously, small miners all had to run their own fully validating node. They all had to store the entire block chain and validate every transaction. Now, most miners offload that task to their pool manager. And this is one reason why, a couple of lectures ago, I said the number of fully validating nodes may actually be going down in the Bitcoin network. So if you're concerned about this level of centralization, you might ask, could we redesign the mining process so that we don't have any pools, so that everybody has to mine for themselves? And once again, that's gonna be a very interesting topic that we'll talk about in our lecture on alternative mining approaches.