 All right. Yeah. Okay. Hey everyone. My name is Sean Tabrizzi. Today we'll be talking about substrate, which is a really cool project working at Perry Technologies. First, a little bit by myself. Is it moving? Let's see if I can get this to change. Sorry. Technical difficulties already. Here we go. Okay. So a little bit by myself. I'm a software developer at Perry Tech on my background. So I think the last four years working at Microsoft doing Cloud Identity and Cloud Infrastructure. During my time there, I learned about Ethereum and started doing some development. So I started developing DApps on Ethereum, and then I decided, hey, I want to jump in and really do blockchain development. So I joined Perry Technologies where I'll be working on a substrate development. So this is going to be an overview of what we're talking about. We'll be talking about substrate. We're talking about Rust, Wazim, or WebAssembly, blockchain upgrades, hopefully we'll do a live demo as well, and then how you can start building on substrate today if you wanted to. So let's do a quick review of blockchains. I mean, if you're in this room, hopefully you know a little bit, but I mean, something really basic. Blockchain is really just the log of state transitions. Each transition is bundled into a block. Each block has a reference to the parent, and then the specific details of every blockchain is kind of defined by that blockchain developer or the blockchain group. The blockchain network is composed of nodes, and in order to build a blockchain node, you need a few things. You need a database. You'll need a peer-to-peer network for the nodes to talk. You'll need a consensus algorithm for the nodes to come to an agreement. Transaction handling to queue and manage messages. And you'll need a state transition function, which is really the main logic and what we will call the runtime. So how does blockchain development happen today? Well, most projects don't have the ability to really get a whole team of developers to build an entire blockchain stack. It's a lot of complicated technologies that are all different. So instead what they do is they fork existing projects, and they make modifications to what they want to customize. Most often this is the actual runtime logic for the state transition function of that blockchain. On the other hand, Parity has a lot of blockchain-building experience. We've built Parity Ethereum, which is probably what we're most known for. It comprises about 30% of the main Ethereum network and is used by enterprises like Microsoft and Google. We also have Parity Bitcoin, which is a robust modular client for miners, and it works on Bitcoin and Bitcoin Cash network. And then we're also working on a client implementation of the Polkadot. And Polkadot's like a next generation multi-chain protocol at the center which is a relay chain, which we were building the client for. And it was really through the development of Polkadot, relay chain that we realized, hey, we've done this a lot. We've built all different pieces of blockchain and really what can we do to generalize and kind of make our lives simpler the next time we've been building another blockchain. And really from Polkadot came Substrate. And so what is Substrate? Well, Substrate is an open source, modular, extensible framework for building blockchains. It's currently listed on the GPL license, but we're switching to Apache too soon that affects anyone jumping on in, which would be better for everyone. Substrate provides you with everything you need to build a blockchain out of the box, all the same things I mentioned before, database layer, networking layer, consensus engine, transaction queue, and a library of runtime modules. You get all that with Substrate. But in addition, each of these can be customized and extended for your needs, which makes this really, really powerful framework. There's so other things you get with Substrate as well. You get connectivity through Polkadot. So Polkadot, I mentioned, is a next-generation multi-chain protocol. And through Polkadot, you'll be able to talk to other chains, exchange messages, tokens, et cetera. You get pluggable consensus. Basically, you can start using Substrate now, and then later, if you need to, you can upgrade your change to use a new consensus algorithm. You get light clients for free. There's a lot of talk with light clients in Ethereum and other projects. These are things that need to be added on top of the existing protocols. Here, we are building it as a first-class citizen, so you get it for free. We get chain synchronization automatically built in. You get published and subscribed, WebSocket API, which we use for all of the JavaScript libraries and toolings which we've already created, and it's available for you to use. We have built-in telemetry and a telemetry dashboard that you can use, and a method to upgrade your chain logic without causing a fork. And it's really this last part that's really interesting, something that I'll touch on more during my presentation. But again, you get all of these things for free just for building on Substrate. So let's look at Substrate architecture real quick. So you'll see at the bottom, we have a WebAssembly interpreter consensus and networking layers which are all written in Rust and that are compiled to the native executable. And at the top, we have the runtime, which I mentioned is the state transition function of the main logic of the chain. And this is also written in Rust, but we compile it into both the native execution language and WASM. And so if you didn't get already, Substrate is written in Rust. And in fact, all of our clients are written in Rust. That's Parity Ethereum, Parity Bitcoin, and our upcoming Polkadot and Zcash clients are all written in Rust. And Rust is really a new systems program language, started by Mozilla and is known for Powering Firefox. So let's talk about why we chose Rust. Well, Parity really is a Rust team as much as it is a blockchain team. We really love the language and we use it for a number of reasons. For example, it's safe. You know, Rust ensures that programs are free from undefined behavior, data races, or any memory safety issues. Rust is really, really fast. It has zero runtime overhead, so it's really lightweight. It's easy to read and once you get a hang of it, it can actually be really fun to write. The other technology I mentioned that we use in Substrate is WebAssembly, or WASM. And it was basically meant to be a platform-independent executable format and tries to be as close to the native machine code as possible to run fast. WASM is great because it's compact. It means you can easily transfer it over the web. It's sandboxable to protect users from buggy or malicious code. It's deterministic. When you remove floating-point operations, and determinism is obviously very important for blockchains getting consensus and having it as part of your runtime logic. And then WASM is near native speed. As we mentioned, it's close to machine code, so it means it runs really quickly. And finally, it's really well-supported. We have a lot of support from the community, including all major browsers and even the companies building on the web. And then, what's great is that, you know, Rust and WASM work really well together, actually. Rust now compiles directly to WASM, which is absolutely great, which means we can actually, as I mentioned before, we build our runtime in both a native and WASM binaries, and we can use the same code base to do that, which is really, really powerful. And because Rust has no runtime, you don't have any extra bloat in your WASM binaries, so it's really, really small. And finally, of course, Perdy, to support other Rust projects, we built a WASM interpreter in Rust, so it makes the integration really, really simple. So if we could take a look back at our substrate architecture, one of the things I mentioned was that WASM, because with Rust, can be made really, really small. What's really nice is that now you can actually put the WASM runtime, store it on chain, and that actually is the magic which enables us to do what we call forkless upgrades, which is the feature I wanted to talk about. So if we take a step back and take a look at, okay, how do existing blockchains do upgrades? Well, usually requires some kind of fork. So what happens is traditional blockchains would update some new, well, it has some new logic, creates some new binaries, and release it to nodes, and nodes would have to manually upgrade their software, and not all nodes will actually do it in time. They need to shut down and restart their nodes, and you can get a fork in the network, basically, where there are some nodes who didn't upgrade and some nodes who did. A great example of this is Ethereum's constant noble upgrade, which is actually a fourth upgrade, and we've seen that it requires a lot of coordination, a lot of social work, and it's really not suitable for distributed systems to do an upgrade like this. So what can we gain by putting the runtime on the blockchain? Well, we can actually avoid forks altogether. So we have some simple logic, basically, that says we check in substrate whether or not the runtime on the blockchain matches the native binaries on your machine. If they do match, we'll just run the native binaries because it's a little bit faster. But if it doesn't match, what we'll do is we'll fall back to the Wasm interpreter that we created, and actually run the Wasm runtime and have that power the state transitions of your blockchain. And so in this situation here, you can have a node syncing, and as long as it's in sync, you'll have the latest runtime and therefore you can continue to stay in sync with the network without ever having to fork. And this is a really powerful technology, again, when you're thinking about building a blockchain and thinking about upgrades or things about the future, this is really how you enable the simplicity and keeping your network together. So I wanna give a demo of this, but first I wanna give you a little bit of context. I think we've mentioned this a few times, CryptoKitties I think has been talked about in this room, but Internet loves cats. And so similar to blockchains managing your token balance, blockchains can also manage and track unique assets called non-fungible tokens. CryptoKitties is an app which basically allows you to create your own unique tokens, and these are represented as Kitties or digital pets. In December of 2017, the game was so popular that it accounted for about 25% of all three of them traffic at peak times. This ended up causing huge delays to transactions and caused significant increases in the gas costs. So it almost broke Ethereum. As adaptive developer, really the only option at the time was to build on Ethereum or some existing platform. And so the question I kinda wanna ask is like, what if subchart was available then? What if you could build your own blockchain network, kind of independent from others and have your project grow and scale independent of the network and the other projects that are building on that? So that's what I wanna show you. So with that, mindless do an upgrade. So give me a second. I'm gonna have to mirror my screen real quick. Let's see if I can figure that out. Arrangement, mirror displays, let's see. Okay, yep. So one of the things that I tried to do, building on Substrate, was to try to replicate the CryptoKitties app. So I'm gonna show you real quick here. There's kinda two folders in my project. There's something in Substrate Kitties, which is basically a Substrate node template. It's basically all the pieces you need to build a basic node. And this is one GitHub repository we have that you can clone. And then we also have a Substrate Kitties UI, which is basically a basic UI which interacts with the web socket, using JavaScript APIs, and basically allows you to create a simple UI that you can build on top of. And this is another GitHub repo that you can clone. And I've already modified these to kinda have a game. So I'll show you here. Within the Substrate Kitties, the Substrate node template in the runtime folder, you can actually see I have a new file here, which defines all of the characteristics of my unique module, which I've added to my runtime. You can see here we have things like events, storage, we have all the public functions that you might expect, and then even some other internal functions. And so what I'm gonna do real quick is I'm gonna run this. Let's see if I can do that. Target, release, Substrate. And so here I have started a, started my blockchain locally. You can see it should be creating blocks. You can see it's imported one, and it started from scratch. And then I've already started running the UI. And so if we go over here, we should see some stuff. So you can see here on this left side, I have basically a block explorer for Substrate. And on the right side, I have my custom UI. And if I refresh this, you should see that these things are in sync. So we have three blocks, a height of three blocks here. And so I'm gonna, I'm starting from scratch here. So I'm gonna take Alice, which is prefunded with a ton of units, and we're gonna send it to Sean. I'm just gonna do the basic verification of, hey, this blockchain works. So I'm gonna send some funds over to myself. And of course, you'll be able to see the blocks continue to grow. Once we get to 10 seconds, the new block will be created, and you'll see a new event, which confirms that a new account, basically a new transfer has happened, and some magic has happened as a result of me getting money for the first time. All right, so I have a balance of 1,000 units. You can see it over here. And as I mentioned, I already built some of the logic of my Substrate Kiddy's runtime, and I already have a little bit of UI in here. So let's say I wanted to make a new cat. So I just put my name Sean. I wanna create a cat. And again, cat's created for me automatically. Let's take a look at the cat. At the top, this is the unique ID for the cat. Underneath it, this matches right now, but it's the DNA for the cat. And we use this DNA basically to pick the traits of the characteristics for the looks of the cat. We have an owner and the generation. And because this is the first generation cat, it's generation zero. And so we can actually do this a few more times, just real quick. And you'll see the cats are unique, and the ID and the DNA is all unique. And so what I wanna mention here is that, okay, well, I built a game. But what if I wanted to add new features, new functionalities, and continue to upgrade my blockchain, upgrade what this DAP is basically doing? And I don't wanna cause a fork. So let's do a forkless upgrade. So I'm gonna go back to my project, and then I have here a breed kitty code. Basically, I mean, we can walk through real quick. Basically, you're going here, making sure you wanna breed two cats, basically have some kind of mix between the DNA of the two and create a new kitty. We make sure the cats exist. We generate some random number. We use that random number to basically pick which parts of the mom or dad DNA that is gonna be selected for the new cat. And then we generate a new kitty and we mint it. And so let's say this code is already written. I'm gonna plug it into my source code. So let's make sure it's the right spot. Yep, this is basically, I'm putting it in the declare module function, which basically defines all the public functions that my runtime shows. Okay, I pasted it. Okay, and let's go back to here, and let's save this, and let's build a new wasm runtime. So here, basically we're compiling it and compiling it to wasm, you can see here, to wasm. And once this is done, we can actually go and do an upgrade in real time. So let's go back to our UI. And again, I'm trying to keep this explore here to show you that everything's happening live. We have a runtime upgrade. So I can select the runtime file. I'll pick this compact file and you can see that it was modified today at 403 and it is 404. So this is a brand new file. If I press, I guess, okay button is not there, but I press enter and I wanna do an upgrade. So we should see when the block is created is a new event called sudo. So it was just like, you know, admin. And basically you can see a new event has been created where we've upgraded our chain. This, before I actually show you the UI, I'm gonna show you that in the UI, I had built in a function which I've hidden. If the breed kitty function, which I just added didn't exist. So in the app.js file, you can see there's if statement here. So if this function doesn't exist, then you won't see these UI elements. So you didn't see them before. But now all I'll do is basically refresh the page and you will now, because we have this new function, see some new UI in my game. And we can now breed a kitty. So you can see this is the orange cat, green cat. This one has stripes. This one has a monocle. This one has a hat. And so we might expect to get a new cat with a combination of these traits. And I need to give it to someone. So let's give it to Alice. So breed cat. Yep, and you can see here we have a cat. Now with a hat, it picked up. It has the stripes from the green kitty, which it didn't have before. And that you can see, actually, if you look at this DNA, you'll see it's a combination of both the green and orange cat. And so here, I mean, basically I've shown you that we have a daff. It was running, relatively easy to build, and then we were able to do an upgrade, add new functionality, and basically have our UI accept and understand this new functionality. And we did it all without having to fork the network or have to do any crazy, like social manipulation or coordination. And this is a really, really powerful thing that you get for free with Substrate. And it's just one of the many things. So I wanted to now go back. I think maybe we'll best from just work from here. No, I want to get back to my display. Maybe we can just make this bigger. So I want to talk to you an upgrade. So we did the demo. And so now I want to say, if you thought that was cool, what we have right now is a workshop that you can actually go and do everything I just did and learn how to build from scratch a runtime, which does the basic cryptocities. We call it the Substrate Collectibles Workshop. And from the beginning, you can learn how to run a Substrate node. You can learn about how to build runtime and development, all the best practices. You can basically build a working chain with the UI and you really need minimal rust experience to be able to do so. And this is all done in a, I think a relatively nice looking workshop that walks you through the steps, explains the different processes. And basically you can today, build what I've built here. And from that, you know, take what you've learned and kind of apply it to your next idea, which you can build on blockchain. So to give you a recap, we talked about Substrate. We talked about how it's an open source framework that really enables you to easily build blockchains. We talked about Rust and Wasm as very powerful tools that enable this Substrate to work. We talked about Fortress upgrades and how it's really important for, you know, the future of DApps and the future of, you know, building on a blockchain framework. And then we talked about the workshop, which is something that you can do today and you can go build your own blockchain. And so real quick, I want to mention that we're hiring. If you're interested in anything we talked about today, if you're interested in, you know, anything blockchain related, you can go look at perty.io.sashjobs. We also have a newsletter that you can subscribe to if you want to get up to date with any events or any updates. And then finally, I am ready to answer any questions and we have a few other perty friends in here who may be able to help me if it's a topic that I'm not super familiar with. But if you have any questions, I would love to get that now. Thank you. Any question? Can the users of this blockchain refuse the upgrade somehow? Yeah, so one of the things I want to mention is that the upgrade ability is actually your choice. So as I mentioned, this is a completely modular framework. You can actually choose to have your blockchain, you know, have upgrades or not. And then if you do choose, it's probably best to have it under some kind of governance system, which we actually have one of our modules, which is available in Substrate. So basically upgrades happen through some kind of governance. You can actually control and modify that governance if you want to do however you want. And you don't even need to include upgrades if you don't want to. That's not what you want to do with your chain, but it's completely modular, but the fact that it's a possibility, and the fact that, you know, things like WASM and Rust have enabled us to do that is really, really powerful, something that we weren't able to do before. Yes. So I'm actually quite clear what I get out of Stratum. So do I get packaged programs that run, so that are the nodes that I can distribute or? Sure. So you're saying, what do you get from Substrate release? What you're asking? Is that accurate? Yeah, so where are my nodes? Or what is my package that I can give to my community? Yeah, so when you compile Substrate, or Substrate node, you'll get some binaries which you can release to your, all the people who want to run a node. And then we have built into our networking layer, ways for these nodes to automatically find each other, discover each other, and then become a network. And that's part of the, all the part of our peer-to-peer network layer. Does that answer? Yeah, okay. Yeah. If I have a custom or new consensus algorithm, like Proof of Burn or something. Yeah, so I can give you, what I haven't shown here is that there's kind of a few levels at which you can touch a Substrate. So the most basic thing you can do is kind of what I did, which is you clone our repo, which is a Substrate node template, which already has kind of packed into it all the basic things you need for a blockchain node. And then you can modify that. And really that's kind of at a much higher level. You're not touching the core parts of the blockchain, and you could just basically add new modules and new functionalities to your runtime. Then you can go deeper, because again Substrate is an open source and modular framework, you can go and touch things like the consensus, touch things like the peer-to-peer network, touch things like the database layer, and you can go and modify it for your needs. So yes, consensus is something that actually, something you can change and something that we are looking to be able to support as something that's like hotspotable and pluggable and something that can evolve over time with your blockchain. Yeah. Next question. Yes. Hello, thank you for the presentation. Yeah. What happens to the second runtime when it becomes obsolete? Yeah, so basically the runtime gets stored in the blockchain under a special storage key. So we have, basically our storage is something very, very abstract, it's just a key value pair. And there's a key called code which stores the wasm, and this is where we check and look for any code. So when you do an upgrade, you're basically replacing in that key what the value is. So the old runtime gets removed. Sure. So I'll try to repeat some of that. Yeah. Yeah, so I'll repeat that. And actually I'll show the, on my screen. Yeah. So yeah, I want to mention here. So there are two compiled versions of your runtime. One is the native executable and one is the, sorry, and so the question was, what happens to the second runtime? Like there's kind of two here, what happens one to the other? So one lives in the native binaries and one actually lives on the blockchain as a wasm binary. The native binary stays there. The thing is there's a logic within your node, within the other parts of your substrate architecture which will basically decide which, where should I go to execute the state transition function for my blockchain, the actual runtime. And if the decision is, hey, the native binaries on your computer are up to date, they will run that. If not, it will go fall back to the wasm interpreter. But that's a little bit slower. What this also means though is that, if you want to, you can release new binaries out there and nodes can choose to upgrade on their own. So again, that's a normal upgrade pattern, but nodes are not required to do that. They will stay in sync while this change happens. So they can kind of do it more freely and there isn't so much craziness in having to manage and socialize everyone. But this native code doesn't go anywhere. It just doesn't get used. There's a fork in the logic. But the wasm binary will just get replaced with any new upgrade that you do. Yeah, so the question is, when I upgrade the runtime, will all the blockchains get upgraded dynamically? And so again, because the wasm runtime is part of the blockchain, it's part of the consensus. It's part of the state transition. So yes, every block, as long as they're staying in sync, will have the latest runtime. Yes. Question. So your demo with CryptoKitties, I guess if you map the analogy to Ethereum though, you would be, you're not forking Ethereum if you upgrade your contract, right? You're upgrading your contract. Yeah, I think the- So like just as far as an analogy with your demo, and you talk about like forkless upgrades. So Ethereum is doing a forkless upgrade of your contract. So is your guys concept basically, instead of having these dynamic contracts that run on all the nodes coming to consensus, you're kind of taking, you're kind of building out to his question, your own network. So if I wanted to come up with my own non-fungible asset, I would recruit hundreds or thousands of people to download my runtime. So- Like let's say we all hide your runtime in the room, and I say, hey, I came up with this new one. Who wants to run it? Yeah. You could download and run it with four other runtimes and the chains could coexist or? Yeah, so there's a few things wrapped in your question. So first I want to say that, I'm not claiming that you can't do upgrades in smart contracts. The upgrade, the CryptoKitties scenario here is basically as a way to kind of show an upgrade, kind of give it some meaning. You can see a new function being added. What I kind of mentioned though is, CryptoKitties on a platform like Ethereum, you know, you can be, or any business on a platform like Ethereum, you can be kind of pushed around by the rest of the network, right? Things like increases in gaffies, increases in the transactions, all that stuff that you can move around. And as a business, if you're reliant on some other platform that you can't really control, that might be scary. And so I think Substrate kind of unlocks a new territory, which is like, I couldn't build a DAP without having to build a whole blockchain. Might as well just put on top of the existing platform. Now you can really spin up a new blockchain and that might be the right decision for you as a business. It may not, that's up to you to decide, but Substrate makes it possible. It was an option that wasn't there before. And then, you know, there are things like, you know, I think you're mentioning, like, you know, will there needs to be a network of nodes as powerful as Ethereum to be able to, you know, protect your blockchain? And there are things like when you connect to Polkadot and you get shared security from the larger Polkadot network. That's something that, you know, I'm not really talking about in this talk, but the Polkadot network kind of provides security to all the smaller blockchains that are connected to it. And as I mentioned, you know, if you do an upgrade, it's not like you have to have everyone in the room agree. There's going to be a governance process on the blockchain, which, you know, you can interact with. People can vote for it if they like to upgrade, if there's new features. And if the vote goes through, one time will execute the upgrade and it will automatically sync to all the nodes that are running your blockchain. So everyone kind of gets free access basically. But again, you know, a lot of that stuff is configurable and can be changed and designed to the way that, you know, suits your needs for your blockchain. Does that answer your question mostly? Any other questions? Yeah, I think there is one. Yeah. Can you wait for the answer? So the question was, is this a one contract per blockchain system? And I think they, is that correct? Yeah, that's exactly right. Yeah, and I think the answer is no. So what I showed you here with the substrate kitties is just one module which composes my runtime. So if you actually go back to my UI here, you can see there's other things like sending funds and sending balances, managing your wallet. All these things are actually modules. Like you can make a blockchain which doesn't have any concept of balances in it or balance transfers. That is actually a function that we've added and it's part of the thing we call the SRML, the Substrate Runtime Module Library. And you can choose and pick different parts like governance or other aspects if you want to add or create. So you could have substrate kitties plus you could have some other aspect or other games all on this chain and you can upgrade and modify it that way. Yeah. Okay, but would those be under the same administrative control, I guess? It would be however you determine your governance system on your blockchain. Yes, that those different things. Another thing I want to mention is one of the modules that we are working on for Substrate is a smart contract module. So you could actually have a turn complete smart contract system on your blockchain. You could have a core crypto kitties app and then people building smart contracts on how they want to interact with those kitties as a part of a smart contract later which gives a good buffer between what access other external users have to your core Runtime, right? So again, what I've shown here, maybe he's not the best example of like, oh, I'm a blockchain developer. I want to build a real, real blockchain. But it kind of shows you like, hey, there are alternatives to that development. And I think it really is illustrated to like how upgrades and kind of how it can be used and can be done simply. And again, the tutorial we have will actually walk you through this process. So crypto kitties is kind of a nice thing to have someone who doesn't really know about Substrate to kind of connect to things they know about Ethereum and they can start building right away. That's interesting, thank you. Yeah, no problem. Yeah, thanks.