 This is Michael, and Michael Yuan, and I'll find you out for that, and this is Jim. Tim, tell them. This is, I got a little bit about ourselves. So we are a company for the second state, and the white second state, you can come and ask me about that, so I know. That's why it's the fourth state. We are a second state. Why? Come to talk to us after that. And so we are open to our contract knowledge company, meaning that we try to stay above the consensus there, so we don't want to do sharding and mining and all that. We want to focus on the execution mechanism, where our expertise comes from, and we call it middleware. I know it's a data work. The middleware force is not a control. The middleware is a volume architecture. So our focus has been developer tools. We have language compiler for different languages, from in and back, and next generation virtual machines and execution engines. So we have virtual machines, and often data services can come up to us, including smart contracts, search engine, and explore. And all those, we combine into a single web-based product for the builder idea. Next to the builder, that's the second state that I own. What it does, it's a little bit like remix, but it doesn't require manual ask, but we are about it. And then you can write your smart contracts, you can write your tabs, you can write web-street, and everything in a single web-based. And then you can write public projects, in a certain classic. You can do that in a couple of minutes. And you ask people, how do you do that? Do you talk about it? Well, there's a way to do it. That's something we'll have that for today. We saw those language standings that we have here, and the execution is a little bit of a back-end. So, we have to play in some classic labs, over to two. So, we are fortunate to be involved in this project. We partner with other public projects, cyber labs, and some other enterprise players. So, it's just a few minutes' talk. We know that's the serial plus, which we are involved in this book. A lot of good blockchain applications. It's published by Amazon, where it's very bitter this year, and if you go to secondstate.io, you can play a little game and do a little discovery on the serial classic blockchain for this kind of development. Okay. So, to start off our talk, because we have a lot of content, I won't set the overall frame or the overall scene of this talk. The two challenges for Solidity, I don't know why, you know, why developers find smart contracts so difficult to grasp and write. The first is, it's not only just Solidity, but all other smart contracts are currently available on the market, especially if the language is generic. It has to be fully compete. So, that means it's difficult to optimize photo means specific applications. We come from an enterprise world. We know that DSL has always been one of the, you know, if you look at the platform and you look at the business as DSL, domain specific language is very important for real world enterprise use cases. And today in Solidity, it's very generic. Everything has to be fully compete, so there's no specific optimization for photo means. And the second is, the design of Solidity and other smart contract language today must support most consensus and non-contents as well. So, you know, we ask ourselves why it's so difficult to do stream manipulation in Solidity? Why is it that there's no random number in Solidity? Why is that no JSON support in Solidity? It's because the Solidity code has to be able to create transactions on the blockchain. If any of those goes in there, it's either creates undeterministic behavior or it consumes too much gas. However, if you look at, from the application developer's point of view, you do need those features. Can we put those features in real functions or pure real functions? And for code, that's not a consensus. So that separation is unclear in most of the smart contract languages today. So that's where, you know, we hope that our innovation should be able to help is that to create a language that's dangerous to address those two problems. Because if you don't have consensus and not on this separation, you are driven towards the voice of how many are there. You have to have all the language features that can't be a consensus. That's not something we think would create a good language in mind. So those are the two challenges of Solidity's smart contract languages today. And those are the things that we want to address. Okay. So now I want to shift over to Hai Dai and to talk about how we address the first challenge. The first is Solidity is too incomplete and it's generic. There's no domain-specific features in that language. How do we add domain-specific features into Solidity? Okay, let's talk about the lately rules engine. And... Okay. Oh, with the iPhone. With the iPhone. I'll do this. Sorry. Sorry. Sorry. I wrote some of the slides. I wrote some of the slides. So first of all, why do we need a rules-based smart contract? A lot of people ask this question. You know, what is a smart contract? It's automated districts triggered by end-resulting stage change according to defined rules. So smart contracts by their very definition of rules. Cool. So it's a perfect match. Like I just said, rules must be transparent, gradient, and even useful. Blockchain is the perfect platform to execute rules. Today, enterprise rules are executed inside databases. And you could argue that's one of the things that blockchain really changed when you tried to make business decisions in an automated manner. You want those rules to be executed in a trusted platform. So blockchain smart contracts is a perfect match for rules. And the rules engine is essentially a decision tree. You know, rules could be essentially implemented in a decision tree using different men's statements. You can have a large guess of if and if then to implement any rules. However, the complexity will exponentially have the rules increased. You know, so if you have multiple interacting rules in the trees, that every single change on this side but say you have two trees, each have, you have two decision trees and they interact on somebody's right. Everything that changes on this side have to result to the evaluation of the entire tree on the other side. So just imagine you have multiple trees like that. So that's why that gives rise to what the enterprise offers for the rules and the business rules and the PRD. So the same set of rules might be evaluated again and again and very difficult to validate or make changes. So if I have a rule that gives people money and their credit gauge to those things like that, it's extremely difficult to validate and adjust the exact statements and it's impossible for them to program. You know, that's someone, a business person wants to change those rules into possible. So this is what I just said, you know, so in the enterprise space, you know, that's, I'm sure I'll do that. So those are hundreds of millions of dollars in size. Seems like tools, GIS, IRR, AIR, AIR, or some of the public companies. That's it for the rules. Okay. So let's go to the demo section and first of all, I want to introduce how we do the rules engine into the solidity of self-plugging. As we know, if we want to add a plug-in, there must be a way to add some new of course or some new instruction. But in our rules engine, we don't do that because we know half walk, half walk, half less too many half walk, we don't want to do that. So we just separate that we add a new grammar called rule. And we just build a new parser for years and new cogent. Also, it is compatible with the original solidity one. So if you go to our repository, you can find we define some rules engine as D and when the parser going inside define O there's a rule and rule when for example when somebody is too old and they can get some money for example. So when it goes touch to rules you are into our cogent session and finally they will combine into one UVM Bible. So you don't you don't you don't need to take care about how there will be two countries or three countries no, you just in one country yes. And the layout will look like that. The original and our rules will be a new section and we add a new rule engine Pandora. A new rule engine Pandora is just like just like your Chrome they in that we add engineers we just add a rule engine Pandora into your smart country. So when when somebody is cute the smart country the rules and you must register some data what kind of data you want to modify because there are lots of variables not every variable need to be modified so you want to address that and our handle will take care of that and just filter out something like the rules and the data. So we just go into our demo and this is our website you can go there and get more example. Yeah so let me show our website. Okay it's too much it's fine that's good. That's good. Okay let me reset it and our first question okay good okay our first example is the edge pension that we define a person who has a number of edge and a mortgage which means you take this for a while and a back gate for his money and this is we define another data structure called back edge it means we have two we have one list called the person list which will store all of the person and the total back gate here and we add a new new requirement called fact insert fact insert is just like notify our handler which variable should be money in this example that oh the back edge will be money by our handle and we just say 10,000 and we go to the rule power first you just write you just write the rules in your country and it's like a rule a ruleman it can be a blah blah stream more it's just a name and the web blog will contain several conditions as you can see you can say oh I want to feel to let that's a person whose edge is greater or equal than 65 and what edge is greater than equal 5 and also our back edge must have greater than 10 and if you find that any any modifier object is in these these these conditions then it will trigger these actions like we will add the person add 10 dollars and just minus our total back edge 10 dollars yeah and another one is how can we add a new person to here we can see we have this here and we create lots of person objects and then that insert to play our handle to modify this this object and the last action is we will call the function called file rules it will just emit all of the rules and and just do these actions so let me compare it and edge pension before it gets there and first of all we add a person like okay we can we just check the first one stayed up 64 21 okay and we add the one is 65 and 20 and 2 7 1 and the third one because this the work edge is larger or equal to 5 so we want to adhere to just the role okay now we have three person now it means the pay function and just check all of the person like the rule but he didn't get any money because it's only 64 years and the second one it gets $10 and the third one no it doesn't get $10 and after all we can just check the baggage it just spend $10 okay this is our our demo for the rules engine if you are interested you can find more examples on our website there are something like like text preparation or anymore yeah good in here yes okay so this retirement age that was very interesting because I don't know if you guys if you retired the longer you live for people who retire like 15 days into the eighties if you retire at 65 you live until 67 something like that so it's really important that the government has all this rule that's who gets what your retirement age so how that can you show up can I get over here sorry okay thank you I can see the line of no no this is oh sorry so you can see all this this is actually a regular submitted you know those are just a contract and by the way this pool is below.secondstay.io you can say build.secondstay.io it's fine you know that's fine you don't have to you know so this is the development tool that we do so our compiler is integrated in here you can do that so you know you don't need you don't have to do anything like that so this compiles regular solidity code but the rule setting stuff is added beneath it that I can show up you can see we added key words like back insert and the rule stuff is just added to solidity so we embedded what we call the main specific language inside solidity and then we have a compiler that compiles to EVM pilot code to any EVM compatible blockchain so that's to be developed just to be developed so yeah well so you know that I know you guys might have questions let's talk afterwards because we have you know quite a few things for in this session so the next one I want to bring people and then he got to talk about how we solve the second review report the first problem is to know the main specific extensions of the language the second problem really is no separation between consensus and non-contractors can we find a way to see the contacts we see EVM1 we get 1.x to separate out consensus application and non-contractors so he'll just talk you through this smart contract search engine so basically we can call this an auxiliary application and what we mean by an application that is really assisting the end user of a blockchain application and it's essentially transforming full node data to make it available to the end user in a useful way so this is not a second layer solution it does not play a role in a network consensus at all and it doesn't play a role in updating the blockchain state so you can consider it like a read only one auxiliary application example would be as we know you have the UTXOs and the system the Bitcoin states represented by its global collection of unspent transaction outputs but the Bitcoin blockchain doesn't actually hold the account balances so a user's account balance in Bitcoin that's put forward by an auxiliary application i.e. the wallet so there's a purpose for auxiliary applications they are safe because you have to remember that an auxiliary application can't really make the blockchain do anything invalid so in example is Alice here she's got two Bitcoin if she thinks that she's got three for some reason and she tries to execute a transaction that won't actually succeed so it can't make the blockchain do anything that's not valid so the smart contract search engine with arbitrary programming languages and for example this will show you in a minute is it's reading the public data that exists so for example if there's a public variable a compiler will create the getters and setters automatically it can go in and grab that information automatically so here's a bit of an overview of the the smart contract search engine is this component here it is 100% free and open source in that it's just using basic Apache 2 on a Linux operating system already in HTML JavaScript and a bit of Python using Flask the indexing we're at the moment we're using elastic search and that's also 100% open source product as well so the blockchain here reads in the data here and then there's multiple interfaces out to different services from there so this is the smart contract search engine here this is the web browser search and this is optional third party push notifications and so on we'll get to this component in a little bit I'll talk about this okay so the smart contract search engine sits between oh I'm just talking to you sits between the full node and the data and it's organizing raw smart contract data and other blockchain data like event logs and so on and it's providing essentially like a search and discovery service for the decentralized applications okay so this demo I'm just taking some screen captures if you go to docs.secondstate.io there's a menu down the left-hand side you'll see this data driven depth here this here with the first paragraph it links off to some coding GitHub and this is HTML JavaScript and Solidity smart contract code and as Michael just showed us this is the build tool that we have and so you put the Solidity code in there you hit compile and deploy this so the argument here's asking for an account name so we put in depth on 5 underscore 001 deploy that to the chain and then what we see in the build tool when we click the play button in the depth tab you actually deploy the front end of your depth so this is what the end user will see and here we have this account and I'll put a value in of 1, 2, 3 and we update the balance and what it does the smart contract search engine goes and finds smart contracts on the blockchain that match so what we do is we sort the ABI and then we hash it so we end up with a deterministic key per ABI and so the smart contract search engine can go through the blockchain and find all the contracts that match to that key and so what it's essentially doing here is finding accounts of contract type X with different names and it's creating the sum total of their balance and then providing that so a smart contract can't do that to another contract because they can't see each other's data but the search engine can aggregate so we just move on to this part here what we call ESSS and again please come talk to me afterwards because there's too much to say in 10 minutes so this is the easiest way to access all this if you don't install or do anything with any of this smart contract code or anything if you just simply go to ESSS.js as an MPM package and you just install that and then you have instant access to blockchain data so we're running Ethereum mainnet Ethereum classic CyberMiles mainnet CyberMiles testnet and the dev chain so these are already set up we have some specific pre-made functions here for your convenience so for example you just ESSS you've got search using address and that's the address and then we'll return data the next thing is specific things search using keywords so in this case that variable name the account we put that in as the data and returns that with JSON so then your phone can pass this right so it's a really efficient way to call data blockchain data and get that back so instead of your phone having to get a thousand records and loop through them all and do decision making what you can do is quite a complex query where you can filter out so like I want to see everything in the last hour from this address with an account name called DevCon and then you'll just get back one record so it's really efficient and then your phone only has to process one small piece of JSON one of the reasons why this is great is because it's separating out it's very flexible but it's separating out the components so if you have a front end developer that's a really different skill set you can just say you know JavaScript and HTML and CSS I want you to this is what I want my doubt to do from the user's perspective you don't need to know when they push the button it's going to call smart contract functions and so on just don't worry about that just code up the front end of the HTML JavaScript and CSS enabling you to have teams work together similar to the the rules engine allows like a business analyst to write rules in drills and hand that off they don't need to actually be able to contract the right-hand smart contract code but that same syntax will apply and just plug straight in and work so there's a similar concept to that you can create your own custom queries you can extend on this to provide like custom push notifications you know triggering when amounts go over or under and I'll pull it up there if you're interested in building your own or using ours or deploying it down and creating a product please get in touch and we'll help you back over there alright thank you alright so we have discussed you know the two challenges and how we address some candidates like this right DSL and so on and the second really is to add new stuff outside of the UVM so that the non-compensate data can flow out of it instead of having to have a social connection and be the lowest common denominator however the future you know we see ETH 2.0 we see a really great opportunity to future-proof all this because now even people have a unified solution that's used various things like LLVM and WebAssembly to build a new toolchain can use computers and new virtual machines so that's all this would no longer be a problem and I'll hand it back to HIDA and to talk about the work that we do with LLVM and EMASM and this is a collaboration project between the second stage and the very short plastic labs okay let's talk about the full benefit that's when we integrate LLVM into our toolchain twice the part and first of all because LLVM developed long ago it's just like your GCC compile so if you can support like C++ C or Rust or Rava all you can see is they all will have a front-end layer so you can support more programming languages if you are not interested in with just the certainty you want to use your ES you can use LLVM and the other part is that with LLVM if we want to define a new target what is new target just something like that we have EVM1 we have EVASM maybe if what then happens maybe there will be the EVASM or maybe EVM3 or 4 or 5 so LLVM provides a mechanism that is very easy to define a new target and this is independent with your front-end so you don't need to have to translate your directly to the new target you can use the LLVM it has intermediate format called LLVM IR so every language will be transformed into a uniform language and then use this into different targets so this is a second part and surprise is that we have lots of debuggers or linkers or something toolchain for LLVM so when we just integrate LLVM into the toolchain so the debuggers we don't need to just redo it we can use the LLVM or something like that and the first part is we want to talk about more after then let's with LLVM framework we can define a new gas optimization skill that can be just like because I have a uniform format here so we can just modify each part can reduce the gas consumption or something like that so the first part is like this more programming language or EVMs and all of the scenes will be translated whether it's 7T or Vipro or Rust or any front-end language they will be passed and LLVM IR and in the face we call it optimization because we can add lots of optimization here something like that we can reduce the deco or we can just simplify a lot of addition or modification of that and finally we have a lot of fans for here and it goes into something like and at least 0.93 that's all possible okay and the second part I mentioned before we've got a lot of developer developers or something like that and we can we can make the performance more higher and this is our approach to and to to reduce the current server application actually in this full chart we only do one thing that is we model the LVM IR with the native by code so we can know every instruction in high level the cost is like 100 200 or something like that lots of different here just right here we met in the assembly and back into the LVM IR so we have a cost model here and when we have a cost model here we can apply the traditional energy consumption issue the optimization of that into this model and we can just here and we get more just my code here okay so let's go into the demo part I will show you how to use our compiler to compile your as they call into LVM IR and finally deploy into it was I think for the EVL part is very quicker I think the LVM will be the demo part but for the EVL part right um yeah okay so first of all you need to connect the meta master to the it was a test that just sound like this and let's oh I don't know what point it's just let's get and we can build it from source you can get going here so you can set the energy and it may be one hour building it so as it is too long we have a part for image so you can just pull it you can just run it and institution the command in our uh next slide and to get a get a bytecode so I think I can do the um I can do the demo diversity okay so oh is that enough oops and first of all you need to uh create a contract well mean and let me copy it oh yeah I have to just pass it uh as you can see this is ES20 contract and we have total supply we have balances and we have an event called transfer and here is a contractor you can sell the full supply you can sell balances and also a function called a balance off you can query it and finally this is a transfer function and if you want to add the step mask protection you can just include library and use it that's fine but for the demo just remove that yes and when you use SOLL you can get the help menu like this and no worries we just compel its action plus emit lvm then contract SOLL and when you cross first enter you get lots of lvir but don't worry about that you need you don't need to modify any line of that you just you just pipeline this output into contract lll and we have uh we have uh helper in the SOLL uh you close and compile plus v and the input is contract.ll okay uh so you can see that we use lots of like lbin link uh lbin optimizer lvm compiler and what's an lb to create the web aesthetic part and you will get true what's a file is the runtime file called contract.ll another is the deploy file called contract deployment and the final part you want to deploy that into the certain it wasn't passenger or should we do just back here and you can find it wasn't hasn't and something like this and just sum your transaction because uh I think the only way to deploy your contract there and because you need to pass your all was to here so you need to close this final file into a string uh we have provide the the the uh the comment here just copy that and enter okay you got this lots of string this is your contract and because it's very very large so I need to just just score down our my terminal and oops a moment comments will ask you to comfort it or you can retry it several times because I have no idea when I just retry it several times to well success it's weird but I don't can get your contract here you can find a West Coast if you want to know why it's the inside of the wasp file you can see this tab and also if you want to see how how the storage variables you can have and you can find this file and we just just change to the token and put your you can get the balance something like this over here push and go and you will get your balance here and you can transfer your your balancing from the up and down by getting out of the account and getting 100 so you can see you spend another 100,000 let's know I've seen the best alright let's you know I think our time is up you know I know we can anyone there's 5 days 5 more days in the conference if anyone wants to find us you can talk to us for a second state and thank you very much