 I'm homey die or you can call me hi die just like the this ID for short and today I want to share about how my team the SRL team to do several at the mine station on Solidity on your and it wasn't the other LLVM framework So here she is our agenda we have full session to Talk about that first is the roadmap and how it's all warps and then we will just mention just a little You will optimizer and LVM optimizer then we want to introduce a very experimental New mechanics and to do some static analysis and Feedback dirty optimization Okay, so let's talk about our roadmap first Actually, this whole project is a start from I think this year the April 4th and Actually, we has do lots of staff to create a new languages tension for a study that be called a leafy if you if you remember we have to talk about that on the Defcon 5 and after the tool we want to just small focus on some optimization research because we believe that Smokon chair for a blockchain will be come more and more popular. So if the engineer to who is writing the smokon chair cannot Will we want to help a land that they don't need to really care about the detail coaching about performance or the cosise want to Leverage lots of my skill and to help them to generate a more a small size by code so here's our the stop point and After we decide we want to use the LVM as our infrastructure We want to choose and that's one foreign and one back end Which is the foreign is we choose the Solidity language because I believe is the most popular smokon chair language in the world So we choose the Solidity and then for the back end. I believe that the Solidity compiler has to Very great work to generate the even by pole very efficiently. So we just want to create a new or choose a new Target back end. So that's why we choose the Solidity and it wasn't for first and Then we go go to the do-do one the really The very first release that is and we want to Create a very small demo, which is just I believe everyone has used this library called a safe mass and We just do very little grammar just you can see here if else or Revered require and very limited Interjust the pole, but before that they've come five. We want to just Join the community and we want to talk to the team to ask for the more Conversation about it wasn't or or something like that. So in this two virgin we focused on how to compile or ERC 20 smart contract and we want to show Our soil has the ability can we can just support the constructor and we can deploy the it wasn't by call to the Issyrian it wasn't has not and actually we We we just finish that and and we have a very good conversation between us and Solidity and after this event, I believe this is very Key event because after our discussion we found that's that's like I remember that's that is told us there's another project called a soul and and they also do the I think just the same thing just compile the facility into It wasn't or into the subject So we just change our goal from supporting the Solidity front end just instead of I'm sorry, we want to support that you will find and instead of the study that he so Michael mentioned yesterday actually the soil now can pass. I think it's 80% of a test switch from the liberal you all and I want to the soil want to accept lots of you will buy coal which is generated by the COLC compiler and We apply the LVM during optimization options into the whole whole cogent and whole by-cogent regime and also we also support the even LVM as our even back end so now the soil can support a very limited Solidity front end and I think Almost the you will find and and we have two back and one is the it wasn't back end And another is the even LVM back end. Okay So here is something we we doesn't support now Just like balance or self-balance something like less and we will just keep going to finish this unemployment instructions just Few months later. Okay. So what is our future roadmap or future goal? that is we want to fully support the you will find and and yesterday that We found that it is a very good extension called a you will pass and I believe if there are some features that's Very interesting out of so we will also add support of the your class after we finish the you will find and and we found found that There are some very interesting things less Actually traditional Applies on the it wasn't may not be the best choice for the for the real world because When we deploy a smart country on on Sorry, and we will we will very care about the whole size rather than the efficiency because The the whole size will take lots of the storage. So I believe is is more expensive than the Than a native computer. Okay, so that's The second goal we want to achieve and the third one is actually we have several online There's you pass in our optimizer and we will discuss that later. Okay, so there's our Romance from the past from the current and the future Okay, now I want to talk about how I saw our work works, so the first thing is that we accept the country which is right right in solidity language and When you get a solidity solidity country, you can just bypass it into the soil see and with the Myronomus IR and myronomus IR optimizer and then you can get a auto mode auto mode you will buy cool and at this stage we accept this you will control into our compiler and If you want to see how you want to get the deploy Deployer plus the runtime you just bypass this your country and we will give you the See that was but if you want to Know why is the detail of the Runtime by code you have to remove the outside Power of the you object because the outside part is the car constructor and and and some something that's Oh It's just a Ripper of the outside. So so you have to remove the UOL object outside the outside UOL object first and then just bypass the remaining part to our compiler and you can get a runtime Watson so what is the detail scenes that the soil compiler do? The first thing is when we get the UOL smart contract We will pass it and check the sematic and create our own ST in in in our compiler pipeline and the second thing is we will come soon in this ST and With our culture module and then we will get the LVM module here So at this stage now we get lots of LVM IR now there is no UOL anymore, so Each line of the UOL statement will just maybe do several line of the LVM IR here Okay, now when we get the LVM module here and the next step is to use our back end Our back end will just apply several LVM optimization tests and we will do lots of steps like like the bit swap because the The EVN is a big Indian integer type and The web assembly is the little Indian integer type, so we need to do lots of the conversion things and then After we finished lots of works now the last step is we will use our talking machine and linker to generate the It was a bike hole or the EVN LVM.LVM IR Yeah, that's our the whole internal process of SLL works Okay, so that's our that's my second session to just describe how the SLL works and the third part we want to just mention some very different things about the UOL optimizer and the LVM optimizer and The first thing is I think the rules between these two is is very different because the UOL optimizer actually is transformed from UOL to UOL so You can have very high-level information here and so We will have a set code that UOL optimizer can do lots of aggressive simulation to Do the inline things to remove the function code But when we go to the LVM optimizer There is a big limitation for us because that's we we just convert all of the UOL statement into the LVM IR statements, so We will lose lots of the in high-level information first and the second thing is When we want to apply to generate to the it wasn't back then we will Need to add lowering integer like because the EVN has 256 bits Big Indian integer, but the we're by some only support us is for bits integer so we have to do lots of conversion and also just the base swap I mentioned before so After we add the several things in our LVM IR code, you will be more hard to do some Analyze this and to reduce with some very Heuristic rule, so I will give you more details in the sample Okay, so the first example is we called the very common Compiler optimization that is loop rolling or unrolling which means Here you have a contract with 10 elements of array and we just write a for loop to feel the error amount with the index and If you compare this simple code to the native computer for example, if you write this algorithm in You write this algorithm in C++ and just compare it to the net if you will find that There are no more for loop because all of the things will be converted into a very zero It was a very assigned assigned your tool Assigned your to the radio. So it would just be ten line of of this statement but In the you will optimizer you will find that actually it just keeps the structure. So you will have a follow-up here and Each iteration will just update the storage variable or once So I think it's very great but when we apply for example, we apply the LVM optimizer with the O3 flag and We will find that all of the loop is be eliminated because in this stage the LVM and the Watson back end believe that we just replace the loop with lots of Constance constant store is more efficiency, but Actually in the in the historian, I don't believe I don't see is a good idea because If this loop become more larger if it's not from zero to ten is from zero to a hundred or a thousand Then we will find the core size will glow Then Then our expected so when we do the loop unrolling we find the final Watson core size will be About 3k, but the if we we disable the loop rolling a loop unrolling We will get the 2.5k bytes here So this is the first very different thing that we have to be more careful when we apply any LVM optimization because Lots of the automation is designed for the native computer not designed for some very special case Okay, the secrecy is In line, I believe that's a very good example that the you will Optimizer can do much better than then LVM Sir, the you can find this is the deaf con dash the example that you will and Is a Store here, and we just call a resum and in the other sound we will call lots of the overloads So after the you will optimize sir Oh, sorry, I mean it's one slide here. Oh Okay, I miss one slide here, and I will I will give you a moment If I can get it back now, okay, and Let me just pass it What's on past Sorry Yes, but could be We're more than you sure Okay, okay, so You can find if we just sorry I just go back so after you will optimize sir, then we will just convert these this You will to a very short one and you can find all of the function code is all of the function code is be even so Let's very very good things. That's that's You will optimize a dude, but when we go back to the to the oh Okay to the to the LVM optimizer o3 Then we will figure out that the arrest sum is be has been in light but the overload has not been in light because in the LVM optimizer we figure out that The function body and the basic block is Is larger than the in Ireland. So In another threshold, so there will be So there will be only the Arisum has been in line and the other one will not be in line. Okay, so that's very different between the LVM optimizer and and you will optimize it because because LVM optimizer the in Ireland has its own threshold and we have to Do lots of the research and to figure out which Treasure is green enough for the it wasn't cost model. So that's the circumstances. We will have to do more research here and The third one is the storage as I see sample. So I just create a new integer storage and and We will do at 10 and at 10 twice. Okay, so when the Contrasts become higher to the you will and after the you are my sir and you can find that There is the sensing like the Function body and it just update a storage value twice and that's the same thing with the LVM optimizer like you can find that here's a add first to add a 10 into this is a temporary rebel means the Original story ready and just story it Oh, here is By swap. Don't worry about that and we call the storage store just to a store F2 value back to the storage But we believe if we can do a very trivial optimization, which is This tool I can be combined into one line which is I plus equal 20 we don't need to do Just like to lie off the Add and to lie off the storage updates. We can just simple lie the Stamen into one line. Oh, that this is several things that we can do more about this case Okay, so here is three here are three examples. We we want to mention let's Oh both of these two optimizer has still has lots of research and and and Optimization Technology we can do more So we want to introduce the final heart, which is we do research to analyze the cost of model So what is the motivation? This is motivation is like I believe the gas cost is just like the energy consumption if you run if you run Okay, if you run a very very bad program on your cell phone Then your cell phone will eat more power and if you write a very bad smart contract, then you will it's gas I think it's just legal. So we apply a very I will apply the The same analysis and optimization Just found some paper to deal with the energy consumption So we create a project called the GPS cat which means a general proposed Static cost analysis to a chain. Okay. It's just a very long name and In this tool we have two face to ocean the first one is we we don't analyze this You will directly we analyze LVN IR because we can do lots of the Debug info we can insert lots of debugging them to help us to to evaluate The LVN IR cost equals to lots of the Web assembly in stretching cost. So we will start from LVN IR first So when we get every IR we can just calculate it into a cost of function and then we will use Up one solver to resolve this function to figure out its score. Okay, so here is our our total analysis the diagram so First of all, since we will define some assembly cost of model Something like if we add a number you will take Let's just say a hundred or 200 something like that and all of the LVN IR by code will be annotate with Debug you info with the debugger location because we want to know that every LVN IR will be generated to what kind of Web assembly instruction so the whole the top idea is likely so after we do lots of the annotation we can give We can get the LVN IR with block cost information then when we get this information we need to have to To apply to framework from the outside the first one is We need to extract the cost of relationship. So we use the LVN to keep up and The second thing is after we have this this cost of relationship We we have to apply the up on solving up on solver to to calculate the Since so here is we use to external project to help us to do this Okay, so after We go through lots of things now we can get if we apply some optimization on the LVN IR Then we can get a new score and a new formula and we can calculate if we apply this The state ns will tell us well your cost will be increased or decreased then we will we can just adjust the stretch hole or address the optimization options to to Help us to create more more suitable At the management phase for the it wasn't cost model, okay so I say I have I say I have full round of time. So the following slide is just to mention how we Annotate the debug info for the LVN IR just like we will say each LVN IR will map into which line and Lowering it into the assembly of the web assembly then we can just get a mapping relationship between the load LVN IR instruction will be do nothing, but the add will be Compar to three Instruction of the Web assembly then with this model we can just Say we have a table to the of the mapping relationship and we have the cost table So we will know each LVN IR is mapping to what kind of the cost and we can Calculate the final basic bar cost and we will know the whole program the whole cost of of this smart country When when it just is cute Okay, I think that's my whole whole talk about SORL and our some something about Automation, so if I do you are interested in you can go to this link to our SORL repository to use them or you can Just I believe when Michael show the video yesterday And if you are interested in actually we have because we we have a need to measure the Bicol efficient and the Bicol And the Bicol performance, so we create our cell phone wasn't virtual machine to do to do this And if you're interested in about the GPS cat here is our repository and all of the examples you can find in this repository here, okay Okay, let's go. Thank you so much Great talk. Thank you So because we have almost one minute delay in the live stream We will give people the chance to ask questions now Either if you're watching the live stream, please make sure to comment in the guitar chat or if you have a question here in the room Feel free to use the raise your hand feature so that I can see you have a question Yeah, Chris go ahead Yeah, thanks for talk I'm wondering so you mentioned that you need to extract the runtime code from the you object in order to deploy it Is there a way you could Support the deploy routine that is written in you or what is the reason for that? Oh Actually because the generated You all country is just like a run time code and a deploy or a constructor part. They are two parts, right? I think I think they are two parts and so if because if you if you get the Give the soil with the run high code and the the constructor called a different code We will just compile the one I call just directly into the Web browser may buy code. So you have no choice. You have no chance to see The LVM IR inside of this runtime So if you want to do some research on Just remove the outside part that's not required for running it It's just if you want to see further details on it If you want to run it you have to of course you have to give the run high code and contractor Well, we need yes Yeah, thanks Okay, another question here mooly. Oh, you're still muted Can you hear me now? Yes. Yes. Thanks. Thank you very very nice talk Can you elaborate a little bit about how much you save in particular how much gas saving are you getting? um Sorry, can you can you uh Oh, uh I will say there are no no any any benchmark or we we doesn't we doesn't calculate the The gas reduce number here because uh in uh, I always said it's a very experimental uh It will be is very uh experimental stage. So uh In this moment, I believe they are they are also uh, don't have very uh, very strong or very complicated Very very complete of the uh, we by simply cost the model. So we just uh, we just assume, uh, we just said lots of the The number there so so we don't have no real number. Sorry about that Yes You're muted again Oh, sorry. So on the conceptual level if you implemented this directly on the yule How much more difficult will it be? What are you getting actually from the lvm as opposed to just running it on the yule? There is my question clear Oh, um Uh, actually, I believe this there's uh, different things because uh, why we choose that lvm framework because uh, it just like the gcc that's uh, there are several people and do lots of the academician research and creates lots of the academician strategy layer. So, uh For us, it will be very difficult because we have to choose which strategy is is Which strategy is suitable for the Yule and then the second thing we just pulled the the algorithm from the lvm ir into the u-automizer. So, uh, I don't So if we can do lots of research on these parts, yes, we can pull lots of the Automation from lvm into the yule automizer, but uh, I believe If, uh We should just just still we just use the lvm framework and and and just add lots of analysis and layer because uh You would have lots of things to do because you have to You have to analyze that and create lots of the The information so with lots of information, we can just do a more aggressive Automation, but you will have I think we'll have too much time to to rebuild all of the all of the things again on your automizer