hydra-v3_subtitles.srt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. 1
  2. 00:00:00,719 --> 00:00:04,960
  3. All right. So, thank you for joining me on this part four on Hydra v3.
  4. 2
  5. 00:00:04,960 --> 00:00:18,240
  6. Now this is largely just going to be about what Hydra is but we are working towards v3 which is a major milestone for us in terms of the functionality that's needed,
  7. 3
  8. 00:00:18,240 --> 00:00:28,960
  9. and we really think that with this release it's really becoming possible for people to build very powerful applications,
  10. 4
  11. 00:00:28,960 --> 00:00:34,800
  12. front-end applications for substrate chains using Hydra, so we're extremely excited about it.
  13. 5
  14. 00:00:34,800 --> 00:00:42,550
  15. As I’ll get to, you know, it's actually a pretty astounding achievement to be able to build and manage this on top of everything else we're doing
  16. 6
  17. 00:00:42,559 --> 00:00:50,710
  18. because you will find many other projects that are very large teams entirely devoted to building something like Hydra,
  19. 7
  20. 00:00:50,719 --> 00:00:55,360
  21. so it's something we're really proud of, and we want to assist other people in adopting as well.
  22. 8
  23. 00:00:55,360 --> 00:01:04,550
  24. So, Hydra. What is the, I guess, the best way to understand it is just in terms of what problem is it solving.
  25. 9
  26. 00:01:04,559 --> 00:01:18,470
  27. Imagine a hypothetical blogging blockchain which is sort of a substrate chain which has the single purpose of sort of implementing some kind of a social blogging platform,
  28. 10
  29. 00:01:18,479 --> 00:01:33,920
  30. and, in fact, a one well-known substrate project called Subsocial which is covered under my little video in the top bottom right corner actually has implemented Hydra
  31. 11
  32. 00:01:33,920 --> 00:01:39,520
  33. so it's not entirely hypothetical, but just for the sake of an argument imagine this kind of a blockchain.
  34. 12
  35. 00:01:39,520 --> 00:01:47,360
  36. So, you have users submitting extrinsics or transactions where they make threads and posts, this sort of stuff.
  37. 13
  38. 00:01:47,360 --> 00:01:50,000
  39. So, that's pretty, you know, simple.
  40. 14
  41. 00:01:50,000 --> 00:01:59,110
  42. And then you can imagine building some sort of an application that's supposed to display something about this blogging infrastructure
  43. 15
  44. 00:01:59,119 --> 00:02:06,560
  45. like allowing people to post stuff, allowing people to read what's happening across different blogs and so on.
  46. 16
  47. 00:02:06,560 --> 00:02:13,520
  48. So, the naive way you would do it and the way most apps for substrate have been built is that you just build some front-end app,
  49. 17
  50. 00:02:13,520 --> 00:02:26,310
  51. you hook it up to your substrate full node, and it queries it in order to ask some simple questions about what the structure of the blog is and who's doing what and so on.
  52. 18
  53. 00:02:26,319 --> 00:02:36,950
  54. The problem that you'll pretty quickly run into is that there are a bunch of very simple queries that are needed in order to render the sort of user experience
  55. 19
  56. 00:02:36,959 --> 00:02:43,120
  57. that people are used to, certainly in Web 2.0 world that just are not possible if you ask a full node directly.
  58. 20
  59. 00:02:43,120 --> 00:02:56,230
  60. If you ask for any of these examples and really any number of other examples you could think of as they are totally reasonable, the full node won't have a pre-prepared
  61. 21
  62. 00:02:56,239 --> 00:03:02,640
  63. index over its history and state which would allow you to easily query and ask for those.
  64. 22
  65. 00:03:02,640 --> 00:03:14,480
  66. The thing that you see people doing is either you have like a front-end app which takes a very long time to sync up because it downloads everything
  67. 23
  68. 00:03:14,480 --> 00:03:24,720
  69. or a large chunk of either what's in the state or history in order to do a bunch of processing on the client side in order to show the right thing for the user.
  70. 24
  71. 00:03:24,720 --> 00:03:29,200
  72. That's slow, complicated, in general just doesn't really scale.
  73. 25
  74. 00:03:29,200 --> 00:03:38,560
  75. This is really the problem that you'll run into writing really any blockchain application, you will, if you're going to make something that's,
  76. 26
  77. 00:03:38,560 --> 00:03:43,280
  78. I would say, has a non-trivial user experience, you're going to have to somehow solve this problem.
  79. 27
  80. 00:03:43,280 --> 00:03:52,790
  81. And specifically for substrate chains, Hydra is the framework approach we've taken to solve this.
  82. 28
  83. 00:03:52,799 --> 00:03:58,400
  84. So, what it is? It's a software framework where it makes it very easy for someone who's developing a substrate chain,
  85. 29
  86. 00:03:58,400 --> 00:04:05,120
  87. such as Joystream, to focus only on the parts that are relevant to them.
  88. 30
  89. 00:04:05,120 --> 00:04:18,000
  90. They get this whole set of tools and nodes that automatically does everything else they need in order to provide this API basically which can,
  91. 31
  92. 00:04:18,000 --> 00:04:22,470
  93. for example, respond to the sort of queries that I showed you before.
  94. 32
  95. 00:04:22,479 --> 00:04:26,720
  96. So, that's the Hydra framework.
  97. 33
  98. 00:04:26,720 --> 00:04:37,190
  99. We actually were really proud to see that the Hakusama judges picked it as the first entrant winner, so that was pretty cool in the,
  100. 34
  101. 00:04:37,199 --> 00:04:44,800
  102. I believe it was the open category if I hadn't… I think that was, yeah, open hack, so that was really cool.
  103. 35
  104. 00:04:44,800 --> 00:04:53,040
  105. For some of you, maybe the way I am describing it, you may feel like you've heard of this before, in particular coming from the Ethereum space,
  106. 36
  107. 00:04:53,040 --> 00:04:59,040
  108. and this is basically because this is very very similar to what the Graph tries to do for Ethereum.
  109. 37
  110. 00:04:59,040 --> 00:05:10,800
  111. Basically, it tries to give that kind of a service for smart contracts whilst we do it for standalone chains.
  112. 38
  113. 00:05:10,800 --> 00:05:16,400
  114. There are some big important differences between the Graph and the Hydra framework.
  115. 39
  116. 00:05:16,400 --> 00:05:28,720
  117. One important difference is, well, at least before the way the Graph used to work was that the Graph company sort of hosted a service where everyone who built an app
  118. 40
  119. 00:05:28,720 --> 00:05:36,880
  120. that was talking to the Ethereum chain would sort of just talk to a server that the Graph company was running.
  121. 41
  122. 00:05:36,880 --> 00:05:47,360
  123. They were sort of not that happy with that, it's not really sort of in the spirit of the Web 3 vision
  124. 42
  125. 00:05:47,360 --> 00:05:56,800
  126. so they always had the goal of building this distributed peer-to-peer type of network that would replace their role in provisioning that service.
  127. 43
  128. 00:05:56,800 --> 00:06:03,120
  129. That's not an easy thing to do but that's something they've started to roll out, so I think over the next coming months
  130. 44
  131. 00:06:03,120 --> 00:06:14,470
  132. or so there's going to be some version of what the Graph, the hosted version of the Graph does for that is decentralized in some way.
  133. 45
  134. 00:06:14,479 --> 00:06:18,080
  135. I mean I could get into the details of what that is but I think that would be a big distraction here.
  136. 46
  137. 00:06:18,080 --> 00:06:27,600
  138. The way we run Hydra and generally people are expected to run Hydra is that the person who hosts the front-end application
  139. 47
  140. 00:06:27,600 --> 00:06:29,520
  141. would pretty much run the query node instance.
  142. 48
  143. 00:06:29,520 --> 00:06:34,800
  144. That's sort of the way we're envisioning this being provisioned.
  145. 49
  146. 00:06:34,800 --> 00:06:44,800
  147. Maybe that we end up shipping a working group which has people running query nodes which, this is what we call Hydra nodes basically,
  148. 50
  149. 00:06:44,800 --> 00:06:54,000
  150. where people are incentivized by our DAO to run them for the benefit of people using either Atlas or Pioneer or any other
  151. 51
  152. 00:06:54,000 --> 00:07:03,360
  153. major front-end application but this is one of those decisions that we are still quite early on in terms of how it's going to be provisioned at scale.
  154. 52
  155. 00:07:03,360 --> 00:07:08,160
  156. How is it that this actually works for a developer?
  157. 53
  158. 00:07:08,160 --> 00:07:11,440
  159. What a developer has to do is they have to define two things.
  160. 54
  161. 00:07:11,440 --> 00:07:18,080
  162. The whole point of Hydra is to alleviate the burden of having to do everything like talking to the chain,
  163. 55
  164. 00:07:18,080 --> 00:07:22,800
  165. and managing a database, and putting your events in there, and making an API.
  166. 56
  167. 00:07:22,800 --> 00:07:28,400
  168. It's a lot of work to get that to happen every time for a new substrate chain.
  169. 57
  170. 00:07:28,400 --> 00:07:37,440
  171. So, what a substrate developer has to do is, first, they have to just define the way the data in their system is organized
  172. 58
  173. 00:07:37,440 --> 00:07:44,240
  174. in a really nice simple sort of GraphQL like markup language.
  175. 59
  176. 00:07:44,240 --> 00:07:55,030
  177. There you would say, for example, if we take the Subsocial example that you have, you know, a blog, and you have posts, and blogs have authors, and posts are part of blogs.
  178. 60
  179. 00:07:55,039 --> 00:08:02,800
  180. You would sort of define a very convenient way, in a way that developers are very comfortable with, how the data is organized.
  181. 61
  182. 00:08:02,800 --> 00:08:11,030
  183. And then you would define what are called mappings which are basically rules which say when I see this kind of an event or this kind of a transaction
  184. 62
  185. 00:08:11,039 --> 00:08:16,080
  186. in the substrate chain, I'm going to put something in the database which then will be queryable later.
  187. 63
  188. 00:08:16,080 --> 00:08:25,680
  189. Either put something or update something or delete something, basically, update the database that holds the information that the front-end apps are interested in.
  190. 64
  191. 00:08:25,680 --> 00:08:29,680
  192. If you provide these two, you basically get everything else for free.
  193. 65
  194. 00:08:29,680 --> 00:08:42,080
  195. So, the way Hydra sort of works in production is that your application talks to a GraphQL server which has the API,
  196. 66
  197. 00:08:42,080 --> 00:08:50,880
  198. that's the API which will allow you to ask those pretty questions that I mentioned in the beginning of the slide deck here that talks to a specific database
  199. 67
  200. 00:08:50,880 --> 00:08:57,120
  201. which holds the data that I just talked about which is managed, sorted by these mappings.
  202. 68
  203. 00:08:57,120 --> 00:09:08,240
  204. Then there is a processor which is this long running process that runs these mappings whenever it sees that the underlying full node
  205. 69
  206. 00:09:08,240 --> 00:09:12,800
  207. has produced some new blocks and some new events and some new transactions.
  208. 70
  209. 00:09:12,800 --> 00:09:23,920
  210. Basically, this indexer database holds a sort of long-standing index of
  211. all the stuff that's happened in your substrate full node.
  212. 71
  213. 00:09:23,920 --> 00:09:29,440
  214. That is the basic architecture that makes a single Hydra node sort of come together.
  215. 72
  216. 00:09:29,440 --> 00:09:40,560
  217. You can basically think of the mappings as defining how the query database looks, and then you can think of the mappings as the logic that runs in the processor.
  218. 73
  219. 00:09:40,560 --> 00:09:44,320
  220. It's quite a nice abstraction.
  221. 74
  222. 00:09:44,320 --> 00:09:50,080
  223. We are extremely proud of having been able to have done that on a relatively small team.
  224. 75
  225. 00:09:50,080 --> 00:09:59,270
  226. A lot of these abstractions have been identified by the Graph, and they've done an amazing job, but it certainly has not been
  227. 76
  228. 00:09:59,279 --> 00:10:04,390
  229. easy to do this with a smaller project with a separate purpose.
  230. 77
  231. 00:10:04,399 --> 00:10:09,680
  232. We're very happy about having developed this, and we hope more people will continue to adopt it.
  233. 78
  234. 00:10:09,680 --> 00:10:18,160
  235. That's the story on Hydra of which v3 is the next major release.
  236. 79
  237. 00:10:18,160 --> 00:10:23,600
  238. So, that's it, see you for the next video.