WEBVTT - Automatic transcript; recognition may contain errors. Reviewed for technical wording and speaker labels. Times match the published episode.

00:00:19.700 --> 00:00:22.060
<v Aaron van Wirdum>Live from Utrecht, this is Bitcoin.

00:00:22.800 --> 00:00:23.280
<v Sjors Provoost>Explained.

00:00:23.520 --> 00:00:25.080
<v Aaron van Wirdum>There you go, Sjors. How are you?

00:00:25.420 --> 00:00:25.760
<v Sjors Provoost>Excellent.

00:00:26.640 --> 00:00:29.040
<v Aaron van Wirdum>Back in good old Utrecht, we were both in London.

00:00:29.280 --> 00:00:29.740
<v Sjors Provoost>That's right.

00:00:29.940 --> 00:00:34.200
<v Aaron van Wirdum>Planning to record some episodes there, but then everybody got COVID.

00:00:34.780 --> 00:00:38.000
<v Sjors Provoost>Yes, and also it's a conference, so it's always a bit difficult to record.

00:00:39.490 --> 00:00:44.750
<v Aaron van Wirdum>So back in Utrecht, and we're going to discuss a blog post. Well, we're going

00:00:44.750 --> 00:00:50.560
<v Aaron van Wirdum>to... discuss a concept that was described in a blog post by Jameson Lopp.

00:00:50.680 --> 00:00:51.220
<v Sjors Provoost>That's right.

00:00:52.420 --> 00:00:57.780
<v Aaron van Wirdum>He actually published a couple of blog posts about backwards compatibility,

00:00:57.780 --> 00:01:02.160
<v Aaron van Wirdum>I guess, or syncing old nodes. That's really what the blog posts were about.

00:01:02.380 --> 00:01:02.660
<v Sjors Provoost>Exactly.

00:01:03.140 --> 00:01:08.880
<v Aaron van Wirdum>Yeah, so Bitcoin Core, of course, releases two new clients each year or at least

00:01:08.880 --> 00:01:11.160
<v Aaron van Wirdum>two new major releases each year, right?

00:01:11.420 --> 00:01:11.860
<v Sjors Provoost>Yeah, roughly.

00:01:12.280 --> 00:01:18.220
<v Aaron van Wirdum>And these blog posts were about syncing older Bitcoin Core nodes to see

00:01:18.220 --> 00:01:21.820
<v Aaron van Wirdum>how fast they would actually sync to the current chain tip right?

00:01:21.820 --> 00:01:22.440
<v Sjors Provoost>That's right.

00:01:22.440 --> 00:01:26.480
<v Aaron van Wirdum>And I think you've done similar research a couple years ago is that right?

00:01:26.480 --> 00:01:32.400
<v Sjors Provoost>Yeah so back in 2017 um what I did was I took a couple of Amazon AWS

00:01:32.400 --> 00:01:37.640
<v Sjors Provoost>machines so these are just cloud machines, and install different versions of

00:01:37.640 --> 00:01:42.080
<v Sjors Provoost>Bitcoin Core on those machines, and then just have them sync the Bitcoin

00:01:42.080 --> 00:01:45.040
<v Sjors Provoost>blockchain as far as possible, and then I would just measure how long it would

00:01:45.040 --> 00:01:49.430
<v Sjors Provoost>take, and those pretty big differences. And he's basically done that again,

00:01:49.670 --> 00:01:53.350
<v Sjors Provoost>probably slightly different, but the same idea and with more recent versions.

00:01:53.990 --> 00:01:54.510
<v Aaron van Wirdum>Right.

00:01:54.850 --> 00:01:56.810
<v Sjors Provoost>And also with some older versions.

00:01:57.780 --> 00:02:02.600
<v Aaron van Wirdum>Yeah, so to be very specific, I already mentioned this, but there were basically

00:02:02.600 --> 00:02:07.180
<v Aaron van Wirdum>two blog posts by Jameson, and the first one was really about syncing old nodes,

00:02:07.240 --> 00:02:11.080
<v Aaron van Wirdum>and I would say the second one was actually mainly about backwards compatibility

00:02:11.080 --> 00:02:15.000
<v Aaron van Wirdum>and forwards compatibility, which, you know, it's a related issue.

00:02:15.690 --> 00:02:21.570
<v Sjors Provoost>Yeah, and he also zoomed in on some of the really old nodes specifically, like

00:02:21.570 --> 00:02:27.450
<v Sjors Provoost>the version 0.3, 0.4, 0.5 from many, many years ago and

00:02:27.450 --> 00:02:29.470
<v Sjors Provoost>how difficult it is to get these things to work at all.

00:02:30.150 --> 00:02:33.210
<v Aaron van Wirdum>Yes, well, that's the backwards compatibility part, right?

00:02:34.280 --> 00:02:38.420
<v Sjors Provoost>Yeah, arguably. I mean, we can get into whether it's backwards compatibility or

00:02:38.420 --> 00:02:40.640
<v Sjors Provoost>whether it's some other problems that he was running into.

00:02:42.040 --> 00:02:46.680
<v Aaron van Wirdum>Which we will get into. Yes all right. First of all for the people that don't

00:02:46.680 --> 00:02:51.070
<v Aaron van Wirdum>know this, what does that actually mean? What is backwards compatibility? Or

00:02:51.070 --> 00:02:55.030
<v Aaron van Wirdum>Sjors, forwards compatibility, because sometimes the terms are sort of used

00:02:55.030 --> 00:02:56.130
<v Aaron van Wirdum>interchangeably.

00:02:56.610 --> 00:03:00.390
<v Sjors Provoost>Yeah, so I'm also going to be sloppy about it. The general idea is that you want

00:03:00.390 --> 00:03:04.610
<v Sjors Provoost>—uh, you don't want to force people to upgrade their nodes at least definitely not

00:03:04.610 --> 00:03:09.870
<v Sjors Provoost>immediately. So older nodes should work well with newer nodes. And if you know if

00:03:09.870 --> 00:03:13.930
<v Sjors Provoost>you change… if you do this soft fork, you know the the new nodes will be able to

00:03:13.930 --> 00:03:18.530
<v Sjors Provoost>the old nodes will just keep working fine while everybody… while other people

00:03:18.530 --> 00:03:21.560
<v Sjors Provoost>upgrade to a new node. um Yeah,

00:03:22.300 --> 00:03:27.040
<v Aaron van Wirdum>Exactly. So like I mentioned, Bitcoin Core releases two new major releases every

00:03:27.040 --> 00:03:32.580
<v Aaron van Wirdum>year. And the goal is that these new releases won't fall out of sync with older

00:03:32.580 --> 00:03:36.700
<v Aaron van Wirdum>nodes or the other way around, depending on how you look at it. The goal is to

00:03:36.700 --> 00:03:42.080
<v Aaron van Wirdum>keep everyone in consensus, including older nodes. Why do we think this is

00:03:42.080 --> 00:03:43.620
<v Aaron van Wirdum>important?

00:03:44.470 --> 00:03:49.270
<v Sjors Provoost>Well, there are multiple reasons for it. Because you want to keep the system as

00:03:49.270 --> 00:03:53.650
<v Sjors Provoost>voluntary as possible. There might be reasons why people are worried about

00:03:53.650 --> 00:03:57.590
<v Sjors Provoost>installing new versions of Bitcoin Core. Maybe they want more people to review

00:03:57.590 --> 00:04:02.910
<v Sjors Provoost>it. If suddenly you have only two days to upgrade your node, maybe there's some

00:04:02.910 --> 00:04:06.450
<v Sjors Provoost>malware in it. But if you wait a year, it's more likely somebody would have

00:04:06.450 --> 00:04:11.490
<v Sjors Provoost>already found it. It's also just maybe not possible to upgrade. Maybe you're busy

00:04:11.490 --> 00:04:13.040
<v Sjors Provoost>doing other things. you know.

00:04:13.040 --> 00:04:17.080
<v Aaron van Wirdum>Yeah, maybe you want to [unclear] the code yourself right? Yeah, it's at least

00:04:17.080 --> 00:04:20.840
<v Aaron van Wirdum>possible someone might want to do that, and that can take a little bit of time,

00:04:20.840 --> 00:04:24.360
<v Aaron van Wirdum>and therefore it's important that they can keep using Bitcoin in the meantime.

00:04:24.360 --> 00:04:28.020
<v Sjors Provoost>Yeah, and and companies you know, that are running exchanges and whatever, they

00:04:28.020 --> 00:04:32.420
<v Sjors Provoost>might be busy, they don't necessarily have… you know they don't necessarily can

00:04:32.420 --> 00:04:37.380
<v Sjors Provoost>do everything for you on January 1st of some year. So it's nice if they don't

00:04:37.380 --> 00:04:39.720
<v Sjors Provoost>have to upgrade. Though it's always a good idea to upgrade because you tend to

00:04:39.720 --> 00:04:42.940
<v Sjors Provoost>stay up to date on security fixes and performance improvements.

00:04:43.520 --> 00:04:48.240
<v Aaron van Wirdum>Yeah, I would argue there's also kind of... And we'll move on after this. But I

00:04:48.240 --> 00:04:52.440
<v Aaron van Wirdum>would argue there's also kind of a philosophical reason. Like in our previous

00:04:52.440 --> 00:04:56.220
<v Aaron van Wirdum>episode, we were discussing like very hypothetical situations where there's a

00:04:56.220 --> 00:05:01.700
<v Aaron van Wirdum>chain split. And like if you're... If you're asking the question, what is

00:05:01.700 --> 00:05:06.240
<v Aaron van Wirdum>actually Bitcoin, then it makes sense that older nodes, if they are still

00:05:06.240 --> 00:05:10.800
<v Aaron van Wirdum>syncing, someone never upgraded their node, why wouldn't that be Bitcoin? That

00:05:10.800 --> 00:05:15.580
<v Aaron van Wirdum>was a big theme during the block size wars. Can you just change the protocol? And

00:05:15.580 --> 00:05:17.440
<v Aaron van Wirdum>there was this argument about backwards compatibility.

00:05:19.310 --> 00:05:23.230
<v Aaron van Wirdum>It's a philosophical argument that if old nodes still sync, then obviously that's

00:05:23.230 --> 00:05:23.950
<v Aaron van Wirdum>still Bitcoin, right?

00:05:24.270 --> 00:05:28.970
<v Sjors Provoost>Yeah. But as we'll find out now, there is some nuance to that argument because

00:05:28.970 --> 00:05:33.990
<v Sjors Provoost>trying to run a node from 12 years ago is not possible, probably.

00:05:34.250 --> 00:05:39.310
<v Aaron van Wirdum>For sure. Well, let's get into that right now, I think. Let's start there.

00:05:39.970 --> 00:05:45.830
<v Aaron van Wirdum>So Jameson did these experiments with some older nodes. And when we

00:05:45.830 --> 00:05:47.730
<v Aaron van Wirdum>say older, how old are we talking?

00:05:48.280 --> 00:05:53.200
<v Sjors Provoost>I think as old as 2012, maybe even 2011.

00:05:53.640 --> 00:05:58.960
<v Aaron van Wirdum>Yeah, that era. 2011, 2012, 2013. It was

00:05:58.960 --> 00:06:04.320
<v Aaron van Wirdum>pre-Bitcoin 0.7, right?

00:06:05.080 --> 00:06:08.360
<v Aaron van Wirdum>Which ones [unclear]? 4, 5, 6, 7?

00:06:08.500 --> 00:06:09.220
<v Sjors Provoost>Even 3.

00:06:09.860 --> 00:06:16.260
<v Aaron van Wirdum>3, 4, 5, 6, 7. Or 3, 4, 5, 6 in this latest blog post, right? Yeah.

00:06:18.540 --> 00:06:20.980
<v Aaron van Wirdum>And these did not sync. Did all of them not sync?

00:06:23.180 --> 00:06:27.820
<v Sjors Provoost>I think at least until 0.5, it could not get to sync.

00:06:28.160 --> 00:06:28.380
<v Aaron van Wirdum>Right.

00:06:28.600 --> 00:06:33.420
<v Sjors Provoost>And that also reflects my own experience when I tried that in 2017.

00:06:36.530 --> 00:06:39.470
<v Aaron van Wirdum>Nodes older than 0.5 will not sync.

00:06:39.610 --> 00:06:40.750
<v Sjors Provoost>0.5 wouldn't sync either.

00:06:41.010 --> 00:06:45.930
<v Aaron van Wirdum>Right. Okay. And then we get into some of the reasons as far as we can tell

00:06:45.930 --> 00:06:51.720
<v Aaron van Wirdum>because... My reading of the blog post is not entirely clear every time why

00:06:51.720 --> 00:06:56.920
<v Aaron van Wirdum>exactly. It's clear where the nodes stop syncing, but it's not necessarily clear

00:06:56.920 --> 00:06:58.940
<v Aaron van Wirdum>why exactly it stops syncing. Is that right?

00:06:59.460 --> 00:07:04.160
<v Sjors Provoost>Yeah, but we can get into some of the reasons, and eventually we'll find out that

00:07:04.160 --> 00:07:09.260
<v Sjors Provoost>with 0.5, I wasn't able to sync it all the way, he wasn't able to sync it all the

00:07:09.260 --> 00:07:14.960
<v Sjors Provoost>way, but there's some recent developments that may still be ways to get it to

00:07:14.960 --> 00:07:16.730
<v Sjors Provoost>sync. We simply don't know yet.

00:07:17.010 --> 00:07:22.620
<v Aaron van Wirdum>Okay, so where does it stop or what's the reason as far as we know? What's the

00:07:22.620 --> 00:07:23.080
<v Aaron van Wirdum>story here?

00:07:23.360 --> 00:07:27.440
<v Sjors Provoost>Yeah, so there's a couple of things and those really all boil down to the theme

00:07:27.440 --> 00:07:30.920
<v Sjors Provoost>of dependencies. So that's a fun topic always.

00:07:31.180 --> 00:07:34.760
<v Aaron van Wirdum>I think we discussed this in a previous episode, but maybe you should...

00:07:34.760 --> 00:07:38.760
<v Sjors Provoost>Very, very long time ago. So our very first episode, I think, or maybe the second

00:07:38.760 --> 00:07:44.240
<v Sjors Provoost>episode, we talked about dependencies like OpenSSL. And how, you know, when

00:07:44.240 --> 00:07:45.580
<v Sjors Provoost>those dependencies change…

00:07:45.600 --> 00:07:47.800
<v Aaron van Wirdum>It's very basic. What is a dependency?

00:07:45.800 --> 00:07:46.400
<v Sjors Provoost>[unclear]…

00:07:48.260 --> 00:07:52.780
<v Sjors Provoost>Or a library. Yeah. So dependency is a piece of software that you include in your software,

00:07:54.030 --> 00:07:58.950
<v Sjors Provoost>basically. So in the case of OpenSSL, it's a very well-known dependency.

00:08:00.380 --> 00:08:04.620
<v Sjors Provoost>It's a cryptographic library. So it means that Satoshi did not have to implement

00:08:04.620 --> 00:08:08.640
<v Sjors Provoost>all of the elliptic curve cryptography, he could just

00:08:08.640 --> 00:08:14.000
<v Sjors Provoost>use OpenSSL and let it handle all the cryptography.

00:08:14.160 --> 00:08:19.560
<v Aaron van Wirdum>Right, so OpenSSL is being developed by another group of developers and

00:08:19.560 --> 00:08:24.320
<v Aaron van Wirdum>their code is essentially used in Bitcoin Core.

00:08:24.690 --> 00:08:25.330
<v Sjors Provoost>That's right.

00:08:25.530 --> 00:08:30.930
<v Aaron van Wirdum>And then it's called a dependency or the problem is if these other developers

00:08:30.930 --> 00:08:35.190
<v Aaron van Wirdum>change something that might affect your own software, right? That's sort of the problem.

00:08:35.390 --> 00:08:39.830
<v Sjors Provoost>Yeah, exactly. And this can be especially a problem when the dependency...

00:08:40.570 --> 00:08:44.970
<v Sjors Provoost>secretly, or not secretly, but like accidentally imposes rules that you don't

00:08:44.970 --> 00:08:45.850
<v Sjors Provoost>know are rules.

00:08:46.070 --> 00:08:46.410
<v Aaron van Wirdum>Right.

00:08:46.890 --> 00:08:51.150
<v Sjors Provoost>And, well, there's a couple of, there's probably three different incidents of

00:08:51.150 --> 00:08:52.930
<v Sjors Provoost>that historically, at least three.

00:08:53.550 --> 00:08:55.030
<v Aaron van Wirdum>You mean in Bitcoin or?

00:08:55.110 --> 00:08:55.690
<v Sjors Provoost>Yeah, in Bitcoin.

00:08:55.850 --> 00:08:56.350
<v Aaron van Wirdum>Yeah, okay.

00:08:56.630 --> 00:08:59.490
<v Sjors Provoost>I mean, in general, dependencies, of course, cause all sorts of headaches. I

00:08:59.490 --> 00:09:05.250
<v Sjors Provoost>think it was in the news last week that somebody in the NPM, the

00:09:05.250 --> 00:09:09.670
<v Sjors Provoost>Node Package Manager, which is a JavaScript library that a lot of... Any website

00:09:09.670 --> 00:09:13.970
<v Sjors Provoost>that looks even a little bit fancy probably uses that in the background. And it

00:09:13.970 --> 00:09:18.750
<v Sjors Provoost>turns out that if you were a developer and you were based in Russia or Belarus,

00:09:19.070 --> 00:09:24.670
<v Sjors Provoost>your computer would get wiped if you updated the dependency. So dependencies are

00:09:24.670 --> 00:09:29.030
<v Sjors Provoost>a nightmare in general, but we won't go into too much detail about that nightmare.

00:09:29.330 --> 00:09:30.730
<v Aaron van Wirdum>Yeah, let's stick to the Bitcoin.

00:09:30.990 --> 00:09:35.270
<v Sjors Provoost>Yeah, so for Bitcoin, we can start with one dependency, which is called

00:09:35.270 --> 00:09:35.870
<v Sjors Provoost>BerkeleyDB.

00:09:37.580 --> 00:09:42.940
<v Sjors Provoost>BerkeleyDB is a database technology that was initially used to store, I think,

00:09:43.000 --> 00:09:46.100
<v Sjors Provoost>information about the UTXO set, or at least information about Bitcoin

00:09:46.100 --> 00:09:50.340
<v Sjors Provoost>transactions. So the node was using that dependency, which is built by other

00:09:50.340 --> 00:09:55.090
<v Sjors Provoost>people. And when the Bitcoin blockchain was small, when blocks were small,

00:09:56.700 --> 00:10:01.160
<v Sjors Provoost>Every block would just add a bunch of transactions to the database. I'm kind of

00:10:01.160 --> 00:10:04.380
<v Sjors Provoost>simplifying it partially because I don't know the precise details. But let's say

00:10:04.380 --> 00:10:07.760
<v Sjors Provoost>a block contains 100 transactions and it would just add those 100 transactions to

00:10:07.760 --> 00:10:13.400
<v Sjors Provoost>the database and the database would be happy. However, it turns out that if you

00:10:13.400 --> 00:10:16.600
<v Sjors Provoost>crank up the number of transactions you start putting in the database, so if the

00:10:16.600 --> 00:10:21.240
<v Sjors Provoost>blocks get bigger, at some point the database won't allow you to add these

00:10:21.240 --> 00:10:27.200
<v Sjors Provoost>blocks. However, that never happened in practice because Bitcoin switched

00:10:27.200 --> 00:10:32.530
<v Sjors Provoost>to a new database type in about 2013 called LevelDB.

00:10:32.830 --> 00:10:33.150
<v Aaron van Wirdum>Right.

00:10:34.230 --> 00:10:38.950
<v Sjors Provoost>And this LevelDB, you know, it's much faster and there was other reasons why it

00:10:38.950 --> 00:10:43.910
<v Sjors Provoost>was better. But what happens is at that point, blocks started getting even bigger

00:10:43.910 --> 00:10:47.610
<v Sjors Provoost>and LevelDB had no problem with it. But because we said we want to be backwards

00:10:47.610 --> 00:10:51.920
<v Sjors Provoost>compatible. Some people were still running nodes that use BerkeleyDB and those

00:10:51.920 --> 00:10:56.320
<v Sjors Provoost>nodes started causing problems because they started hitting those limits. And so

00:10:56.320 --> 00:11:00.440
<v Sjors Provoost>the database would say, hey, this block is too large. Kind of.

00:11:00.760 --> 00:11:06.440
<v Aaron van Wirdum>Right. So if a big block, and by big we mean one megabyte, I guess, or

00:11:06.440 --> 00:11:07.800
<v Aaron van Wirdum>maybe close to one megabyte…

00:11:07.920 --> 00:11:11.020
<v Sjors Provoost>Yeah, or 300 kilobytes. I don't know where it went wrong.

00:11:11.160 --> 00:11:15.660
<v Aaron van Wirdum>Whatever it was. If a big block would have been mined, say, in 2012, would that

00:11:15.660 --> 00:11:20.450
<v Aaron van Wirdum>have meant that Bitcoin... Core nodes it wasn't even called Bitcoin Core back

00:11:20.450 --> 00:11:24.310
<v Aaron van Wirdum>then, Bitcoin nodes then would have crashed is that sort of…

00:11:24.310 --> 00:11:27.270
<v Sjors Provoost>I think they would have not have crashed, but they would have rejected the block,

00:11:27.270 --> 00:11:31.790
<v Sjors Provoost>but it was worse than that because it was not deterministic, so it's like some

00:11:31.790 --> 00:11:36.630
<v Sjors Provoost>Bitcoin Core nodes would have stopped and others would not have. Um so because

00:11:36.630 --> 00:11:41.350
<v Sjors Provoost>you were hitting internal, basically internal intricacies of the database

00:11:41.350 --> 00:11:46.270
<v Sjors Provoost>package, it wasn't like a clear coded limit, just running into the internal

00:11:46.270 --> 00:11:51.850
<v Sjors Provoost>magic. And so what ended up happening was a short chain split where the decision

00:11:51.850 --> 00:11:57.410
<v Sjors Provoost>was made to undo the update and then everybody was told to either update to a new

00:11:57.410 --> 00:12:02.540
<v Sjors Provoost>version of Bitcoin Core or change a slight setting in that database.

00:12:03.750 --> 00:12:09.690
<v Aaron van Wirdum>Right, but my… question and you've answered it but just to be clear, essentially

00:12:09.690 --> 00:12:14.210
<v Aaron van Wirdum>what you're saying is there was actually a problem in Bitcoin clients back then.

00:12:14.210 --> 00:12:19.210
<v Aaron van Wirdum>We just never noticed it because all blocks were almost empty or very small. Yeah

00:12:19.210 --> 00:12:24.950
<v Aaron van Wirdum>and only if you start to try to sync it now, now the blocks are big, it's

00:12:24.950 --> 00:12:28.330
<v Aaron van Wirdum>that the problem is really revealed. So there was kind of a bug in old nodes right?

00:12:28.330 --> 00:12:32.410
<v Sjors Provoost>Yeah but it got revealed as soon as they upgraded it, and my guess would be that

00:12:32.410 --> 00:12:36.230
<v Sjors Provoost>you know, the miners are also running the same software to create the blocks, and

00:12:36.230 --> 00:12:38.650
<v Sjors Provoost>so they wouldn't have created those big blocks in the first place. So maybe

00:12:38.650 --> 00:12:42.640
<v Sjors Provoost>that's why it happened at the same time. Or maybe, you know, it could have been

00:12:42.640 --> 00:12:48.100
<v Sjors Provoost>deliberate. But it turns out that had that upgrade not happened, we would have

00:12:48.100 --> 00:12:53.400
<v Sjors Provoost>run into another bottleneck in that same software later on. And that's what me, I

00:12:53.400 --> 00:12:57.320
<v Sjors Provoost>think both me and Jameson ran into. That if you keep running that old software...

00:12:57.320 --> 00:13:00.860
<v Aaron van Wirdum>Sorry, this is the same dependency. Also BerkeleyDB? We're still talking about BerkeleyDB.

00:13:00.860 --> 00:13:05.840
<v Sjors Provoost>So if you stick to BerkeleyDB, if you decide, you know, you go back in your time

00:13:05.840 --> 00:13:08.760
<v Sjors Provoost>machine to 2013, you say, you know what, I don't want to install this update.

00:13:09.150 --> 00:13:12.210
<v Sjors Provoost>I'll just change this configuration as people recommend, and then I'll just keep

00:13:12.210 --> 00:13:16.830
<v Sjors Provoost>going. If you do that, then I think in 2015 or something like that, you start

00:13:16.830 --> 00:13:21.410
<v Sjors Provoost>running into blocks that will still crash your database. And that's the new

00:13:21.410 --> 00:13:27.390
<v Sjors Provoost>development where I posted a question on Stack Overflow years and years ago

00:13:27.390 --> 00:13:31.090
<v Sjors Provoost>asking I'm running you know, I can't get past this block with this old version of

00:13:31.090 --> 00:13:35.130
<v Sjors Provoost>the software. Can anybody help? And nobody replied to that until yesterday.

00:13:35.130 --> 00:13:39.450
<v Sjors Provoost>Andrew Chow actually replied to it and had some suggestions on how to get past

00:13:39.450 --> 00:13:43.860
<v Sjors Provoost>those error messages. This is why it's still a mystery. We it's possible that

00:13:43.860 --> 00:13:49.000
<v Sjors Provoost>with a few other changes in the settings you know, it might still be able to

00:13:49.000 --> 00:13:53.800
<v Sjors Provoost>reach the tip of the modern blockchain. My guess is it will run into other

00:13:53.800 --> 00:13:57.760
<v Sjors Provoost>limitations in that database because it's just not been tested with the giant

00:13:57.760 --> 00:13:58.940
<v Sjors Provoost>blockchain that we have today.

00:13:59.860 --> 00:14:00.100
<v Aaron van Wirdum>Right.

00:14:01.800 --> 00:14:07.400
<v Aaron van Wirdum>Okay. So again, like the previous example, essentially there was always a problem

00:14:07.400 --> 00:14:13.010
<v Aaron van Wirdum>in Bitcoin code back then and it was just never revealed because the blocks

00:14:13.010 --> 00:14:16.230
<v Aaron van Wirdum>never were created that were big enough to actually reveal the problem.

00:14:16.470 --> 00:14:16.690
<v Sjors Provoost>Exactly.

00:14:16.990 --> 00:14:21.380
<v Aaron van Wirdum>It's only if you... sync an old node that the problem will reveal itself. So

00:14:21.380 --> 00:14:23.800
<v Aaron van Wirdum>we've had two of these problems, two twice.

00:14:24.220 --> 00:14:28.280
<v Sjors Provoost>We've had one that people really noticed it in the wild that caused an actual

00:14:28.280 --> 00:14:32.940
<v Sjors Provoost>split. And we've had one that you can notice yourself if you try to use very old software.

00:14:33.260 --> 00:14:36.920
<v Aaron van Wirdum>Right. And you mentioned there might be even more if we get past this new block

00:14:36.920 --> 00:14:41.740
<v Aaron van Wirdum>and someone tries syncing again and new problems. So basically this Berkeley DB

00:14:41.740 --> 00:14:46.160
<v Aaron van Wirdum>database, that was kind of a problem and we got rid of it. And now the new...

00:14:46.910 --> 00:14:48.630
<v Aaron van Wirdum>Nodes perform better for that reason.

00:14:48.990 --> 00:14:49.070
<v Sjors Provoost>Yeah.

00:14:49.290 --> 00:14:49.770
<v Aaron van Wirdum>Is that right?

00:14:50.010 --> 00:14:54.330
<v Sjors Provoost>Yeah. And so there's a second dependency that's been a cause of headaches. And we

00:14:54.330 --> 00:14:57.070
<v Sjors Provoost>have discussed that one in the earlier podcast, which is OpenSSL.

00:14:57.250 --> 00:15:00.090
<v Aaron van Wirdum>We discussed it in this podcast, I think, a minute ago.

00:15:00.230 --> 00:15:06.150
<v Sjors Provoost>But specifically, the problem there is that OpenSSL, the very old versions of

00:15:06.150 --> 00:15:11.410
<v Sjors Provoost>OpenSSL, so the ones that Satoshi installed, those were very permissive in terms

00:15:11.410 --> 00:15:15.140
<v Sjors Provoost>of how the signature could be encoded. So you couldn't make a fake signature, but

00:15:15.140 --> 00:15:20.520
<v Sjors Provoost>the way you write a signature down, it could have like 75 characters or maybe

00:15:20.520 --> 00:15:25.440
<v Sjors Provoost>more. And later versions of OpenSSL said, no, no, no, we're going to make it more

00:15:25.440 --> 00:15:30.340
<v Sjors Provoost>precise. You have to only use, I don't know, 73 characters for your signature and

00:15:30.340 --> 00:15:35.690
<v Sjors Provoost>no more. And it happened to be, if I understand correctly, that

00:15:35.690 --> 00:15:41.310
<v Sjors Provoost>there never was any signature with that many characters in

00:15:41.440 --> 00:15:47.410
<v Sjors Provoost>practice. No, I think there was. So let me see if I get

00:15:47.410 --> 00:15:51.490
<v Sjors Provoost>the problem. So yeah, so I think there was a signature that was bigger, but

00:15:51.490 --> 00:15:54.630
<v Sjors Provoost>nobody ran into the problem because if you had installed an old version of

00:15:54.630 --> 00:15:59.790
<v Sjors Provoost>Bitcoin Core back in the day, you would have had the old version of OpenSSL and

00:15:59.790 --> 00:16:03.410
<v Sjors Provoost>therefore you would have been able to sync just fine with these bigger

00:16:03.410 --> 00:16:08.840
<v Sjors Provoost>signatures. But if now you try to install that old version,

00:16:09.440 --> 00:16:14.300
<v Sjors Provoost>today, on a modern computer, you're going to have a modern version of OpenSSL and

00:16:14.300 --> 00:16:17.380
<v Sjors Provoost>you're going to produce a version of Bitcoin Core that will not accept these old blocks.

00:16:17.680 --> 00:16:21.500
<v Aaron van Wirdum>Right, yeah. So this is kind of the opposite problem as the previous one. The

00:16:21.500 --> 00:16:25.360
<v Aaron van Wirdum>previous problem we just mentioned with Berkeley is essentially that Bitcoin Core

00:16:25.360 --> 00:16:28.860
<v Aaron van Wirdum>clients were always, you know, they always had these bugs essentially, but the

00:16:28.860 --> 00:16:33.080
<v Aaron van Wirdum>bugs were never revealed because blocks were never big enough to reveal them. And

00:16:33.080 --> 00:16:37.640
<v Aaron van Wirdum>now the problem is kind of different because Jameson was doing these tests. He

00:16:37.640 --> 00:16:42.960
<v Aaron van Wirdum>had to rebuild old clients. And while he was rebuilding the old Bitcoin Core

00:16:42.960 --> 00:16:48.220
<v Aaron van Wirdum>clients, the only way he knew to do it or... was by...

00:16:48.430 --> 00:16:49.540
<v Aaron van Wirdum>I don't know how this works.

00:16:49.660 --> 00:16:51.800
<v Sjors Provoost>Yeah, he was using the most recent version of the dependencies.

00:16:52.080 --> 00:16:55.360
<v Aaron van Wirdum>Yeah, so then you get a new dependency. So now we have sort of the original

00:16:55.360 --> 00:17:00.260
<v Aaron van Wirdum>dependency problem that I discussed is that the dependency changes and now the

00:17:00.260 --> 00:17:04.520
<v Aaron van Wirdum>original client doesn't work anymore. However, so here the problem would be the

00:17:04.520 --> 00:17:09.040
<v Aaron van Wirdum>opposite way that if you were still running that old software, you never changed

00:17:09.040 --> 00:17:13.580
<v Aaron van Wirdum>it, you're still using your old computer from 2012 or whatever. you would still

00:17:13.580 --> 00:17:17.420
<v Aaron van Wirdum>actually sync to the current blockchain because then you're also still using this

00:17:17.420 --> 00:17:20.420
<v Aaron van Wirdum>old OpenSSL code, right?

00:17:20.480 --> 00:17:26.000
<v Sjors Provoost>Yeah, and in fact, there was a soft fork at some point that restricted the size

00:17:26.000 --> 00:17:29.540
<v Sjors Provoost>of signatures in the consensus rules. But again, because it was a soft fork, your

00:17:29.540 --> 00:17:34.640
<v Sjors Provoost>old node would be fine with the new rules, but it would not detect a violation of

00:17:34.640 --> 00:17:37.820
<v Sjors Provoost>the new rules if somebody produced a signature that we no longer consider

00:17:37.820 --> 00:17:42.070
<v Sjors Provoost>invalid. But there was, again, a transition period, I think it might have been

00:17:42.070 --> 00:17:47.930
<v Sjors Provoost>2013 or even 2015, where this was actually a problem for people who were

00:17:47.930 --> 00:17:52.610
<v Sjors Provoost>compiling their own nodes. They actually had to be careful to when they compile

00:17:52.610 --> 00:17:56.210
<v Sjors Provoost>their own nodes to either use an old version of OpenSSL or

00:17:56.210 --> 00:18:02.210
<v Sjors Provoost>apply a little patch to a Bitcoin Core that would work around the newer

00:18:02.210 --> 00:18:03.330
<v Sjors Provoost>versions of OpenSSL.

00:18:04.150 --> 00:18:09.770
<v Aaron van Wirdum>Right. Does this have anything to do with the 2013 blockchain split that actually

00:18:09.770 --> 00:18:11.310
<v Aaron van Wirdum>happened for like six blocks?

00:18:11.410 --> 00:18:13.810
<v Sjors Provoost>No, that was the one we just talked about. That was a Berkeley DB.

00:18:14.010 --> 00:18:15.570
<v Aaron van Wirdum>Oh, that was a Berkeley DB problem.

00:18:15.810 --> 00:18:21.270
<v Sjors Provoost>And I think this is later. I think this is 2015, but I'm not sure. In any case,

00:18:21.490 --> 00:18:26.280
<v Sjors Provoost>this was a problem in reality for people who compile their own nodes. It was not

00:18:26.280 --> 00:18:29.680
<v Sjors Provoost>a problem for people who download the nodes because the downloaded versions would

00:18:29.680 --> 00:18:33.900
<v Sjors Provoost>all have the old version of OpenSSL in it or the newer version would have the

00:18:33.900 --> 00:18:36.940
<v Sjors Provoost>workaround in it. It was never a problem when you download Bitcoin Core. It is a

00:18:36.940 --> 00:18:40.640
<v Sjors Provoost>problem when you compile it yourself. And it was even a problem back then.

00:18:41.460 --> 00:18:46.240
<v Aaron van Wirdum>Right. At the risk of getting sidetracked a little bit, would it be possible

00:18:46.240 --> 00:18:52.100
<v Aaron van Wirdum>to... you know, basically rebuild an old client also using like an old library?

00:18:52.320 --> 00:18:54.920
<v Aaron van Wirdum>I guess you'd have to find it somewhere and that's the hard part then?

00:18:55.220 --> 00:18:59.260
<v Sjors Provoost>Yeah, no, exactly. I mean, a lot of the open source libraries are still available

00:18:59.260 --> 00:19:03.980
<v Sjors Provoost>somewhere. It gets a bit more. I think that's what Jameson did. He installed like

00:19:03.980 --> 00:19:07.880
<v Sjors Provoost>a super old version of Ubuntu and then tried to also find some of the very old

00:19:07.880 --> 00:19:11.560
<v Sjors Provoost>packages. But the problem is, of course, most operating systems that you would be

00:19:11.560 --> 00:19:15.810
<v Sjors Provoost>building on will have the most recent versions of the libraries. And obviously

00:19:15.810 --> 00:19:19.470
<v Sjors Provoost>you do not want to actually use a computer with an outdated version of OpenSSL

00:19:19.470 --> 00:19:23.170
<v Sjors Provoost>because you'd have heartbleeds and all these like very bad security

00:19:23.170 --> 00:19:27.830
<v Sjors Provoost>vulnerabilities on your computer. But there are ways to do it, even safe ways to do it.

00:19:29.440 --> 00:19:29.840
<v Sjors Provoost>Yeah.

00:19:30.220 --> 00:19:30.520
<v Aaron van Wirdum>Right.

00:19:30.820 --> 00:19:36.140
<v Sjors Provoost>So this is a problem for, say, an historian like a thousand years from now. If

00:19:36.140 --> 00:19:39.960
<v Sjors Provoost>you're a historian and you want to really study Bitcoin in the old days, you're

00:19:39.960 --> 00:19:42.460
<v Sjors Provoost>going to have a problem because a thousand years from now, you'll probably still

00:19:42.460 --> 00:19:44.440
<v Sjors Provoost>find the old source code of Bitcoin.

00:19:46.450 --> 00:19:50.470
<v Sjors Provoost>But you'll have a very hard time building a computer, even a virtual computer,

00:19:50.710 --> 00:19:55.010
<v Sjors Provoost>that will behave the same as a computer from today.

00:19:55.390 --> 00:20:01.200
<v Aaron van Wirdum>Right. So we've now discussed three reasons why old nodes stalled.

00:20:01.340 --> 00:20:06.040
<v Aaron van Wirdum>I think they were three, right? Have we covered them all? Right. And just to

00:20:06.040 --> 00:20:11.580
<v Aaron van Wirdum>reiterate, in two of these cases, they were actually bugs in the old code, or

00:20:11.580 --> 00:20:12.300
<v Aaron van Wirdum>essentially, right?

00:20:13.580 --> 00:20:17.780
<v Aaron van Wirdum>Compared to... you can't sync to new blocks because... Do we call them bugs?

00:20:17.920 --> 00:20:18.460
<v Aaron van Wirdum>I would.

00:20:18.720 --> 00:20:19.560
<v Sjors Provoost>Yeah, I think so.

00:20:19.720 --> 00:20:22.360
<v Aaron van Wirdum>Yeah, all right. So in two cases, there were actually old bugs and old code that

00:20:22.360 --> 00:20:27.510
<v Aaron van Wirdum>just weren't revealed until, you know, much later when no one was using it

00:20:27.510 --> 00:20:31.930
<v Aaron van Wirdum>anymore, essentially. And in one case, it was because of the dependency changed.

00:20:32.290 --> 00:20:32.430
<v Sjors Provoost>Yeah.

00:20:32.570 --> 00:20:35.110
<v Aaron van Wirdum>And the old code would have actually synced to the new blockchain.

00:20:35.430 --> 00:20:35.550
<v Sjors Provoost>Yeah.

00:20:36.130 --> 00:20:41.310
<v Aaron van Wirdum>All right. Let's get into the next part of the podcast then, which is

00:20:41.310 --> 00:20:42.570
<v Aaron van Wirdum>syncing.

00:20:44.200 --> 00:20:47.080
<v Aaron van Wirdum>So syncing is probably one of the main

00:20:48.360 --> 00:20:52.140
<v Aaron van Wirdum>user experience bottlenecks. Can we call it that?

00:20:52.500 --> 00:20:55.920
<v Sjors Provoost>Yeah, because it's the first thing you do when you install Bitcoin, when you

00:20:55.920 --> 00:20:59.880
<v Sjors Provoost>install Bitcoin Core. And the first thing you do is sit and wait for a long time.

00:21:00.320 --> 00:21:04.700
<v Sjors Provoost>And so it's not a great experience. Unless you really like progress bars.

00:21:04.940 --> 00:21:08.120
<v Aaron van Wirdum>Yeah, and the reason for that is, of course, because you're essentially...

00:21:09.720 --> 00:21:13.020
<v Aaron van Wirdum>rechecking or learning about the entire history of the blockchain. You're

00:21:13.020 --> 00:21:16.760
<v Aaron van Wirdum>downloading and checking the entire history of the blockchain in order to get up

00:21:16.760 --> 00:21:20.780
<v Aaron van Wirdum>to date with what's the state of Bitcoin today, who owns what.

00:21:20.980 --> 00:21:24.460
<v Sjors Provoost>Exactly. And in earlier episodes, we've talked about some ways to either speed

00:21:24.460 --> 00:21:29.940
<v Sjors Provoost>that up or to skip it altogether with things like AssumeUTXO. But for now, and

00:21:29.940 --> 00:21:33.200
<v Sjors Provoost>probably for the foreseeable future, yeah, you need to check every single block,

00:21:33.420 --> 00:21:37.200
<v Sjors Provoost>not just to know if it's correct, even just to know which coins actually exist.

00:21:39.080 --> 00:21:39.560
<v Aaron van Wirdum>Right.

00:21:41.190 --> 00:21:47.100
<v Aaron van Wirdum>And the goal for every new Bitcoin Core release is essentially to make this

00:21:47.100 --> 00:21:48.320
<v Aaron van Wirdum>a bit faster, I think.

00:21:48.560 --> 00:21:54.380
<v Sjors Provoost>Not for every Bitcoin Core release, but there's this repeating theme.

00:21:54.380 --> 00:21:59.560
<v Sjors Provoost>It's not even a goal. It's just that it gets better very often with little

00:21:59.560 --> 00:22:00.860
<v Sjors Provoost>changes or with bigger changes.

00:22:01.140 --> 00:22:03.980
<v Aaron van Wirdum>Yeah, well, actually, when we say better...

00:22:04.320 --> 00:22:04.940
<v Sjors Provoost>Faster.

00:22:04.940 --> 00:22:09.580
<v Aaron van Wirdum>Yeah, well when we say faster, and I guess this is part of the research, the

00:22:09.580 --> 00:22:13.260
<v Aaron van Wirdum>thing is, every… by the time there's new Bitcoin Core release the blockchain

00:22:13.260 --> 00:22:15.420
<v Aaron van Wirdum>itself has also become bigger.

00:22:15.420 --> 00:22:15.960
<v Sjors Provoost>Yes.

00:22:15.960 --> 00:22:21.760
<v Aaron van Wirdum>So does it actually take more time year over year to sync, or do the performance

00:22:21.760 --> 00:22:25.220
<v Aaron van Wirdum>improvements keep up? That’s sort of one of the questions.

00:22:25.220 --> 00:22:30.340
<v Sjors Provoost>I think there have been times when the performance improvements kept up. I don't

00:22:30.340 --> 00:22:31.280
<v Sjors Provoost>think that's the case anymore.

00:22:31.280 --> 00:22:31.900
<v Aaron van Wirdum>Right.

00:22:33.180 --> 00:22:37.040
<v Sjors Provoost>So it is getting worse. So there's a couple of things that are good. There's

00:22:37.040 --> 00:22:40.560
<v Sjors Provoost>Moore's law. That means new hardware is just faster. If you have a new computer,

00:22:40.680 --> 00:22:43.420
<v Sjors Provoost>you'll sync faster. If you have more RAM, you'll sync faster. If you have a

00:22:43.420 --> 00:22:49.120
<v Sjors Provoost>faster disk. And the other is these improvements. But in the long run, it's

00:22:49.120 --> 00:22:54.220
<v Sjors Provoost>very hard for them. I think when I looked at it in 2017, it was basically

00:22:54.220 --> 00:22:58.600
<v Sjors Provoost>just almost constant. Despite dramatic improvements in the performance of the

00:22:58.600 --> 00:23:04.130
<v Sjors Provoost>code, it was just getting... it was taking about as long. But of course, the

00:23:04.130 --> 00:23:08.330
<v Sjors Provoost>hardware is getting faster too. When Jameson and I were running these tests, we

00:23:08.330 --> 00:23:12.550
<v Sjors Provoost>were running the same modern hardware to run the tests on, just to have a bit of

00:23:12.550 --> 00:23:18.140
<v Sjors Provoost>a fair comparison. But I think people like Luke Dashjr have done projections on

00:23:18.140 --> 00:23:21.840
<v Sjors Provoost>it, like how long is it going to take until it actually starts getting faster

00:23:22.540 --> 00:23:27.300
<v Sjors Provoost>just based on Moore's law. And I think the estimates are like 2040 or later when

00:23:27.300 --> 00:23:32.500
<v Sjors Provoost>this growth in the blockchain is no longer as bad. They won't outpace anymore the

00:23:32.500 --> 00:23:33.060
<v Sjors Provoost>Moore's law.

00:23:39.540 --> 00:23:45.420
<v Aaron van Wirdum>Okay, sure. So tell our listeners something interesting about this.

00:23:45.460 --> 00:23:46.540
<v Aaron van Wirdum>How long does it take to sync?

00:23:46.880 --> 00:23:51.640
<v Sjors Provoost>So that really depends on your computer and how well you configure it, the

00:23:51.640 --> 00:23:54.800
<v Sjors Provoost>Bitcoin Core node. So with the default settings, it's not as fast as it can be.

00:23:55.580 --> 00:24:00.760
<v Sjors Provoost>There was a test by Jonas Schnelli, a former Bitcoin Core developer

00:24:00.760 --> 00:24:06.460
<v Sjors Provoost>and maintainer. And I think two years ago, he got an Apple M1

00:24:06.460 --> 00:24:12.400
<v Sjors Provoost>chip, one of those Mac minis. But he only had four gigabytes of RAM. And the

00:24:12.400 --> 00:24:16.480
<v Sjors Provoost>first time he tried it, he was able to sync the whole chain in 12 hours, I think.

00:24:16.700 --> 00:24:22.100
<v Sjors Provoost>And then somebody suggested a few better settings to him. And it was six hours.

00:24:22.650 --> 00:24:26.130
<v Sjors Provoost>So that was like state-of-the-art hardware six hours two years ago.

00:24:27.370 --> 00:24:31.250
<v Sjors Provoost>But if he had used more RAM, he might have been able to do it a little bit

00:24:31.250 --> 00:24:32.430
<v Sjors Provoost>faster, maybe in four hours.

00:24:33.880 --> 00:24:39.580
<v Sjors Provoost>But if you have a super slow Raspberry Pi, it might take you two or three weeks.

00:24:39.800 --> 00:24:40.320
<v Aaron van Wirdum>Sure.

00:24:40.620 --> 00:24:46.620
<v Sjors Provoost>And if you're running, say, a web server, so say you want to install a BTCPay

00:24:46.620 --> 00:24:52.510
<v Sjors Provoost>server somewhere, and you want on that server to sync the node from scratch, it's

00:24:52.510 --> 00:24:57.610
<v Sjors Provoost>going to take you weeks. Because these web servers typically are very low

00:24:57.610 --> 00:24:58.050
<v Sjors Provoost>performance.

00:24:59.370 --> 00:25:03.810
<v Sjors Provoost>Once it's caught up, it's fine. It'll catch up with all the new blocks. But

00:25:03.810 --> 00:25:08.350
<v Sjors Provoost>catching it up from the Genesis block, it has low memory, usually only has one or

00:25:08.350 --> 00:25:12.210
<v Sjors Provoost>two CPUs, and it's all virtual, so it's pretty horrible.

00:25:13.300 --> 00:25:17.760
<v Aaron van Wirdum>Yeah this is one of these things that you really kind of want to see in a graph

00:25:17.760 --> 00:25:23.600
<v Aaron van Wirdum>and I'll try to remember to include the links to the actual blog posts

00:25:23.600 --> 00:25:27.140
<v Aaron van Wirdum>in the show notes, but can you tell us anything interesting about the

00:25:27.140 --> 00:25:28.280
<v Aaron van Wirdum>improvements over the years?

00:25:28.680 --> 00:25:29.100
<v Sjors Provoost>Yeah.

00:25:29.160 --> 00:25:30.700
<v Aaron van Wirdum>How much has it improved?

00:25:30.980 --> 00:25:36.660
<v Sjors Provoost>Pretty dramatic. So one of the, like, I think Jameson found like a factor of 40,

00:25:36.920 --> 00:25:37.980
<v Sjors Provoost>depending on how you measure it.

00:25:38.320 --> 00:25:39.260
<v Aaron van Wirdum>40 since when?

00:25:39.480 --> 00:25:41.340
<v Sjors Provoost>Since these very old versions.

00:25:41.630 --> 00:25:45.160
<v Aaron van Wirdum>Since like 2012. 0.4 or whatever. Yeah. Okay.

00:25:45.620 --> 00:25:49.720
<v Sjors Provoost>But it's probably more than that. And there's a couple of reasons. I mean, some

00:25:49.720 --> 00:25:52.500
<v Sjors Provoost>of you might call cheating, but it's not because it actually improves the

00:25:52.500 --> 00:25:58.450
<v Sjors Provoost>experience for the user. So we did an episode about AssumeValid which is where

00:25:58.450 --> 00:26:03.930
<v Sjors Provoost>basically the developers pick a block that's before a release, and then the

00:26:03.930 --> 00:26:07.550
<v Sjors Provoost>Bitcoin Core node doesn't verify the signatures up until that block. It verifies

00:26:07.550 --> 00:26:11.350
<v Sjors Provoost>everything else, but not the signatures, and that saves, I don't know, a factor

00:26:11.350 --> 00:26:12.090
<v Sjors Provoost>two at least.

00:26:12.210 --> 00:26:15.070
<v Aaron van Wirdum>Yeah, well, I wouldn't call that cheating, but it's definitely a shortcut.

00:26:15.650 --> 00:26:20.350
<v Sjors Provoost>Yeah, I mean, you can turn it off if you don't like it for all these reasons, but

00:26:20.350 --> 00:26:25.760
<v Sjors Provoost>it speeds things up a lot. Another improvement was, well, we talked about it,

00:26:25.860 --> 00:26:29.920
<v Sjors Provoost>LevelDB. So switching from BerkeleyDB, the database that had all these problems,

00:26:30.270 --> 00:26:32.330
<v Sjors Provoost>but it was also slower to LevelDB.

00:26:32.590 --> 00:26:37.530
<v Aaron van Wirdum>By the way, you just mentioned, sorry, I'm interrupting you, but on the previous

00:26:37.530 --> 00:26:41.990
<v Aaron van Wirdum>point, you mentioned AssumeValid, but Jameson actually did not.

00:26:43.030 --> 00:26:43.790
<v Sjors Provoost>No, exactly.

00:26:43.480 --> 00:26:47.550
<v Aaron van Wirdum>[unclear] AssumeValid, right? He intentionally left that out for the reason that

00:26:47.550 --> 00:26:51.890
<v Aaron van Wirdum>it is a shortcut, and he wants to make a fair comparison, which I think that's

00:26:51.890 --> 00:26:52.590
<v Aaron van Wirdum>how I would have done it.

00:26:52.610 --> 00:26:53.930
<v Sjors Provoost>Yeah, it's a reasonable thing, and that's also what I did.

00:26:54.030 --> 00:26:58.630
<v Aaron van Wirdum>So you mentioned a 40x improvement, but that's without AssumeValid. So with

00:26:58.630 --> 00:27:00.110
<v Aaron van Wirdum>AssumeValid, it would be even more.

00:27:00.210 --> 00:27:04.910
<v Sjors Provoost>Yeah, exactly. I think so. And I did that in my blog post from 2017. I did two

00:27:04.910 --> 00:27:08.150
<v Sjors Provoost>things. I think I showed the difference between AssumeValid and Not AssumeValid,

00:27:08.150 --> 00:27:12.340
<v Sjors Provoost>and it was quite dramatic. And then I also showed... the differences you know,

00:27:12.340 --> 00:27:16.440
<v Sjors Provoost>with AssumeValid turned off between the older and the newer versions which is

00:27:16.440 --> 00:27:19.880
<v Sjors Provoost>also dramatic. So in terms of things that were improved, like we said,

00:27:19.880 --> 00:27:24.840
<v Sjors Provoost>AssumeValid, LevelDB. Another thing is uh, this is done many many years ago, as

00:27:24.840 --> 00:27:29.670
<v Sjors Provoost>validating signatures in parallel. So if you're if you're validating a block, one

00:27:29.670 --> 00:27:33.030
<v Sjors Provoost>of the things you need to do is actually check the signatures. And if you have

00:27:33.030 --> 00:27:36.790
<v Sjors Provoost>multiple processor cores on your computer, which you probably do, one of the

00:27:36.790 --> 00:27:40.290
<v Sjors Provoost>improvements was just to make these multiple processors verifying multiple

00:27:40.290 --> 00:27:41.530
<v Sjors Provoost>signatures at the same time.

00:27:41.890 --> 00:27:45.610
<v Aaron van Wirdum>Right. So that obviously doesn't help if you use AssumeValid, or at least it

00:27:45.610 --> 00:27:50.870
<v Aaron van Wirdum>doesn't help until that AssumeValid… But after that it works, or if you have...

00:27:50.770 --> 00:27:53.790
<v Aaron van Wirdum>AssumeValid switched off, then it helps as well.

00:27:53.790 --> 00:27:57.070
<v Sjors Provoost>In general, when you're syncing the node, you'll notice with the default

00:27:57.070 --> 00:28:03.010
<v Sjors Provoost>settings, you'll notice in the beginning it's mostly disk usage. And then after

00:28:03.010 --> 00:28:05.150
<v Sjors Provoost>a while, your CPU starts getting really hot.

00:28:06.490 --> 00:28:10.610
<v Sjors Provoost>When you go past the AssumeValid block, your CPU starts running at 100% and gets

00:28:10.610 --> 00:28:11.050
<v Sjors Provoost>really hot.

00:28:11.170 --> 00:28:11.390
<v Aaron van Wirdum>Right.

00:28:11.670 --> 00:28:13.870
<v Sjors Provoost>Because then it has to validate all these signatures.

00:28:15.410 --> 00:28:19.350
<v Sjors Provoost>Another thing that was done that was probably at least marginal, but maybe even

00:28:19.350 --> 00:28:25.110
<v Sjors Provoost>more, is just the download blocks in parallel. So rather than getting one block

00:28:25.110 --> 00:28:28.450
<v Sjors Provoost>at a time, you would get more of them at the same time from multiple peers.

00:28:28.690 --> 00:28:29.010
<v Aaron van Wirdum>Right.

00:28:29.970 --> 00:28:33.710
<v Sjors Provoost>We talked about that. The other, I think it was almost a 5X improvement, was

00:28:33.710 --> 00:28:39.510
<v Sjors Provoost>getting rid of OpenSSL and using libsecp256k1 that we did a whole

00:28:39.510 --> 00:28:40.050
<v Sjors Provoost>episode on.

00:28:40.530 --> 00:28:44.330
<v Aaron van Wirdum>Oh, yeah. So we haven't mentioned that, but so that's an entirely, like that's a

00:28:44.330 --> 00:28:46.870
<v Aaron van Wirdum>Bitcoin native library, right?

00:28:47.090 --> 00:28:47.330
<v Sjors Provoost>Yeah.

00:28:47.430 --> 00:28:48.630
<v Aaron van Wirdum>Am I describing that right?

00:28:48.850 --> 00:28:54.190
<v Sjors Provoost>Yeah. It's basically, instead of using OpenSSL for all the signatures, it uses

00:28:54.190 --> 00:29:00.080
<v Sjors Provoost>libsecp, which Pieter Wuille wrote at the time. And it was initially designed as

00:29:00.080 --> 00:29:03.880
<v Sjors Provoost>a performance improvement, but it also helped dealing with these bugs that we

00:29:03.880 --> 00:29:06.670
<v Sjors Provoost>just talked about. So kind of nice...

00:29:06.670 --> 00:29:12.290
<v Aaron van Wirdum>Yeah, so we got rid of OpenSSL altogether, and that's also a performance

00:29:12.290 --> 00:29:13.490
<v Aaron van Wirdum>improvement. It's also faster.

00:29:13.770 --> 00:29:18.390
<v Sjors Provoost>Yes, exactly. Another thing that happened in, I think, 2017 was that the UTXO

00:29:18.390 --> 00:29:24.370
<v Sjors Provoost>database, just the database structure was changed. If you structure

00:29:24.370 --> 00:29:26.730
<v Sjors Provoost>a database in a more intelligent way, it can perform better.

00:29:26.970 --> 00:29:27.410
<v Aaron van Wirdum>Right.

00:29:27.710 --> 00:29:33.660
<v Sjors Provoost>That, I think, was in turn the cause of... this very scary

00:29:33.660 --> 00:29:39.560
<v Sjors Provoost>inflation bug in 2018. So, you know, it's nice to improve

00:29:39.560 --> 00:29:43.240
<v Sjors Provoost>performance, but you want to be extremely careful. But I think this performance

00:29:43.240 --> 00:29:46.540
<v Sjors Provoost>improvement was actually necessary because the performance was so bad that

00:29:46.540 --> 00:29:49.660
<v Sjors Provoost>somebody could attack Bitcoin by exploiting the bad performance.

00:29:50.400 --> 00:29:51.640
<v Aaron van Wirdum>Right. How?

00:29:51.840 --> 00:29:55.920
<v Sjors Provoost>By just creating very unfavorable transactions so that nodes get slower and

00:29:55.920 --> 00:29:56.700
<v Sjors Provoost>slower and slower.

00:30:00.110 --> 00:30:05.510
<v Aaron van Wirdum>That would get so slow that it takes longer to verify a block than to create a

00:30:05.510 --> 00:30:06.070
<v Aaron van Wirdum>block, essentially.

00:30:06.230 --> 00:30:10.050
<v Sjors Provoost>I guess that would be the absolute worst case. I don't... I mean, not to... I

00:30:10.050 --> 00:30:13.810
<v Sjors Provoost>mean, yeah, blocks come in every 10 minutes, so if a node cannot verify a block

00:30:13.810 --> 00:30:16.590
<v Sjors Provoost>within 10 minutes, you're doomed. I don't think it was that bad.

00:30:17.020 --> 00:30:21.620
<v Aaron van Wirdum>Well, there were some older clients. I read this maybe in a Reddit comment under

00:30:21.620 --> 00:30:25.940
<v Aaron van Wirdum>one of these blog posts that some of the very old clients would actually have

00:30:25.940 --> 00:30:30.100
<v Aaron van Wirdum>that problem now. They couldn't sync because it just takes too long to

00:30:30.100 --> 00:30:35.160
<v Aaron van Wirdum>download and verify a block. And by that time, there's more blocks.

00:30:35.420 --> 00:30:38.380
<v Sjors Provoost>Yeah, I would not be surprised. And keep in mind that these would also be running

00:30:38.380 --> 00:30:44.030
<v Sjors Provoost>on older hardware. So if you started a node and you put it in your

00:30:44.030 --> 00:30:48.510
<v Sjors Provoost>nuclear bunker and you can't get back into your nuclear bunker, then at some

00:30:48.510 --> 00:30:54.500
<v Sjors Provoost>point it's just not going to be able to keep up anymore. But, you know, let's see

00:30:54.500 --> 00:30:58.180
<v Sjors Provoost>another one. There's lots of very small improvements. There's not even a complete

00:30:58.180 --> 00:31:03.410
<v Sjors Provoost>list of them. For example, part of the block consists of checking hashes. It's

00:31:03.410 --> 00:31:09.150
<v Sjors Provoost>SHA-256 hashes. And it turns out that many modern computer chips have special

00:31:09.150 --> 00:31:13.210
<v Sjors Provoost>instructions on them to do SHA-256. They don't have those instructions because

00:31:13.210 --> 00:31:17.450
<v Sjors Provoost>the chip makers like Bitcoin, but because SHA-256 is used in a lot of places.

00:31:17.680 --> 00:31:18.080
<v Aaron van Wirdum>Right.

00:31:18.250 --> 00:31:22.770
<v Sjors Provoost>And so if you actually take advantage of those special instructions, which

00:31:22.770 --> 00:31:26.720
<v Sjors Provoost>involves writing some machine code... then it'll get faster. And I think very

00:31:26.720 --> 00:31:32.720
<v Sjors Provoost>recently, one of those things was done for ARMv8 chips, which are used

00:31:32.720 --> 00:31:37.480
<v Sjors Provoost>in Raspberry Pis, but also used in the Apple M1 chip. So that'll probably speed it up.

00:31:37.560 --> 00:31:42.420
<v Aaron van Wirdum>But you're talking about hardware now. Has there been Bitcoin Core codes released

00:31:42.420 --> 00:31:43.560
<v Aaron van Wirdum>that takes advantage of this?

00:31:43.740 --> 00:31:49.530
<v Sjors Provoost>Yeah, exactly. So when a specific chip has a feature

00:31:49.530 --> 00:31:52.790
<v Sjors Provoost>that could make Bitcoin Core faster, then Bitcoin Core developers could if they

00:31:52.790 --> 00:31:57.410
<v Sjors Provoost>want to write special machine code for that chip. So the software, when you

00:31:57.410 --> 00:31:59.610
<v Sjors Provoost>compile it, will just check whether or not you have this chip.

00:32:01.250 --> 00:32:04.630
<v Aaron van Wirdum>And they did, or you're not sure?

00:32:05.210 --> 00:32:09.050
<v Sjors Provoost>Yeah, they have. I mean, it's been done over time for different chips, for

00:32:09.050 --> 00:32:10.130
<v Sjors Provoost>different optimizations.

00:32:10.330 --> 00:32:10.610
<v Aaron van Wirdum>Got it.

00:32:10.790 --> 00:32:14.750
<v Sjors Provoost>So the most recent one I'm aware of is for this ARMv8, which I think is what's

00:32:14.750 --> 00:32:20.010
<v Sjors Provoost>used by the Apple M1 and by many modern Raspberry Pis, maybe not the old ones.

00:32:21.990 --> 00:32:27.970
<v Sjors Provoost>Another thing, I don't know, some magic math thing in libsecp

00:32:27.970 --> 00:32:31.190
<v Sjors Provoost>that made 15% faster signature validation.

00:32:32.530 --> 00:32:36.950
<v Sjors Provoost>Those things, I can't review them because I just see magic. The only thing I can

00:32:36.950 --> 00:32:40.270
<v Sjors Provoost>see is like, hey, the test still passed and I can still sync the blockchain

00:32:40.270 --> 00:32:42.850
<v Sjors Provoost>without getting a consensus error. So I guess it's correct.

00:32:44.690 --> 00:32:50.110
<v Aaron van Wirdum>I think SegWit could be considered an improved... Well...

00:32:50.540 --> 00:32:55.180
<v Sjors Provoost>No, it's a mitigation of not making it worse. So the block size was increased

00:32:55.180 --> 00:32:59.900
<v Sjors Provoost>with SegWit, but the damage caused by that block size increase was mitigated

00:32:59.900 --> 00:33:04.440
<v Sjors Provoost>because the SegWit rules put some restrictions on the transaction they can put

00:33:04.440 --> 00:33:09.200
<v Sjors Provoost>into it. Because basically, I think there's some things that you can do in

00:33:09.200 --> 00:33:14.060
<v Sjors Provoost>transactions that take quadratic time to validate. So if you add five of these

00:33:14.060 --> 00:33:18.740
<v Sjors Provoost>things, it's 25 times more expensive to verify it. And I think SegWit got rid of

00:33:18.740 --> 00:33:22.380
<v Sjors Provoost>those problems so that you can double the block size and only double the time it

00:33:22.380 --> 00:33:27.760
<v Sjors Provoost>takes to validate rather than quadruple or, you know, [unclear] the time it takes to validate.

00:33:27.760 --> 00:33:31.640
<v Aaron van Wirdum>Well, that's not what I was referring to. What I was referring to, actually, this

00:33:31.640 --> 00:33:35.580
<v Aaron van Wirdum>was one of the things that Lopp mentioned in his blog post is that actually older

00:33:35.580 --> 00:33:40.700
<v Aaron van Wirdum>nodes will sync faster post the SegWit activation point.

00:33:40.820 --> 00:33:43.160
<v Sjors Provoost>Well, because they don't verify any of the signatures for SegWit.

00:33:43.280 --> 00:33:47.370
<v Aaron van Wirdum>Right. But it still counts, don't you think? Well, it's also kind of a shortcut.

00:33:47.890 --> 00:33:51.650
<v Sjors Provoost>Yeah, but I mean, if you want to go that route, I can think of some even scarier

00:33:51.650 --> 00:33:55.670
<v Sjors Provoost>proposals where we just, you know, make all the blocks empty for all nodes and

00:33:55.670 --> 00:33:57.550
<v Sjors Provoost>just put the real transaction somewhere else.

00:33:58.490 --> 00:34:01.970
<v Aaron van Wirdum>Well, yeah, now that you mentioned empty blocks, that's also maybe interesting to

00:34:01.970 --> 00:34:02.430
<v Aaron van Wirdum>mention.

00:34:02.590 --> 00:34:04.370
<v Sjors Provoost>That's definitely a way to make really fast validation.

00:34:05.190 --> 00:34:10.430
<v Aaron van Wirdum>At the first I think, 200,000 blocks, so basically, the first four years, for the

00:34:10.430 --> 00:34:13.850
<v Aaron van Wirdum>first four years it doesn't really matter that much which node you're running

00:34:13.850 --> 00:34:16.370
<v Aaron van Wirdum>because all blocks were empty anyways, right?

00:34:16.370 --> 00:34:21.430
<v Sjors Provoost>Yeah, I'm sure it got a little bit better. The the newer nodes are even better at

00:34:21.430 --> 00:34:22.430
<v Sjors Provoost>running through empty blocks.

00:34:22.430 --> 00:34:23.310
<v Aaron van Wirdum>Yeah, but but…

00:34:23.310 --> 00:34:26.350
<v Sjors Provoost>Generally when you start up a node, the first couple hundred thousand blocks will

00:34:26.350 --> 00:34:29.830
<v Sjors Provoost>fly by in 15 minutes, and then it just starts taking a really long time.

00:34:29.830 --> 00:34:33.660
<v Aaron van Wirdum>Yeah, exactly. All right, well, so you've listed a number of performance

00:34:33.660 --> 00:34:37.280
<v Aaron van Wirdum>improvements over time. And do you want to keep going?

00:34:37.580 --> 00:34:38.900
<v Sjors Provoost>No, that was the whole list I had.

00:34:39.040 --> 00:34:39.300
<v Aaron van Wirdum>Okay.

00:34:39.500 --> 00:34:40.580
<v Sjors Provoost>But there's probably more out there.

00:34:42.570 --> 00:34:46.790
<v Aaron van Wirdum>Yeah, Bitcoin Core developers are squeaking out… squeezing out new improvements.

00:34:47.250 --> 00:34:50.930
<v Sjors Provoost>Yeah, but it's getting more and more marginal. I mean, if you make a 5%

00:34:50.930 --> 00:34:55.930
<v Sjors Provoost>improvement, but the chain gets 20% bigger, then it's not enough.

00:34:57.790 --> 00:35:00.470
<v Aaron van Wirdum>Okay, Sjors, well. I guess that's the podcast then or not?

00:35:00.730 --> 00:35:05.930
<v Sjors Provoost>Yep, I think so. So thank you for listening to Bitcoin Explained.

00:35:07.470 --> 00:35:08.210
<v Aaron van Wirdum>There you go.

