[00:01:25] Hi, everyone. I just shared my screen. I don't know if you confirm. Is the screen visible? Okay, great. Thank you, Prashant. Thank you, Rohan. I see 153 participants are joined. Let us just wait for one more minute in case if somebody joins. Otherwise, we will get started. Okay, guys, so let us get started. [00:02:23] We have waited enough for the participants to join. [00:02:26] Today, we are going to implement a small blockchain using Python. [00:02:34] We are not going to study blockchain. [00:02:36] We are just going to only use blockchain as an application. [00:02:43] And we are going to use it as a workload that allows us to observe how the operating system manages [00:02:53] CPU execution, processes, memory, and system calls. [00:02:59] Just for a very basic understanding, [00:03:03] a blockchain consists of blocks [00:03:06] linked through cryptographic hashes. [00:03:11] Before getting into that, [00:03:14] what we are going to have is [00:03:16] we have a Python application, blockchain application. [00:03:20] When we are going to execute that, it's basically proof of work. [00:03:26] It is going to mine and loop using knowns to six shadow. [00:03:33] And it will use a difficulty level and then repeat. [00:03:36] This is what exactly this application is going to do. [00:03:39] And what we are going to observe is, we are going to observe using some of the tools, [00:03:45] both the user space, the hash calculation and Python logic, [00:03:50] as well as we are going to observe the kernel services, [00:03:55] the process creation, scheduling, and file operations. [00:03:59] So this is what is our objective today. [00:04:03] Now, quickly, just for our basic understanding, [00:04:10] Let us understand what a blockchain is. [00:04:16] So let me go ahead and share another image. [00:04:21] No worries, I'll share all these images in the model, not to worry. [00:04:27] So a blockchain is nothing but a peer-to-peer network. [00:04:36] that could be simply defined as a shared immutable ledger [00:04:44] where transactions are permanently recorded. [00:04:50] When we say immutable, we all understand that [00:04:54] we will not be able to modify. [00:04:58] Okay, perfectly fine. [00:04:59] When it is permanently recorded, [00:05:02] we will be able to only append. [00:05:06] we will not be able to modify, we will not be able to remove. [00:05:12] So let's begin by breaking down the definition of blockchain [00:05:16] if we were to explain it to a five-year-old in one sentence. [00:05:24] Blockchain technology essentially allows a person to make a trade [00:05:29] with anyone without the need for a physical store or a middleman. [00:05:37] direct business can happen and without the need even to know the other person. [00:05:46] We don't need to know the other person. [00:05:48] We don't need any intermediate, but still we will be able to make a trade. [00:05:54] This is possible because a blockchain is a distributed ledger [00:05:58] that is shared among the nodes of computer network. [00:06:04] DLT, which is Distributed Ledger Technology, [00:06:11] allows a blockchain to maintain a secure [00:06:13] and decentralized record of every transaction. [00:06:20] So it would record a trade. [00:06:25] And it also allows a blockchain to maintain a secure [00:06:31] and decentralized record of every transaction [00:06:34] that has historically occurred on the chain. [00:06:39] even the past. Blockchain technology's key element of innovation lies in the fact that it ensures [00:06:47] the fidelity and security of the data records. It maintains and helps create trust without [00:06:55] requiring a trusted third party. There is no third party required. There is no secure technology [00:07:01] required itself secures the data the transactions within the chain this encourages peer-to-peer [00:07:11] transactions directly without the need for an intermediary to structure all the data that a [00:07:18] blockchain holds it groups information together in what is known as blocks so everything is stored [00:07:29] in a block and these blocks have certain capacity limits which means once it is filled the block [00:07:38] is closed once it is filled the block is closed and a new block is now created and attached to [00:07:44] the previously filled block so it's block by block it creates a chain that's why we call it as [00:07:54] blockchain this results in historical record of all transactions ever recorded okay when was this [00:08:05] blockchain first invented interesting question right the concept of blockchain first described [00:08:11] by scientists haber and sternetta in 1991 has evolved significantly over the years [00:08:20] It was when an individual or group published a white paper under the name Satoshi Nakamoto, focusing on Bitcoin. [00:08:31] I believe every one of us would have heard Bitcoin. [00:08:35] A peer-to-peer electronic cash system in 2018, that the concept of digital money based on blockchain technology first came to the light. [00:08:46] and the technology's popularity began to see a massive uptick. [00:08:51] The Bitcoin blockchain was made open source [00:08:55] and released to the public in January 2009, [00:09:00] making it possible for people like us to examine the code and reuse it. [00:09:06] But how does it work? [00:09:09] If we understand how does it work, [00:09:12] then definitely we will be able to understand the program [00:09:17] and the behavior of the program in relation to the operating system. [00:09:23] Let me just stop sharing this. [00:09:27] Let me share another speech. [00:09:31] Basically, it defines how does it work, how blockchain works. [00:09:38] So let me share this window now. [00:09:42] Hope you are able to see my window. [00:09:45] Though blockchain technology has applications in virtually every industry today, [00:09:50] the essence of how blockchain works remains constant for every use case. [00:09:56] There is no change. [00:09:59] The steps that occur when a blockchain executes a transaction is what we are seeing here. [00:10:07] So the first is basically recording the trade. [00:10:10] basically the recording or it could be a transaction basically to indicate an exchange [00:10:19] of digital or physical asset between parties on a blockchain network a transaction must be recorded [00:10:29] and this record is used to list digital signatures from the parties involved and other details like [00:10:38] who was involved in the transaction [00:10:40] what was the transaction [00:10:42] is all about [00:10:43] when and where the transaction [00:10:46] occurred why the [00:10:48] transaction occurred among other [00:10:50] details this is something that [00:10:52] every block will [00:10:54] store once the block [00:10:56] is filled and the block is closed [00:10:58] it is closed forever [00:11:00] we will not be able to [00:11:02] modify the block [00:11:03] once the recording [00:11:06] is done [00:11:08] the block is closed, now it has to be validated. [00:11:15] Validation means what it has to validate. [00:11:18] Once the transaction has been recorded, [00:11:21] validating it is the next step. [00:11:25] On a decentralized network, like the blockchain, [00:11:31] most of the computers on the network called nodes [00:11:34] must reach a consensus that all the nodes should accept [00:11:39] that the transaction or trade is real to validate it. [00:11:44] Everyone, every node in the network should accept. [00:11:48] These rules of agreement can vary depending on the type of network, [00:11:53] but are usually established at the beginning itself. [00:11:58] Even the validation criteria, validation rules, [00:12:01] acceptance criteria acceptance rules everything is established even before the blockchain [00:12:07] is created okay now adding and linking the blocks once a transaction is verified [00:12:17] the validated transaction is added to a block if that is the first block in the chain then it will [00:12:26] be initiated as the block and all other transactions as a block will get attached to it this is the [00:12:35] block this transaction when it the block is closed now it forms a chain now this is equivalent to [00:12:47] recording transactions on the pages of a ledger book if somebody is from the accounting background [00:12:53] they can understand a ledger, somebody from financial background [00:12:59] they can understand, a ledger is nothing but a book [00:13:03] where the details of the transactions will be written in it [00:13:06] so this block is equivalent to that ledger page [00:13:14] each block contains a unique code [00:13:17] sorry, unique code called a hash [00:13:21] each block is identified with a hash [00:13:25] and the hash of the previous block in the chain. [00:13:29] If this is the chain of three blocks, [00:13:32] if we are considering this block, [00:13:34] then this block will have hash [00:13:37] and this block also is going to have a hash in it. [00:13:43] And the third block which is joining now [00:13:45] will also have the hash. [00:13:48] So the hash of the previous block in the chain [00:13:50] for this block, [00:13:52] the hash of the previous block in the chain [00:13:54] is the hash in this block. [00:13:58] That also will get stored. [00:14:01] And that is what is going to link these two blocks. [00:14:05] Once that is linked, we will not be able to move the block out of the chain also. [00:14:12] We cannot move this block and attach it to this block. [00:14:15] Or can we move this block which is first in the chain and make it as the third move? [00:14:21] Once it is attached, it's permanent. [00:14:23] This could be seen as a similar of staking, blocks on top of each other. [00:14:31] Whenever you're building or constructing a building, [00:14:37] when you keep the blocks of concrete, once it is placed, it is placed. [00:14:45] You can't take it out and remove it, put it in another place. [00:14:49] so once it is stacked [00:14:51] once it is set it's done [00:14:53] forever [00:14:55] similarly this [00:14:56] blocks are [00:14:59] ever linked [00:15:00] and if you remove a block from [00:15:03] the middle the entire chain [00:15:05] falls can I forcibly [00:15:12] remove yeah [00:15:14] you can do it technically it is [00:15:17] possible [00:15:17] but the moment you use the force [00:15:21] the entire chain [00:15:22] breaks [00:15:24] and then you need to build a new chain [00:15:27] with all the blocks that you have. [00:15:31] So now after the block is linked to the chain, [00:15:34] once this block is linked into this chain, [00:15:38] a copy of the central ledger is distributed [00:15:41] to all participants in the network. [00:15:45] So everyone will have the information [00:15:47] about these three blocks in this chain. [00:15:50] Everyone will have. [00:15:52] Now the same process will be followed to add more blocks. [00:15:58] Now, what is the advantage of these blocks? [00:16:04] Let us understand that. [00:16:06] Let me go back and share the previous screen. [00:16:11] The first one, it is immutable. [00:16:19] Blockchain technology supports immutability, [00:16:22] which means that its technology makes it impossible [00:16:28] for any data recorded on its network to be erased or replaced. [00:16:35] Both cannot be done. [00:16:36] We will not be able to erase. [00:16:39] We will not be able to modify. [00:16:42] And this helps prevent any data tampering and any data manipulation. [00:16:48] That's the first advantage. [00:16:50] The second one is the transparency. [00:16:54] A blockchain network is decentralized, allowing any member of the network to scrutinize the data recorded. [00:17:02] If you have like 2 million nodes in your network, then all the 2 million nodes will have access to all the 2,000 blocks in the chain. [00:17:17] This creates transparency and builds trust among the public using the network. [00:17:24] So if you are going to use that network, you are 100% sure that no data tampering and no data manipulation. [00:17:34] and the blockchain is inbuilt with security [00:17:41] owing to the fact that [00:17:45] its transactions require validation from network members [00:17:50] to be considered real and accurate. [00:17:56] This creates a tight layer of security [00:17:58] for all trades and transactions in the network. [00:18:03] The fact that the transactions are immutable, number one. [00:18:07] Second, it is transparent. [00:18:09] And the third one, it has to be approved [00:18:11] from by all of the network members. [00:18:15] So that means if you are adding a block with that data inside it [00:18:19] into the chain, you can be 100% sure that it is protected [00:18:26] from third-party attacks. [00:18:30] And also, there is no room for the data to be prone [00:18:34] to rogue administration activities. [00:18:38] That is also not possible. [00:18:40] If that's then, definitely the chain is going to break. [00:18:48] Once it breaks, then you have to create a new chain with all the blocks. [00:18:53] Now, these are all the advantages. [00:18:58] But are there any cons? [00:19:00] Yes, we do have disadvantages of the blockchain. [00:19:03] High cost of implementation. [00:19:07] Though blockchain technology reduces cost for users, [00:19:11] It requires high cost for companies to implement. [00:19:15] So it's not for the users. [00:19:16] It is for the companies to implement. [00:19:19] It involves higher cost. [00:19:22] Not only that, proper planning and implementation are a must. [00:19:26] If companies want to successfully integrate this technology into the processes. [00:19:32] Second is performance. [00:19:34] Since blockchain technology carries out more operations, it is seen to be slower. [00:19:42] From the performance perspective, it is a little slower than traditional databases. [00:19:49] Inefficiency can also arise from the process that blockchain technology is defined by, [00:19:57] like its mechanism of receiving validation for a single transaction by several network users. [00:20:03] it's not like our variable [00:20:07] and a condition [00:20:09] if condition [00:20:09] where we are [00:20:11] checking the value of the variable [00:20:14] if it is more than [00:20:15] 10 [00:20:17] that can happen very fast [00:20:20] but if the same operation [00:20:22] needs to be done [00:20:23] not only by one if condition [00:20:26] but assume that one million if conditions [00:20:28] then you can think about [00:20:30] it will definitely [00:20:32] slow down [00:20:33] because every network member has to agree, accept. [00:20:40] Then only it will get added to the network. [00:20:46] Third is immutability. [00:20:49] Immutability leads no changes to data. [00:20:53] And modification of data itself is a con. [00:20:59] So it can also be a big obstacle [00:21:02] when necessary modification is required. [00:21:04] For example, somebody made a transaction for $10. [00:21:13] Now, after some time, they come to a compromise and say the transaction at $9. [00:21:19] Will I be able to change from $10 to $9? [00:21:23] No, we cannot. [00:21:26] And the process of rewriting is incredibly time-consuming and very expensive. [00:21:36] So most of the blockchain implementation, if you look at it in the industry, where there are not much of modification of data required, that's where exactly it got implemented. [00:21:51] but we do have multiple types of blockchains based on the structure characteristic and usage [00:22:01] based on these three aspects there are four types of blockchains exist basically public private [00:22:09] hybrid and consortium so i'm not going to go in deep we should be aware what is blockchain [00:22:15] sorry blockchain how it works what are the different types the pros and cons and where [00:22:22] it is implemented so it is implemented in financial markets health care [00:22:30] decentralized finance real estate is another area there you can see blockchain implemented [00:22:41] smart contracts. [00:22:44] So in financial services, if you look at it, [00:22:48] you can refer Bitcoin, Ethereum, [00:22:51] are popular examples of cryptocurrencies [00:22:54] built on blockchain technology. [00:22:56] If you're speaking about healthcare, [00:23:00] you can think about a medical chain. [00:23:04] And it was one of the first medical companies [00:23:07] to implement blockchain technology [00:23:13] to help facilitate the storage and utilization [00:23:15] of electronic medical records. [00:23:18] Where they are using it? [00:23:20] They are using it for the safer and faster way [00:23:22] of managing data and track medical supplies. [00:23:27] And if you are speaking about supply chain, [00:23:30] a great example is IBM Food Trust. [00:23:36] That is a project developed to help improve [00:23:38] the supply chain of the food. [00:23:42] Or you can also think about Propi, [00:23:43] a platform using blockchain [00:23:46] to transform how people market, [00:23:50] search for, buy, sell and invest in the real estate. [00:23:56] So these are all the use cases [00:23:59] that we should be aware of [00:24:00] when we are speaking about a blockchain. [00:24:05] Okay, perfectly fine. [00:24:08] Now, how do we understand it? [00:24:15] Understanding it is very, very important. [00:24:21] Now for this lab, we are going to have two or three different parameters. [00:24:33] One is difficulty level and another one is the block parameters, that is hash. [00:24:46] And the third one is the arguments. Okay, cool. Now let me go ahead and [00:24:58] share my screen what i'm going to share now is basically my console so hope you are able to [00:25:06] see my console let me change the settings so that you are able to [00:25:14] see it legibly and let me make it 12 hope it is legible let me try ls minus l yes [00:25:25] hope it is legible if not please let me know i can adjust the size of the screen okay cool [00:25:39] Now let us look at the code. [00:25:50] What we are going to use is we are going to use this code, Python code. [00:25:55] Let me open it in nano. [00:26:00] QW is nothing but proof of work in blockchain. [00:26:05] So now if you look at it, [00:26:09] we are going to use a simplified hexadecimal prefix. [00:26:16] This production blockchain protocols can use more elaborate [00:26:20] numeric targets or could be block headers [00:26:24] or consensus. But for this [00:26:28] particular lab perspective, what we are going to [00:26:34] do is, our code [00:26:39] basically starts from the genesis. [00:26:47] so it's a huge one actually if you look at it it is going through the entire title of what we [00:27:01] book so here if you look at it the genesis this is where actually our blockchain is starting [00:27:10] if Genesis is previous hash [00:27:16] so we have a return false [00:27:20] this is where exactly our code starts [00:27:26] but what is there before? [00:27:30] it is basically what we are going to define [00:27:36] what we are going to define is [00:27:38] what we are going to understand [00:27:41] Now, let us understand the code from the top. [00:27:48] I told Genesis is where exactly the blockchain operation starts, [00:27:51] but before that, we need to set the environment [00:27:54] for the blockchain to function. [00:28:00] So what we are trying to do here is [00:28:01] we are trying to import all the packages [00:28:07] that we require from the Python. [00:28:10] For example, argument parse, arg parse, hashlib, [00:28:16] JSON. Hashlib provides [00:28:20] cryptographic hashing algorithms. [00:28:24] It includes SHA-256. [00:28:28] So basically the proof of work algorithm depends on this. [00:28:33] We are importing JSON. It converts [00:28:36] structured block data into a consistent [00:28:41] serialized representation. And we are also [00:28:46] importing multiprocessing as [00:28:49] MP. It creates and manages [00:28:51] independent worker processes. [00:28:53] So for each of these purposes [00:28:55] we are importing all the [00:28:56] libraries that it is required [00:28:59] and we are [00:29:01] also importing operating [00:29:03] system related [00:29:04] OS library, time [00:29:07] library and as well [00:29:09] date and time. So which imported [00:29:12] module is responsible for [00:29:14] creating the operating system [00:29:16] processes when I am going [00:29:18] to execute this Python [00:29:19] it's multiprocessing, the one what we are seeing here. [00:29:26] This is what is going to be responsible for creating the operating system processes. [00:29:35] Now, let us come to the next block. [00:29:41] Here we are calculating the hash. [00:29:44] We are writing a function to calculate the hash. [00:29:48] This function accepts the fields that contribute to the block's hash. [00:29:54] So if you look at it, it is speaking about index, the timestamp, the current timestamp. [00:30:01] Data, the actual data that needs to be within the block. [00:30:06] It will also look at the previous hash. [00:30:09] Previous hash is nothing but the hash of the previous block. [00:30:15] And finally, knowns. [00:30:16] So now, these are all the block contents if you look at it, index is equal to index, timestamp is equal to timestamp, data, whatever data it is available, data, previous hash, previous hash, and the nodes as nodes. [00:30:34] Now, in this function, the dictionary represents the block fields that we want to hash. [00:30:44] The hash fields itself is not included because it is the output of the calculation. [00:30:49] Then the next block of the code, [00:30:53] which is mine worker. [00:30:56] Now, the mining worker. [00:31:00] This function is actual mining worker. [00:31:03] Each worker receives the block information, [00:31:07] target difficulty, its own ID, [00:31:11] the total number of workers, and a shared result, Q. [00:31:16] Now, if you look at it, target is equal to 0. [00:31:20] the difficulty. If difficulty is 4, here it is 0. That means there are no prefix. [00:31:31] Suppose if the difficulty is 4, the target prefix becomes with 4 zeros. [00:31:37] If you have the difficulty as 5 or 6, that means it will be prefixed with 5 or 6 zeros. [00:31:47] Now, one of the things is the knowns, which is equivalent to the worker ID. [00:31:53] The initial knowns differs between workers, the initial one. [00:31:57] The attempt counter records how many hashes this worker has calculated. [00:32:06] And the timer measures its elapsed mining time. [00:32:10] so basically this mine worker is also going to run a loop while loop the loop calculates the [00:32:21] hash for the current nodes and the increments the counter that's all this loop is going to [00:32:28] and actually if you look at it this is the main cpu intensive portion of the program [00:32:36] So if we are able to identify which part of the program is going to consume more CPU, [00:32:44] which part of the program requires more memory, then it is easy for us to manage. [00:32:54] So now this known is the CPU intensive process. [00:33:01] The loop repeatedly calculates. [00:33:03] If you look at it, it is repeatedly calculating here. [00:33:06] And this repeat calculation without a deliberation, [00:33:13] it will be waiting or performing a system call for each attempt. [00:33:20] For each attempt, it is going to create a system call. [00:33:24] And that is where exactly it is going to be CPU intensive. [00:33:29] Now, this if condition to that, [00:33:36] Basically, this test whether the hash satisfies the proof of work requirement, just trying [00:33:44] to understand the logic. [00:33:47] Now, the actual starting the mining, that is the next function which is mine block. [00:33:58] This function coordinates the mining workers and assembles the resulting block. [00:34:03] So basically, this function is responsible for assembling the resulting block. [00:34:12] This function generates timestamp, creates a queue for worker results, [00:34:17] and also initializes the list to track the processes. [00:34:23] Perfectly fine. [00:34:26] Now, we are getting into the loop within this mining as well. [00:34:30] That's a for loop. [00:34:31] If you look at here, it is a far loop. [00:34:36] And this far loop is also a little CPU intensive, [00:34:41] but unlike a while loop. [00:34:46] So now this entire thing is about creation of the block, [00:34:52] mining and creation of the block. [00:34:57] The next is what is going to happen is the validation of the [00:35:03] block. So the corrected validated underscore chain [00:35:08] is going to help us to validate the block. This validate underscore chain is going to help us to [00:35:17] validate which chain and what is the difficulty level. If target is equal to zero, that's the [00:35:24] initialization target. But depending upon the difficulty level that we provide as an input [00:35:31] to the execution of the program it will get modified and run it actually [00:35:40] so within this validation we have multiple stages where we validate the genesis block [00:35:50] that's the first thing we do and the second thing what we do is we are also going to validate [00:35:56] the subsequent blocks as well it goes through the entire validation of the chain [00:36:08] so that it ensures that all the blocks are attached to the chain which has valid data in it [00:36:19] and also it protects it so now finally if you look at it as part of our main program [00:36:28] where it actually defines the main program [00:36:32] and creates a command-line argument parser. [00:36:35] So nothing but we are creating a command-line argument parser. [00:36:41] So that means we can actually give [00:36:48] with the command-line argument, [00:36:55] we will be able to. [00:36:59] So basically now, [00:37:01] So if you really want to execute this, [00:37:06] then we will run the program entry point. [00:37:10] We'll run on this. [00:37:13] But before that, let me close this program. [00:37:19] And let me stop sharing. [00:37:23] Before we start running this program and understand. [00:37:26] Oh, good. [00:37:27] I'm seeing 242, 241 attendees today as of now. [00:37:31] Okay, cool. [00:37:33] Any queries, any questions? [00:37:37] So I'm just saying, [00:37:38] hi sir, once blockchain was much hyped, [00:37:41] technology like AI today, [00:37:43] but it is still struggling with mainstream adoption, [00:37:46] unlike AI. [00:37:48] Do you see it coming mainstream or reminding? [00:37:52] It is expected. [00:37:54] See, first of all, it is a niche. [00:37:57] Obviously, it is a niche technology. [00:37:59] and it is expected to remain niche. [00:38:05] It will not become a popular adaptable technology. [00:38:11] Hash is a unique value for each block. [00:38:15] Like in case if you are using shadow passwords and all, [00:38:20] each password is unique and each password is translated [00:38:24] into a 128 or 256 equivalent shadow password. [00:38:29] something similar to that it is unique and it is can be attached only to one block [00:38:37] and okay i think it has responded okay great cryptographically encoded by various techniques [00:38:48] okay this block info or block ledger is stored where in the data centers [00:38:54] okay so [00:38:57] the chain and the block [00:38:59] is actually virtual [00:39:01] end of the day it is just [00:39:03] data, data stored in a [00:39:04] storage [00:39:07] so but yes [00:39:10] like how we are [00:39:13] creating volumes with the storage [00:39:14] volumes are virtual [00:39:16] but still is available and it is [00:39:19] usable [00:39:21] by us [00:39:22] it has its own properties, it has its own [00:39:25] pros and cons [00:39:25] similarly this block also [00:39:28] ok great I see [00:39:31] so many of you [00:39:33] why this is called [00:39:35] web3 [00:39:36] Nidish the quiz is not [00:39:41] uploaded I know that [00:39:43] I will definitely do that [00:39:44] both quiz 1 and assignment [00:39:47] 3 will be released [00:39:49] so I do see [00:39:51] a response from Akshay for [00:39:53] why is it called web3 [00:39:55] and I see [00:39:56] ok [00:39:58] Okay, knowns is a random value. [00:40:00] Yeah, that is right, Strenuous. [00:40:02] Knowns is a random value. [00:40:06] And please share this Python code. [00:40:09] Yes, obviously, I will be sharing this Python code. [00:40:13] You can also try. [00:40:15] Let me see if I can share it in the chat box itself. [00:40:23] Sometimes the length of the code creates a problem. [00:40:28] It's just plain text, full code. [00:40:44] Yeah, seems to be. [00:40:48] Seems to be. [00:40:49] Let me send it. [00:40:51] This is the code, block. [00:40:54] You can also parallelly run it. [00:40:58] Fair enough. [00:41:00] So why is it costly for company? [00:41:03] Because the demand for resources, the demand for security. [00:41:09] the access everything is premium that's why it is costly for [00:41:15] now i'm not sharing any screen so i just stop sharing [00:41:23] okay costly to implement undistributed servers yeah the hardware requirement today [00:41:30] that also can be addressed by using cloud virtual missions but [00:41:36] looking at the requirements of the blockchain generally we don't do that with cloud [00:41:44] So that's the reason it is very costly. [00:41:51] When will the case one show? [00:41:53] Maybe by Monday. [00:41:56] What is target and what is difficulty used in the code? [00:42:02] Okay. [00:42:05] See, when you are trying to create a block, [00:42:08] the block needs to be unique. [00:42:10] And how difficult it has to be to actually someone need to guess. [00:42:20] And this difficulty level is going to increase the security level. [00:42:27] Based on that, the hash key will be generated. [00:42:31] So indirectly, it has a relationship to... [00:42:36] These days, tokenization of real-world assets or things has changed. [00:42:40] How blockchain is viewed by everyone, any opinion on this? [00:42:44] with it [00:42:47] as far as blockchain is concerned [00:42:49] then it is [00:42:52] not, organizations [00:42:54] won't prefer [00:42:55] because of the cost involved in it [00:42:58] the effort, time [00:43:00] and management [00:43:01] involved in maintaining it and running it [00:43:04] but still it is [00:43:06] one of the technologies implemented [00:43:08] by the niche industries [00:43:10] and the niche companies within [00:43:12] the niche industries, something like [00:43:14] even within the [00:43:16] financial industry [00:43:17] you can't see much bank [00:43:20] doing it but you will see [00:43:21] markets implementing [00:43:24] it [00:43:24] so I see Mohit [00:43:32] Mohit I am just allowing your mic [00:43:34] please let me know [00:43:37] can it be [00:43:39] implemented it in [00:43:40] public procurement yes we can [00:43:43] there are public blocks [00:43:45] you can definitely [00:43:47] create and maintain [00:43:48] yes marit yeah good evening sir sir i'm having a little basic doubts here right [00:43:54] the first doubt when you say the data is stored i mean it's virtual and somewhere it will be [00:44:01] stored right then how it is the decentralized how we can say that because if let's say the [00:44:07] data is stored somewhere into a data center certainly aws or whatever so then how we can [00:44:13] say the decentralized this is the first question for me and then let me answer one by one okay [00:44:19] when you are using the blockchain so generally it will not be a single data center [00:44:27] even if it is a single data center it won't be a single server so you will create a cluster of [00:44:35] servers. And then you will define that network as a closed. So the nodes that is part of that [00:44:44] network only will be able to access this data if it is already added to the block or if it is [00:44:53] already added to the chain. If it has to be [00:44:57] added to the chain, then [00:45:00] all the network nodes, the cluster [00:45:05] nodes has to come to the consensus. There are different types of [00:45:09] consensus, mechanisms available [00:45:11] and proof of work is one of them. Proof of stake [00:45:17] is another. So there should be some proof for everyone to agree [00:45:21] that, yes, this block can be added to the chain. [00:45:28] Suppose if you have a data center in AWS region US [00:45:33] and region Australia, [00:45:36] and you have virtual machines running there, [00:45:40] which is part of this cluster, [00:45:43] and this cluster is what is going to maintain your blockchain. [00:45:48] So there could be servers in Australia, [00:45:51] there could be servers in US which is taking part of it. [00:45:55] So it is distributed, number one. [00:45:57] The second understanding of the distribution is, [00:46:00] suppose if one block is stored in one of the servers in Australia, [00:46:05] the next block can be stored in another server [00:46:08] within the Australian data center, [00:46:12] or it could be in the US data center also. [00:46:16] It's not that the data is getting stored sequentially in a server. [00:46:21] It need not be. [00:46:23] But there will be. [00:46:25] That is where exactly this hash comes into the picture, [00:46:28] which creates from the knowns. [00:46:31] So it will get attached to. [00:46:34] So the block, to block the chain is created with the hash. [00:46:40] And that's where the current will have the previous hash. [00:46:43] So it will know where the previous block is. [00:46:45] System will know. [00:46:46] The network will know. [00:46:48] So the data is also distributed. [00:46:51] It's not like, okay, I'm running a MySQL server [00:46:53] in one of the servers [00:46:57] and all the data is stored in that server. [00:46:59] It's not like that. [00:47:01] Blocks can be split between [00:47:03] and whichever server is storing that particular block of data [00:47:07] is the owner of that data. [00:47:10] And it definitely has... [00:47:12] Anyhow, it needs to go ahead with the consensus [00:47:15] of the data before it gets added. [00:47:19] so it can get added to any node in the cluster it need not be this specific node only so that's why [00:47:26] we call it as yes yes go ahead please yeah so i mean i will just reiterate what you said so it [00:47:34] means that all the database will be available to all the nodes connected to the other cluster [00:47:39] basically that's what the meaning yes it will be available available okay 100 percent yes yes okay [00:47:47] thanks for that the second doubts are regarding when you say into the programming that there's a [00:47:53] while loop or for loop is running so python will run into the serial mode but you said [00:47:59] one statement that it will be gpu intensive work and cpu not gpu sorry cpu cpu okay okay [00:48:09] okay no doubt sir thanks not gpu if you have heard gpu sorry for that it is [00:48:15] okay thanks okay cool so i do see puja puja kumari i'm allowing your mic please let me know what is [00:48:24] your query yes puja if you're talking yeah you're audible now yeah clearly sir sir i have a doubt [00:48:40] regarding that first slide uh where uh where there are so many things like recording validation [00:48:48] linking the blocks, and the last one is sharing the ledger. [00:48:52] So I want to, can you please brief about that last sharing the ledger thing? [00:49:01] Okay. [00:49:02] The ledger is a commercial, okay, it's not a technical part. [00:49:08] What we are referring ledger here is nothing but the block of data [00:49:12] that is written within the block. [00:49:15] and that block can be stored and linked [00:49:20] in any of the nodes. [00:49:23] Once the trade is completed, validated, [00:49:25] then it has to be stored within a block. [00:49:28] A block is nothing but a virtual data store [00:49:31] and we will store it there [00:49:33] and then we will link it to the chain. [00:49:36] Once it is linked to the chain, [00:49:39] like how the ledger is accessible [00:49:41] by any finance team member once it is posted in the ledger. [00:49:48] Similarly, this block which has been already added [00:49:52] is considered to be a ledger of data [00:49:54] and is accessible by all the nodes within the cluster. [00:49:59] That is what sharing the ledger means. [00:50:04] Make sense? [00:50:05] So that means that the hash, right? [00:50:11] No, not the hash. [00:50:12] Hash is basically the identity of that particular block. [00:50:18] Not only hash, even the data is accessible. [00:50:21] The entire block is shared. [00:50:24] The block is identified by the hash. [00:50:27] And once it is identified, suppose if you want to access that data from a specific block, [00:50:33] then you will refer to the hash. [00:50:36] And that hash will refer to the actual block. [00:50:39] And within that block, you might have, for example, if it is a trading data in Bombay Stock Exchange, then the Bombay Stock Exchange provides the transaction date and time, open price, bid price, accepted price, closed price, that they convert into open, high, low, close. [00:51:05] So close is nothing but the price in which both the buyer and seller has agreed to conduct the transaction. [00:51:14] So buyer will buy from the seller at that price. [00:51:17] So like this, every transaction will have data. [00:51:22] And finally, the end of the day, the data also is going to be provided by the stock exchange. [00:51:29] So probably all these data will become, [00:51:32] every data will become 1-1 block [00:51:35] and get attached to the chain. [00:51:38] Now, when every data becomes block, [00:51:41] the block also needs to have an identity [00:51:43] and that block's identity is the hash. [00:51:47] So the block will also have a reference [00:51:49] to the previous block's hash [00:51:52] so that they are connected. [00:51:55] Now hash is only reference, an identity. [00:51:58] But what is shared, the actual data inside that block, which is open, high, low, close for that particular day or for that particular script. [00:52:10] That data is shared among the nodes. [00:52:13] Probably one block is stored in server one. [00:52:17] Another block might get stored in server seven. [00:52:20] But still, these two are connected with the hash information. [00:52:24] And all the nodes know where these blocks are stored, in which. [00:52:31] And for availability or disaster purposes, [00:52:35] we can also store a block in multiple servers, two or three servers. [00:52:41] Within that one primary will have, in that primary is not available. [00:52:45] One of the other servers will provide that block to the entire chain. [00:52:50] So hash is just a reference. [00:52:52] what is shared is not the hash [00:52:55] but the content inside the block [00:52:57] make sense [00:52:58] you mean we need that [00:53:03] hash to access the information [00:53:05] of that particular block [00:53:06] that's right [00:53:08] it is very similar to how you are [00:53:10] accessing your [00:53:12] hard disk [00:53:13] how the hard disk stores the data [00:53:17] in its own [00:53:18] way [00:53:20] it is physical device [00:53:23] It's a magnetic device or it has SSD, whatever it has. [00:53:27] Everything has a way to store the data in its device. [00:53:32] Suppose if you want to access, [00:53:33] suppose if you have formatted that hard disk as blocks, [00:53:39] then each block will have a reference number [00:53:41] and your data is going to be stored within the blocks. [00:53:46] So now each block will have reference to another [00:53:49] so that you will refer the block number [00:53:52] In turn, it will refer whichever way it has to identify. [00:53:57] Different hardware architecture has different ways of accessing the physical device and retrieving the data. [00:54:04] At the end of the day, it is going to store it as either on or off or zero or one, however you refer it as. [00:54:10] So it will go and it will fetch those switches, construct that into your data and give it to us. [00:54:18] Similarly, we will use hash to access the block. [00:54:23] And if you have access to the block, you will be able to retrieve the data. [00:54:26] The only way to retrieve the data from the block is identifying it by the hashes. [00:54:32] Make sense? [00:54:35] Yeah. [00:54:35] And one more question, sir. [00:54:37] Suppose I have three blocks, block A, block B, and block C. [00:54:41] So can I access hash from block C to block A or I have to go consecutively? [00:54:50] Can I skip B and I want to access the data? [00:54:53] You can directly access from the third block in the chain. [00:54:58] You can directly access 3,000th block in the chain. [00:55:02] It is not that you need to access in sequence only. [00:55:07] Same way, right? [00:55:08] You have like 100 documents stored in your hard disk. [00:55:13] You are going to access only the document that is required for you now, [00:55:17] and it is going to get it from the physical address, [00:55:20] and it will open the document for you. [00:55:23] It doesn't mean that you have to sequentially access your hard disk. [00:55:27] Similarly, it's not needed here. [00:55:29] You can directly access any block within the chain [00:55:34] by referring to its hash. [00:55:42] This chain is basically to make it secured [00:55:45] so that nobody will be able to alter the chain [00:55:49] and nobody will be able to modify the data within that. [00:55:54] Tomorrow, if somebody wants to move the block number 3 [00:55:57] from the chain to block number 4, that's not possible. [00:56:01] To ensure that it is not possible, [00:56:04] we have these chains between the blocks [00:56:07] and that is also referred by the previous hash only. [00:56:13] So hash is playing a very critical role in blockchain. [00:56:21] Make sense? [00:56:22] Yes. [00:56:25] Be cool. [00:56:26] Thank you, sir. [00:56:27] Anytime. [00:56:28] Anything else? [00:56:29] See, why I'm spending this one hour on this understanding the blockchain is, [00:56:34] tomorrow if you want to understand, you have written a code, [00:56:38] you need to understand which part of the code is CPU intensive, [00:56:42] which part of the code is memory intensive [00:56:45] which part of the code is storage intensive [00:56:49] if you are going to access [00:56:52] more data directly from the storage [00:56:56] then it is storage intensive [00:56:57] then you need to have type of storage [00:57:00] which is supporting your feed of access [00:57:03] if it is a memory intensive application [00:57:06] then if you are not [00:57:09] providing appropriate number of memory, [00:57:14] then it is going to hit the threshold [00:57:15] and give alerts, issues, time and again. [00:57:22] If you are not able to identify while writing the code, [00:57:25] at least while performing the performance testing, [00:57:28] you should be able to identify it, [00:57:31] which part of the code is memory intensive [00:57:33] and which part of the code is CPU intensive. [00:57:36] These two are very much critical. [00:57:39] If we can manage these two, [00:57:41] Then other things can be managed. [00:57:47] Are we good? [00:57:53] Okay. [00:57:55] So let me disable the mic for Puja Kumari. [00:57:59] I do see Anuja Shahraf. [00:58:02] Yes, Anuja, I have allowed your mic. [00:58:06] The last question I will take before the break. [00:58:09] Could you move? [00:58:10] Yeah. [00:58:13] Yeah, go ahead, please. [00:58:15] Okay. [00:58:16] So my question was very specific to the hashes. [00:58:19] One is the identity hash, which we place up with the block where the linking evolves around the picture. [00:58:26] Second is the public and private key hashes that we actually utilize when the consensus is to try to decrypt the actual validation of the block itself with the data which is being actually published. [00:58:42] So how both are actually linked records? [00:58:45] First is this. [00:58:46] uh and this and the second part of the picture we're trying to understand that uh where we [00:58:52] already know i mean there in the software engineering that we have the public tokens [00:58:57] and the private keys like to access any kind of uh encrypted document we need a private key [00:59:04] so how within the block here when the linking goes up how both are actually does present in [00:59:10] terms of forming a consensus and if i say the consortium is actually playing a picture in [00:59:16] terms of making a proof of work whether it could be mining or whether it could be any other kind [00:59:23] of algorithm which is running behind the scene how this kind of motion is happens while we try [00:59:30] to read any encrypted linked block say a to b is happening so how it happens okay so there are two [00:59:40] hashes as you referred one is the identity for the block that is what our focus were until now [00:59:48] we were never discussing about the keys that needs to be supplied for authenticating that [00:59:57] yes we can access the block i can say okay i wanted to enter kailash block 3 [01:00:05] When I enter, I know that I need to go to flat number 357. [01:00:13] I know who is staying there. [01:00:16] I also have the phone number of them. [01:00:20] But I need to provide my identity at the security gate so that they will record it. [01:00:28] If I say that I don't have an identity, then having all this information is futile. [01:00:35] So the second hash that you are speaking about is also related to the identity, but that can be generated by using different technologies. [01:00:50] You can use any third-party tool also to generate your identity for the access. [01:00:57] And you just give, okay, this is my other card number. [01:01:01] They will just, are they going to verify it at the gate? [01:01:04] No. [01:01:05] But the verification is going to be done by whom? [01:01:08] Actually, somebody who is going to approve your entry inside the apartment. [01:01:14] So at the gate, the security is just going to take the information and input into the system. [01:01:20] So similarly is your public key. [01:01:23] That will be inputted into the authentication system. [01:01:27] And it will be mapped with the private key that is available inside the campus. [01:01:32] so the person who is going to allow you [01:01:35] is not the security [01:01:36] but the person whom you said you wanted to meet [01:01:40] now you have provided your other [01:01:43] now if that person denies your entry [01:01:46] then you can't even enter the campus [01:01:48] having all the even providing the identity [01:01:52] if authentication is not happening [01:01:55] for example that individual is not at home [01:01:59] because for every denial [01:02:01] well, there could be different reasons. [01:02:04] Not only the same reason that you are not allowed to meet me. [01:02:07] No, I am not at home, so I am denying your entry. [01:02:11] So what are you going to do by entering the society [01:02:14] and pressing the bell? [01:02:16] Probably I will deny your entry and then I will call you saying that. [01:02:20] No, I am not at home. [01:02:21] Sorry, you should have told me before. [01:02:23] At least I would have made myself available. [01:02:25] Pretty much possible. [01:02:27] So any authentication that is not happening, [01:02:31] is also not a bad thing. [01:02:36] And this authentication needs to have a consensus. [01:02:41] The person who is coming to meet [01:02:43] and as well as the person who is [01:02:45] either available or not available to meet in that compass, [01:02:49] so both needs to have a consensus, [01:02:51] then only you will get an entry. [01:02:53] Similarly, here the entire network needs to [01:02:56] have a consensus at the level 0, [01:02:59] that S, this access can be allowed [01:03:02] and once it is allowed [01:03:05] then [01:03:05] it means that the block is existing [01:03:08] so if I just [01:03:11] try to mimic your point [01:03:12] if I have to access point [01:03:14] or you can say block B [01:03:16] then I have to take a consensus of [01:03:18] you can say decryption [01:03:21] as a way, proof of work [01:03:22] from the 0th, that is [01:03:23] start of the chain itself [01:03:26] till that block [01:03:27] it's like a mining [01:03:29] till that block if I just say [01:03:32] in a right way or something different [01:03:34] no this authentication can [01:03:36] be random from [01:03:37] the nodes of the cluster [01:03:39] it need not be every node [01:03:42] but [01:03:44] there should be a consent among [01:03:46] the node it could be [01:03:48] you could have just implement [01:03:49] saying that if three nodes [01:03:51] are having the traffic to enter [01:03:54] then [01:03:54] are consenting to [01:03:57] that could do any three nodes can have the consensus to the traffic to get in so it depends [01:04:04] on the mechanism that's what i said there are so many ways implement the hash which is it has a [01:04:13] and it has and there should be one level above is that that is from them it could be [01:04:21] not from the [01:04:23] it is [01:04:25] that needs to give the consensus [01:04:27] suppose if there are like [01:04:29] 250 nodes in that cluster [01:04:32] and if the mechanism [01:04:33] says that if any [01:04:35] three nodes have the [01:04:37] consensus [01:04:37] the entire network has it [01:04:40] that has been built in [01:04:43] if three nodes give the [01:04:44] consensus [01:04:44] so it depends on what you have implemented [01:04:51] for the consensus [01:04:52] so [01:04:54] So, every type of [01:04:56] has a different [01:04:57] methodology, different technology [01:05:00] and different way of work. [01:05:03] So, that's why I said I'm not going [01:05:04] to get into the details of the blockchain. [01:05:08] Make sense? [01:05:10] There is no single [01:05:11] way of consensus. [01:05:14] Yeah. [01:05:15] Just to extend the same [01:05:17] part, does it private [01:05:19] encryption and the [01:05:21] cryptographic decryption [01:05:24] that we say about [01:05:25] shard 256 does [01:05:27] resemble the [01:05:27] similar direction [01:05:28] which we are [01:05:29] talking right [01:05:30] now or it [01:05:30] has a different [01:05:31] mode of [01:05:32] discussion [01:05:33] the way the [01:05:34] way the [01:05:35] shard 256 [01:05:36] works it is [01:05:37] not changing [01:05:37] okay we are [01:05:39] not modifying [01:05:40] any technology [01:05:41] but we are [01:05:42] using technologies [01:05:44] to arrive at [01:05:45] the concerns [01:05:45] that's all [01:05:47] we are not [01:05:49] modifying the [01:05:51] way of any [01:05:51] technology that [01:05:52] works [01:05:52] okay uh one one additional point is does anyhow there is a distributed way of [01:06:04] you can say authentication or you can say decryption is possible like [01:06:09] if i have a block and i can try to have my authentication to be done while you can say [01:06:16] decrypting it from two different other blocks like a password is residing with my again again [01:06:22] i'm trying to tell you the authentication is not done by blocks it is done by notes so suppose if [01:06:31] you have a block reference yeah please go ahead yeah what i meant is just not around the password [01:06:38] i was my i meant around the linkage block so like if i'm if i'm block is b and there's a part can [01:06:45] actually underground and try to have the hash which can be produced only if i try to mine [01:06:52] the two other blocks that is [01:06:54] B plus 1 or B minus 1 [01:06:56] like it's a forward linkage and blank [01:06:58] linkage. Now you [01:07:00] are talking about [01:07:02] adding and connecting the [01:07:04] blocks. Am I right? [01:07:06] Yes. So that's how the [01:07:08] path description that this [01:07:10] is an actual block which is actually [01:07:12] I'm trying to find. See definitely that chain [01:07:15] the chain [01:07:15] will start from one block [01:07:18] at this point of time [01:07:20] it might be ending with block n block a to block n currently it is a chain now if you are going to [01:07:29] add a block to this chain obviously it is going to get added to the block n you cannot add it [01:07:36] between h and j you cannot add it between c and d that's not possible the chain cannot be altered [01:07:45] If you want to add a block, you can only add it after the block N, which is currently. [01:07:51] This will become block O. [01:07:55] And if you want to remove the block, it has a different way of doing it. [01:07:59] By default, it is immutable. [01:08:02] Nobody will be able to remove a block from the chain. [01:08:07] Nobody will be able to modify the data within the block. [01:08:10] Both is not possible. [01:08:17] And you cannot insert a block in between. [01:08:19] and there is no authentication [01:08:22] required from the block [01:08:24] previous block [01:08:25] the previous block is going to provide [01:08:27] its identity which is the hash number [01:08:30] to the block O [01:08:31] so saying that the block O will say [01:08:33] I am connected to block N [01:08:35] that's all [01:08:37] now I cannot add a block [01:08:40] between N and O [01:08:41] it's already linked [01:08:43] you cannot insert [01:08:45] you can only add to block O [01:08:47] that is how it works [01:08:49] no modifications [01:08:51] no deletions [01:08:53] no removals nothing [01:08:55] the data is [01:08:57] the blocks are permanent [01:08:58] I mean why I just said a quote because the block [01:09:03] assembly until unless you have a [01:09:05] previous block hash [01:09:06] and your miners doesn't [01:09:09] solve the complete problem of [01:09:11] that proof of work [01:09:12] maybe it's like a [01:09:14] puzzle or a broadcast [01:09:16] solution that is happening [01:09:18] randomly selecting the proof [01:09:20] of stake within that [01:09:22] block assembly, it's [01:09:24] like never been here. So just [01:09:26] the thought of confirming that [01:09:28] how that new block is different. See, proof of work is [01:09:30] different and proof of stake is different. [01:09:34] Yeah. [01:09:37] So [01:09:38] what I [01:09:40] suggest, Anuj, [01:09:42] yeah, you can get it clarified, but that's [01:09:44] not our focus. [01:09:46] Any which way we have spent [01:09:48] more time on it. [01:09:50] but that's not our objective as well so we will take will not take 10 minutes break [01:09:57] we'll take only five minute break we will come back and we will look at how this program [01:10:03] performs and how we need to identify the utilization how we need to identify the [01:10:12] roadblocks from the operating system perspective and the hardware resources perspective that was [01:10:19] our objective thank you guys I'll be back in five minutes hi everyone I'm back am I audible am I [01:17:02] clear can one of you confirm please okay great thank you so much let me go ahead and share my [01:17:18] screen this time let me share my screen hope my screen is visible right now you should be able [01:17:29] to see the console. [01:17:32] So now [01:17:32] what I'm [01:17:35] going to do is I'm just going to [01:17:36] execute this Python. [01:17:40] So now [01:17:40] I have two [01:17:42] terminals. [01:17:49] So we are going to [01:17:50] execute in one [01:17:52] and observe in the other. [01:17:55] So just to ensure [01:17:56] that we are able to see, let me just [01:17:58] try to resize [01:18:00] it so that [01:18:02] we are good [01:18:03] so yes [01:18:05] let us have this running [01:18:09] like this and this is [01:18:15] our observation window [01:18:16] let me minimize this so that I [01:18:20] have two laps [01:18:22] so now [01:18:23] let me run this [01:18:28] first of all [01:18:29] I'm going to use the Python 3 [01:18:31] and I'm just going to [01:18:34] provide the [01:18:35] parameters for this program [01:18:38] of [01:18:40] for the time being let us not understand [01:18:43] why those parameters [01:18:44] are given. Our focus is basically [01:18:46] when this program is running [01:18:48] what is that we are going to [01:18:50] see. [01:18:52] So the hyphen u option [01:18:54] basically it enables [01:18:56] unbuffered standard output [01:18:58] and standard error [01:19:00] helping progress messages appear [01:19:03] promptly. [01:19:04] So that is what it is. [01:19:06] So the name of [01:19:08] The program is pow underscore blockchain dot py. [01:19:16] Along with this, I need to give the difficulty level for this chain, [01:19:22] which is, let me give it a six. [01:19:25] How many workers? [01:19:30] Let me give it as two workers. [01:19:34] And how many blocks to mine? [01:19:36] Three blocks to mine. [01:19:38] So this is what we will be anticipating. [01:19:46] What is happening with this is, okay, the workers W is missing, I believe. [01:19:53] Let me add it. [01:19:58] Workers 2 and the blocks 3. [01:20:00] Now in the next one, let me go and display the top. [01:20:05] So this top is basically is giving us information about the process identifier, the user which it is running the process, utilization, both CPU and memory in terms of actual number and percentage. [01:20:28] On the other hand, I've not started executing it. [01:20:34] What I'm going to do that is, I'm just going to execute this. [01:20:40] The moment I execute, you should be able to see there is a jump in realization [01:20:46] and you should also be able to see what is happening. [01:20:52] Okay. [01:20:53] Then difficulty sex workers too. [01:21:03] What is wrong? Where am I? I do have an ls minus l. Who am I? I am root. Cool. Let me [01:22:06] do one thing let me just remove this file let me create the program again probably something [01:22:15] is missing I don't know okay let me copy the code again hopefully it works control x yes [01:22:42] okay fair enough now let me go ahead and execute let me have a different level [01:22:55] if I turn three okay difficulty let me make it six workers let me make it two and blocks let [01:23:05] you get as three okay so yeah it works now i'm not sure i need to check the code so if you look [01:23:14] at it it is mining the block one with two workers in the meantime if you look at the top you should [01:23:22] be able to see that the root user the process here if you look at it 37030 [01:23:30] 37036 [01:23:32] 37037 [01:23:34] 36922 [01:23:35] so [01:23:37] nouns is [01:23:39] 3778248 that's a random number [01:23:42] and this is the [01:23:44] hash [01:23:45] winning worker attempts [01:23:47] winning worker elapsed time [01:23:50] it took almost like 10 seconds [01:23:52] wall clock [01:23:54] mining time is almost 10.5 [01:23:57] seconds [01:23:57] now if you start [01:24:00] looking at the highest utilization in terms of percentage 99 percentage and if you look at [01:24:08] the actual memory utilization here the cpu and if you look at the memory free is only 987 [01:24:17] utilized used is 706 there is a buffer cache and swap is not being used [01:24:27] the swap is [01:24:29] anyhow is of no utilization [01:24:31] the difficulty [01:24:33] level 6 basically it will [01:24:35] go so many rounds now it has [01:24:37] come out so [01:24:39] basically blockchain validation [01:24:41] is false [01:24:43] blocks in the chain is [01:24:45] 4 why there are 4 [01:24:46] this is the genesis block [01:24:49] which is already existing [01:24:50] now it is mining 3 more blocks [01:24:53] so 1 plus 3 is [01:24:55] 4 [01:24:55] So now if you look at process ID, it has actually released the memory, the CPU utilization and the memory. [01:25:10] Now the percentage of CPU utilization is only very minimal, 1%, 1.3%, but that too not related to our blockchain process ID. [01:25:23] so whenever it is mining [01:25:26] where did we see the highest utilization [01:25:28] whenever this [01:25:30] mining happens it is [01:25:32] but the [01:25:34] moment it has treated [01:25:36] the mining [01:25:37] this particular process [01:25:40] ID was on top initially [01:25:42] and then when the [01:25:44] second mining was going on the process [01:25:46] ID has changed [01:25:47] we were able to see [01:25:49] 37032, 37036 [01:25:53] The process ID also has changed. [01:25:55] That means it was creating different system calls [01:26:00] that was creating different processes, [01:26:03] which was using the CPU. [01:26:08] Now, since each of the mining process itself [01:26:10] was using almost like 99% of the CPU, [01:26:14] how many CPUs I have? [01:26:15] I have only two cores. [01:26:19] Now, if you look at the load average also, [01:26:21] So it is coming down. [01:26:23] At that point of time, it was 0.76. [01:26:28] Now this is completed. [01:26:31] The loading average, sorry, the load average, [01:26:33] if you look at it, it is coming down. [01:26:36] It was, at peak, it was 0.99. [01:26:39] Now it is at 0.41. [01:26:41] Now it is reducing. [01:26:43] It will get stabled at around 0.3, 0.35. [01:26:47] Because so many processes are still running. [01:26:49] So it will, the load average will stabilize down around that. [01:26:54] thing. But when the second [01:26:57] mining block, [01:26:59] second block being mined, [01:27:03] immediately [01:27:03] we saw the process ID changed [01:27:05] from 37030. [01:27:08] Initially, [01:27:09] I just asked for [01:27:10] the main process ID to come [01:27:13] to display here. [01:27:15] And the sub process ID is [01:27:17] 37031, 37032 [01:27:19] and another one was [01:27:21] 37036. [01:27:22] We were able to see that sequentially here, coming here sequentially, because that was [01:27:30] the only CPU capacity that we had. [01:27:36] Now if I reduce the difficulty level, if I use lesser number of workers to mine lesser [01:27:47] number of blocks, you'll be able to see difference in the behavior of the CPU utilization. [01:27:55] So now earlier, and this block and this mining activity will be continuous in any system. [01:28:05] Let me not give a higher difficulty. [01:28:08] Let me make it as four. [01:28:10] Let me not use two workers. [01:28:12] Let me make it as one worker and let it mine only two blocks. [01:28:19] So now if you look at it, it's perfect. [01:28:22] It is so fast. [01:28:23] because the initial mining it took time [01:28:27] now the genesis is directly available [01:28:29] only one worker [01:28:32] so that was the only worker which was mining [01:28:37] so it mined and it created the block and it closed [01:28:39] and the difficulty level also is 4 [01:28:43] now let me keep the difficulty level as 4 [01:28:46] and let me make 3 workers [01:28:50] and let us mine 4 blocks [01:28:56] but let me make it as [01:28:58] 6 blocks. Difficulty [01:29:00] level is 4, that means 4 [01:29:02] 0s will be prefixed to the [01:29:04] hash. That's what it means. [01:29:08] Now also you can see multiple workers [01:29:10] minor 1, [01:29:12] winner is the minor 1, [01:29:14] here also winner is minor 1, here [01:29:16] minor 0 is the winner, [01:29:18] here minor 2 is the winner, because [01:29:20] we had 3 workers. [01:29:24] So now [01:29:25] with 3 workers, it was mining [01:29:27] you can see that the wall clock it is only 0.1575 seconds now what if if i make the difficulty level [01:29:37] as eight let me clip the workers on the blocks six so if you look at it blocks in the chain [01:29:48] is 7. 6 plus [01:29:49] 1, the Genesis [01:29:51] block itself. [01:29:53] Now let me add, let [01:29:56] me say mine 4 [01:29:57] blocks, but the difficulty [01:29:59] level is 8. [01:30:02] Oops. [01:30:04] It is [01:30:04] okay, between 1 and 6. [01:30:10] That is [01:30:11] the check it [01:30:13] does. Why it [01:30:15] is giving difficulty level 8 [01:30:17] is not possible. [01:30:19] Let me open the ring. [01:30:23] And here if I go to the ring, [01:30:27] there is an if condition [01:30:30] which is actually checking [01:30:33] whether it is between 1 and 6. [01:30:41] Yeah, here it is. [01:30:43] If not, lesser than or equal to 1 [01:30:46] and lesser than or equal to 6. [01:30:49] difficulty must be between 1 and 6 only [01:30:52] workers must be at least 1 [01:30:55] you can't say 0 workers [01:30:57] it has to be minimum 1 [01:30:58] that is what the code is checking [01:31:00] that's the reason I'm not able to [01:31:02] add more difficulty [01:31:04] if I add [01:31:04] if I change the condition here [01:31:07] then it will allow me to [01:31:09] have the difficulty 8 [01:31:11] now let me make [01:31:13] the difficulty 6 [01:31:15] workers [01:31:17] 1 [01:31:18] let me have the workers 2 [01:31:20] let me make this [01:31:23] block as 8 [01:31:24] now you can see [01:31:27] there are 2 workers mining it [01:31:29] mining the block [01:31:31] 1 with 2 workers [01:31:32] since we did not get [01:31:34] the winner [01:31:36] you can see 37 [01:31:38] 140 [01:31:40] and 37137 is the [01:31:43] main process ID [01:31:44] you can see 37140 [01:31:46] 141 [01:31:48] Utilization of the CPU is almost 98%. [01:31:51] These two are the two workers working with one block. [01:31:56] Since there are no more resources, [01:31:59] it is not mining other blocks. [01:32:03] Once this mining is completed, [01:32:06] once this utilization is released, [01:32:10] then you will have both the workers mining for the next block. [01:32:15] We have chosen four blocks. [01:32:17] So, it has to complete all the four blocks before closing the program. [01:32:25] So, currently, you can see there are six users. [01:32:28] When it was idle, we were seeing it as only four users. [01:32:32] Now, two more processors. [01:32:35] Now, if you look at the load average, load average is at peak, it was 1.38. [01:32:42] Average is 0.57. [01:32:44] Minimum is 0.34. [01:32:46] Till the CPU. [01:32:47] Memory is not being utilized because mining is a CPU intensive process. [01:32:56] So now you can see, you can see that the process ID has changed 145, 146. [01:33:03] Now, second block also is completed. [01:33:06] You can see 148, 149, which is consuming a similar CPU. [01:33:11] once that is completed you'll be seeing another process that is coming up for the fourth block [01:33:18] once all are completed once these processes are clearing it off once the program comes out [01:33:25] you will see the load average coming back to the normal what is the general load average [01:33:32] we would not like to see more than one more than one is nothing but 100 but you can see [01:33:40] the load is at 2.01 at peak now average itself is 0.90 now you don't have any zombie process [01:33:50] that is good but there are only three processes that are currently running [01:33:55] and all the three process if you look at it is related to this mining only [01:34:01] 3 7 1 5 2 1 5 1 3 6 9 double 2 and that itself is 99 percent is one cpu 98 percent is the another core [01:34:13] and i have two cores with me both the cores are occupied now i'll wait until this is completed [01:34:23] once it is completed you should be able to see the processes going out and the cpu utilization [01:34:31] Now assume that I'm the developer [01:34:34] who has developed this code. [01:34:37] We don't want our code to be performing like this. [01:34:41] Actually, this should have come out [01:34:43] in my performance testing itself. [01:34:47] Now I want to cap the CPU utilization. [01:34:51] On the other hand, [01:34:52] I don't want to take more time for mining also. [01:34:57] So now I have three options. [01:35:00] One is that optimizing this not to use. [01:35:05] Now you see 7% CPU have become 99 immediately. [01:35:10] Now it's a new process ID. [01:35:12] That means the new block. [01:35:16] So block 1 is, now you will see. [01:35:21] Block 4, so block 5 will come. [01:35:27] If I am the developer, [01:35:28] if I need to ensure that both [01:35:33] because if I'm going to take more time [01:35:39] for every block mining [01:35:42] then my end customer is not going to be happy [01:35:45] if I'm not [01:35:47] if I'm consuming all the resources [01:35:50] and if that is the reason for my delay [01:35:53] my performance [01:35:55] then I should [01:35:57] either try to increase the number of cores in the CPU [01:36:02] or I should limit [01:36:06] the program to use. Because if I can [01:36:11] process all the six blocks, eight blocks, whatever I'm [01:36:17] mining, parallelly, here if I'm [01:36:21] doing it parallelly, it is doing sequentially [01:36:25] only because the resource is not available and also I will be able to achieve a speedier response [01:36:34] back to the customer. If this is how the blocks are going to get added, then definitely the end [01:36:41] customer would come back. So this is something which needs to be caught in the unit testing [01:36:48] itself. The performance what I am observing now is part of my unit testing. I have not given any [01:36:57] performance parameters as a performance testing i'm not restricting anything in my code now that [01:37:05] i know this type of mining this type of difficulty levels is going to consume so many [01:37:14] then definitely yeah there were eight blocks which we have requested [01:37:19] So one block addition, it does like this within milliseconds. [01:37:25] Two blocks additions, what if there are like 3,000 blocks to be added? [01:37:32] It can happen, right? [01:37:33] A Bombay Stock Exchange can send you data. [01:37:37] 3,000 transactions in a second. [01:37:40] It is pretty much possible. [01:37:43] Every second, if it is sending 300 records, 3,000 records, [01:37:47] that means you are expected to create [01:37:50] 300 blocks and 3000 blocks [01:37:51] if this is what is the performance [01:37:53] that it is going to make [01:37:55] then [01:37:57] what is the analyst which is going to [01:38:02] see on the other hand [01:38:03] because they are going to make a decision with the [01:38:06] current trend [01:38:07] if data is going to get delayed by [01:38:10] 3 seconds, 10 seconds [01:38:12] like this [01:38:13] this has actually taken more [01:38:15] it's 30 seconds it has taken [01:38:17] one block has taken 66 seconds but in between one block it completed in 1.9 seconds [01:38:24] so this is the performance that it is going to make then the analyst who is seeing the trend [01:38:31] will actually miss the trend and make a wrong decision either to buy or sell so basically the [01:38:41] system, which has been designed for the decision making, will not happen. I made this particular [01:38:49] case purposefully 30 seconds and 50 seconds. In the code, you'll be able to see that. [01:38:56] Especially when you're giving higher difficulty and higher number of blocks, [01:39:01] some blocks will be slowed down. If you just go through the entire code, you'll be able to [01:39:07] understand why is it happening. Just to ensure that we are able to see the performance on the [01:39:15] screen. So now what is the normal behavior? We have seen the load average up to 2.01. That's [01:39:23] the maximum. The maximum itself is 0.31. Average is 0.95. This will come down as time passes [01:39:32] because this is the average. [01:39:34] This is the minimum. [01:39:36] Now this is the current. [01:39:39] Current is 0.32. [01:39:41] Where is 2.01 and where is 0.32? [01:39:44] It also is coming down. [01:39:45] Now if you look at the percentage utilization, [01:39:47] the top which is utilizing is only 1.3%. [01:39:51] Or 1.3% of the CPU. [01:39:55] 1% of the CPU. [01:39:56] 0.7%. [01:39:57] Together itself, [01:40:00] if you look at the CPU percentage, [01:40:03] nothing. [01:40:04] it's nothing actually it is 0.7 which is the current process now it is 0.8 [01:40:12] so suddenly it goes to 99 so that should not be our program should [01:40:18] this is what exactly the quality team will be looking at when they are looking at two type [01:40:29] of testing. One is the performance testing. They will see [01:40:32] is the utilization appropriate? Is the resources [01:40:37] planned as appropriate? Do we need to optimize [01:40:41] the code or do we need to add resources? That type [01:40:45] of calls will be taken from this type of testing. Apart from [01:40:49] these parameters, there will be some performance [01:40:53] parameters supplied by the quality engineers which [01:40:57] we are not going to focus on. [01:40:59] Basically, they will look at the performance [01:41:01] and they will take a decision whether to have [01:41:03] the infrastructure architect to modify the environment [01:41:08] or the developer optimizing the code. [01:41:12] Generally, the option would be to exercise both. [01:41:17] The call would be made to both [01:41:21] by giving the performance report. [01:41:24] And the optimization will happen automatically. [01:41:27] The second option is, blindly increase the infrastructure by auto-scaling, if you have the ability to auto-scale. [01:41:42] If this solution is in the cloud, yes, you have. [01:41:45] So at least, when you know that your program is going to be highly CPU sensitive, then definitely you will opt for a vertical scaling in the cloud, and you will vertical scale only CPU for that moment so that the customer is not impacted. [01:42:08] But in the background, obviously you will get a report saying that we were using 12 cores of CPU, now we have increased it to 24. [01:42:19] That report will come to you and you will see like which part of the program is consuming more cores of CPUs and then you will start addressing that issue. [01:42:30] Either you address it before it goes to the production. [01:42:34] That's the best practice. [01:42:35] and monitor using the production [01:42:38] but as a precaution [01:42:39] enable the autoscaling [01:42:41] which indirectly will increase [01:42:44] the cost of operations. [01:42:46] Because the more resources you are going to use [01:42:47] the more cost the cloud service [01:42:50] provider is going to bill you. [01:42:54] But in a [01:42:56] production environment, both would [01:42:58] be included. [01:43:01] Business won't mind [01:43:02] adding some more cost [01:43:03] for the initial operations once [01:43:06] the code is deployed into the production [01:43:09] but can be optimized a little later [01:43:13] to reduce the cost of a resource utilization. [01:43:17] And they will also try to fix the code [01:43:19] even before it goes to the production [01:43:21] in terms of the performance testing. [01:43:25] In extended way, they will do the security testing [01:43:27] to ensure that the code is not exposed [01:43:30] because the technology that it is implementing, [01:43:33] my code which is implementing, [01:43:35] which needs to be secured enough. [01:43:37] So performance testing, level 1. [01:43:40] Level 0 is functional testing. [01:43:41] Level 1 is performance testing. [01:43:44] And level 2 is security testing. [01:43:47] All the three has to be qualified for the code to go into the production. [01:43:53] With all these things, pre-unit 0, pre-testing level 0, [01:44:00] there should be a unit testing before even it comes to the quality team. [01:44:06] So what I performed now is a unit test. [01:44:09] And if I myself know that my code is going to slice this much, spike this much resources, then I'm supposed to look back into the code and see what optimization I can do. [01:44:24] So this is how I've just taken the blockchain as an example to see how it makes the system calls, how the processes are created, how each worker has its own processes. [01:44:39] and then further it will go ahead and access the resources using the same [01:44:46] architecture that we saw but what we observed is only from the utilization perspective [01:44:52] it's very clear that our code is spiking at times which is not a expected behavior [01:45:05] so i'd like to pass here and check there are any queries questions let me stop sharing so [01:45:11] so that I can look at the chats and other things. [01:45:19] Yes, Satendra, I should have done it, [01:45:22] but I thought I'll repaste the code issues. [01:45:30] Anything else from anyone? [01:45:39] I could see how many minimum nodes are required [01:45:44] in blockchain process. [01:45:45] There are no minimum that is required, [01:45:50] but I see there is a response down [01:45:53] depending on the degree of decentralization [01:45:56] you want for security. [01:45:57] That's right. [01:45:58] the more nodes the more secure it is here makes it centralized so if you're going to have [01:46:05] three or four nodes that's not is this blockchain topic that's the level so definitely not aditya [01:46:15] but as i spent that 10 extra minutes [01:46:19] they can't serve just taking examples to showcase processes and cpu and ram utilization that's right [01:46:26] okay cool in either query sashes for integrity that is right these days okay that we have [01:46:37] addressed any queries any questions please raise your hand how many distributed servers [01:46:47] your code is calling to validate blockchain as of now it is a single server the only one node [01:46:58] that i have to be uploaded uh see it's partially uploaded and it's delayed from my end i'll [01:47:07] complete it for by tomorrow and your quiz one as well as assignment should open up soon by monday [01:47:18] or tuesday it should be anything else vijay that is a blockchain topic proof of work and proof of [01:47:37] take we will definitely spend some time we get some time a theory session i'll explain because [01:47:54] this lab is only two hours so we are limited with two okay cool i don't see any placed hands [01:48:09] if there are no queries then we are good close this session i will upload the content yeah [01:48:18] tomorrow is a little busy day i have applause sessions after the sessions i will upload the [01:48:25] quiz as well as the material by tomorrow itself thank you very much guys take care bye