10.02.2016 Views

Bitcoin and Cryptocurrency Technologies

1Qqc4BN

1Qqc4BN

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Of course this assumes that every node implements this logic where they keep whatever they hear<br />

first. But there’s no central authority enforcing this, <strong>and</strong> nodes are free to implement any other logic<br />

they want for choosing which transactions to keep <strong>and</strong> whether or not to forward a transaction. We’ll<br />

look more closely at miner incentives in Chapter 5.<br />

Sidebar: Zero-confirmation transactions <strong>and</strong> replace-by-fee.​In Chapter 2 we looked at<br />

zero-confirmation transactions, where the recipient accepts the transaction as soon as it is<br />

broadcast on the network. This isn’t designed to be secure against double spends. But as we saw,<br />

the default behavior for miners in the case of conflicting transactions is to include the transaction<br />

they received first, <strong>and</strong> this makes double-spending against zero-confirmation transactions<br />

moderately hard. As a result, <strong>and</strong> due to their convenience, zero-confirmation transactions have<br />

become common.<br />

Since 2013, there has been interest in changing the default policy to ​replace-by-fee​(RBF) whereby<br />

nodes will replace a pending transaction in their pool if they hear a conflicting transaction which<br />

includes a higher fee. This is the rational behavior for miners, at least in a short-term sense, as it<br />

gives them a better fee. However, replace-by-fee would make double-spending against<br />

zero-confirmation attacks far easier in practice.<br />

Replace-by-fee has therefore attracted controversy, both in terms of the technical question of<br />

whether it is possible to prevent or deter double-spending in an RBF world, <strong>and</strong> the philosophical<br />

question of whether <strong>Bitcoin</strong> should try to support zero-confirmation as best it can, or ab<strong>and</strong>on it.<br />

We won’t dive into the long-running controversy here, but <strong>Bitcoin</strong> has recently adopted “opt-in”<br />

RBF whereby transactions can mark themselves (using the sequence-number field) as eligible for<br />

replacement by higher-fee transactions.<br />

So far we’ve been mostly discussing propagation of transactions. The logic for announcing new blocks,<br />

whenever miners find a new block, is almost exactly the same as propagating a new transaction <strong>and</strong> it<br />

is all subject to the same race conditions. If two valid blocks are mined at the same time, only one of<br />

these can be included in the long term consensus chain. Ultimately, which of these blocks will be<br />

included will depend on which blocks the other nodes build on top of, <strong>and</strong> the one that does not get<br />

into the consensus chain will be orphaned.<br />

Validating a block is more complex than validating transactions. In addition to validating the header<br />

<strong>and</strong> making sure that the hash value is in the acceptable range, nodes must validate every transaction<br />

included in the block. Finally, a node will forward a block only if it builds on the longest branch, based<br />

on its perspective of what the block chain (which is really a tree of blocks) looks like. This avoids forks<br />

building up. But just like with transactions, nodes can implement different logic if they want — they<br />

may relay blocks that aren’t valid or blocks that build off of an earlier point in the block chain. This<br />

would build a fork, but that’s okay. The protocol is designed to withst<strong>and</strong> that.<br />

92

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!