What did the Polkadot team just pull off?

Satoshi's Mamma
7 min readJul 24, 2018

--

So those of you who follow Parity/Web3/Polkadot on either Twitter or the Riot channels, might have noticed a small flurry of messages mid-last week talking about protocol upgrades, runtime changes, governance and “PoC-2”. If you’re wondering what the fuck it all meant, then this post is for you. I promise I’ll keep it short.

A caper to be proud of

Let’s start with the basics. A blockchain is a peer-to-peer (“p2p”) network consensus protocol. Let’s take those terms one at a time:

  • “network”: This means that all of the communication is done over a set of connected machines, usually the internet.
  • “peer to peer”: No actor/computer in Polkadot is intrinsically more special than any other: they’re all peers of each other, and everyone judges everyone else on their actual merits (in some sense) rather than because they have some artitrary authority. This is in contrast to e.g. Google or Facebook, whose leaders (Mark & Larry/Sergei) and machines (their servers/certificates) are authorised to run their services and tell the shit-munching masses what is what and who is who.
  • “protocol”: The machines (“nodes”, in p2p parlance) talk to each other using a language which necessarily includes a set of rules that help everyone understand what’s going on with everyone else.
  • “consensus”: The point of this protocol is to help everyone come to an eventual agreement over “some stuff” with everyone else.

The nature of the blockchain determines the nature of the “some stuff” that everyone needs to agree on. In Bitcoin’s case it was simply what “value” (in a strictly abstract, computer sciencey interpretation of the work) that any given digital signature could unlock. In Ethereum’s case it was the state of a global data store (a large and abstract set of ledgers) after any given “instruction” or message from the outside world.

The nature of a blockchain is known, in blockchain jargon, as the “state transition function”, because it’s the bit of the protocol that says what instructions do what. This function interprets all of the messages that have been assembled from the “outside world” (that’s us) and decides what shit’s gone down. Most of it’s pretty dull, like “Please pay Bob 5 DOTs, signed Alice”. But some of it gets interesting; the more interesting stuff usually means a more complex “function” definition. Ethereum’s state transition function includes the definition of an entire computer!

So far so good. Problem is that during the development of a product and, if assuming it’s a long-lived product, then during its lifetime, you might want to change things. Maybe there are fixes, maybe there are feature improvements. Whatever it’ll be, updating or upgrading is an important feature to have. As we all know, the “version 1.0” of most products is incomplete in some way (and Silicon Valley mentality is that if it’s not so incomplete as to be embarassing, then you’re obviously not made of the right stuff).

If you’re running a centralised and trusted show, like our technology overlords Google/Facebook (sorry, that should be Twitter/Amazon now, I don’t want to seem overly vindictive), it’s a bit of a collective pain in the ass, but still perfectly reasonable thing to do. You just upload a bunch of new software to your servers, tell your users to hit reload and job’s-a-good’un.

Things get a little more complex with network protocols and things like backwards compatibility and versioning need to be introduced. Still, despite the pain, it can be made to work (…eventually, at least, if the transition from IPv4 to IPv6 is anything to go by).

However, by the time we get to consensus protocols, we’re in a slightly different ballpark. Here’s why. Whereas non-consensus protocols like HTTP (“the web!”) or SSH (remotely using another computer) only require the two peers (i.e. me and whoever I’m talking to) to agree on what language they talk and what it all means, consensus protocols need “everyone” to agree on the above. Since an upgrade necessarily changes the language, then the solution lies in getting everyone to upgrade and restart their software all at the same time. In a decentralised network, that’s a pretty difficult thing to achieve.

There are workarounds. Ethereum has the Ethereum Foundation, and in particular their unicorn-loving, “surely-on-the-spectrum” mascot Vitalik Buterin, to tell everyone what’s up and when to get their shit switched over. (With the assumption that if he don’t say shit, then the current software is just dandy.) Obviously, that’s just side-stepping the issue — a solution worthy of the greatest centralisationist in the land of decentralisation, Dan Larimer.

Bitcoin might be considered a little cleverer. They introduce the concept of “miner voting”, where some of the currently-more-important nodes on the network express support for an upgrade and once a proportion of these guys give their thumbs up, it’s just assumed everyone else will follow suit soon enough. Of course, not everyone does, and for some people it’s a mess, but what’ya gonna do? After the guys at Bitcoin-core (the original project and self-styled leaders of the BTC currency) tried to get through a protocol upgrade and found that miners weren’t too supportive of it, they decided to force the issue with a “user activated soft-fork”, aka “fuck you, miners, we’re doing this shit anyway”. The Marlon Brando of miners (and one of this year’s 40 under 40 for the blockchain, no less!), Jihan Woo, together with the Bitcoin-core arch-enemy Roger Ver, saw they were beat and so just forked Bitcoin off in to Bitcoin Cash. Now there’s two Bitcoins (well, actually there’s one or two others but nobody really gives a shit).

So let’s get back on to the topic at hand. Polkadot (or Substrate — they’re pretty overlapping at this point): what did it just do? Well, 2 or 3 months back, the team lead by “impossible to get on with” Gavin Wood kicked out its first and somewhat boring version named “PoC-1”. This included a bunch of stuff, but most importantly for our little bit of schooling is that it included a “Wasm execution environment” and, specifically “runtime upgrades”. So what the fuck is a “runtime” and how can it be “upgraded”?

Well one of the genius bits of Polkadot/Substrate is to split out a few of the components of a blockchain protocol. In this case, they boxed up all of the “nature of the blockchain” stuff (i.e. the bits that decide what to do about all of the instructions that are coming in from the external world) and called this box of goodies the “runtime”, because, you know, its gets run sometimes (yeah, I know that made no sense). The rest of the protocol, the bits that select and include and decide and share which of the messages from the external world go in — and of course, in what order — well that’s all handled by The Rest of Substrate (not the fucking runtime).

Ok, great, so the two have been isolated from eachother. So what? Well, get this, the bit that’s the runtime doesn’t go into the software that people install like it normally would do with Bitcoin or (insert-another-of-your-shitty-currencies-here). Only the other part does. So, I hear you ask, how could the the software know how to form a consensus in that case? Surely if it doesn’t know the nature of the blockchain then it couldn’t interpret all of the messages and agree on what they do? Well, here’s the bit where it gets all Red Pill on you. The runtime — the nature of the block chain — is stored on the blockchain itself!

So the very first block of the chain, the so-called “genesis” block (kind of judeo-christian religion centric isn’t it, Satoshi?), actually has the first such runtime baked into it, much like the first block of Ethereum had everyone’s crowdsale balances in there (not to forget the 10% of the ether that Buterin alloted to himself and the various pre-sale slackers for free). For Polkadot, the genesis block had right in there the “PoC-1” runtime. So it behaved with the early “PoC-1” logic for 2 or 3 months.

Every self-describing series must have a genesis…

Well, the runtime can do a bunch of stuff when it’s… well… running, but the only thing that’s really important is that 1. it’s Turing complete (like actually Turing complete, unlike gas-bound Ethereum); and 2. it’s got a fat-ass database (think LevelDB) to put stuff in that persists between the instructions that it’s interpreting. One entry in the database is, you guessed it, none other than the fucking runtime itself, expressed as a fat hunk of WebAssembly (and yes, Brendan, turns out something as simple and abstract as Wasm can, in fact, be used for blockchain, fucktard). This lets the Rest of Substrate know what logic to run when executing a block, or if you like, it defines the current nature of this blockchain.

So it follows that the blockchain doesn’t just describe itself, but the genius thing can also decide to change itself, by just writing in a different hunk of code right there in the database. And from the next block onwards, the nature of the blockchain will have changed! And that’s just what happened last week. For the first time in the wild. In the world. Ever.

The specific logic for changing the runtime involved a not-really-democratic voting process. The account that held a fuck tonne of DOTs voted for it, and impressively enough, the thing went through. So now the very same blockchain that they all called the “PoC-1 testnet” is now called the “PoC-2 testnet”. Though it seems that to avoid the ensuring confusion, they just renamed the thing to “Krumme Lanke”. In any case, that “PoC-1” blockchain started months ago is now running all of the lovely upgraded logic of PoC-2, and that means parachains, bitches!

With that I bow out. If you want more expletive-led technical commentary, be sure to come back.

--

--