When does a miner decide to stop collecting transactions and start calculating hashes to try to win?


I am confused about whether a miner chooses to wait for more transactions (more fees) or starts as soon as it receives the first transaction from the network. Once a miner has started calculating the hashes, it will queue the new transactions, correct?

Yes, they can begin mining as soon as they see the previous, and update the block template with new transactions they see whenever they would like. The early Satoshi client updated the template every few seconds, modern miners seem to do it every half a minute or longer depending on the software. There's no advantage for them to update the block template other than that they might get more fees if they do, if they miss transactions there's no real harm done.

If I am lucky to find the solution for a block with just one transaction, but someone else finds the solution for a block with my transaction and one more, so he wins, correct?

No, this isn't correct, no miners break ties with the number of transactions in...

0 0

They were never "waiting" in the first place.

A miner is incrementing nonces and computing hashes continuously. As soon as a new transaction a2 arrives, it is added to the Merkle tree, the block header is regenerated, and hashing continues with the new block header.

It's misleading to call this a "restart", since that implies there was some progress that is being lost. Mining is progress-free. Each hash is an independent trial with equal probability to succeed, regardless of what the underlying block header is.

To emphasize this, suppose you have a block header h1 on which you have already tried a billion nonce values, and a header h2 which has just been generated and on which no nonces have been tried yet. If you have the choice as to which one to hash next, which should you choose, for the greatest chance of finding a winning nonce? The answer is, it makes no difference - they both have exactly the same probability. So there is no harm in switching to...

0 0

I have been trying to understand the protocol and reading related documents, there is a point where i get stuck.

As far as i understand (correct me if not), when a transaction occurs, it is broadcast to the network and some miners receive it. When a certain number of transactions is reached, they are packed in a block and hash race begins.

What i fail to understand is; in this scheme, don't all the miners have to be in perfect memory coherence and time sync, so that they know when a block is to be sealed and start to iterate for hashes? Or do they not need to mine and hash the same global block, but have separate blocks which are later validated by other miners and interblock transaction collisions don't matter?

I know i misunderstand a very basic point in the protocol, but i can't figure...

0 0

A stale block (often mistakenly referred to as 'orphan block') occurs when two competing blocks were found and then another block builds on top of one of them.

See the following minimal example: B1 and B2 were discovered at the same time and then the discovery of C clarifies that B2 is part of the chain with the most difficulty ("longest chain"). At this point B1 becomes obsolete, as it is not part of the best chain.

B1 A -> B2 -> C

So, a miner would have received A, then started to work on finding a successor to that. When B1 and B2 appeared, he would have received one of them first and started building on top of it, ignoring the other as not part of it's best chain. When C appeared, the miners that were trying to build on top of B1 reorganize to B2 -> C and start building on C.

At no point would you process a stale block because once it is clear that the block is stale, it must already be part of an alternative chaintip that is not the longest...

0 0

Essentially, everyone is already proceeding randomly, and there is no common search space.

When miners are trying to find a block, everyone works on a different set of candidates: The block reward is paid out through the coinbase transaction. The coinbase transaction's output is specific to the miner because it includes the miner's address as recipient. The coinbase is part of the transaction set that is used to derive the Merkle root. The Merkle root is included in the blockheader. Ergo every mining entity works on different block candidates.

SHA-256 is a cryptographic hash function. One of their properties is that any change in the inputs will cause a completely different output. There is no predictable relation between the change in the input and the change in the output. Therefore, you cannot predict where you will find a block – any new candidate whatsoever could be a valid block. This means that there is no progress towards finding a block, there is no stack of...

0 0

Here is an extremely simplified sketch of the problem, but it should give a pretty good idea of what the problem is.

The data:

This is the hash of the lastest block (shortened to 30 characters):


These are the hashes of a few valid transactions waiting for inclusion (shortened).

5572eca4dd4 db7d0c0b845

And this the hash of one special transaction that you just crafted, which gives 25BTC (the current reward) to yourself:


Building the next block:

Now, let's use a gross approximation of what a new block might look like (the real one uses binary format). It contains the hash of the previous block and the hashes of those 3 transactions:


Now let's do mining by hand! Our goal is to complete this block with a nonce (a piece of garbage) such that the hash of the new block starts with 13 zeros (considering the previous hash, it seems...

0 0

Why miners try to produce big blocks?

Because transactions pay fees. The more transactions they include, the more fees can be collected. They prioritize transactions with higher feerate to maximize this.

What if, does a miner deliberately produce a block with a single transaction without considering the whole unconfirmed transactions, in order to gain the reduce of network latency advantage or some other purpose?

Some do that (though mostly because they just received a new block, and haven't had the time to construct a valid set of transactions on top).

In recent times, the argument for faster propagation also does not apply very much anymore. Techniques like Compact Blocks (BIP152), the Relay Network, and FIBRE can efficiently transmit blocks as long as they mostly consist of transactions that were seen before. This almost entirely removes the effect of size from the...

0 0

You can get realtime transaction fees calculated for you at bitcoinfees.21.co. If you are interested in how those numbers are calculated, read below.

First, when we quote a "Bitcoin transaction fee", we will usually quote one of two numbers:

Consumers care about the total fee. This is the total fee that you're paying in a transaction, such as 10,000 satoshis or 0.0001 bitcoins. This is probably the most important number for consumers as they only care about the fees associated with their particular transaction. Miners care about the fee per byte (or kilobyte). This is the total fee divided by the number of bytes in a transaction, such as 40 satoshis/byte or 0.0004 bitcoins/kilobyte. This is the most important measurement for miners. The reason is that they use this to decide whether to include your transaction in the blocks they attempt to produce, as they can only include about 1 million bytes of transactions in their blocks. As such, they prefer to include...
0 0

This week, we’ve invited Ofir Beigel to guest blog for us. We’ll let him take it from here.

Recently, scaling bitcoin has been a hot topic for the bitcoin community. Why is this? Well, as bitcoin grows and more users hop onboard, a big priority is to ensure the network can efficiently handle the increasing transaction volume. And lately, many users have been expressing their worries over transaction delays caused by network congestion. In this post I’m going to talk a bit about how transaction confirmations work, and the role that fees play in the process.

Miners, bounties, and newly-generated bitcoins

In order to understand transaction confirmations, we’ll need to cover some key concepts of bitcoin mining. I won’t attempt to explain the whole process of bitcoin mining in this post, but I’ll try to simplify the process with this short explanation. Every day hundreds of thousands of transactions are sent and received on the bitcoin network. These transactions need to...

0 0

Now, first of all. I'm not stupid. I know it's not clever to mine with VPS for various reasons. One of em being that most VPS doesn't have GPU's or dedicated CPU for you, and why I decided to post this little guide where to get cheap/free Virtual Private Server was because there's been questions about where to get one in the MinerGate chat lately.

But as long as it's cheap or free, why not build an army of Virtual Private Servers for CPU mining? So I'm listing here some of the services I'm using currently for CPU mining, some of these require CC for validation, some of these doesn't. If you don't have an CC, you can use prepaid Visa CC for most of em. Some even accept Visa Electron's if you're using "Verified by Visa" service on it. I don't know if every bank has this service or not.

Microsoft Azure: (Requires CC / Visa Electron was fine.)
BCN hashrate: ~600 H/s [Using MinerGate GUI for Windows and selected that 16 core A11 CPU...

0 0

If you’re reading this post I assume that like many others, you sent a bitcoin transaction and was kind of confused as to why it’s still listed as “unconfirmed” or “pending” after a few hours or so.

I mean Bitcoin transactions are supposed to be instant right?

In this post I want to try and explain in a very basic way how a Bitcoin transaction works and why the fee that you attach to each transaction has a crucial role in how long it will take the transaction to go through the network.

Here’s what happens when you send Bitcoins to someone

Whenever you send someone Bitcoins, the transaction goes through different computers running the Bitcoin protocol around the world that make sure the transaction is valid. Once the transaction is verified it then “waits” inside the Mempool (i.e. in some sort of a “limbo” state).

It’s basically waiting to be picked up by a Bitcoin miner and entered into a block of transaction on the Blockchain. Until it is picked...

0 0

Last updated: 26th November 2013

There are three main categories of bitcoin mining hardware, each more expensive and more powerful than the last. This guide to setting up a bitcoin miner explains each of them, and talks about how to make them work.

By this stage, you will understand how bitcoin works, and what mining means. But we need to get from theory to practice. How can you set up a bitcoin mining hardware and start generating some digital cash? The first thing you're going to need to do is decide on your hardware, and there are two main things to think about when choosing it:

Hash rate

This is the number of calculations that your hardware can perform every second as it tries to crack the mathematical problem we described in our mining section. Hash rates are measured in megahashes, gigahashes, and terahashes per second (MH/sec, GH/sec, and TH/sec. The higher your hash rate (compared to the current average hash rate), the more likely you...

0 0

This article explains Bitcoin mining in details, right down to the hex data and network traffic. If you've ever wondered what really happens in Bitcoin mining, you've come to the right place. My previous article,

Bitcoins the hard way

described how I manually created a Bitcoin transaction and sent it into the system. In this article, I show what happens next: how a transaction gets mined into a block.

The purpose of mining

Bitcoin mining is often thought of as the way to create new bitcoins. But that's really just a secondary purpose. The primary importance of mining is to ensure that all participants have a consistent view of the Bitcoin data. Because Bitcoin is a distributed peer-to-peer system, there is no central database that keeps track of who owns bitcoins. Instead, the log of all transactions is distributed across the network.

The main problem with a distributed transaction log is how to avoid inconsistencies that could allow someone to spend...

0 0
0 0

I think I’ve come up with a way to cheat a little at Bitcoin mining.

Bitcoin “mining” is the process in which new transactions are officially entered into the running ledger. Every 10 minutes, the current outstanding transactions are combined together in a “block”, then a "miner" calculates the SHA256 hash for the block.

The wrinkle here is that Bitcoin is decentralized, so no one person is responsible for calculating the hash. Miners must compete to create a hash. Therefore, the hash must have certain properties, namely, the first 64 bits of the hash must be zero (the current difficulty level is 63.8 bits, it changes over time to accommodate more mining power). A little bit of random data is added to the block before hashing, and the miner keeps changing that random data until the resulting hash has the proper number of leading zeros. Currently, that requires 18 quintillion calculations, or 18 billion billion, or 18,446,744,073,709,551,616 – or in technical terms, a...

0 0

Is it finding a key by brute force method for the newly generated hash of the newly generated block?

This is the first part of the problem.

Previous block hash + Version + Transactions (merkle root) + Time + Difficulty + Nonce = New block hash

With all of this information being static, only by changing the nonce (and sometimes transaction order, called extranonce) can you attempt to generate different block hashes.

The tricky part you're missing is the difficulty of the block hash, which is adjusted roughly every 14 days.

New block hash = SHA256 hash *Valid* block hash = SHA256 hash which is preceded by X number of zeros. (Simplified)


Block #450,827 is 0000000000000000023deabe6c71b7b15eff0a13a2e9871ee8796549d3693efb Block #150,000 is 0000000000000112f644be7e7ee3bb716017d729327bd196139a92446fb71f21 Block # 50,000 is 000000001aeae195809d120b5d66a39c83eb48792e068f8ea1fea19d84a4278a

You can easily see the difference in difficulty in generating...

0 0

Why does Bitcoin have “Miners?”

Gold has miners because people want gold and it just so happens, unfortunately, that most gold is deep in the earth. Bitcoin has miners because people want bitcoins, but something here seems silly: how did a bunch of bitcoins, the tokens of a man made invention, end up locked up in circumstances demanding mining? What’s the point of that?

Not the Best Name

The truth is, bitcoin “mining” is a misnomer. When gold is mined, nothing is achieved beyond the discovery of new gold. When bitcoins are mined, however, a valuable service is provided to the Bitcoin network: decentralized transaction recordation and validation.

Double Spending

Bitcoin relies on miners to record and validate transactions because of a particular problem inherent in any system of digital currency: double spending. Double spending is the high-tech incarnation of counterfeiting. Say, for example, that a currency user, Alice, has a $5 note and she...

0 0

The Powerball lottery jackpot has hit a whopping $400 million, and the question on everyone's mind is "At what point should I actually start caring about the Powerball Lottery"?

Answering this question is not so simple, because in addition to calculating the odds of winning a potential jackpot, you also have to figure out the odds that you will have to split the potential jackpot. And the odds of a split change all the time, because the bigger the jackpot, the more people buy tickets. So we've decided to really drill down into the math to combine all the factors, including jackpot size, and the odds you will have to split the pot if you do win.

Powerball is interesting in the sense that there are a number of stagnant cash prizes that you can win, as well as an ever-increasing jackpot.

The expected value of spending $2 on a Powerball ticket is actually -$1.58 when you ignore the jackpot. That's right, the expected value of playing when you...

0 0

In Part 1 we took a look at the incentives involved in Bitcoin mining and how they are used guarantee a single transaction history needed to prevent bitcoins from being double spent. In this post we will take more a technical look at the cryptography involved and how it is used to secure the network. As I said previously, Bitcoin is very accessible. While we will be discussing cryptographic concepts, it shouldn’t discourage you from continuing further.

Cryptographic Hash Functions

Before moving forward we should take a moment to learn about hash functions since they are used all throughout the Bitcoin protocol. To put it simply, a hash function is just a mathematical algorithm that takes an input and turns it into an output. For example, suppose we have an algorithm which just adds all the digits in the input string together. If our input is 1234 we would get an output of 10.

1234 ==> 10

Simple enough. However, there are certain properties of really good hash...

0 0

A few days ago I was sending my friend a payment of 1.2 BTC. My account had only slightly more than this amount available, not even enough for recommended transaction fee. Instead of borrowing or waiting for a miner to generate more, I decided I would push a transaction with a much smaller fee to the network and hope it gets confirmed in under a day. It did not happen. According to Bitcoin wiki, a transaction needs to pay the recommended fee unless all outputs are more than 0.1 BTC and few other conditions. I did not meet this condition, because I had one 1.2 BTC output and one change which was smaller than transaction fee. It was stuck there for more than a day, my mining pool paid me, so I decided I want to just cancel this transaction and create a new one with a proper fee. Easier said than done :).

I use Electrum as a client - it is much better than stock Bitcoin client and there’s a nice console. I was able to extract the transaction and try to modify it to include the...

0 0