Overview

About this video

What You'll Learn

  1. Deploy Rust and WebAssembly functions through a documented REST API.
  2. Hot-swap deployed Wasm versions while keeping the same endpoint.
  3. Use stateless functions with ephemeral storage and OCR demos.

Tim McCallum joins to demo Second State's serverless WebAssembly function-as-a-service. We write Rust, compile to Wasm, deploy via SSVM up, call functions through a Postman-documented REST API, hot-swap versions, and run an OCR / TensorFlow demo.

Chapters

Jump to a chapter

  1. 0:00 Holding screen
  2. 0:40 Introductions
  3. 0:42 Introduction
  4. 3:20 What are the use-cases for Second State?
  5. 9:00 JAM Packed - OpenAPI / Postman spec for Second State
  6. 13:00 Deploying our first WASM function
  7. 22:20 Testing the image processing function
  8. 26:00 Deploying our first WASM function (Take II)
  9. 31:00 Deploying a new version of our function
  10. 33:50 Making our function private
  11. 39:40 OCR and translation demo
  12. 44:00 Convention for server side fetching
  13. 58:00 Permanent and ephemeral storage / state / persistence
Transcript

Full transcript

Generated from the English captions. Timestamps jump the player to that moment.

Read the full transcript

0:42 Introduction

0:42 Hello and welcome to Rawkode live. I am your host Rawkode. Today, we're gonna be taking a look at Second State. We're gonna be playing with a combination of functions as a service, Rust, Node JS, and some random other bits and pieces thrown in together. Joining me today, we have Tim McCallum from Second State Project. Hey, Tim. How are you doing? Fantastic. Thank you. Thanks for having me. No. My pleasure. I I always love it when I get to play with WebAssembly. So I'm really excited to kinda kick the tires on Second State and see what we can do

1:12 with today. Perfect. Should we start by you giving us a small introduction into yourself and then we'll talk about Second State in a little bit more detail. Yeah. Sure. So developer for Second State, we have developers all around the world, in China, Taiwan, The States. At the moment, we're working on a a variety of different projects, some blockchain, some web assembly, very much at the, virtual machine level and the blockchain VM, work that we've done in the past ties in really nicely with the WebAssembly VM work. And last year, Michael and I, we went over to

1:54 the first, WebAssembly summit, Google headquarters there in Silicon Valley. So that was really interesting, really great. And, since then, we've just come back and just been powering on, developing a whole bunch of different, software applications and tooling and tool chains and, really, taking it, to the server side as well. So working, with WebAssembly on the server side and creating a function as a service for the open web. So, like, a cloud agnostic function as a service that anybody can call just over the web using secure HTTP requests, and that means so compiling and launching code as well as

2:34 executing it, deleting it, updating it, lock hot swapping it, live in production. Probably touching it, fairly soon, but the WebAssembly VM is obviously a sandbox. You know, it's got some advantages that it works in a sandbox environment, so it's safe to run untrusted code, etcetera, but also has some interesting nuances like it's stateless. There's no storage, doesn't have strings, you know, like the four data types. It's basically integers and things like that. So we've worked really hard to try and bring together a whole ecosystem. And I'm essentially part of the the open API, which is a function as a service, which

3:13 we could have a a good look at today, that'd be that'd be really cool. Alright. Excellent. What do you think some of the what are the main use cases for someone who would be wanting to adopt Second State? What what problems would they be trying to solve? So probably the the one, that would relate to the work I do is traditionally, you have, you want to build a web application or a website, something with a little bit of functionality. You'd essentially have to go through and create the LAMP stack, you know. So you've got the the Linux and Apache and PHP and

3:20 What are the use-cases for Second State?

3:47 you'd have MySQL and then you've got all these issues around, you know, setting up the database, all the security aspects of that, doing all your IP tables on the survey, installing the server software. And in any institution, you're essentially running, you know, like you've got a security team and those guys are doing all of the work to secure the network and to maintain all the firewalls and the servers and things like that. And what we do is we take away all of that, and we just offer a function as a service, but not in a proprietary cloud environment

4:23 where you have, like, this proprietary, you username and login and dashboards or any sort of user authentication access control, all those sorts of things. We throw all that out the window, and we just give you a an API endpoint, essentially like a rest RESTful API. So you can stand up a website in five minutes, like, highly functional, you know, doing things like, facial recognition, image classification. Your previous videos there where you did the anagram solver and things, I've turned that into an API in a few minutes and deployed that. The this jam stack, I don't know if you've

5:00 talked about that a fair bit, but so the Java API and markup, that's a really cool framework. So, essentially, the problem we're solving is we're just saying you can just use the JAMstack. So you can have some HTML, maybe one JavaScript function, and you call one of the APIs, and you're off to the races. You've got a a fully functioning web application on the open web with no infrastructure. So it's like a zero infrastructure. You can even open it statically on your PC, and you just, you know, say you we might do this a bit later.

5:37 You know, you click a button that files off a JavaScript function that calls an API and returns a result, And you can just do that all even if it's just statically on your system. So there's no servers, there's no hosting, there's no security, no databases, all that stuff. It's all by the by. Nice. Alright. Let's tackle a couple of comments. So first, we gotta wash hands thumbs up. Thanks, Miley. Pignesh is saying what is Second State really? I I think we just covered that hopefully. And we're about to get hands on with it, so you'll see it in action and

6:09 hopefully that will answer any of those other questions that you have. But feel free to add more comments if you need. And hello from Cube Daily. Hey, Cube. So can we think of Second State as a, you know, you said there's no infrastructure, I just need to write my functions that gets compared to Wasm and then I deploy them to second state essentially like a like, you know, if I were writing a JavaScript application, I may throw it to Netlify or to Versal second state is that but for WebAssembly. It's my understanding there. Correct. Awesome.

6:39 That's right. So the the the function execution is done on a a standalone VM, a WebAssembly VM. So Second State itself is much broader. The the company Second State Inc, do a lot of blockchain work. You see on the website there, which you'd probably pop over and visit in a sec. Yep. We have a lot of affiliations with some some large projects in the blockchain space. So there's a fair bit to go through on the site there. What what I'm mainly, working on at the moment, is the function as a service, which is the serverless tab up

7:12 there. And, if you click on the blockchain tab or the other tabs, you'll see the other projects that we're working on. We're we're going full steam ahead in in a lot of directions. So probably too much to cover in in one call, but we can certainly look at the function as a service, the serverless stuff today. But, yeah, a lot of work in the VM space, machine learning AI, the building blockchain VM for other really high profile projects. And it's all open source? There's no proprietary bits, or is it a mix? Yeah. Yeah. Every free and open source, the GitHub

7:46 repository is just full of all of our work from the developers in China, Taiwan, America, Australia. Yeah. Nice. Well, let's kick the tires on this then. Let's see if we can get some functions deployed. Is the best place to start clicking on serverless and then get started tomorrow? Yeah. I guess the the yeah. Maybe just suggest a couple of things. If we just primarily look at the function as a service stuff today, if you have a, like, your code editor, if we just open up like a blank page, I just recommend that whilst we work through

8:20 this, we'll just use that as like a like a chalkboard to just paste some text in so we can come back to it. And I'll show you how when we launch code, it gives you, like, an ID, which you then use that ID to call the code and things like that. So we just have, a blank sketch pad, if you will. I'll send you through a link, which is the Rawkode livestream links. There's a API there. If you just click on that API docs, we might start there. That's okay with you. Sort of jump straight

8:51 in and Yep. So this repository is just on github.com/tpmccallum. The link will be in the description afterwards, but feel free to check it out at your own leisure. And here we have so this is like the open API generated document? Yeah. Yeah. So just recently entered this into the Postman API hack, and the name I came up with was Jampack because we just talked about the JavaScript API and markup. And this really is jam packed. You can do everything with this. So you can essentially write Rust source code, compile it to WebAssembly, and launch it, and

9:00 JAM Packed - OpenAPI / Postman spec for Second State

9:30 then call it. So your application can be as wild as what you can come up with essentially, and we can do a bit of that today. So if we scroll down here, this gives you a bit of an intro into it's like an overview. But if we just jump straight into the, API calls here, the first one there that get request, is, yeah, that guy there, if we just on the right, you can see the curl command. So if you paste that into your terminal and hit enter, if that's okay with you, like we just

10:03 yeah. Is that my computer infected with some crazy Watson virus? I was a bit too trusting there, I think, with that curl command. So these are all so we're just doing secure HTTP requests. So those are all of the Wasm IDs that are in the system. So when we deploy one, it sends you back an ID. And so if you go down a little bit further, we've got the the next one there. Oh, actually, go down a a couple. When you deploy a an executable, you can actually get back a Wasm SHA two fifty six hash.

10:38 So if we paste the two fifty six hash filter by into the terminal so it's Oh, no. I think I just need to Oh, no. That's we escaped the, I think we escaped the square brackets with a backslash. I think that would resolve that. Yeah. I think that's cool. So what that's doing is returning you a hash of the executable code that you deployed. And this is good because, say, you're using somebody else's like, say, do a Celsius to Fahrenheit conversion or something like that, and I just wanna share that with the world. If I know that the SHA

11:17 two fifty six is that, then my I can programmatically check that either before and after a call. So if anybody changes like, if the owner of the executable code changes the any part of the code, then it will create a completely different hash, and then I will know, oh, hang on. I'm not actually calling the function I intended. Now it's something different. So we cover that off in a bit. So does that mean if I deploy if I deploy a function on Second State, it's publicly available for for for everybody? Correct. And you can also, when you deploy it,

11:55 make it only available to you exclusively. So 100% private by just putting in a in the header. You just it'll it'll create a usage key. And if you don't have that key, then you can't use it or see it or anything like that. So and the the feature of this is if you go if you make it public actually, we can do this if you want. Yeah. Let's do it. We'll launch one. Yeah. Cool. Okay. So let's do let's do a hello world. So if we head on over to, probably back to that GitHub file

12:29 that I sent you, if you go to demos, let's just click on any one of those oh, just hang on a sec. I'll just sorry. If you just go to GitHub dot com forward slash second hyphen state. Github dot com. Second state. Yep. Second-state. Yeah. And then go just scroll down and click on the it's Wasm Learning. So just in the middle there, Wasm Learning. Yep. And then if you look down there, there's a folder called f, double a, s, function as a service. If you click on that guy. Yep. And we might just do

13:00 Deploying our first WASM function

13:23 hello. So this is essentially just a hello world example. Yep. And if we scroll down there, you have Rust installed already. Right? I do. Yes. Okay. So if you just scroll up a tiny bit, there is a little message that says that you install Rust and SSVM up. So if you click on that SSVM up link, we'll just quickly go ahead and install that. This is a tool chain essentially for the Second State function as a service. So, it's just that, yeah, that bottom guy there. If you paste that in minus the dollar sign at the

13:56 start, that will automatically install for you. Piping to our shell, live on the stream. I get into trouble for that all the time by my audience. VM up. Alright. Okay. And so what we do is if we go and get clone the Wasm learning repo onto your system, then we'll have access to all of those demos. Yep. That's it. Alright. Let's refresh. Not done yet. Oh, no. It's quite big. Give it a second. Okay. Almost there. Got a yield from Jared. Hey. Welcome to an introduction to Second State. Alright. I think we're almost there. So we've

15:04 got fast and we're going into hello. This is a Rust project with. Yep. Yep. Hello, world. Right. It's just hello, world. Yeah. So we could kick off with this. So if you go to your terminal and go into that hello directory. Yep. Yep. And once you're in there, if you just type SSVM up as one word and then build, so space build. Yep. That will get that ready for you. So So this is gonna do a Rust compilation of the project with a target of Wasm. There's nothing magic about that at the moment. Right? And then the SSV Yeah.

15:50 Correct. Is that uploading it to the second state? No. It's just compiling it ready for you. Yeah. Yeah. Do we need a rest up at target wasn't 32 VASI? No. No. This will this will do it. Okay. Let's see what the error was. That. Oh, I don't have a CC compiler. Okay. Let's install GCC. Let's hope Homebrew is feeling quick today, which it rarely ever is. I'm sure there's a know what's going on. Have you got in your home directory, have you got a target set in your cargo dot conf file? I think that might be it. It's actually

16:46 trying to use because you might have done you might have compiled some WebAssembly on the system already or something? Can't remember how to check that, is it? Okay. So that's a tool chain. Target list. There's a whole bunch. Okay. So you said this as target set of my cargo right now. Is there a way I can just get rid of that? Yeah. I'll just have a look. See if I can remember how to do this. So I have compiled WebAssembly before. Is that potentially Yeah. I think you've got a you've got one set there to

18:01 to use that other target, whereas we're just we're doing this through SSVM up. Let's see. What can I do? Yep. Should I just remove these? Remove. Was it 32 of Azure? Yeah. The other two aren't installed. Let's see if that helps. Yeah. It says no download in that target. Mhmm. Oh, no. Oh, wait. Invalid active developer path. Oh. That's that weird x code thing, isn't it? Ugh. Okay. Okay. See, it's it's always my oh, one hour thirty minutes. That better speed up. Let's set and watch it. Yeah. Okay. It's it's it's going quick. I think

19:29 we should be okay. I actually did my max always popping up asking me to install updates and I let it I let it do it last night and I'm assuming that's just x code just needs that little nudge now. So Okay. Sure. So it's quite late for you. Right? You're in Australia? Yeah. Yeah. Well, it'd be midnight soon. This should take us up to midnight. Yeah. Well, thank you for staying up late and and joining me. No. It's a pleasure. Yeah. I think it's it. Drink coffee and eat dark chocolate this light, so it's a bit of treat.

20:08 Yeah. I've been trying to my coffee consumption is through the roof, but I've been trying to get better by switching to decaf. And the taste is well, decaf after 2PM. And I think the taste is alright, but I think mentally, I know that it's decaf, so I just clutch it a little bit. Yeah. Yeah. I want the caffeine. Mac is always wildly inaccurate with its time frames as well, isn't it? Yeah. Yeah. It grows. Seems to have settled on four minutes. So why don't we take a look at some of these other examples for the time being?

20:43 Yeah. Sure. Sure. So see those in fact, I'm gonna throw something wild out. When we ran that curl command, we got a list of a whole bunch of Wazee IDs. Can can we Yeah. Run one of them? Can we use one of these functions? Yeah. We absolutely can. So let's do oh, actually, I'll tell you what I'll do real quick. We'll we'll sort of jump to the front end, because we're we're compiling stuff now and then pushing it in. So let's actually have a look at what it would look like. So if you go back to that GitHub

21:19 page, there'll be some demos. So there's the demos there like the image processing is probably a good one to to start looking at just to explain like this holistically. And I'll just show you one other thing too. If you go back to the, GitHub page again, there's a logs section. What did I put it in there somewhere? So look. Right here. This one. Right? Log. Yeah. Yeah. So it's it's that's not HTTPS. It's only HTTP. Oh, you've got it. Okay. Cool. So this will essentially, I've created a, like, a forward facing log. So when you run,

22:07 it'll actually give you the output of the execution from the server, but it's pumping it out into your browser. So you've got some indication of what's going on. So what we can do is you can just refer back to that whenever you feel like it. If we go to the the demo there This just wants me to upload an image and then I can do some weird modifications with it. Yeah. So I've got an example of an image there. If you just right click open new tab of that, that example link. Yep. And then just save that to your

22:20 Testing the image processing function

22:43 desktop or wherever, and we can use that guy. Alright. So we select the Open browse. Select that. Cowboy. Yeah. That's it. Alright. So we can So if you click, like any any of those buttons will be fine. Yeah. That's sweet. And if you have a if you have a look at the log file there that we've got open, you'll see that when that executes. It calls, WASM ID 273. And so, basically, if you just click any of those buttons, it will just keep calling and doing, the image processing. Okay. Yeah. So we can we can go have a

23:31 look. Actually, if you just right click and view source, because that's like a a really simple page. So what we've got is a JavaScript function up the top there. If you see that, I think it's called call service. And so this is the the j in the Jamstack. So all we're doing is we're calling, the URL there, rpc.ssvm.second state. That's where we're actually you know, the call command before that we're actually just using that same that's the endpoint. And so what we're doing here is we're saying we've got a multipart form data, and we're gonna run a function at that wasm ID

24:10 of x. And the function name is called flip or rotate or whatever. And this particular one on the end is slash bytes because we're we're dealing exclusively in just in raw bytes here. So we're sending an image through to the to the endpoint, and it's processing it using the Rust, which is compiled to WebAssembly, and then it's sending it back as bytes. And then the the browser's rendering those bytes as an image. So we're just running it in its native, image as as bytes. And so that's the j. That that that's the only JavaScript, essentially. And if

24:45 you scroll down to the buttons, I've just made a bunch of different buttons there. And each button, obviously, has got a different name, you know, flip, rotate, whatever. And so when we click on that, they're all calling call service, but they're just passing in the appropriate Wasm ID. So to to go back to your thing before, like, what if we called one of those that they're all calling the relevant Wasm IDs. So, obviously, those are all public at the moment. And if you wanted to have your own custom Wasm anything, you could deploy it and make

25:17 it private. So Very cool. I I I like that. I mean, there was this idea. I don't know if you're familiar with it. I think it was, like, ten years ago where Google tried to launch something called web intents, which was this idea that you could deploy functions to the web and they would reveal their intent like like similar to Android does it. So you say, hey, this function is available at this URL and it satisfies an intent called crop image. And it exposes an API that anyone can call and then your your application can just say, hey, I wanna

25:47 resize an image and it would find the intent from the system and this feels like this could be a really important part of actually making that a real thing like where the same state VM and and the hosting provider infrastructure and functions. Yeah. Really cool way to connect the dots there. So I like this. Yeah. Let's see if we've at least satisfied this as well just now. Well that looks a bit better, it's actually compiling. That looks a bit better. Now we just have to deal with cargo being the slowest compiler in the world. Rusty

26:00 Deploying our first WASM function (Take II)

26:19 being the slowest compiler in the world. But, yeah, that's very cool. I like this. And it's really the fact that it's exposed over just a really basic issue to p rest style or RPC API Yeah. Makes it really convenient and easy to integrate into my application as well. I love that that is Super easy. Yeah. So, you know, you can, if you go back to when phones came out, you know, and we had, like, programming the web and apps and things like that, I think creating apps is is a really difficult framework to work with. You got all these different languages and

26:53 frameworks, and then you've got two different phone companies. You have to, like, build an app for each one. And then if you have an update, you have to, you know, basically tell the people, oh, that the app's been updated, and they have to pull an update onto their phone. It's just to me, that's it's super clunky. This is just using the web as the web is intended. So if we have one of these WASM IDs, you can even hot swap. So if you wanna do an update because, know, obviously, we're doing image processing here, but it could be literally anything. It could

27:22 be accounting packages or, you know, IoT stuff or whatever. Say you wanna you change your business rules or what have you and you wanna do an update, you just recompile your WASM. You don't relaunch it, you just do a put request. So it's the same endpoints as RESTful. And when you do the put request, it'll update the new executable code. And then when that function executes, it now does the new thing. But the user's oblivious. They don't need to know it. It just does what it's supposed to do. Now, obviously, from an application point of

27:50 view, you've got that hash. So if there was a security issue where you didn't wanna run a hash that you didn't know, that's fine. So it's like an inbuilt security mechanism. But at the end of the day, you can create an app in a few minutes just using HTML and JavaScript. And Yeah. Yeah. It's it's super clean. It's all open free on the web. Yeah. There's no sort of proprietary roadblock. Yeah. So I've got I've got two questions, and there's one from Jared in the chat that'll pop up in just a minute. Sure. So firstly, can can

28:19 anyone override what the function does as an ID? Could I could I replace ID 372 just now? You can if you have the if you're the owner, but you can't if you're not the owner. So I guess if if that's built, let's go ahead and build it and and launch it, and then I'll show you how that works. It's it's really straightforward how this works. It's super simple. Okay. So it looks like it's built okay. Alright. Cool. Okay. So in the p k g folder, if you just do an l s on the p k g folder, you'll

28:51 see that there's a hello lib v g w w m. Now, probably the best way to do this is to go back to the, instructions, so that read me file where we were before for the hello, and it'll show you how to deploy it. So, yeah, just back to that GitHub page with the hello. Yep. And so there is a so what we're doing here is we're doing a post request, and we're sending it to that RPC. And so that's all prefilled, actually. If you paste it in, that'll work because it knows that's a hello underscore lib underscore b g.

29:32 You send that off. Yep. And I get an ID back. Cool. So if you grab all of that, that's just a JSON response. If you just take that remember we talked about having a blank like a a whiteboard? We just let's just post that into your blank file and for for future reference. Yep. Yep. And so the WASM ID now is 327 for the hello, and there's your your hash. And there's a bunch of other information, but let's not worry about that for now. Oh, actually, just if you could predify that or just scroll to the right, we'll have a

30:07 look at the SSVM admin key. Yep. Let's just see if this is admin dot j s. Ew. It didn't make it. Oh, that's okay. That's okay. Alright. I'll just go over now. Not sure why Yeah. So we'll just have a look at the SSVM usage key. You'll see that that's zeroed out, and that means that anybody can use it. And so the admin key, which is the next one coming along, which is sent back. Yep. Yep. The admin key is what you would use in the headers if you wanted to change something, like, do a put

30:55 and and update the code. So couple of things we could do. We could one, we could hack the hello and say Rawkode says hello or something and then redeploy it at the same WASM ID and then see the sha 256 change. Would shall we do that real quick? Yeah. Okay. Okay. So we're gonna modify this. We want it to say Yeah. Hello from Rawkode live. And then SSVM build. Yep. And then I I just have the same curl command. I need to pass in my ID. So yep. So what we do now, if we go to the that API, that Jamstack API

31:00 Deploying a new version of our function

31:37 thing I sent through That's probably oh, actually, there might be an example in here to do a put instead of a post. Yeah. Maybe just yeah. Maybe just head over to the Jamstack API. Yep. Yep. And it's probably the first put there. Go on. Up update your put. There we go. Yeah. So there we go. So obviously, we need to tweak that a little bit. So maybe just put that in your blank file so we can oh, wherever you want. Yep. So what we're doing is the WASM ID needs to be correct. Yep. And then so application

32:21 octet stream, that's cool. We need to whack the admin key in there, so that gives us the power to do this. I thought nobody watching the stream has updated it already. Good point. Alright. And then we just update We'll we'll delete it when we're finished. And then obviously, the correct yeah. It wasn't far. I'll leave BG. Yeah. Pop that in. I think that's all good. Oh, that should be package. Oh, yeah. Package. Yeah. Ta da. Yep. So if you grab that and just pop that in the blank file, so same OSM ID 327NewSHA256 hash. Yep.

33:11 Yep. Great. Same admin key, and the usage key will also be zeroed out. So now if we run that by calling it so if we go back to the, API or or actually even to the yeah. To here is fine because it'll be in this these instructions. So we wanna do, yeah, down the bottom there. And just tweak the. Yeah. Oh, I broke it. I'll try again. 327. Yeah. There we go. Rawkode lives. Yeah. Cool. Alright. So now what we can do is it's public at the moment, so we wanna now change our mind and lock it down.

33:50 Making our function private

34:05 So what we do is we hit a different endpoint, if we go back to the API docs. And so just to reiterate, everything that we do is all RESTful API. There's no logging into service whatsoever. It's all just done through this open web calls. So we wanna do a I'll just have a look on mine. My screen's a bit bigger here. So if we go down to yeah. So down I think it's, the last put in that the last put down there. There is a API keys usage key. Yep. Alright. And if we put yep. Put

34:55 the correct WASM ID in there and then the admin usage key. So now if you don't have that key in the headers, it won't work. And but that's super easy to put that in the header. So if we wanna call that again yep. Alright. Yep. Where's the call? This one? Yeah. And so we wanna add a header. So dash dash head on a new line. What's the header called? With so capital SSVM. So capital s, capital s, capital v. Let me just find it. Okay. Just one second. S s v m underscore usage underscore key. Yep.

36:08 That's the one. Yep. That's the key. And Equal. Then the value is the yep. Oh, because I got the format wrong. Okay. There we go. It worked. Okay. Cool. And so, obviously, we can see that if if you don't have the key, it's not gonna let you do it. Now when you create when you launch the executable the first time, if you wanted to create a key for you and you don't have to go through this process of having it open and then closing it, you just put, there's a parameter there which is, like SSVM key and then

36:42 you put true. And then it will be private right from the get go. Now you can refresh the key. So say you do, like, a class or a hackathon or something and you wanna, like, reset it, you can run that command we just did, and it'll generate a new key. So it doesn't necessarily have to be zeroed out. It can just create another key. So you can, like, flush if there's a cohort of students or something, you can flush that executable and kick them off and then give the new the new cohort the new key and that

37:09 sort of thing, or you can just open it right up and zero it out. Yeah. Yeah. I changed it. Yeah. So fairly simple, all just done with some simple calls. Okay. So that's So I'm curious then. Right? Like Yep. And, Jared, I've not forgot your question. I'll get to it in just ten seconds. But I've not given you any money. I'm deploying functions onto the web that I can then use. Are there usage limits before I start having to pay? Are they Yeah. Like, how how does that work? So it's rate limited at the moment, and I've just

37:45 set it to some, like, arbitrary, like, a hundred requests a minute or something like that. So what we do I'll talk I'll talk about this really quickly, but it's a it's a whole another subject. But in the in the blockchain space, you know, there's this notion of gas. Like in Ethereum, the the EVM has gas, and so you wanna perform a transaction. So you give it some gas, and it goes ahead, and the miner's mine, and they make a profit and these sorts of things. We have that same infrastructure on the WebAssembly VM, we where we

38:15 have this notion of gas. So we have a statistics section which is implemented on on here, and it will depending on what the computation is, it will charge you a point system. So it's essentially like calculating compute. And the gas is a number. And so ultimately, it's a only pay for what you use system. It's very efficient. So there's no, like, monthly subscriptions or any sort of costs. So really brilliant for a a business model for if you were a web developer and you wanted to create an app and do some, like, you know, image recognition, like plant recognition or something, there's

38:55 all these functionality in the Rust that I can show you later where we do, some machine learning and AI stuff. You would pay, like, fractions of a cent per piece of gas or whatever. But if no one's using your app, you're not paying anything. But as soon as they use your app, then the gas is being calculated. So there's a there's a good business model you could take to investors and say, you know, if the app's dead for forty eight hours, we're not being billed. And so it's different to a cloud provider where you've got any sort of infrastructure that

39:25 you're, holding on to and paying for when you're not actually using it. It's strictly a pays pay for what you use, architecture. Yeah. Which is the best way we have to do it. Yeah. It's it's kind of the ultimate way. Okay. Well, that you mentioned ML there, and I'll I'll bring in Jared's question, which was Yeah. Okay. Coral did quite nicely. But he asked this, you know, is this mainly used for ML functions? I guess I would pivot that a little bit. I mean, do you see people using this for machine learning workloads? Yeah. I'll show you a really cool demo. Go

39:40 OCR and translation demo

39:56 back to the the Rawkode links. I just did this one the other day. I thought it was really interesting. If you go up, there's a OCR and language translation demo. Mhmm. And I really love this one because this has actually happened. You know, you go to a restaurant and so if you save that as like, you have a a French restaurant and you have no idea and the waiter wants you to order and you you honestly don't know and so you point at something and you get something you don't want, It's kinda funny. And I've been I've been caught in

40:33 places downloading apps and, you know, it's kinda ruining the experience because you're trying to do the language translation. I've done this so many times myself. I'm sat there with my phone trying to get a picture and get it and get it to translate for me. So so we just knocked this up the other day. This is like a super simple web app. If we right click in view source, you'll see that. But, basically, what it's done is it's taken your image. It's on one hand, there's a there's a function as a service endpoint there, which we can see

40:59 in the source code. It'll have a WASM ID, and it has taken the actual letters out of the image and turned them into characters. And then there's a second function call which converts the language to the language of your choice. And so now we have the menu in plain English. Very cool. I like that one. Yep. Using using TensorFlow. So you can go ahead and train to do whatever you want. We have, like, birds and food. And there's one where I have a video, and you play the video, and it'll tell you what the pizza topping is and stuff

41:31 like that. So we're just building the infrastructure, though. These are just, like, prototypes, demos of what you could use it for to create your app. And then once you get that user base, then you pay for what you use, and it makes your app attractive too. There's a code for this? Can we take a look at that? Yeah. Yeah. Sure. So if we start off by right click view source, we'll have just have a look at the the basic bare bones of the the Jam. So there's a function there, I think. Yeah. So it's fairly

42:02 straightforward, the JavaScript. So it's just that call service again, and it's multipart form data as well. And if you can see there, we've got the, Wasm IDE of 284, and one of the functions is called OCR. And then the next one below that, a few lines down, is is also two eighty four, and it's called translate. So we can pop over and have a look at that Rust, which compiled to WebAssembly and was executed on the VM. So I think that is Yeah. Let's see. OCR? Yeah. I think if you go to OCR, open up that.

42:42 Yeah. That's it. So I've deployed that. I've done an SSVM up build and deployed that, and it's come back with that WASM ID. So that's the the Rust code that will execute. Sorry. That will compile to web assembly that'll ex yeah. The the code jumped there from hello world to OCR with TensorFlow. Don't need to understand that, but I like what it does. So that's cool. Yep. We have a a question from who's asking, is there a time out for the function execution? No. Not at this moment. So I could write a function that takes

43:20 thirty seconds, five minutes, and that'll run quite happily in SSVM. Yeah. I might I might actually show you something. One of the powerful things about this and one of the reasons why we built this is because a lot of technology in the hand of users is moving from powerful machines to smaller and smaller, light clients, thin clients, you know, phones, IoT devices, and that sort of thing. What we've done is taken as much of the heavy lifting and all the processing and storage and memory and all that stuff, and we've taken that off the end user like the client, and we've

43:54 moved that across to the Second State infrastructure. So we've come up with ways that we can actually stop functions from taking too long. Essentially, you use the infrastructure as it's intended, your function should never really take that long. Like, this is a great example of doing some really powerful processing here in fractions of a second essentially. And so this this is very quick. Where we find it's slow is if I have a giant image that I need to upload from my tiny phone on my very poor bandwidth and then process it and then send the

44:00 Convention for server side fetching

44:26 whole that that's actually a bottleneck. But it's it's not really the system. It's more like my bandwidth and my device. So I could show you something really cool. We can do a remote fetch of an image. So you know how we're doing the image manipulation before? Mhmm. What we can do is we can hack the so, like, the thumbnail demo Mhmm. In the Wasp learning. And instead of us uploading, you know, you opened it on your system and then it sent it to the server and back, what we can do is we can get it to go and

44:57 remote fetch an image so it's not actually using your bandwidth, and then it processes it, and then it sends you back a thumbnail. So to clarify, instead of a browse button here, we'd have a text box Yeah. Pick a URL Exactly. And then okay. Yep. Yep. That's right. So if we go to a different one because that's sort of like a holistic demo. If we go to the was I'm learning and the fast and maybe click there's an image thumbnail, like image hyphen thumbnail. Oh, sorry. So just in you have Second State. Yep. So in there.

45:39 Yep. Yep. Yeah. Perfect. Okay. So in the HTML section of that folder so we're in the Rust source code now. If we go into the HTML, open this guy up. We can go and do a bit of a hack down below. So instead of in the form, instead of the, where is it? Instead of the the input typing file, we can change type equals text. So just switch out the word file for text. That that would work. And then that's probably all we need there. So then in the Rust where we get the baits received, right now we're

46:25 That that'll be okay. We don't need to touch that. Because what we're gonna do is we're gonna allow the HTML to tell Second State, hey. I'm not giving you an image. I want you to go get it yourself and then do stuff to it and don't use my bandwidth. So if we, if we go up to we'd have to do one more thing in the HTML to make that work. So if we go up to the form where we actually have the form data and it says form data dot append input underscore one, and then it's passing in the actual file.

47:03 What we do is we take away that and we would exchange that for something like document dot get, you know, dot value or whatever. So we're actually gonna take the text out of the the input text and use the text instead of the file. I'll just do a quick Google for that. Okay. So it'd be like document dot get element by ID value one oh, input one. Sorry. Yeah. And then, dot value. That should be okay. And then we add that, and then we append that to the form data. Yeah. Yeah. So I'll just explain something real quick before

48:16 we leave this. When you have multiple inputs to a function, we know that in any programming language, you have a function and then you have that signature. Right? So you have, like, your arguments. They have to be in the right order. And so when you're dealing with something like this over the web, if we just say, hey, go get a bunch of images, they're all gonna come back at different speeds, and that's gonna break. So what we do here is we have this convention in the Second State infrastructure where we just simply underscore with a number,

48:49 and then it will arrange those in the right order. So I'm I'm explicitly saying underscore one, and then I'm giving it that particular URL. If we just pop over to the Rust, just have a a real quick look. Yep. Yep. So we we sort of got this agreement. It's like a convention where the function is called thumbnail and it takes one argument. So I'm saying in the HTML that this is underscore one. If we had two arguments, let's say we're watermarking an image and we had text as well or something, the second argument would be the text. So the Rust

49:22 is expecting that. So what I do in the HTML is say input underscore two. The input is irrelevant. It's just the two that matters. So as long as there's like one, two, three, four on the end Mhmm. It'll know, oh, this is the order of the arguments that need to go and be sent over to the Rust. Does that make sense? Yeah. Yeah. You're just you're using like that incremental IDs convention for the the the Yeah. Functionality. Right? So does that mean that we need to change this image to be load from memory to load from URL or something?

49:48 Because that's really No. Not at all. No. It'll it'll send it to the function as a service system will go and do that for us. There's two there's two ways you can do it. One, you can if we pop back to the HTML Mhmm. The one way you can do it is you can do a, like, a a post request. And the other way, if you just put in a URL, it will just go and fetch that. And so the the convention for this is if you put see where it says input underscore one on that

50:16 line you're on now? Mhmm. If you because the URL equals yeah. So if you put the word fetch underscore as a prefix yeah. Prefix. Uh-huh. And and so fetch underscore input underscore one. Yep. Fetch underscore input underscore. Now what it's saying is, oh, hey. This isn't just text. I want you to actually go get this. And this is our convention that we created. So now it knows to actually go and get the image and bring it back as as raw image data. Yeah. Yeah. I like that. And that should work. Now I'll just I'll just get you

50:58 an image. If you go back to the GitHub with the links Mhmm. Maybe just scroll up. I've just, like, plunked an image up here in the there's like a remote image underscore one up the top there as like a JPEG. You can click on that. Click on the download button. Yep. I think you can actually click on it because you need the raw image. Yeah. And then take that URL. Does that say raw.github? Yes. Yeah. Cool. So that if we paste that in the text box, it will actually just go and get the the images raw bytes.

51:39 Well, we'll have to deploy this first. Right? Just have to you'll actually just have to click save on the HTML because we're not actually changing the rust at all. Oh, so you just want me to open this HTML file? Yeah. Just on your desktop. Yeah. So just save the HTML and just open it on your locally on your PC. And this is where the Jamstack thing comes in. You don't actually have to deploy it. It doesn't have to be served. It will just work. Yeah. There is a way to open this in my browser, isn't there? I'm

52:08 sure I've done this before. I'll just do it from here. So what this was the image thumbnail. So open Yeah. Image thumbnail HTML index. Looks like bitcdn.net might be a little slow. There we go. Oh, yeah. Cool. So do we have a text box then? Do we do that? Yep. Oh, cool. Okay. And then, hopefully, if you hit that, Today. Okay. So what that's done is your computer has only sent that text. Like, in the HTTP request, you sent that text that you've pasted in. The server side's gone off to GitHub, got the image, come back, run the thumbnail,

53:16 and then just sent you back the thumbnail only. Does that make sense? Yeah. Yeah. I like how the JavaScript is just, you know, a very thin layer on making like an interface to the actual back end code and then you've got these conventions of fetch input which tells Yeah. Second state to, hey. You wanna go grab this link and send it into the rest function. So that's Yeah. Yeah. I quite like that. Very cool. There's other things, similar. So you can do, callbacks. So after a function executes, you can put in the header or the

53:52 body, or actually, you can submit a callback into the system. There's, like, a few different ways to do everything because we just try to be as flexible as possible. And what that'll do is it will execute a function, and then when the function's finished, it will perform a callback. So it'll kinda call back on itself and do more stuff. So, like, you could maybe now send a text through a service or, you know, send an email or something like that, say your image is ready or what have you. Can I use that So does that Is

54:19 that callback the same way you would recommend to do, like, functional composition of chaining more than one second state function together, or is there another primitive for that? No. Exactly that. Yeah. That's exactly right. Yeah. So you'd have we have a convention with which is SSVM callback. And if you put that in the header and you put in adjacent object, which is a callback, say, like host port body, it'll actually perform that when it'll wait and say, okay. Do all your stuff. And then the result comes back, and then it goes, oh, hang on. I gotta call back, and

54:51 then we'll do that on the end and then send you back the result. So things like, you know, you might oh, and there's also a prefetch as well. So you'll do, like maybe go check a price of a stock or something and then then calculate some change with rust. And then when it's finished, then maybe the callback converts it from British pounds to Australian dollars or whatever, and then it will send that back to you. So you can do a bunch of different things. It's sort of like programming the web with web assemblies. Alright. I

55:22 guess I got an idea then. I'll throw this out here. You can get me away from it if you want. But if we wanted to show the functional composition, I believe you've already deployed the anagram finder to Second State. Is that right? Yeah. Yeah. So so could we then write a page like this? It takes a string and put and we just have a really simple function that trimmed the space and then forward that onto the anagram finder and then give us a list of the potential anagrams. Yes. So if we go to the anagram finder,

55:55 I think I linked to that on the GitHub page with the Rawkode links. Yeah. Which I think I've now went away from. Let me just pull that back. I think there's a demo there. Let me just close a few of these tabs actually before I get to Okay. Sure. Well, like that log one. Let's let's keep that Yeah. That looks cool. Okay. So anagram. Pop you open. I think that's the article I wrote. Alright. Okay. Okay. So That's cool. Yeah. There's gonna be a link at the bottom there somewhere. Yeah. I'll put this article in the show notes

56:38 as well. Cool. Thanks. I was just trying to give examples. I saw you guys do that. I'm like, this is brilliant. Because that that would be a killer app for a for a trivia night or for a Oh, yeah. It's safe. So we can see here a cage ever comes back as trace. That's right. Yeah. So what happens done there if I Sorry. Go. I'm just gonna add some spaces. That should break it. Right? Yeah. There we go. Yeah. Spaces at the start, spaces at the end. We've broken that again, but we actually want this to work. So I was like,

57:10 can we just throw together something that takes this input and then chain like the straps the spaces or non alpha pneumatics, whatever we wanna do and then pass it on to the Anagram Pinder. Yeah. Sure. Yeah. Sure. So we're gonna write a new Rust function that strips the spaces, and we deploy that as a new Wasm ID. We call that. And then when that's finished, then we're gonna come back and and then do this. Yeah. That that we can do that. Yeah. Okay. You think we could do that in half an hour? Yeah. Yeah. Yeah. Alright. Okay. Yeah.

57:45 Sure. So why don't we just start with like something I know this is it seems almost trivial, but let's say I wanna create a new second state function that just takes a string, strums the spaces and spits it back out. What what's the how do I do that? So we would Unless you have any cooler demos, by the way, if it shows off. Well, yes. So basically, what we do is we'd instead of using the the prewritten demos that we've got, we just do a cargo new and, you know, we we just write a a

58:00 Permanent and ephemeral storage / state / persistence

58:19 Rust function does that. But I do actually have something really cool to show you. I don't know how long it will take, but it's it's super cool because it solves one of the problems that WebAssembly well, it's not a problem, but it's just like a nuance of WebAssembly and its, persistence. Because one of the things with WebAssembly is it executes in a stateless environment. So essentially, when you call a function, it creates a new instance of the VM, the stack, and it executes. And then when it's finished, the stack the the instance of the VM is destroyed, and

58:51 it's gone. And so that runs by itself in a standalone sandbox environment. And then when it's done, it's gone forever. And that's a cool safety feature. And that's the fundamentally what WebAssembly how it works. But what you don't have is any persistence. So to write anything useful, if you're gonna execute a function and then it just disappears and you and then you have no persistence, then you can't really write an application. So what we created was a storage mechanism to have persistence, and I'd love to show you that if that's okay. Yeah. That's really cool. Yeah. Okay. So

59:28 there is a Hello World called I think it's called Hello Storage. Let's see. It is indeed. So pop that open. And so what this Rust does do you mind me sort of diving a bit deep into, like, how we did this? No. Go for it. Is that cool? Yeah. Okay. Cool. So essentially what we did was the WebAssembly VM is written in c plus plus and we're compiling Rust to WebAssembly. And the WebAssembly VM only deals in its native, you know, data types. And one of those is the I 32. Right? So what we did was we wrote

1:00:18 a library in Rust and put it in Crades that takes any high level Rust data type like string, structs, doesn't matter, and it serializes it to I 32. And then what we're able to do is have the WebAssembly VM chew that and process it because it's it's saying here, have a bunch of I 30 twos, do stuff with them. And what we did was we used the foreign function interface. So between Rust and c plus plus to actually say, here's a high level Rust object. I've converted it to a whole bunch of I 30 twos. Here they all are. I want

1:00:59 you to take those verbatim and shove them into your memory. And then what we did was which which we're basically gonna show here is you can go and you can go and fetch them and bring them back. So this this persists. But when a step further, which is even cooler, instead of just doing that with like, you know, here's some stuff I want you to store it and give me back a key, we're actually using the Rust standard env. So you program like you would here, and you don't have to actually manage any keys. It's just if your application like, if your

1:01:31 function endpoint is deployed at Wasm ID number one and you put some data into that, it will just persist. And then when you come back like a year later and say, give me back my data, it'll say, there you go, and just give it straight back to you. So it's it's really it's a fantastic solution to persistence in Rust WebAssembly tool chain. Does that make sense? Am I explaining that? Yeah. Let me try and summarize that back to you then. So Sure. I am familiar with the fact that WebAssembly only speaks arrays of bytes, alright? So you've got to

1:02:06 run that problem by providing a serialization layer that actually allows you to work with native rust objects and types and then SSVM handles the translation. What's really cool though is that you're handling or providing persistence across runs by just allowing the programmer to use environment variables. And then the SSVM is actually gonna say, oh, there's a new environment variable in this execution, I'm gonna go store it somewhere. And then the next time they come back, that was an ID allows that state to be then pulled back and from whatever storage back end has been provided. Again,

1:02:40 by just saying here, there's an environment variable that's available to you. They don't have to worry about fails. They don't have to worry about anything like that. It's just really simple. Exactly. Very convenient. Now you don't have worry about databases or anything like that. Yeah. That's exactly right. So the the VM disappears. It's done. It's gone. When you call that function again, a new VM comes up. It's spawned out of nowhere. However, it says, oh, you've got some data here. Would you like it? Are those keys mutable over time? I can modify them in any

1:03:11 execution? There is two modes. So the top one is mutable, and the bottom examples are immutable. So the the top we can do it. Do wanna do you wanna call this? Yes. Let's do it. Cool. Yeah. So if we go to the GitHub page, which has the so the the Wasm learning Hello Storage, I think there's some, like, cool commands in there. We can actually we can actually use this. Yes. So And we can we can definitely do this in half an hour. We could, like, we can do all this. So Second State while I'm learning.

1:03:52 Yep. So Vignesh has said it's kinda like Cloudflare workers. Not actually familiar with Cloudflare workers, to be honest. Hello story. There we go. Yeah. Yeah. Okay. So let's build it. Yeah. Storage manager. And then recur less with our ID. Uh-huh. Oh no, that's a deploy. Okay. Got it. Yep. We'll just give Rusty a couple of couple of hours of catch up. Yeah. So what's actually piloting that storage on the on the back end? Rocks DB. Rocks DB. Nice. Yeah. And we just transacting back and forth, in its native, binary format. So we're not converting anything to

1:05:06 strings or doing any, like, cumbersome conversions. We just take the high level thing, we serialize it and just pump it straight into rocks. And rocks takes whatever you give it. So And wanna just just hands it back. I wanted to store like a, you know, like an image, would I have to base encode that first or is that something that would be handled? I know you just would you would just send it as raw bytes and Rawkode would just take it as raw bytes and just say thanks. The if you wanna have a a real quick

1:05:40 look, I I wrote a piece of software which makes this possible. Sorry. I'm interrupting now. Maybe. Back in that Rawkode links, there's a there's a down a bit, I think. Oh, yeah. The serialized, deserialized, the crate. So that's basically what because you know how you can serialize anything to, like, UA. Yeah. So you just get like a byte array. What this does is it takes that byte array and it turns it into Wasm variables. So a whole bunch of Wasm variables, and it will safely do that back and forth for you. So that's what that's the, like, the link that

1:06:33 makes this possible to to the Wasm VM. So the Wasm VM says, oh, I understand that. Give me all those I 30 twos I'm gonna do, put them into RocksDB. Then when they come back out again, it gives them back. And then this part of it turns it back into the byte array, which then obviously the the high level can understand. Like an image, you know, it says, oh, I'm an image, you know, once you get a display that. So there's like this middle section that which is what you're looking at now. Okay. So let me pop back to

1:07:06 okay. Got another question from Vignesh. What if the value is larger than a gigabyte? It it does up to four gigabytes at the moment is the the storage limit is four gig. Yeah. That's quite generous up to four gig. Yeah. Yeah. Alright. We got our ID, so now I can store a string inside of this. Yeah. So our ID is 32 Yeah. So let's store Hello, everyone. And I always like to throw emojis into the mix here. So let's get a Nice. Let's put in the meeting. There we go. My chairman doesn't like it. Okay.

1:07:52 And 328. Okay. Done. Cool. Okay. Now interestingly correct. Now that's the mutable, so if you do another one, it'll give you back a different key. And now you can have this whole array of like, if you're doing this programmatically, you can store all these in an array and have all this data that you can call by keys, and they'll all they'll refresh the keys for you. And and you can update the data at a key, but you can also generate new keys and things like that. So this is one modality. And so this isn't using

1:08:37 these Sorry? Yep. So I guess I guess I'll I'll let you do the Alright. Okay. The demo. Yeah. And then I actually got the feedback, so that's good. Nice. Yep. And so now if we do the standard end, like, if we scroll down, there's a different demo. I'll just go to it as well so I can see it. Storage. Okay. So we called store a string, and now I can call store a string via standard env. Yeah. Okay. So if I just let's say, change this one. Mhmm. What was it? Store a string via standard. And

1:09:39 Via s t d yeah. Via underscore s t d underscore e n v. Alright. And then let's add another emoji. So hello. And we'll in a wave. Cool. And we get a different ID. So this is our wave theory. Now you don't need to store that ID. It just returned it because it could. That will always be the same because that's that WASM ID standard and signature. That's that's persistent. That's immutable, essentially. That's Gotcha. Gotcha. Okay. Yeah. You so you don't have to manage keys is is essentially what's happening. Yeah. You can manage them, but you don't have

1:10:22 to. If you use standard end, but just it's just there when the VM spawns. It's your data is just sitting there waiting for you. So does that mean if I take off that parameter and just modify the function call here, do I get that back? Yeah. I'll just check if that'll work. Hang on one sec. So load a string. And yes. Oh, I beg your pardon. I'm in the wrong spot. Load a string. Yes. Just do just do no header either. Just nothing because you're not actually putting anything in. So just the post and then stop after the function name, and

1:11:06 that should be There we go. Yeah. And you set that And you can put anything in there, like a JSON object or a image or a so that can be like that function as a services standard end storage. You you might wanna pause, Jason. So when it comes back out, you might wanna, like, crack it open with cert and say, you know, give me all the keys or whatever. It doesn't have to be just text. It could be a struct. But it's it's not immutable because I think I just modified it. But the the key is fixed. That's

1:11:41 what the value is there. I got it. Okay. That makes sense. Yeah. Yeah. Right. Yeah. So so you're not managing keys at all. It just is. It just it's just some data that you've got access to by standard. Yeah. Yeah. That makes that makes sense. I understand that now. So I can use that function, use the environment to store it. So whatever calculation, whatever I need to process, and then next time I call, I could pull it out, pull it out as often as I need. Excellent. Yeah. Very cool. I like that. We have another feature as well which

1:12:10 may or may not be useful. It's called ephemeral storage, and it's really easy to use. You don't have to write any rust or do anything. It's just an endpoint. If we go to that, jam packed API, we can have a quick go of that. And I'll just explain that in a bit more detail about why it exists and because storage is a big, I guess, you know, given that the the WebAssembly VM is stateless. That's so if we go down to one of the put I think it's a put request. I'll just open mine up so we can see.

1:12:48 There's callbacks. Ephemeral storage. There we go. Femoral storage. Yeah. You got that. Okay. So there is a I think there might be one up from that. It might be a post. I just need to find it. Sorry. I'm Yep. Post. There you go. There's a post? Yeah. Okay. Oh, yeah. Cool. So if you post the raw data I guess you could just do that, like, literally paste that in your cool. So that's giving you back a key. So if you now take that key and do the next command using by passing in that key now this

1:13:42 is just a as a rest endpoint. You're just sort of putting the key on the end of the URL. You're not actually doing anything with complex headers or bodies or anything. Yep. What? Cool. And what'll happen if you do nothing else, that will disappear in exactly one hour. But if you do anything to it, like update it or touch it or whatever, then it will persist. So it's just like this additional feature which is right up at the top of the API stack, if you will, and it's for IoT devices and things like that. Like, if you've

1:14:22 got a temperature sensor that's just recording, like, once per second, and you you kinda want it's almost like cache, like buffering. And then so you're not writing any rust or doing any sort of low level stuff. It's just right up at the at the API level. And then you can use those keys to you you might wanna consolidate a whole bunch of information over the course of, like, thirty minutes and then do something with that. It's just to stop the developer from having to write Rust to do everything and deploy things, and it's just like a high level convenience storage.

1:14:55 Yeah. Because of the fact that you would we're dealing in a stateless environment, it sort of makes it a bit trickier to write an app. So I I think those last two examples are there's something really subtle there. Right? But I wanna kinda call it out is that with the storage with the save and storing thing from the first example and with this ephemeral storage that has an error. I mean, I essentially I could use these as a database, a key value database. And the latter one function very similar to something like Redis with a time to live

1:15:25 on that cash value as well. Even if I don't use any other of the functions of the service, which is also really cool, is that I have a key value Redis available to me on Second State Virtual Machine for free Over the the rate limits. Yeah. And and I guess the only catch is, like, if you could guess that key, then you could see the data, but that's gonna be pretty tricky because it's open. So Yeah. I mean, I could I could use I mean, I didn't have to use the I mean, it's a UID. It's like a

1:15:57 secure in a weird way, but it would be great to start getting Well, I I guess I guess you hit if someone was trying to just brute force keys, they'd hit the right limit. Right? So Well, yeah. I'm not saying I would use this storage as my, you know, one password replacement or anything like that where I just think, oh, my UUIDs can store my passwords. So Yeah. Yeah. That that would be a cool hackathon project actually. Yeah. Yeah. Alright. That's really cool. I like that. I've covered so much. Like I could write Rust code, compel it to Wasm and store

1:16:27 it and it's always available over an HTTP endpoint. And then beyond that, you've already got these pre canned functions which are deployed for a femoral storage, and I can use persistent storage. Are there any guarantees on the persistent storage for my application? Like, could I or should I expect that to disappear at any point? It's, you know, technically, it's forever because the system will run and continue to function, and the the information goes through into the RoxyB, and it will be there when you come back. That that's the the premise. You know? That's the all things being equal, it's

1:17:10 that that that functionality is intended. So yeah. Okay. Just a random question. Who provides the compute? Is this sponsored by Second State? Are you providing all the compute power here, or is this where the blockchain comes in and other people are providing compute? Is this distributed in the back end? Do wanna give me a little bit of information on that? So so that's essentially the next step is to we've come up with a plan where not only is it feasible for for us to host this because we have this the statistics like the gas and the metering and things like that.

1:17:51 Any app developers who wanna build upon this, they can also talk to their investors and say, you know, I've written a few hundred lines of Rust. Here's some HTML and some JavaScript. Here's what it looks like, and here's what the users would do to convert their menus to English or whatever whatever usage use case they have. And then, you know, what's it gonna cost me? Says the investor. Well, it'll cost you, you know, 2¢ per or, you know, or 0 something cents per use. And so, you know, if the if the application if the web application users are paying a dollar

1:18:25 for the app or something, then you're gonna cover those costs. So the the business model is sound in that. We have a mechanism to meter and charge in. But that's really the implementation of that is coming. We've built out as flexible infrastructure as possible so that we can do stuff. And the machine learning and AI and all the TensorFlow, and and the Rust components and, all of that sort of those prototypes are just trying to demonstrate that you can build a lot of cool stuff on this. It's kind of up to your imagination really as to what you can build.

1:19:01 I've tried to write articles and, you know, like, anecdote. I'm like, that's cool. I could do that. That that's easy. But you could come up with some really nifty stuff and build it out in, like, no time, and and it would be fairly cheap to run. Yeah. There's no doubt that the WebAssembly VM's very powerful. Oh, probably the most important thing I should mention is we're not running just in time compiled the native WebAssembly executable that gets uploaded, we actually our developers have written so we actually convert that to a o t compile, which is why it's so

1:19:35 fast. And there's an article just published, which I can send you, and and you can link to that about the benchmarking between the Second State WasmVM and the other runtimes and the other VMs. And our IoT compiling component means that our stack like, our execution is blisteringly fast. So the the the latency across the network is really the the biggest thing that we're seeing. And the other the other cool part about this, the SSVM up tool is basically, it's based on Wasmpec, but we're not just writing this for, like, the web or for the for the browser.

1:20:15 We're taking this onto the server side. So you can do all of this on the server as well, like, even in the command line. So no API, no web. Just if you have, like, a factory or some sort of closed environment where you just want really powerful execution, you can just do that on like, directly on the server by installing the SSVM on on that machine and and executing that. We're trying to cover off all the different areas. This open API is essentially giving end users access to the back end through the open web. But you

1:20:49 can you can run this stuff just straight out on the on the server if you want. Like, literally command line and pass in a big file and do whatever you want to it. Awesome. I mean, there's just so much flexibility and options to the way I interact, engage and kind of compose these things together. Like you you can do a lot with this. Is Yeah. Is there anything that you wanna show before we finish up for today? Is there anything that we've missed that you'd like to? I don't think so. I think that's that's a fairly good

1:21:28 yeah. We've done remote fetching and we've done storage and yeah. I think that's that's a good Yeah. We we've a lot. I mean, we we had some Rust code. We built it. We deployed it. We upgraded it. We then interacted with it through really simple HTML with a little bit of JavaScript. We covered the semantics around how the inputs with the numbers work. We covered fetching. There's just so much there. And then at the state, the ephemeral storage interacting with the environment. So much good And there for people. And we covered the, security aspect. So it

1:22:04 can be a private function, or you can open it up, have it public, but you can choose to toggle between those two with just a simple request. So that's that's a big part of it, I think, too, is Yeah. I think code reuse is interesting because, you know, the DRIP principle and KISS principle and all these things that you learn. We really we really shouldn't have to write, like, a basic example, like, you know, Fahrenheit to Celsius or something. That should only probably exist in one place. Right? Or any sort of decent function that exists. It'd be amazing if instead of

1:22:41 people writing that separately, if it was in here and someone could improve on it, they could come and have a look at the Rust source code, make a change, improve it, prove that it's more efficient or whatever, and then get approval to update it. That was my idea, and then that's like your superior function for that purpose in the world. And and but that's not reality, is it? I've got a a really cool hack project for us to maybe work on if we if we have the time where I I'd really love to see like, can I add

1:23:09 arbitrary headers to my function deployment, like as metadata? To the rust or to the Yeah. So if I write a function Yeah. Can I just scrape that to Second State somehow? Can I like if I wanted to add an intent header, SSVM underscore intent, it says resize these images? And then could I then provide a function which discovery via that metadata to actually build out that intent system on Second State? I think that would be really Yeah. Yeah. Absolutely. We could definitely accommodate that. And I think it it'd be great if you had a place where you could go to shop

1:23:46 for functions or functionality and and then you could, like, rate it. You know, this is the best temperature conversion function because of whatever reason. And, you know, you're sort of, like, building up a what would you call it? What's that restaurant app where you Yelp or something? Yeah. Yeah. Yeah. Yep. Yep. That would be brilliant. You can be shopping for a function. You know? What's what's the best OCR function? Test it out. Yeah. That works. Plug it into your app and then give it five stars and yeah. I I think me as a as a developer, right, especially

1:24:18 if I'm leveraging a platform like this, and I say, oh, I really wish I could translate this from English to French and I I shouldn't have to write that again. Other people have done it, they should expose it as a translator with languages that they support and then I just call it and I can pick what I like or I could just tell the intent system, hey, I wanna translate. Don't really care which one you use. To and like lots there. Not gonna try and drag us into a different conversation right now, I think we should continue this offline

1:24:44 at some point. We do have one more question from our audience. Fagnes is back again. Thank you, man for the questions. Keep them coming. Is the function deployed globally? So, you know, I'm in Scotland right now. Where where is this being served from? Because the latency has been quite good, actually. Yes. It is deployed globally. Yes. And at the moment, we're just running this from The United States. And so me calling it from Australia, I generally find it's you know, when we take talking millisecond execution on the VM, I I'm finding, a second to me seems like a long time. But when

1:25:18 I but when I deploy it in Sydney, it's super fast for me. So it's it's really the latency. But, yeah, it is global. Yeah. And we're setting up another server, another lot of infrastructure at the moment, which I'm gonna do, which is inside China. So that's just doing it on a different platform. Yeah. So Awesome. Alright. Well, that was really great. I really loved learning about Second State, and I can see so much potential and how other people can leverage it and and use it. And I I can't wait to kick the tires on it

1:25:51 a little bit more. Do you have any final thoughts before we finish for today? No. I'm all good. Alright. I'm good. Thank you for having us. It's been a pleasure. It's been really great fun. No. Thank you. I I know you stayed up really late. It's getting to what? Probably half eleven at night for you. So, you know, thank you for taking the time joining me today, walking me through this. I had an absolute blast and we'll chat again Awesome. Thank you so much. Have a great night. Okay. Thanks. Bye. Bye.

Technologies featured

Meet the Cast

Weekly Cloud Native insights

Stay ahead in cloud native

Tutorials, deep dives, and curated events. No fluff.

Comments, transcript, and resources

Documentation

More from Rawkode Live

View all 173 episodes

More about WebAssembly & WASI

View all 17 videos
Rust

More about Rust

View all 22 videos