I want to talk about our lessons that we
learned by building a decentralized
application on top of write client who
view here is fairly like who you know
what is a light client like kind of if
you think you know what
like fairly well what's a like land ok
it's like half of the person so I will
be a bit slow at the beginning just to
make sure we are all on board on why we
want to use a light client actually by
the way I will use the words light
client light node for me it's the same
because we're talking about a node so
just two words about myself i'm t-bo I'm
working at 30 I'm fronting dev and I
work on pretty feather which I will talk
about right now I work also on parity
signer which I had to talk about before
pretty interesting you should check it
out and right now I'm actually working a
lot on polka dot J's and and UI so this
talk is about three things we want to
understand first why we want to build or
use like lines then I will show you how
to hack on a library that we made that's
called like Jess and then in the end
I'll talk I'll show you a bit more about
feather this application that we built
on top of a light client you you can see
I use light node inside an electron app
right now like clients same thing so
let's start why light clients are
important so first of all you probably
all know but running the full node is
not as simple as it could seem or as
simple as we hope it would be when
people build a node in there in first
place we thought ok everybody should be
able to run a full node on a laptop
right why it's not really possible
anymore so what do what people do when
you want to build a light clients are
sorry when you want to build and test
centralized application you do not
connect to full node you connect
actually to intra or to a third-party
service that provides you full node to
access the blockchain and the thing is
infrared super awesome like
you can build an application connect to
the blockchain within a couple minutes
that's really really nice like it helps
turn the community to grow but there are
many problems in there yeah those are
numbers that I mean actually kind of odd
numbers it's probably much higher now
how many taps have been developed using
infra how many billions of requests
infrareds actually serving the problem
you can all see that we call these
decentralized applications but we're all
connecting to one server here like or
one set of server that is owned by a
company that it's not decentralized
that's that's actually not the right
thing to do right so so what is the
light client it's a node that stores
header but will remain trustless so it's
a note so it's something that does
access the blockchain and can give you
many information about the blockchain
can help you do almost anything a full
node would help you do from a
decentralized application perspective
but it is not decentralized it is sorry
decentralized and it is not centralized
it is it is just and it does not so it's
not as secure the full node I will not
talk about this in his talk because it's
just it gets too complex but it still is
trustless so you cannot get fake data or
something you know it's decentralized
and it it actually verifies all the
requests and all the information that
that gets so just to cope oh yeah
numbers to show the differences between
a full node and a light node or light
client the sync time is a couple seconds
if you're lucky if you're not so lucky
maybe a couple minutes but we're not
talking about hours or days right as
long as you have internet I'm not
talking about this Wi-Fi here because it
could be could be it's not easy I tried
it I did sync a light note in the
and send for instance with my 40 you
right it took a couple minutes but it
was it was doing tubule the state size
so how many gigabytes or whatever are
you going to download on your mobile
phone or on your PC with a light client
is going to be zero it does not source
the state with a full node of course
that's its job it's gonna
have gigabytes and gigabytes of state
and the database that you're gonna have
again on your on your desktop or on your
mobile it's going to be tens of
gigabytes people are talking about
terabytes I won't go into this debate
but anyway for full notes and like
client its we're talking about couple
hundreds of megabytes so what is the
like line or why do we want to use a
like lines so today you have on the
right the notes the full nodes that are
connected to each other and they form
the ethereum network and you have your
decentralized application that is there
and sits there and when you want to
connect when you connect to say in here
you connect to one of these nodes or
let's say a set of note that is owned by
a company and you trusted this person so
this person can actually turn bad and
what they can do is they cannot change
your transactions or something they
cannot you know spend your money on your
behalf or something that's okay but
still they can track you they can know
exactly who you are with your IP they
can see okay this person is using this
address all the time like they can do
many mean mean stuff or they can censor
you right infrared they are nice we know
them and they actually want to get
decentralized more they had talks about
it I'm just saying this is not the right
way to onboard people we all know that
okay we want to care about
decentralization in the space that's why
we want to bring people more people to
the space so let's let's do it right and
what we can do is so the the new dots
here or like lines so they are connected
to full nodes and what we want to do is
actually embed a light client in our tab
this is what we did and this is what we
want actually to let people do more so
to let people and better light client
and use a light clients in their
centralized application we both library
that is called light yes so it's super
light it's for light client everything
is right and here's what here's how a
stack that you would have today for your
normal app so basically you have your UI
in JavaScript monstro
using react angular whatever then you
embed web through J's which you want to
use to just send transactions and do
stuff on the blockchain this web 3js one
of the first thing you do with web to
jess is setting the provider you have
new provider and there you most probably
use some URL from infra with the token
that you have and then infer us or this
centralized service node that you have
to trust in this case we'll talk to a
theorem and what we want to do so yeah
these guys can eventually censor you or
or track you and so what we what we want
to do with this light J's is actually
instead of what three J's you use this
light Jess and this will talk to a light
node on your own inside your app
actually and you will talk directly to
the ethereum network so the difference
here is that you remove write the
centralized node and you put the light
node actually inside the tap right so
this like Jess library is a high-level
reactive and easy to use library we'll
talk about it's just a bit
we are whoa how do you install it just
like any other real library you probably
insulted a it's from the party name face
and slash like dot J's so let's have a
look a bit at some code I hope you can
see that all right so that's a really
simple sample code so you can see that
we import light and we import balance
off and block number and those balance
often drop number have a dollar behind
and it means there are these are
observable and just like we would do
with web 3gs today you would just do
light set provider with your provider
and then you can do with these
observables Rock number you can
subscribe for instance and this will
give you a block number that you can log
and so in this in this little program
we'll just subscribe with the block
number and just block the current block
number and we do kind of the same with
balance of so balance off you want to
say which address
want to see the balance off and then I
don't know if you if you wear or if you
know how to use reactive or rxjs but
basically you can get what's the result
of balance off and pipe it and do
something with this with this result so
what we're going to do is this balance
is going to be formatted or you have a
question so the question is well
balanced off will be actually stream and
updated and the answer is yes and this
is the nice thing without observables
and and your you'll see that in your in
a second so the balance off will be you
know not formatted nicely so what we
want to do is from way we want to format
it basically and then what we do is we
do the same as before we subscribe to
this and we just log it so what happens
is when you just run this in the console
it will just go like this current block
blah blah blah my balance and then it
updates and then it updates you change
the balance boom balance will show the
new balance and then it updates and it
goes on so this is an observable and
well yeah that's or XJS like this is not
what we built this specifically we just
built on top of this and and this is
awesome that's why we will use it so
like Jess I said is right it's actually
extremely simple we did not go crazy
with the amount of thing we wanna
support we actually just support what we
need and what the community up to now
has told us lean it so we have twelve
functions and that's it right we have
like super basic things the block number
you know you can post transaction post
row transactions already signed
transactions you can get some contracts
you can get you know like my balance the
version info of the node and suffering
this so just to see an overview of the
differences between for instance web
through Jess and like Jess so the
account management the way it's done no
sorry there a synchronous management
with what we Jess you would use from
eyes we use observables
the coverage of the our pcs that we that
we support we keep it very very simple
right and if you need some more please
just let us know and of course and this
is the very important thing
light client like this is built the way
we have it in mind is it's built to be
used on top of light client and it
brings a lot of things that yeah that do
not come embedded in what 3GS and I'll
talk about it right now
so so behind the scene the light yes
uses the least possible resources on the
light line so what you're gonna do today
just before I showed you okay what's the
latest what's the latest header frames
or what's my balance for instance your
balance will not change every second
right the block number the block time is
five fifteen seconds on therm does not
make sense to just bother the node you
know every second on fifty five hundred
milliseconds right today you can do that
with the theorem but it does not bring
anything so light client the largest
library will do this for you right will
actually get just a push notification
will not have pull so you will get the
the latest information
when it's there not when you ask for it
because sometimes developers just don't
know everything and that's fine and
that's why we want it to be light yes
this way so it fetches States on you
head and not whenever you want so it
just gives you new information whenever
there is new information actually it
handles the subscriptions to to the node
for you it handles cash and it keeps the
amount of network calls to the minimum
but to the I mean it still it's so
there's you know you won't be like
outdated you won't get how they did
information it just does the thing like
in an efficient way right so I'll go and
the reason why we built all of this
elbow is to embed light clients
everywhere as much as possible and
facilitate a very mass adoption while
maintaining the centralization because
we do not want to to just trade this off
right so because of this we you know
probably parity has
builds a node and this node can be run
as a light node or as a light lines the
thing is we wanted to use it and to see
how things work and we wanted to embed
like let people in that light client
everywhere so that's why we will build
feather so feather is an application on
top of a light client and I will show
you just I'll show you in a minute I
want to just talk very briefly about the
stack so just like we said before so we
have you Act UI in react we use light
jazz to interact with a light node that
is inside an electron app and all this
app will interact with directly with the
term network without third party service
in between so truly decentralized wallet
is what better is it used to be not the
only one because mist used to be also
using a light wallet unfortunately it's
not possible a light client sorry and
foster only is not available anymore due
to other reasons so to my knowledge
feather is the only application
unfortunately on top of our light
clients so it uses light just as I said
it's bundled with a parity of theorem
right client and it syncs in couple
minutes depending on the Wi-Fi we have
other interesting libraries that you
might want to see one of them is called
parity electron it's a small library to
start and stop parity I am from a
node.js environment and you will see the
UX and everything about feather right
now so here I just launched feather and
this is what happens at the bottom you
will see that it's start syncing right
now and it just shows you you know like
and it shows you there how far you are
and shows you an empty page because you
have no account so I'm going to check
create a new account this looks like a
green cat so I'm gonna name that green
cat you know and now it's it's getting
synced you know like at the bottom you
can see sometimes so we show the you
know the mnemonic blah blah blah
you have to be careful with the mnemonic
please type the new Nanak again and then
you're gonna have the password and just
to secure your account and it's tricky
sinking in the in the bar in the
background so it's you know it's not
extremely fast but it's alright and I
can also for instance import an account
using I don't know Jason so here my
window was a bit not on the right side
but I'm just importing a Jason and just
shows you know the name and stuff and
yeah so by the time I'm done with this
process actually I'm done thinking you
can see that it's inked and now if I
click on an account it takes a bit of
time to get the balance again it could
be super quick this Wi-Fi was not like
awesome okay now it's dated and I have a
new C 20 token as the other one the
other balance so here for instance I can
add I don't know another token so it's
gonna be a fake token it's my token so
it's just cheap coin and yeah you know
at some point you choose updates and to
send a transaction so I'm just going to
click on this one and I'm just gonna you
know say to whatever these amounts I can
select the amount way so here does some
call right it does like okay how much
this transaction is gonna cost etc does
some calls in the background and then
right using just a transaction like
nothing nothing very right so I'm just
gonna cut this because it takes some
times to send the transaction but you
you get it so what do we do now with
this application so it has been outdated
this is the first time I say it actually
it has been operated this summer by
trail of bits I'm super happy because
there was no big critical problem found
we fixed actually all the problem now
and we're gonna have a release probably
next week with everything fixed and we
want to give this to the community if
anyone is interested to actually keep
this going because this is not something
we're gonna go further on we do not have
to bandwidth for this and yeah so if
anyone's interested please talk to me
and
we'll be happy to - yeah go on with with
feather because I have a bit of time I'm
also having a shameless plug here we're
hiring a full stack developer we have
awesome other stuff to do with light
clients with many many things and please
talk to me or anyone party that's about
it we have a couple minutes for
questions thank you so much and yeah if
you have any question
[Applause]
you