Episode 93: The Great Consensus Cleanup Revival (And an Update on the Tornado Cash and Samourai Wallet Arrests)
Ep. 93

Episode 93: The Great Consensus Cleanup Revival (And an Update on the Tornado Cash and Samourai Wallet Arrests)

•

Episode description

In this episode of Bitcoin, Explained, Aaron and Sjors discuss the Great Consensus Cleanup Revival soft fork(s). This proposal would fix some known bugs in the Bitcoin protocol, specifically the timewarp vulnerability, large block validation times, 64 byte transactions and BIP 30 verification.

Sjors also provides a quick update on the court case against Tornado Cash developer Alexey Pertsev, and places this in the context of the recent arrests of Samourai Wallet developers Keonne Rodriguez and William Hill.

Chapters

00:00:00 Introduction and COLDCARD sponsor
00:01:49 Tornado Cash conviction and developer liability
00:07:13 Samourai Wallet arrests, Whirlpool and Ricochet
00:13:40 The Great Consensus Cleanup Revival
00:16:49 Timewarp attacks and the proposed fix
00:26:47 Slow scripts and block validation limits
00:32:49 64-byte transactions and Merkle tree ambiguity
00:45:04 Duplicate coinbases: BIP 30 and BIP 34
00:48:27 Soft fork activation and future Bitcoin upgrades

===

This episode’s sponsor: CoinKite, maker of the ColdCard

Aaron’s Twitter: @AaronvanW

Aaron’s Nostr: npub1art8cs66ffvnqns5zs5qa9fwlctmusj5lj38j94lv0ulw0j54wjqhpm0w5

Sjors’ Twitter: @provoost

Sjors’ Nostr: npub1v25jqj332n630klwtqeqxgyrjl4alw4phmluhu2x6lcxzwy9m03suqexw3

If you’d like to sponsor the show, please email info at bitcoinexplainedpodcast.com.

https://bitcoinexplainedpodcast.com/

Transcript

Download transcript (.vtt)
0:19

Aaron van Wirdum Live from Utrecht, this is Bitcoin,

0:22

Sjors Provoost Explained.

0:23

Aaron van Wirdum Sjors, it's been a month. That means you had a whole month to think about this poem that you told me you're going to tell our dear listeners for this episode. Let's hear it. Let's hear it.

0:35

Sjors Provoost That's right. So it's cold outside. The government is cold. You know what else is cold?

0:42

Aaron van Wirdum Sjors, our sponsor.

0:44

Sjors Provoost That's right.

0:45

Aaron van Wirdum The COLDCARD. The COLDCARD. If you have coins, you want to store them. COLDCARD is the place for that. Is the audio okay? Are we too loud?

0:53

Sjors Provoost It's too much echo.

0:54

Aaron van Wirdum Too much echo? Okay, uh, COLDCARD COLDCARD COLDCARD COLDCARD COLDCARD COLDCARD I think that was like our 20 seconds that we're obligated to talk about the COLDCARD. What do you think?

1:09

Sjors Provoost I think it's great, but it's a hardware wallet, for people who don't know.

1:12

Aaron van Wirdum Yes. Why did you say the government is cold?

1:15

Sjors Provoost Well, that's a segue to our next section.

1:18

Aaron van Wirdum So this episode we're going to talk about the Great Consensus Cleanup Revival, which is a proposed soft fork, which sort of includes several soft forks into one, you could kind of argue, right? Basically, that's what it comes down to. But before that, a lot has happened in the Bitcoin and Ethereum space in a way that's relevant to Bitcoin as well. So you want to touch on that a little bit first. You've been following it pretty closely. Let's start with... Where do we start? Let's start with what happened with Tornado Cash in the Netherlands.

1:56

Sjors Provoost Yeah, in case anybody was living under a rock, the Tornado Cash, we talked about that in episode 69. But he got convicted, so that's bad.

2:08

Aaron van Wirdum Yeah, Alexey Pertsev, one of the Tornado Cash developers, got convicted for 64 months in prison.

2:15

Sjors Provoost Yep.

2:16

Aaron van Wirdum Which does seem to have a lot of relevance for Bitcoin because... really he was just writing codes, uh, you know, he was writing privacy code, but he was never… Maybe you should give the context. Well, why do you think it's relevant for Bitcoin?

2:30

Sjors Provoost Well, the main point of relevance for us, I think, is the fact that he was building a non-custodial system. So a system that does not hold the coins yourself. I mean, there's a website and those kind of tools. So that's a very dangerous precedent, I think, because it's not very clear where that line is.

2:49

Aaron van Wirdum Yeah, we already knew that running a custodial mixer, which a lot of other mixers were, where you just send coins to someone and that someone sends different coins back. That was always illegal, and everyone knew that was illegal. If you're doing that, that's basically money laundering, and that is illegal.

3:05

Sjors Provoost Well, I think you can narrow it down slightly. It's not illegal to mix the coins, but it is when you don't do KYC, I guess. That's maybe a different interpretation.

3:15

Aaron van Wirdum Right.

3:15

Sjors Provoost But for all practical purposes, you can't build a mixer with KYC in an ethical way anyway. So it, you know, effectively mixers are illegal, but technically I think the the non-KYC part of the mixer is what makes it illegal.

3:30

Aaron van Wirdum Fair enough. In either case, so far it was generally assumed that, yeah, if you're taking coins and they're sending other coins, then you you're at risk, but if you're just developing software which allows other people to send their coins to other people, then, you know, that that then you're not the one money laundering. However, the Dutch court just struck that down. And now it looks like, nope, just developing code can make you responsible for how other people use that code, right?

3:58

Sjors Provoost Well, probably, but we don't really know because this verdict was extremely unclear about that. So we don't know if it's simply the act of writing code or it is the, you know... making that code available on your own website, or making that code available on some automatic website-like system, or whether it's about maintaining this code after you've written it once, or if it's about promoting the code or making money from the code, it's very unclear. And in fact, the prosecutor seemed to emphasize making money from the code, but the judge much less so.

4:33

Aaron van Wirdum Yeah, the prosecutor really... honed down on it essentially being a business. And that's why you say the making money part was important. But the judge didn't even really seem to focus on that. The judge just said, look, if you write this code knowing that it can be used for this purpose and you don't do anything to stop that, then you're responsible if it's really used for that purpose, right?

4:57

Sjors Provoost Yeah, pretty much.

4:58

Aaron van Wirdum The purpose here, of course, being money laundering.

5:01

Sjors Provoost Yeah, what was especially interesting, though not clear entirely how that's going to apply to Bitcoin, was the argument that... he made the whole thing unstoppable. So in Ethereum, part of the system at least is unstoppable. It's a smart contract, unless you stop Ethereum itself, of course. And the fact that he did that, where the prosecutor just tried to argue, well, it's not all decentralized. Some of it is fake decentralization. Others is real. The judge completely ignored that and basically said, well, the fact that you even tried to make it decentralized, that is actually making it worse. And that argument, of course, can apply extremely broadly because you could say, well, if you just publish source and you know that other people are using that source and you just keep updating that source code, well, that's also kind of unstoppable in a way.

5:46

Aaron van Wirdum Yeah.

5:47

Sjors Provoost So that might also be a problem. And of course, we all know somebody, or we don't know them, somebody who created an unstoppable system a long time ago and kept working on it.

5:59

Aaron van Wirdum So you're referring to Satoshi Nakamoto.

6:01

Sjors Provoost Exactly. So we're waiting for his arrest warrant, I guess.

6:04

Aaron van Wirdum Yeah, well, the short way of looking at it, I would say, is we all thought so far that there was a fairly clear line of what would make you, you know, what would be… what would make you responsible, which is custody in a way. And now it's kind of an all bets are off type of situation.

6:25

Sjors Provoost Yeah, and this creates a bit of a problem because we assumed that this line existed, we did not do much to defend people who built custodial mixers. And in retrospect, that was probably a mistake because as soon as you lose that line of defense, now... I guess the only way to win now is to go all the way back and say, no, all mixers should be legal, including custodial ones. But now you have all this precedent that wasn't stopped. So that's a problem.

6:51

Aaron van Wirdum Right. Okay, let's move on to the actual Bitcoin case, which is the Samourai devs.

7:00

Sjors Provoost And just add one little detail. As far as I know, he is going to appeal. So we'll see what happens. And appeals can quite dramatically change things.

7:09

Aaron van Wirdum Yeah, is there any timeline?

7:11

Sjors Provoost I don't know.

7:13

Aaron van Wirdum Okay, so let's move to the more Bitcoin relevant case.

7:16

Sjors Provoost The more direct Bitcoin case.

7:18

Aaron van Wirdum Yeah, exactly. So the Samourai wallet developers, Keonne Rodriguez and Bill Hill, William Hill. Both of them you know, right?

7:29

Sjors Provoost Yep, yeah. I used to work with them when I was at blockchain.com. Back in time, blockchain.info.

7:35

Aaron van Wirdum Right, so they were arrested as well. One of them in Portugal, one of them in the United States, but both on, uh, behalf of the Department of Justice. Justice, DOJ. Uh, so, how… What what do you want to say about that, if anything? How…

7:52

Sjors Provoost Well, I'm not surprised that this happened, because, you know, the fact that, uh, they were going after Tornado Cash made it clear that they would go after non-custodial systems after non-custodial mixer. So it seemed like a matter of time before they would go after it. And then obviously they always go after the biggest or at least a big one. So the only question was, were they going to go after Wasabi or were they going to go after Samourai? Samourai has some interesting marketing that maybe made them more interesting to prosecute, but I don't know if the difference, you know, and of course we know that Wasabi was doing some proactive compliance-ish things. But I don't know why they picked one and the other. Ultimately, we'll find out. What else was I going to say about it?

8:40

Aaron van Wirdum Well, it was my suggestion to just sort of explain how the Samourai mixing actually worked. But at this point, should we just move on to the main topic of the episode?

8:52

Sjors Provoost No, I think it may make sense to briefly explain a little bit. So there's three aspects to Samourai Wallet, I think, that are relevant. But one is it's not just a mixer. Definitely not. It's a wallet, right? It's a non-custodial wallet. And so far, it seems that that wallet was taken down mostly as a side effect of taking the mixer down, not as a direct target. But it is down. But fortunately, it was a non-custodial wallet and people wrote down their 12 words, hopefully. And so they should be fine because they can just import it into another wallet. But there was also a mixer component. I think the two most important parts of that are something called the Whirlpool, which is a five input, five output mixer that you can use multiple times.

9:37

Aaron van Wirdum Yeah, it's just a CoinJoin which uses equal amounts.

9:41

Sjors Provoost Yeah. And then there is something called Ricochet, which basically just, as far as I understand it, just forwards your coins a couple of times. So you're making a couple of unnecessary transactions and then you send the amount that you want to send. And that might help when you're dealing with an exchange that only looks at, say, five hops ago or two hops ago. then maybe you can get around that. I don't know how effective any of these things are.

10:06

Aaron van Wirdum Yeah, you're basically making transactions to yourself a couple times.

10:09

Sjors Provoost Yeah, now it should be noted that from my reading of the indictment, they don't even talk about whether or not these tools, these mixing tools were effective or not. They just, you know, the fact that it's doing any mixing, that is the problem. So that's something to keep in mind.

10:26

Aaron van Wirdum Yeah, I would say the Ricochet one, the fact that that one is even mentioned, is blatantly absurd. Like, every wallet, with every wallet you can send coins to yourself. This is just a button that just sort of automates that you do that a couple of times.

10:42

Sjors Provoost Exactly.

10:43

Aaron van Wirdum That this is even… Like, the other, the Whirlpool, I can sort of at least understand why it's seen as some… I mean, I don't agree with…

10:51

Sjors Provoost Well, the Whirlpool requires coordinating with other users, right? Whereas the Ricochet thing does not. It's just your wallet sending a transaction to itself essentially five times in a row.

11:01

Aaron van Wirdum Yeah, which again, literally every wallet can do.

11:04

Sjors Provoost But I would be very surprised if in the court case they're going to debate the specific details of what is and what is not mixing. My guess is they just go go with the marketing. They say, well, you guys called it a mixer, and that's all we care about.

11:22

Aaron van Wirdum Right, anyways. Yeah, seems like a new era in Bitcoin and Bitcoin development to me.

11:32

Sjors Provoost Yeah, and I think we could briefly do a recap of the differences, how these cases relate to each other. So we brought up most of the things. So the interesting thing about Samourai is that it's only happening in the US, whereas the Tornado Cash trial is happening in the US and the Netherlands in parallel, which is interesting.

11:50

Aaron van Wirdum Yeah, you didn't mention that yet, but yeah, one of the other... Tornado Cash co-founders was arrested in the US and will be on trial there.

11:59

Sjors Provoost Yeah, and this is interesting because the Dutch court system is not very transparent. You can go to the court hearings, but you don't get to see any of the dossier. Whereas in the US, it's much more transparent. So we'll probably learn much more about the Dutch case through the US case. Both of them are non-custodial. Both of them use a... Well, no. So the Samourai uses a central coordinator. So that might be a service. Whereas in Tornado Cash, it's a smart contract. So that's not really a service. Although the prosecutor argued that it's a service anyway.

12:36

Aaron van Wirdum You mean the main smart contract?

12:39

Sjors Provoost Yeah, the main smart contract and everything around it. You could argue like it's an autonomous system, so it's not really a service, but that's what they're arguing, I think, in both the Netherlands and the U.S. against or for, depending on which side you're at. I'd say Samourai used fees, fairly, pretty direct fee system, whereas the... Tornado Cash system did not charge fees directly. At least the fees don't go directly to the developers or operators. They have a more convoluted tokenomic system where at least the prosecutor argued that these tokenomics are, you know, how it is how the business works.

13:19

Aaron van Wirdum I think the short summary I would give is if the Tornado Cash developer is guilty in the Netherlands, which he is, then the Samourai developers have to be as well. So it's sort of even more straightforward.

13:34

Sjors Provoost Exactly. Samourai is a simpler case.

13:37

Aaron van Wirdum Right. So, yeah, bad news. Let's move on to our actual topic for the podcast. What do you think?

13:45

Sjors Provoost Yeah, also some bad news in a way.

13:48

Aaron van Wirdum Yeah, but bad news that we're gonna fix, right?

13:50

Sjors Provoost Sure. Yeah, exactly, that we hopefully fix in time.

13:53

Aaron van Wirdum So we're gonna talk main topic of the of the podcast. Finally we're here. We're here, ladies and gentlemen. We're gonna talk about the Great Consensus Cleanup, or maybe more specifically the Great Consensus Cleanup Revival. That's right, because the Great Consensus Cleanup was proposed by Matt Corallo a couple years ago and was recently revived by Antoine Poinsot. Am I saying that right?

14:19

Sjors Provoost Probably.

14:20

Aaron van Wirdum It was him, right? I got the person right, at least, whether I got the name pronunciation right… Well, yeah, not sure about that one. Uh, and the Great Consensus Cleanup Revival, maybe what's the difference between the original and the revival? Is there a difference?

14:39

Sjors Provoost Yeah, there is. So the revival adds something, and I guess I'll let you know when we get to that new bit.

14:46

Aaron van Wirdum Okay, and as far as I understand, the great consensus cleanup would be, well, would basically be one soft fork that bundles several soft forks, and these soft forks sort of fix existing bugs in the protocol.

15:01

Sjors Provoost Yeah, there could be individual soft forks, and in the worst case, maybe out of the four components, people really like three of them and are kind of arguing about the fourth one, then you can simply do three and not do the other one.

15:14

Aaron van Wirdum Okay, and if I understand correctly, basically everyone, and when I say everyone, I mean everyone that has enough expertise to have an opinion in the first place, agrees that at least the bugs are problems. there's maybe at most like some conversation about the best way to solve these problems, whether these are the best ways. But the problems are real. There's no one that says, no, these are actually features, right? These are just real problems, bugs that exist in the Bitcoin protocol.

15:44

Sjors Provoost I think when it comes to the time warp attack, there might have been someone who could think of some interesting schemes that you can do using a time warp attack.

15:53

Aaron van Wirdum That's right. Yeah, you're thinking of Mark Friedenbach, who had some sort of proposal years ago to sort of increase the block size. And yes, yeah, yeah, you're right, but let's…

16:03

Sjors Provoost Every bug is a feature.

16:04

Aaron van Wirdum Yeah, let's table that for a second. Although, I mean, it is interesting that you bring that up.

16:08

Sjors Provoost But, well, I mean, that won't work if somebody exploits the time warp maliciously before the legitimate use case happens, I think.

16:20

Aaron van Wirdum Well, is the legitimate use case still possible after this bug would be fixed?

16:25

Sjors Provoost Actually, I'm not sure.

16:26

Aaron van Wirdum Probably not, right?

16:27

Sjors Provoost We'll show that. So there may be, you know, as always, there may be some ways that you could use this to your advantage. I think it's better to fix them.

16:35

Aaron van Wirdum Yeah. Okay. And so there are basically four bugs, right? There are four bugs. There are four things that this would solve.

16:43

Sjors Provoost That's right. Plus an open invitation to anyone who knows another bug.

16:49

Aaron van Wirdum Okay, so four. Let's start with the first one. So the first one, you already mentioned it, the time warp attack, the time warp problem, what do we call this?

16:58

Sjors Provoost Yeah, the time warp attack.

17:00

Aaron van Wirdum Yeah, and so it's about the the time warp… The time warp attack is possible now and we're talking about fixing that that is possible. Like, that shouldn't be possible, essentially, right?

17:10

Sjors Provoost That's right. And we did an earlier episode about the time warp attack. It's episode number five, so scroll all the way back.

17:17

Aaron van Wirdum That's a long time back.

17:18

Sjors Provoost Where we explain how it works, I think. I didn't listen back to it. Um, but basically, I mean, the TL;DR is that you can mess with the timestamps in every block. So miners can, you know, Bitcoin is not a clock contrary to popular belief, but blocks do have a timestamp in it. And this timestamp cannot, I mean, the miner can pick this timestamp however they want, but there are a few restrictions on it based on earlier possible attacks. One of the restrictions is that it cannot be more than two hours in the future as determined when you receive the block. The other rule is that every, I think it's the rolling average or the median, I should say, of the last 11 blocks has to go up by one second every block. And so basically, the block time has to go up a little bit and it can't be too far in the future. Those are the only two restrictions, but it turns out you can still mess with the system with those two rules.

18:17

Aaron van Wirdum How so?

18:19

Sjors Provoost Well, you can basically fool the system. I think we need to explain another related bug here first, which is how the difficulty adjustment works. So the goal of the system is to keep one block every 10 minutes, and this is achieved by looking at the last block in the difficulty adjustment period and comparing it to the first block in that period, and then dividing it by 2016. And there are multiple problems with that, but the biggest one is that you are not comparing the first block of each period to the first block of each last period. You're comparing the first block of a period to the last block of a period. And that allows you to kind of mess around the edges.

19:08

Aaron van Wirdum Oh, yeah. Okay. So how do you mess around the edges?

19:12

Sjors Provoost Well, one thing you can do here is you can increase the timestamp of... Basically, you increase the timestamp of every block as little as possible. So the entire two-week period... will look like it's only a few minutes, basically.

19:28

Aaron van Wirdum Yeah, and to be clear, this would require a majority of miners to collaborate, right?

19:33

Sjors Provoost Yeah, the time warp attack is a 51% attack, basically, or requires a 51% attack.

19:39

Aaron van Wirdum So a majority of miners is faking the timestamps, and all nodes on the network will accept this because it's not breaking the rules. The nodes are just looking, is this block mined in the future? And is it mined at least one second previously, later than like the 11 blocks before?

19:58

Sjors Provoost Exactly.

19:59

Aaron van Wirdum So then you can mine, you can fake the timestamps to make every blocks look like it was all mined within the same minutes, basically.

20:06

Sjors Provoost Yeah.

20:06

Aaron van Wirdum Like a whole period mined within the same minute.

20:08

Sjors Provoost Why would you want to do that? Well, there's another part of this attack, which is where you take the last block of the difficulty adjustment period, and there you don't lie. You just put it two hours in the future or right now. It doesn't really matter. If you do that in just one difficulty adjustment period, it really has almost no effect, right? Because the first block in that period had a real time because you weren't lying. The last block in the period has a real time because you weren't lying. You were only lying for all the other blocks. So the difficulty will just stay the same because it took you two weeks to make these blocks. But the attack has already begun, even though it doesn't have any visible effect yet. For the next two weeks, you do the same thing. So the first block, you set a fake time as low as possible. So much older than the last block of the previous period. You just keep that original clock going.

20:59

Aaron van Wirdum Right. So now you're back in the original minute, so to say.

21:03

Sjors Provoost Yes. And now the last block, you're speaking the truth again. The last block of the period. And now if the blockchain is looking at what to do with the difficulty, it's seeing the last block of the period, which is real. And it's seeing the first block of that new period, which is now four weeks ago.

21:23

Aaron van Wirdum Right.

21:23

Sjors Provoost Because we've only increased that timer very slowly.

21:26

Aaron van Wirdum Yeah.

21:26

Sjors Provoost And so that means the difficulty can be cut in half now.

21:30

Aaron van Wirdum Yeah.

21:30

Sjors Provoost And then you repeat this little trick.

21:32

Aaron van Wirdum Yeah. The rest of the network, all nodes are looking at these two blocks and they're thinking, wow, it took a whole month to mine 2016 blocks it's way too long. We got to decrease the difficulty by half. So now difficulty is divided by half. Even though that was not really necessary, it's just the timestamps were all being faked.

21:50

Sjors Provoost Exactly. So now you can make two weeks worth of blocks in just one week.

21:57

Aaron van Wirdum Assuming that all the hash power is still the same, now you can mine two weeks of blocks in one week.

22:04

Sjors Provoost Because again, and then at the end of that one week...

22:07

Aaron van Wirdum But you're still faking the timestamps. So we're still sort of back mining in the first minute.

22:11

Sjors Provoost Yeah, so at the end of that week, which for the blockchain is two weeks, you're like, okay, this was five weeks. This took five weeks to produce this block. So it could decrease the difficulty even more. And then it gets cut in half again. So now you can mine in about two and a half days, the equivalent of two weeks. And the blockchain is like, whoa, that took five weeks and two days. I've got to reduce the difficulty again. And so the difficulty goes to one very, very quickly in a matter of about 40 days, according to Antoine's calculation.

22:44

Aaron van Wirdum Right. So, yeah, miners, like you said, it's basically 51% attack where miners can drive the difficulty down to one. And then they can mine all remaining coins that are still to be mined.

22:57

Sjors Provoost Exactly.

22:58

Aaron van Wirdum Over the next century.

22:59

Sjors Provoost They mined the equivalent of until the year 2106. They've got every last sat. We've got, you know, millions of blocks in a very short period of time.

23:08

Aaron van Wirdum Yeah.

23:10

Sjors Provoost And then they probably stopped the attack because there's no need to do it anymore.

23:13

Aaron van Wirdum Yeah. And then on top of that, that would mess up probably a bunch of like smart contract things, time lock types of things.

23:22

Sjors Provoost No, well, time locks are, well, they might be affected, but... because time is moving more slowly, your time locks would indeed not expire because… But that's that's probably not a big deal, like, during this attack, because the attack takes five weeks plus a little bit to suck all the coins out.

23:38

Aaron van Wirdum Well, it could definitely… The time locks that are locked on a certain block in the future…

23:43

Sjors Provoost Yeah, so if you're looking at height locks, I guess you call them, height locks are definitely affected, because if you have a contract that expires in block one million, well, guess what, that is that happens immediately. Yeah, but a time lock would be kind of during the attack, it would be effective because your time lock is never happening because they keep the time behind. But once they stop the attack, it'll be fine. So you might be unlucky if your lightning thing is in the wrong place. Yeah, it could be bad. But the worst aspect of this attack, other than the five-week disruption, is simply that they have now exhausted the full subsidy. And so we were hoping to not have to deal with the no-subsidy world, uh only 20, 30 years from now, but we have to deal with it in, well, 40 days, if this is exploited, and it could happen at any moment.

24:34

Aaron van Wirdum Okay, so…

24:34

Sjors Provoost And a majority of miners, you know, might think, well, you know, why not? We're the majority of miners. Well,

24:41

Aaron van Wirdum I mean, one reason why not is that it would probably undermine trust in the protocol, but let's ignore that. Let's see if we can fix the protocol instead of, uh, relying on that kind of trust. So what's the fix here?

24:52

Sjors Provoost The fix is actually fairly simple. Well, the ideal fix would be that we just compare every block to the same block in the last period, but that's a hard fork.

25:03

Aaron van Wirdum Okay.

25:04

Sjors Provoost So instead, at least I think it's a hard fork.

25:07

Aaron van Wirdum So by that you mean instead of comparing the first to the last block within the same period? and checking if that's two weeks, we should really just check the first block to the next first block. But that's not possible, right?

25:22

Sjors Provoost As far as I know, that's a hard fork, so I can't do it.

25:25

Aaron van Wirdum But also, how is that even possible? Because by then, the difficulty should have already... adjusted, right? By the time the first block of the next period is made.

25:34

Sjors Provoost Well, obviously you'd have to change exactly how the difficulty adjustments happen, but you should just do the difficulty adjustments correctly. Yeah. But the simplest solution here is that every first block or block zero of every period needs to be in the present or two hours ago, but no more than that.

25:52

Aaron van Wirdum Every what?

25:53

Sjors Provoost Every first block of every period, so block zero, block 216, et cetera, has to be in the present, the timestamp. And it can be two hours ago for weird mining-related reasons. And it can, of course, not be more than two hours in the future. But basically, it has to be in a four-hour window between two hours ago and two hours in the future.

26:14

Aaron van Wirdum Every first block has to be.

26:16

Sjors Provoost Yes.

26:17

Aaron van Wirdum Right. Okay, yeah, that sounds like a pretty simple fix.

26:20

Sjors Provoost Yeah, because remember the attack involved comparing the last block to the first block and really messing with the first block. That's the part of the messing that you weren't messing with the last block already, but you were messing with the first block and this fix basically makes that impossible and therefore the difficulty adjustment will be correct, problem solved.

26:39

Aaron van Wirdum Okay, makes sense.

26:40

Sjors Provoost Yeah, and as far as I know, that's still the proposed fix that hasn't changed.

26:47

Aaron van Wirdum Okay, that was a time warp attack fix. What's the next one?

26:52

Sjors Provoost Slow scripts. So as you know, it takes a while to validate the whole blockchain. And some blocks take a bit longer than others. That can be because there's tons and tons of transactions in them. But there's certain, you know, at least we have a limit on the block size. A block can be more than four megabyte. So there's some limit to how much you can do in a block. But it turns out you can make some special transactions that are really quite slow to verify. And that's usually a combination of lots of signature checks. Because signature checks take a while. You have to do the ECDSA thing. And hashing. So we talked about this signature checking speed problem back in episode, let me see, I think episode 32 and episode 76. Um, yeah, yeah.

27:47

Aaron van Wirdum So from what I understand, the problem here essentially is like every transaction includes scripts. And for many transactions, that's just a straightforward check that the signature is valid type of thing. But you can make more complex transactions that includes, like you say, hashing or more signature validation. And if you would intentionally want to design a transaction or maybe even a block full of transactions with complicated stuff, then that could, in the worst case, lead to blocks that take minutes to actually validate.

28:25

Sjors Provoost Yeah, and so, you know, people have been… Uh, Antoine, I believe, has been doing some math on seeing what is the absolute worst you can do. And he came up with something that took more than one hour to validate on a Raspberry Pi 4.

28:37

Aaron van Wirdum Right.

28:38

Sjors Provoost And that's not good. Now, you could say, well, it sucks to have a Raspberry, but it'd be nice if it didn't.

28:45

Aaron van Wirdum And even on a fast laptop, it took several minutes, right?

28:49

Sjors Provoost Yeah, and several minutes would be bad, right? So if you are a miner and you receive that block that takes you several minutes to validate, well, now your competitor can do all sorts of shenanigans because you're kind of stuck validating.

29:02

Aaron van Wirdum Yeah, or not shenanigans, just get a head start on finding a nice block, for example.

29:08

Sjors Provoost Right, that's one shenanigan, but I think there might be other things you can do.

29:11

Aaron van Wirdum Yeah, it would be a disruptive thing for the network if blocks take minutes or even longer than that to validate.

29:17

Sjors Provoost And so the question is, how do we prevent those blocks from being created? Now, for now...

29:24

Aaron van Wirdum Just to give you a comparison, how long does it take to validate an average block right now?

29:30

Sjors Provoost I think on a good laptop, a fraction of a second.

29:33

Aaron van Wirdum Yeah. And on like a Raspberry Pi?

29:36

Sjors Provoost Probably one second.

29:37

Aaron van Wirdum Yeah. Okay. Just to sort of paint the context there. Okay. So the solution.

29:45

Sjors Provoost Well, the solution is in the original proposal by BlueMatt, there was a solution, which was... Just changing a few rules, I think now there's discussion about a slightly different solution. So that's actually still ongoing research, what is the actual best solution. But the gist of it is that there are certain extra rules in SegWit and in Taproot that make the script safer. This was why the block size could be increased with SegWit, because any of these extra SegWit transactions would not be as expensive and as slow. These worst case couldn't happen. But it looks like some of these rules should also be applied to legacy scripts, to legacy transactions. And then the problem is you can't just apply all of SegWit's rules to legacy transactions. So you have to be very careful which ones you'd want to apply. Main problem there is, you know, somebody might have a transaction that they put in a cold wallet. Or like offline wallet, right? So we don't see it on the blockchain. And now they want to broadcast it, but we changed the rules and now they can't spend it anymore. Now, you know, the changes that people have in mind would only impact the most bizarre, unrealistic transactions that you can possibly imagine. But still, that could still be controversial. So the key is to find the absolute minimum extra rules that you need in order to fix the problem and no more. Because the simplest solution would just be to say, hey, you know what? You can only make Taproot transactions. That would fix the problem. But it would make a lot of people very angry.

31:20

Aaron van Wirdum Yeah, I thought the idea was also to, like, only apply these new rules from a certain block height, so if you already had your coins in some…

31:32

Sjors Provoost So those are other things you could do to restrict the possible damage that a rule could do. But the trade-off there is complexity. So a rule that says only do this after this block or only when the coins you're spending is from this block, that's extra complexity that you'd prefer not to have. Plus, you know, if the attack, this is one of the problems, once you publish the exact fix, somebody might come up with what it is fixing. and then do the attack before the software is activated. That's probably inevitable anyway, just like the time warp attack. Everybody knows what to do there.

32:09

Aaron van Wirdum Yeah.

32:10

Sjors Provoost So there's that.

32:13

Aaron van Wirdum Yeah. Well, you really want to avoid that people lose their coins, right? That's kind of a...

32:17

Sjors Provoost Yeah. So realistically, even the original proposal by BlueMatt, I think it was changed a bit by him because there were several things that he wanted to change for this problem. And I think they ended up dropping one of these things. So hopefully there's a way to make sure that you can, like, this that nothing gets unspendable. It might just take more fees, for example. Right.

32:42

Aaron van Wirdum Okay, so that was slow scripts. Are we done with those scripts?

32:48

Sjors Provoost Yep, we are.

32:49

Aaron van Wirdum All right, and the next point is about banning 64 byte transactions. Is that right?

32:55

Sjors Provoost Yes. 64 bytes, bad. Why? Well, we've mentioned this a few times in other episodes. I don't think we've done an actual episode about it. But in our episode 81, we talked about a change to Bitcoin Core 25 that makes transactions that are 65 bytes or greater. I think they make them illegal again or something weird about that. I forgot what exactly we discussed. The point is 64 byte transactions are bad. And the reason they're bad is because they look the same as two 32 byte transactions next to each other in the block. Because of the way the Merkle trees are made.

33:36

Aaron van Wirdum Sorry, we have to take a step back here, Sjors. What does it mean? Why is there such a thing as a 64 byte transaction and also such a thing as a 32 byte transaction? Why aren't all transactions the same number of bytes?

33:49

Sjors Provoost Because the size of a transaction depends on the number of inputs, the number of outputs, what kind of script you have in those inputs and outputs and whether it has a witness or not.

33:57

Aaron van Wirdum Okay. And then 64, but a 32 transaction would also look like two 16-byte transactions, right?

34:09

Sjors Provoost Yeah, but I don't think you can make a 16-byte transaction because simply it wouldn't fit.

34:15

Aaron van Wirdum Okay, and a 128-byte transaction would look like four 32 bytes. Why is 64 singled out is my question.

34:23

Sjors Provoost Okay, so the Merkle tree that the Bitcoin transactions are stored in takes the SHA-256 hash of every transaction and then puts that next to the SHA-256 hash of the next transaction. So you take all the transactions and you take their SHA-256 hashes and then in pairs you put those hashes next to each other. And the size of a hash is 32 bytes.

34:49

Aaron van Wirdum Right. That's always 32 bytes.

34:52

Sjors Provoost Yes.

34:52

Aaron van Wirdum Yeah. I vaguely remember this problem. We discussed it.

34:58

Sjors Provoost So two hashes next to each other is 64 bytes. And so then the question is, when you are... So I guess it's not two 32-byte transactions because you can't have 32-byte transactions. Too small.

35:09

Aaron van Wirdum Right.

35:09

Sjors Provoost Because the minimum size of a transaction, keep in mind that a transaction has an input, at least. And the input is already 32 bytes plus a little bit more. Because the input of a transaction refers to the hash of a previous transaction. We just set the hash to 32 bytes. So then it has to have a number and a few other things. So yeah, a transaction cannot be 32 bytes. But it can be 64 bytes. It would be a pretty nonsensical transaction, but it can be 32 bytes. And so...

35:36

Aaron van Wirdum 64.

35:37

Sjors Provoost 64, yeah.

35:38

Aaron van Wirdum But that would look like two hashes that are both 32 bytes. And why is that a problem? Like, where are these hashes in the blockchain?

35:46

Sjors Provoost It's caused multiple problems in the past, exactly. So in each block is a Merkle tree of all the transactions in that block. And all the leaves of the tree are 32 bytes, these transactions. And then you go one level up, and it's 32 bytes again, it's 32 bytes again. And now what you can do is you can give somebody a block and say, here's a block, and here's all the transactions in this block. And then you verify it, and you see these 32 transactions. Sorry, you see these two times 32s, and you combine them, and it looks all good. But somebody could leave out the actual transactions and just pretend that it's only a 64-byte transaction instead of two separate ones. But then you validate the 64-byte transaction, and you say, hey, this is an invalid transaction, so the whole block is invalid. And now you think this block is invalid. And the next time you see this block, because somebody gives you the same block hash, you're like, I don't, you know, I'm not going to check this block. It's invalid. But actually it's not invalid. Because somebody sent you, because now you got the real one where you actually have the two separate transactions in it.

36:55

Aaron van Wirdum I'm lost. Who's the target here? What's the problem? And what's the, like, who are we targeting?

37:02

Sjors Provoost Well, they're different targets. So this example, I think, could be used to make a network split. where you would make a real block with two 32-byte transactions in it, but that when you combine those two 32-byte transactions, it would also make a real 64-byte transaction. So the hashes of those two transactions, not 32-byte transactions, but the hashes of those two transactions, if you add them together, look like a real transaction, but it's an invalid transaction. So now... you are, or the other way around, the 64 byte thing is valid, but the two individual transactions are invalid. So if you give somebody a block, it will have the same hash at the top because the Merkle tree is the same at the top. And that's the only thing you're communicating when you're communicating a block hash. So I'm giving you a block hash and I'm giving somebody else the same block hash, but I'm going to give you the two transactions. And I'm going to give this other person the one 64 byte transaction. And now one of you is going to say this block is invalid and the other is going to say this block is valid. Now you have a network split.

38:12

Aaron van Wirdum Yeah, okay. I kind of get that now, except what do you mean? Why would they check for different things?

38:20

Sjors Provoost Because I've given you the block hash, the root of the Merkle tree. I've also given you all the transactions individually. Okay, so you're actually putting those back in a tree. But I'm giving you a different set of transactions than I'm giving the other person. They get the same root of the tree, but one of them will say, hey, this transaction is invalid because, I don't know, it's spending more money than it's earning. Some other rule that's violated.

38:43

Aaron van Wirdum Right. And that's because it's not really a transaction. It's really two 32-byte hashes.

38:49

Sjors Provoost Yeah.

38:50

Aaron van Wirdum Am I saying that right?

38:51

Sjors Provoost Of real transactions.

38:52

Aaron van Wirdum Of actual transactions. Yeah. So for one person...

38:55

Sjors Provoost One person sees a 64-byte transaction.

38:57

Aaron van Wirdum One person sees one invalid 64-byte transaction.

39:00

Sjors Provoost Or valid. One person sees one 64-byte transaction. The other person sees two other transactions. Doesn't matter what size they are.

39:08

Aaron van Wirdum Yeah.

39:09

Sjors Provoost And if these two transactions are invalid, but the 64-byte one is valid, then you come to a different conclusion out of the block.

39:19

Aaron van Wirdum And this depends on which transactions you saw earlier, essentially, kind of.

39:25

Sjors Provoost Well, the rest of the block is the same, right? So it's just that one of these transactions is actually invalid. So the 64-byte transaction might be invalid or it might be valid. It has nothing to do with what you've seen before. You're basically just giving two versions of the same block that [unclear] think is the same block because it only remembers the hash and it's not. So that bug has been fixed by simply not storing the block if it's invalid.

39:53

Aaron van Wirdum No, hang on. I have a question. I still have one question. You and I are both running a node, okay? Now... Some joker sends us a block that has this one 64-byte transaction in it.

40:12

Sjors Provoost Yes.

40:12

Aaron van Wirdum Why would my node look at this like two 32-byte transactions while your node is looking at it like a one 64-byte transaction?

40:21

Sjors Provoost Because as the joker is sending you the hash of the block and is sending you all the individual transactions. So he's sending you... two individual transactions at the end of this block. And it's sending me one individual transaction of 64 bytes. So they're sending us different things.

40:40

Aaron van Wirdum Isn't that just in the block? Isn't that just the block that he's sending? That's the block, right? The in the block is the transaction.

40:47

Sjors Provoost A block, when you receive a block, what it really is, is a message, right? And the message starts with the header and it's followed by the list of every single transaction.

40:57

Aaron van Wirdum Yeah.

40:57

Sjors Provoost And so... that list of transactions, yeah, it's very… It's different. So if you were to look at the bytes on on the… If you printed it out a piece of paper, you would see that at the end of the piece of paper it's different.

41:06

Aaron van Wirdum Okay.

41:06

Sjors Provoost You and I got a different block.

41:07

Aaron van Wirdum We got a different block. It just has the same hash.

41:10

Sjors Provoost Yes.

41:10

Aaron van Wirdum It hashes to the same hash.

41:12

Sjors Provoost And because you say it's invalid.

41:14

Aaron van Wirdum Yeah. Because it is invalid. The one you sent me is invalid. It's yours.

41:17

Sjors Provoost Exactly. But now if somebody else sends you the correct one…

41:17

Aaron van Wirdum It's only sending you… Yeah. Then I'll be like, no, I already saw this and it was invalid.

41:23

Sjors Provoost Yeah. And that problem, you know, keep in mind that this problem was discovered in 2012 or something. So back then that attack was cheap.

41:30

Aaron van Wirdum Right.

41:30

Sjors Provoost Right now this attack would be expensive, but the attack was fixed because basically when this happens to you, you say, hey, this block is invalid, you just forget it. And so the next time somebody sends you the correct one, you're fine. So that attack is fixed. But then there was other ways that you can fool light clients like SPV wallets using the same trick because they are asking just for an SPV proof. So they just want proof that a transaction was included and you could now give them a transaction that they think is included because you gave the SPV proof, but it wasn't included. Because the real block had two separate transactions that happened to combine to this one fake transaction. And this could be used to steal light wallets, but possibly also to rob sidechains if those sidechains only use SPV proofs for peg-ins and peg-outs. And that problem, I think, was solved by telling light clients to be careful. I don't think it was actually solved.

42:19

Aaron van Wirdum Okay, back to the great consensus cleanup revival. What's the solution here?

42:23

Sjors Provoost Don't allow 64 byte transactions.

42:25

Aaron van Wirdum Well, what if my transaction is 64 bytes though?

42:28

Sjors Provoost Then you are out of luck. So if you still have one of those in the safe, you better spend it.

42:34

Aaron van Wirdum I create a transaction that consists of 64 bytes because I want to pay exactly... this many people, this many coins with this many UTXOs, then the Bitcoin network say, no, your money is not valid.

42:49

Sjors Provoost Yeah, I think the actual examples would be burning coins. So you can make an OP_RETURN transaction that burns your coins, doesn't send it anywhere. And that can be shorter than 64 bytes, but it could also be 64 bytes. So if you want to burn your money using an OP_RETURN that is exactly 64 bytes in total, then yeah, you can't do that.

43:09

Aaron van Wirdum Are there no normal transactions that are exactly 64 bytes?

43:13

Sjors Provoost I believe not. So you can already not send those in the mempool today. It won't be relayed.

43:20

Aaron van Wirdum Okay.

43:21

Sjors Provoost And so I think that was the change in version 25. So I think there was a rule that says nothing under 64 bytes or sorry, nothing under 65 bytes. That was the mempool rule. And then people were like, well, but it could be useful to have a 63-byte or a 62-byte transaction to burn your coins. And so I think the rule was changed to no 64 bytes. So the difference is make this consensus rather than policy.

43:46

Aaron van Wirdum Okay. So most transactions are well over 64 bytes or at least more than 64 bytes. That's normal for a transaction to be more than 64 bytes. If you see a 64-byte transaction, it's kind of something special.

43:58

Sjors Provoost Yeah, then it's probably an attack.

44:00

Aaron van Wirdum Okay, right. And now the Great Consensus Cleanup says let's just get rid of that all together. However, 63 or 62, that's still okay, if you really do, like, if you're not attacking but you're burning coins, that that should work. But yeah, so basically if people make 64 byte transactions in the future and the soft fork happens, then their transaction wouldn't be confirmed.

44:24

Sjors Provoost Yep.

44:25

Aaron van Wirdum Then I have to make a new transaction that's either 63 or 65 or something else, as long as it's not 64.

44:30

Sjors Provoost And you can probably malleate it. So we… I think we talked about transaction malleation, where you can, like, mess with another transaction, so you might, even if you lost the original coin that you used to make this thing, I think you might be able to just make it one byte longer, but I'm not entirely sure about that.

44:47

Aaron van Wirdum Right. Okay, got it. Sounds like…

44:51

Sjors Provoost But this is another case of like, yes, you could just ban anything under 64 or anything under 65, but you want to make the minimum change possible to reduce controversy. That's not too complicated.

45:04

Aaron van Wirdum Okay. Last one. BIP 30, 34.

45:08

Sjors Provoost Yeah, we did a whole episode about this called episode 87. It was called the block 1,983,702 problem.

45:17

Aaron van Wirdum Right. What was that problem again? It was about two transactions that look similar, right?

45:23

Sjors Provoost Yeah, so the TL;DR of this one is that there was a BIP 30 that prevents duplicate transactions. Because having duplicate transactions, transactions with the same hash, it causes problems. You can override coinbases, do all sorts of weird things. It happened a few times in the beginning of Bitcoin. It was fixed. The problem of this fix is that it was a slow fix. So every time there's a new block coming in, you have to check every transaction to make sure that it doesn't already exist. And this check is expensive, requires a lot of disk reading. Unfortunately, and so there was a way to speed it up. The way to speed it up was to force the coinbase transaction to have the block height in it. So that makes every coinbase transaction unique. And since every transaction eventually descends from a coinbase transaction, every descendant is unique.

46:12

Aaron van Wirdum Yeah, that way you can't have duplicate transactions anymore.

46:15

Sjors Provoost Yeah, and so then people thought, okay, so we can turn off this expensive check. But it turns out you can't because there are some very old transactions before this BIP 34 rule was introduced that if you read them, you could interpret the first bytes of those transactions as a version. Sorry, as a block height.

46:36

Aaron van Wirdum Yeah. So there's something in these old transactions, in these old UTXOs, I guess we should say.

46:42

Sjors Provoost Yeah, that is effectively the same as putting a block height in there, but the wrong one.

46:45

Aaron van Wirdum Yeah.

46:46

Sjors Provoost And so these ones, we're going to start encountering these, and we've already encountered a few, but they didn't cause problems. So we got lucky. And so as of the first one, we're going to encounter again is block 1,983,702. So there is an old transaction out there that looks like it's at that height. So in theory, somebody could then make a coinbase transaction that's a duplicate of that old one. And we don't want that. So the BIP 30 check, the slow check, is re-enabled from that height on. That's annoying because that check, as we said, is slow. So the proposal here is to do something else that makes sure that this duplication cannot happen. So not just putting the height in the coinbase, but also putting something else in it. What that something else is, we don't know. My favorite is to make SegWit mandatory, as in SegWit commitment, because every SegWit block has an OP_RETURN and followed by the hash of the witness data. And right now, if there is no transactions in a block, including if there's no SegWit transactions even in the coinbase, well, then there's no witness commitment. And so that OP_RETURN is not present. But you could make it mandatory from off. Basically, you could make it mandatory starting at block 1,983,000. And so people will have 20 years to upgrade.

48:08

Aaron van Wirdum Yeah.

48:08

Sjors Provoost But if they don't, they could accidentally mine an invalid block at that height.

48:12

Aaron van Wirdum Right.

48:14

Sjors Provoost There's different ways to do it.

48:15

Aaron van Wirdum We discussed this at length in the other episode, of course, which was 87, for anyone who wants to know more about this problem. And then also the potential fix, 87.

48:27

Sjors Provoost So that's the whole great consensus cleanup. And so as you can hear, some changes are very straightforward. There's not really any discussion. Some, there is discussion. And so we'll have to figure that out. And then at some point, somebody will have to take the initiative to... actually propose this as a soft fork, do activation parameters, hope there's no drama.

48:48

Aaron van Wirdum Well, that is kind of one of the, you know, side goals of this proposal, I would say, is figuring out how we actually do soft forks and how we actually do Bitcoin upgrades.

49:02

Sjors Provoost Exactly. This was proposed long before Taproot as a way to sort of get over the SegWit trauma.

49:07

Aaron van Wirdum Yeah, like, we're still… it's still not clear how we're supposed to do these kinds of things. So then the idea was let's do something that's very uncontroversial that everyone should or does or will agree on. There's nothing, like, it's just very obvious bugs that we're gonna fix, and then we can figure out how we're actually supposed to do these soft forks. And then, you know, it's sort of a good trial run for future soft forks, I guess.

49:37

Sjors Provoost Yeah. Now we've already done Taproot, but of course there was still discussion about how that soft fork was activated. So I don't know if we really now have broad consensus on how to do this.

49:46

Aaron van Wirdum We definitely don't, Sjors.

49:47

Sjors Provoost But this may be another case of nobody cares what the activation mechanism is just activate it. The main thing is, of course, this takes away the options of miners to do a time warp attack, so if they actually like to keep that option, they might veto it, and then you get into more difficult territory. Um, well, but they may…

50:08

Aaron van Wirdum I don't know if we want to get… We don't want to get into the activation discussion in this podcast episode.

50:14

Sjors Provoost We do not. I'm just saying, like, it might be straightforward, it might not be, and we'll have to… We may have…

50:18

Aaron van Wirdum No, I'm telling you it will not be.

50:20

Sjors Provoost Okay.

50:21

Aaron van Wirdum For sure.

50:22

Sjors Provoost I'm more bullish. Okay. And of course, we keep in mind that you can deploy multiple soft forks in parallel. So this doesn't have to be before or after your favorite feature X. You can activate, I don't know, 10 soft forks at the same time.

50:38

Aaron van Wirdum Yeah, remember when people thought that would actually happen? Good times. Good times.

50:44

Sjors Provoost Good times, indeed. I'm just saying, you know, don't worry about that aspect. Okay, I think that's all we've got. Thank you for listening to Bitcoin,

50:51

Aaron van Wirdum Explained.