[Applause]
so this is more or less a continuation
of the talk I gave at DEFCON 4
let's guess community it's not problem
if you haven't seen that talk just
context not talk I explained how we want
to want to to leverage an intermediate
language so that and in several involve
accessibility it was which back-end you
have to comply to IBM to be Muslim in
one run five or
and on the bottom you can see some
example new code is in allocation or
it's a standard sylheti alligator memory
allocator and i think is obvious what it
does
okay what did we do so this was
basically we have up the top of last
year and what happened after that we
started the rewrite of the salinity
generator this would be the first third
of the talk then I will tell you how he
wasn't called from solidity and the last
part of the perpetrator we are actually
far with that we had to stop at some
point because we want to really insulate
you zero sixes
we are the reason the main reason why we
didn't do that in the o2 villages
because it yeah
these checks will have promised Ofsted
you know he has those variables and
these are rather direct translation from
variables to a state machine but in
general you have to worry about
mystically also there is one of the most
complex parts in the celebrity culture
it is false because the product foot has
so many parameters and it also depends
whether one whether you want ivory or a
regular function or whether you specify
the gas over they specify the value and
so on so there is different ways to use
the follow up code and all the time you
have to keep track of where everything
is on the stack in the old code
generator and if you consider it just
reference stuff by their names
it's just yes and
another thing is that so when the Opel
generator we forgot to the world did not
yet implement a certain feature but by
accident the stacked layout is correct
then this will need to code that will
actually generate it and will of course
do something about it in the new code
generator some expressions are always
referenced by their identifier and a
full generation of that sub expressions
are implemented then the identifier
logistics is in the universe an
additional level of checks on the
intermediate language and this will be
detected and how can you actually use it
I'm going to show you how to use it on
the command line the standard Chasen
also works
so - my art will generate you vote from
facility code and for safety reason we
do not support a direct translation from
civility through you'll TBM because it's
only an experimental stage so you have
to yeah copy the ultimate on the first
stage and then rerun the sudanese
compiler in assembly mode and then
transform the video recorder - yeah
that's a gonna get how that looks in
practice so this is an example years and
20 content already a hard early years in
20 contract we have an event we have the
mapping of the balances to supply a mint
function that generates tokens which is
conscious which is called in the
instructor so center gets 20 points and
the mid function
this required also Everest mint to
cannot be the similarities and then
towards my analysis is modified and the
transfer event now we compile that to
unity and so this is not the quote
directly generated particle generator
but this is the code after optimization
I think it's really nice that this is
still nice detail and you will see but
you see that it still have expressions
and yeah it so you would even see the
mid function call here and he was
recognized the name mint the the issue
here is just that the mint function in
the init context is only called once and
because of that is first in line and so
the function eternal but we so it starts
with initializing the memory allocator
then we have the core value checks
people and then the second thing here is
required that the and as we meant to
it's not zero you actually see the error
string here here's 20 in minute to the
zero edges so this this block here is
the require home and then we update the
tour so this this is this is a common I
am menu yeah you take the stuff that is
take the day that is currently at
storage vacation you have 29 useful now
it it calls for the user-defined
function called check add this is the
the overflow check I was talking about
earlier and that is one of the two
functions that's not visible on the
screen here and the rest of the rest of
the coast all the all there is to the
instructors instructor called missing to
school functions and now we update the
balances this is the kind of problem
there is a function
access team mapping and so on it's a
little bit longer so the reason is that
so this is the the in x-axis helper
function for storage mappings and the
name is generated from the type and I
think we still have to come up with a
way to shorten it so it's very cool yeah
and another issue here is you see that
not even a success the function was just
talking about it's called here and it's
also called here again with the same
parameters usually the optimizer is able
to combine them and call it only once
the problem here is that it calls the
Kaptchuk function which works on memory
because of that it has to access the
memory and the optimizer cannot yet
recognize that writing this stuff so
that the stuff that is written in the
first call and the stuff that was
written said Paul did no conflict
because it exactly the same so they
write to the same memory location
because of that it can't really swap
them but it should detect that it's
actually the same step this really yeah
talking about exercise and the truth you
can
this is 256-bit EVM code and I think
it's also a lot more obviously 20 then
it was a big challenge but we can
prepare the compiler that goes why you
will and does not kill why are you so
there the particle politics
1747 bytes that's been unfair because it
doesn't alter como flow checks if we add
the objects it's fine and if you do that
why it's 2062
so it shows that are still some work to
do actually I did not you find the time
to see where it has these additional
bytes so it might be just amenities ok
webassembly similar to assault see my
expense I already knew SSD - - he wasn't
it will so and this will actually
generate he wasn't text representation
in one run thing is it's not tested at
all it's not tested you know because we
couldn't get find execution environment
we can Callaghan took my contracts and
the reason for that is that we
transform web-centric text
representation tumor center by the
representation and you need that for
deploying the fraction deploying the
contract smooth because it means the
return of ivory
I'm representation how does the compiler
- II wasn't work it takes the regular
IBM you know so it starts exactly at the
point where the civility to usually be a
provider went and so you have to you
have to transform 256 bit code to 64-bit
code and this is that by splitting all
the you'll variables into four modules
and at that point we have some kind of a
mix of web assembly
because we still use the EBM opcodes but
we already use 64-bit variables and then
we add kind of a library code that
implements all EVM opcodes
has used different functions using the
EVM
LED wasn't within functions and at that
point we have it wasn't favorable and we
run the regular optimizer will also have
an EVM you with slight modifications
because we have different approaches and
yeah it turns out that we are able to
reuse almost all of the proponents of
the PM's you will optimizer yeah in
terrorist academy yeah pretty
straightforward transformation
everything
yeah that's secretive that is specific
some example we just use we just store
the current block element at position
zero in memory this yeah I have to warn
you because of those 256 bits 64-bit
thing this will be complicated okay
what we do is guesstimate returns a 256
bit value so we have to split that into
four variables
that's what is done here in the
beginning so we call guesstimate and
selected for variables and then we for M
store that may be kind of sweet new
hybrid EVM it was new function that
takes eight parameters with one for the
address and proper value and then we
have the implementations of the idiom of
codes in some built-ins of gasoline for
example just cause you don't get of
Testament and an M store our wheat for
minion swapping because what assembly is
a machine is not very complicated but if
you apply the optimizer then it will of
course in line the guess that we call
here and also remove all the other
varieties we don't get anymore
also the M store it has all the
constants here so it's probably make
sense and then and
like this only the engines watches
okay now the three tarts third part of
the talk the original optimizer all all
components of the optimizer take your
coat
transform it and I'll put you in yes sir
it's so all the motives are simple that
can be combined in an arbitrary rating
if all the modules are correct and the
Veloster it turned out that we need a
little bit more notice that we initially
thought we currently have roughly 25 but
most of the motives are really tiny and
there are only two to three components
that we store a data structure so so for
example the condition of 35 is that it
takes a look at branches so for some you
see we start the body of this is almost
earnings so after the body you need you
know that C is false or so so the only
thing that this asses injects
assignments of this form after
terminating branches and other motifs in
the optimizer can pick that up and use
their information but the information is
visible below this is not stored in some
Hey
talk about the future memory times we
already saw that we have some problems
with memory this will hopefully be
solved by adding memory chunks as a
built-in type into you that way
different memory stores two different
data structure are fully independent
because it uses kind of a different hand
into excess memory also we're thinking
about hanging a super optimizer so in
optimizer that takes a really long time
and tries to really crunch the numbers
and find a good way to optimize the code
and that can have that can maybe have
shortcuts if you want to recompile stuff
that it's it's faster and when thinking
about adding a genetic I really need to
find a good order for applying steps it
has already said each step individually
should be correct the order doesn't
matter for correctness but it matters
for efficiency and yes
fortunately come up with a good order to
apply them
the truth was that
[Applause]