1
00:00:01,110 --> 00:00:04,280
So, now let's talk about how
Bitcoin blocks get put together.

2
00:00:04,280 --> 00:00:06,100
So we've been talking
about the blockchain and

3
00:00:06,100 --> 00:00:08,850
the fact that transactions
are actually grouped by blocks.

4
00:00:08,850 --> 00:00:10,300
But everything in this lecture so far,

5
00:00:10,300 --> 00:00:13,520
we've been talking about just individual
transactions getting published.

6
00:00:15,100 --> 00:00:17,750
So why do we group transactions
together into blocks?

7
00:00:17,750 --> 00:00:19,860
Well, a couple reasons.

8
00:00:19,860 --> 00:00:22,600
One is that that creates a nice,
single unit of work for

9
00:00:22,600 --> 00:00:26,520
miners that's bigger that
the individual transaction size.

10
00:00:26,520 --> 00:00:29,790
So if the miners had to do work and
do hashing and add metadata for

11
00:00:29,790 --> 00:00:33,440
every transaction in the system,
that would provide too much overhead.

12
00:00:34,790 --> 00:00:37,630
It also makes the hash
chain of blocks shorter

13
00:00:38,750 --> 00:00:42,607
because we only need one block for
a large number of transactions.

14
00:00:42,607 --> 00:00:46,360
And that's going to make it easier for us
to verify the blockchain data structure.

15
00:00:46,360 --> 00:00:49,890
So what does the blockchain
data structure look like?

16
00:00:52,980 --> 00:00:57,750
It's a pretty clever combination of two
different hash-based data structures.

17
00:00:57,750 --> 00:01:02,048
So on the top here,
we have a hash chain of blocks.

18
00:01:02,048 --> 00:01:05,924
Each one has a block header and
then a pointer to some transaction data,

19
00:01:05,924 --> 00:01:09,620
as well as pointer to the previous
block in the sequence.

20
00:01:09,620 --> 00:01:11,170
And remember these are hash pointers.

21
00:01:12,830 --> 00:01:16,040
And then we have a tree of all of
the transactions that are included in

22
00:01:16,040 --> 00:01:16,990
each block.

23
00:01:16,990 --> 00:01:19,820
So this is a hash tree or
what's called a Merkle tree.

24
00:01:21,760 --> 00:01:25,770
Which commits to all of the transactions
in the block in quite an efficient way.

25
00:01:25,770 --> 00:01:31,050
So it's easy to provide just the path
through the tree which will be logarithmic

26
00:01:31,050 --> 00:01:34,810
in size to prove that that transaction
is included in a specific block.

27
00:01:36,850 --> 00:01:39,059
So that's the high level
idea behind the block.

28
00:01:40,090 --> 00:01:42,150
What does it look like in
practice at the low level?

29
00:01:42,150 --> 00:01:46,010
So we'll do another deep dive
into the actual data here.

30
00:01:47,410 --> 00:01:49,840
So this is what a Bitcoin
block looks like.

31
00:01:49,840 --> 00:01:53,270
There's what's called the block header
which has all of the metadata for

32
00:01:53,270 --> 00:01:53,870
that block.

33
00:01:55,200 --> 00:01:58,240
And then there's that Merkel
tree of transactions.

34
00:01:58,240 --> 00:02:01,180
So basically a long list of transactions.

35
00:02:01,180 --> 00:02:04,780
All of the hashes are arranged in
this tree structure, which gives you

36
00:02:04,780 --> 00:02:08,820
the ability to efficiently prove which
transactions are included in a block.

37
00:02:10,930 --> 00:02:17,000
The most important part, of course, is
the header, which mostly has information

38
00:02:17,000 --> 00:02:21,240
related to the mining puzzle, which was
talked about in the lecture on consensus.

39
00:02:21,240 --> 00:02:23,110
And we'll revisit in
the lecture on mining.

40
00:02:24,320 --> 00:02:28,360
But recall that the most important thing
here is that the hash of the block header

41
00:02:28,360 --> 00:02:31,400
has to start with a large number of
zeros for the block to be valid.

42
00:02:31,400 --> 00:02:35,190
And then there's some other
data to make that happen.

43
00:02:35,190 --> 00:02:36,970
There's a nonce that miners can change.

44
00:02:36,970 --> 00:02:38,680
There's a time stamp.

45
00:02:38,680 --> 00:02:43,310
There's an indication of how
difficult this block was to find.

46
00:02:43,310 --> 00:02:45,150
That's all stored in the header.

47
00:02:45,150 --> 00:02:48,560
And the important thing is that
the header is the only thing that's

48
00:02:48,560 --> 00:02:49,780
hashed during mining.

49
00:02:49,780 --> 00:02:54,850
So to verify that chain of blocks,
all you need to do is look at the headers.

50
00:02:54,850 --> 00:02:57,960
And the only transaction data
that's included in the header

51
00:02:57,960 --> 00:03:01,210
is that one route of the transaction tree.

52
00:03:01,210 --> 00:03:03,204
So that's this mrkl_root parameter.

53
00:03:07,604 --> 00:03:11,512
The other thing that's interesting about
blocks is that they have one special

54
00:03:11,512 --> 00:03:15,181
transaction in the Merkle tree which
is unlike all the other transactions

55
00:03:15,181 --> 00:03:16,260
we looked at before.

56
00:03:17,340 --> 00:03:19,490
And this is the coin-based transaction.

57
00:03:19,490 --> 00:03:22,499
So this is where the creation
of new coins in Bitcoin happens.

58
00:03:23,595 --> 00:03:27,182
It mostly looks like a normal
transaction with a few exceptions.

59
00:03:30,143 --> 00:03:34,436
So the value of this transaction is
going to be equal to currently a little

60
00:03:34,436 --> 00:03:36,150
over 25 Bitcoins.

61
00:03:36,150 --> 00:03:40,770
As we discussed, this is a flat mining
reward which is set by the system and

62
00:03:40,770 --> 00:03:43,230
which is halving every four years.

63
00:03:43,230 --> 00:03:46,510
In practice it will be a little
bit more than 25 Bitcoin,

64
00:03:46,510 --> 00:03:50,030
because it also gets to include
the transaction fees collected from

65
00:03:50,030 --> 00:03:52,390
every transaction included in the block.

66
00:03:52,390 --> 00:03:56,220
So the pointer to the output transaction
that this coinbase transaction is

67
00:03:56,220 --> 00:03:58,240
receiving is a null pointer.

68
00:03:58,240 --> 00:04:00,550
It's a hash of all zeroes.

69
00:04:00,550 --> 00:04:03,780
And this is an indication that since
this is the creation of new coins,

70
00:04:03,780 --> 00:04:05,530
there is no antecedent.

71
00:04:05,530 --> 00:04:08,860
There's no previous transaction that's
being consumed to create these coins.

72
00:04:08,860 --> 00:04:13,800
And there's also this special
coinbase parameter, and

73
00:04:13,800 --> 00:04:16,210
the coinbase parameter
is completely arbitrary.

74
00:04:16,210 --> 00:04:18,520
The miners can put whatever
they want in there.

75
00:04:18,520 --> 00:04:22,120
So, famously,
in the very block ever mined in Bitcoin,

76
00:04:22,120 --> 00:04:25,270
the coinbase parameter had
a quote from the newspaper.

77
00:04:25,270 --> 00:04:28,120
It had a quote from the Times of
London describing a story involving

78
00:04:28,120 --> 00:04:32,780
the chancellor bailing out banks,
which was both a political commentary on

79
00:04:32,780 --> 00:04:37,490
the motivation for starting Bitcoin, and
served as a commitment that Bitcoin,

80
00:04:37,490 --> 00:04:41,040
the first block was obviously mined
after this newspaper came out.

81
00:04:42,410 --> 00:04:43,000
But since then,

82
00:04:43,000 --> 00:04:46,570
miners are free to put whatever they
want in the coinbase parameter.

83
00:04:46,570 --> 00:04:50,130
It's been used as a place to put some
arbitrary data for different reasons.

84
00:04:50,130 --> 00:04:53,740
To signal support by miners for
new features, but

85
00:04:53,740 --> 00:04:56,870
there's no actual limits on
what miners can put in there.

86
00:04:57,940 --> 00:05:01,910
So with the block format and
the transaction format that we described

87
00:05:01,910 --> 00:05:06,020
earlier, the best way to learn
it is to just see for yourself.

88
00:05:06,020 --> 00:05:08,970
So there's a lot of websites
that make this data accessible.

89
00:05:08,970 --> 00:05:13,420
This is a screenshot from blockchain.info
which I found very helpful

90
00:05:13,420 --> 00:05:18,290
myself in understanding and exploring
what's going on at a low level in Bitcoin.

91
00:05:18,290 --> 00:05:21,490
There are a lot of other websites that do
a great job of making this information

92
00:05:21,490 --> 00:05:22,880
accessible.

93
00:05:22,880 --> 00:05:24,770
So you can look at
the graph of transactions,

94
00:05:24,770 --> 00:05:28,010
see which transactions redeem
which other transactions.

95
00:05:28,010 --> 00:05:30,820
Look for
transactions with complicated scripts,

96
00:05:30,820 --> 00:05:34,570
even look at the block structure and
see how blocks refer to other blocks.

97
00:05:34,570 --> 00:05:39,050
It's all available online, because again,
the Bitcoin is a public data structure, so

98
00:05:39,050 --> 00:05:41,560
a lot of different people
have put very pretty wrappers

99
00:05:41,560 --> 00:05:43,280
around this to explore it graphically.

