<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Saiteja on Medium]]></title>
        <description><![CDATA[Stories by Saiteja on Medium]]></description>
        <link>https://medium.com/@tejargukt123?source=rss-116747073b07------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*jyA2-ObAcw0op91M</url>
            <title>Stories by Saiteja on Medium</title>
            <link>https://medium.com/@tejargukt123?source=rss-116747073b07------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 16:06:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tejargukt123/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Does IBC scale for Sovereign rollups?]]></title>
            <link>https://medium.com/vitwit/does-ibc-scale-for-sovereign-rollups-c3d01e43d375?source=rss-116747073b07------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3d01e43d375</guid>
            <category><![CDATA[zkrollup]]></category>
            <category><![CDATA[optimistic-rollup]]></category>
            <category><![CDATA[modular-blockchain]]></category>
            <category><![CDATA[rollup]]></category>
            <category><![CDATA[blockchain-technology]]></category>
            <dc:creator><![CDATA[Saiteja]]></dc:creator>
            <pubDate>Mon, 18 Mar 2024 10:59:48 GMT</pubDate>
            <atom:updated>2024-03-19T05:51:23.122Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*q_nUy5_kPxGOIjBrQvAWiA.jpeg" /></figure><p>Inter Blockchain Communication (IBC) is the most popular trust-minimized cross-chain bridging protocol, used by over 110 chains and facilitating over $72B in annual transfers so far (<a href="https://mapofzones.com/home?columnKey=ibcVolume&amp;period=30d">reference</a>).</p><p>While other bridging solutions may have well-defined decentralized protocols, they still require users to trust the third-party protocol, which increases trust assumptions.</p><p>If I’m making a transaction from chain A to chain B, I should only trust that chains A and B are working fine. Why do I have to depend on some other third party, no matter how good it is? That’s the core principle of IBC: trust the chains, not the bridge.</p><p>IBC achieves this by making cross-chain functionality native with the help of light clients. Refer this <a href="https://medium.com/@tejargukt123/security-of-ibc-from-first-principals-08b196b8a6d5">blog</a> for more details on IBC but in brief, this is how it works :-</p><ul><li>Chain A keeps a light client of Chain B in its state, and vice versa.</li><li>Chains don’t have any idea whose client they are maintaining (chains agnostic) until a connection handshake process is initiated, which connects two chains by performing double authentication.</li><li>Chains themselves don’t communicate with each other directly. If they want to communicate with other chains, they will commit some predefined message in their own chains.</li><li>Relayers listen to these commits as events and pass them to the receiver chains in the form of transactions.</li><li>The receiver chains can verify these transactions against the light client and process them.</li></ul><p><strong>Trust Assumptions:</strong></p><ul><li>While relayers act as the main transport layer, the chains don’t need to trust them; they can’t affect security. As for liveliness, one honest relayer is enough. That’s a weak trust assumption.</li><li>Light clients only verify the consensus of the chains, not the actual state transitions. As long as the light clients can guarantee certain properties, IBC tends to function properly. That would be a weak trust assumption for highly secured chains and a strong trust assumption for weakly secured chains.</li><li>Two chains can have multiple clients of each other and multiple connections between them. The receiver chain treats assets from one channel differently from another channel, even though they are from the same chain.</li><li>One interesting thing to consider is that the receiver chain doesn’t have to verify the security of sender chains as long as their light client is functional. It is not responsible for the state frauds of the counter party. From its perspective, all assets received via IBC are the same (since they all pay fees). They can’t disrupt other assets, as the only way for them to revert to the original asset is by traveling via the route it came from.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*UoQm0j3DCNLbhwmfET03cQ.png" /><figcaption>Source: supermeme.ai</figcaption></figure><p>So to speak, for monolithic chains (eg: Cosmos-hub with tendermint consensus) which have strong consensus, ibc light client architecture works like magic in a trust-minimized way. But what about the rollups, the systems which don’t have the consensus themselves but inherits the security from other L1s like DAs and settlement layers?</p><p>Let’s consider some rollup architectures and see if they can scale for ibc.</p><p><strong>Zk rollups and Optimistic rollups with Settlement layers :-</strong></p><p>With the Settlement layer like Ethereum finalizing rollup blocks, it is fairly simple to integrate IBC as long as the said Settlement layer have a working light client implementation.</p><p>Dymension is another example (in fact Dymension might be the most complete case study for IBC + rollups for now). Refer to their <a href="https://docs.dymension.xyz/learn/dymension/bridging/ibc">official docs</a> to see how Dymension leverages ibc.</p><p>In simple terms, a light client of rollup (for packet inclusion proof) with conditional clients, DA consensus light client (for Data availability guarantee) and Settlement layer consensus light client (consensus guarantee) are enough to form a trust-minimized IBC bridge.</p><p><strong>Sovereign Rollups :-</strong></p><p>Having a settlement layer makes it easy to integrate IBC for rollups. However, having it affects the sovereignty of rollups.</p><p>Removing a settlement layer for rollups might completely change how one can look at rollups. Traditional rollups are like a scaling extension of L1 chains. But sovereign rollups are different. They are completely independent networks that rent the consensus from DA layers. The source of trust lies in the network itself, not on the settlement layer.</p><p>Let’s discuss the trade-offs involved in integrating IBC for sovereign rollups, the rollups in which end-users can verify the state without relying on any L1 (settlement layer).</p><p><strong>Rollkit’s Pessimistic Rollups :-</strong></p><p>Pessimistic architecture is the simplest of the rollup architectures. A centralized sequencer executes the transactions and updates the state machine. It publishes the transactions data to the configured DA layer so that anybody can download the data in a trust-minimized way and have guaranteed ordering. The verifiers can then execute the transactions and can verify the correctness by checking their state root against the sequencer’s state root.</p><p>Things to take note of in pessimistic architecture :-</p><ul><li>Only full nodes can verify the correctness of the state machine.</li><li>This architecture doesn’t have byzantine tolerance (atleast current design). It’s unclear how honest full nodes can come to a consensus to elect a new sequencer without relying on settlement layer. (ofcourse considering settlement layer is also impossible since it can’t afford to run full nodes in its state machine).</li></ul><p>Until the above limitations are not resolved, IBC needs to have some strong trust assumptions to work. A light client of rollup can guarantee double signing resistance, and a conditional light client of DA can guarantee data availability. But since rollup itself doesn’t have any consensus, that makes it a strong trust assumption towards validity of state transition.</p><p>One guarantee is that, in byzantine case, the relayers (running full nodes) should stop the relaying once it detects fraud state transition so that the client will be frozen. Relaying is costly (in rollup R to chain C IBC transfer, paying fees for receiver chain while they get compensated on a byzantine state machine is bad business), they should be sensible to enough realize the loss.</p><p>We can also try decreasing the light client’s trusting period, enforcing even more cost to maintain the light client. Then again, its still another strong trust assumption. One dishonest relayer is enough to keep the IBC connection lively thus continuing fraud state machine.</p><p>Though in the worst case, anyone can hard fork starting from the fraud block height, since the data is available on DA. Then think of how to recover funds that transferred after the invalid block.</p><p>So In conclusion, the current pessimistic architecture itself suffers from scaling (trust minimization requires running a full node), it might be hard to integrate IBC without some strong trust assumptions. So its better to consider more robust rollups like optimistic ones or zero knowledge ones.</p><p><strong>Optimistic Sovereign Rollups :-</strong></p><p>Optimistic Sovereign rollups reintroduces concept of light clients though with a twist. The light clients we have been hearing are the ones that achieves trust minimization by tracking consensus updates. They don’t have the capability to validate the state.</p><p>But this new light clients do! <br>These new lights are capable of validating the state transitions (invalid state transition to be more precise) even though themselves don’t maintain the complete state. Let call them state light clients for now to differentiate them from consensus light clients. This is not an official name by the way.</p><p>This architecture’s flow is pretty similar to that of the pessimistic rollups but the main difference is if one want to verify the correctness of the state, <br>they don’t need to run the costly full nodes, running the light weight state light clients is enough. <br>When a state light client receives a block, it initially assumes that block have valid state transitions. Hence the name, Optimistic.<br>But when some(any one honest) full node detect a fradulent state transition, it will construct the state fraud proof and pass it to their peer networks.</p><p>The state light nodes can then verify these fraud proofs and can decide if a fraudulent state transition really occurred or not. If proven, they can rollback to the latest trusted block height, halt itself and wait for recovery to take place.</p><p>Things to consider :-</p><ul><li>At least one honest full node is required for this architecture in trust-minimized way.</li><li>While running state light node is better than full node, the state light nodes don’t have instant finality unlike full nodes. That’s the reason why some window time period is installed. A block when received considered valid but not finalized. Only when some predefined time is passed and no valid fraud proof is submitted till then, it will be considered finalized.</li><li>Technically the state light nodes don’t have instant finality, but practically the block can be considered finalized. The probability of fraud occurring is very low since it is easily detectable and costly.</li></ul><p>Now that we have these state light clients to verify the state frauds, can we consider using them for IBC?<br>We definitely can! though it requires some considerations :-</p><ul><li>IBC requires instant finality which state light clients doesn’t have. We can solve this problem by introducing fraud proof window period.</li></ul><pre>// Overhead :- <br>full node &gt; state light client &gt; consensus light client (eg: tendermint light client)<br><br>// instant finality :-<br>full node &gt; consensus light client &gt; state light client<br><br>// security :-<br>full node &gt; state light client &gt; consensus light client</pre><ul><li>One concern about IBC is that running a normal consensus light client in state machine itself is being considered a bit of roadblock and not very optimal. Wouldn’t this more so in case of state light clients? Then again, this concern might be relevant only in fraud case, which has a low chance of occurring.</li><li>Implementation of state light client. The concept of state light client is great, but is it easy to implement? proving state transition without maintaining application state requires more than some simple inclusion merkle proofs. Especially considering all different merkle trees available like AVLs, SMTs, Patricia Merkle tree, etc. It might be hard to implement a generalized state light client.</li></ul><p>In conclusion, while there might be some challenges for integrating IBC with optimistic rollups, it is still possible to achieve a trust-minimized IBC bridge.</p><p>There is one more interesting way.<br>If there is an L1 chain which can act like a hub of rollups i.e.. running state light clients of rollups, then this can become source of trust for IBC. A consensus light client of this hub can become conditional client, like how a consensus light client of DA can be a conditional client. It removes the need of implementing a state light client directly into IBC.</p><p>This hub is just a source of trust for IBC, not for the rollup itself. So it doesn’t effect the sovereignity of the rollups. Think of it more like a service to rollup similar to how a DA guarantees Data availability.</p><p><strong>Sovereign ZK-Rollups</strong></p><p>Zk rollups are way more straightforward compared to previous architectures. The blocks need ZK proofs to become finalized. So a verifier can verify these ZK proofs and finalize the blocks instantly, without needing to have to run full nodes like in pessimistic rollups and have optimistic view like in Optimistic rollups.</p><p>Things to consider :-</p><ul><li>These are considered hardest to implement. A deep understanding of cryptography is essential which can be a hard road block for wide spread adaptation.</li><li>While ZK proofs provides instant finality, from the perspective of receiver chain, processing them on chain still introduces a lot of overhead. Considering there can 10s and 100s of rollups one chain can connect it to, it might not be practical to run all those verifiers on state.</li></ul><p>To tackle the second issue, the Avail Fusion of Avail Trinity talks about a unique solution: Proof Aggregation, to remove the necessity of running multiple verifiers for each ZK-rollup. Refer this <a href="https://blog.availproject.org/the-avail-vision-accelerating-the-unification-of-web3/">blog</a> for more details. To conclude, while challenging, it is possible to integrate IBC for ZK rollups in a trust-minimized way.</p><p>In summary, Sovereign Rollups represent the latest trend in achieving application-specific blockchains without the need to individually secure consensus security. <br>At the same time, IBC serves as the cutting-edge bridging protocol driving towards the ultimate endgame of blockchains: establishing a network of interconnected chains where each chain can communicate with every other chain anonymously and trust-minimally, without the need for a third party.</p><p>Therefore, understanding the various trade-offs involved in connecting these two innovations is very crucial.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*KPIJC5BrtjyfSnS2l4H8mg.jpeg" /><figcaption>source: google</figcaption></figure><p>Note: This blog reflects my personal opinions and understanding. If you believe there are omissions or inaccuracies, please don’t hesitate to provide feedback. Your input is greatly appreciated. Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3d01e43d375" width="1" height="1" alt=""><hr><p><a href="https://medium.com/vitwit/does-ibc-scale-for-sovereign-rollups-c3d01e43d375">Does IBC scale for Sovereign rollups?</a> was originally published in <a href="https://medium.com/vitwit">Vitwit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementation of Merkle Trees and Inclusion proofs]]></title>
            <link>https://medium.com/@tejargukt123/implementation-of-merkle-trees-and-inclusion-proofs-bb647daccc0b?source=rss-116747073b07------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb647daccc0b</guid>
            <category><![CDATA[merkle-tree]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Saiteja]]></dc:creator>
            <pubDate>Sat, 10 Feb 2024 17:05:27 GMT</pubDate>
            <atom:updated>2024-02-10T18:26:28.125Z</atom:updated>
            <content:encoded><![CDATA[<p>How blockchains store transactions data?<br>How are blockchains immutable?</p><p>The answer is Merkle Trees. Most people know that. But,</p><p>What are Merkle Trees?<br>Why Merkle Tress?<br>Merkle Trees do X and Y with Z% more efficiency. That’s great, but how?</p><p>Very rarely do we consider these questions. With the amount of abstractions these days, we don’t necessarily need to know these to build great systems. That’s even more applicable now with tools like ChatGPT, Bard, etc. But I personally believe knowing the underlying low-level stuff makes us way more aware and flexible.</p><p>So what exactly are Merkle Trees?</p><p>At the core, they are nothing but simple binary trees.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r8POSNy1PDrTvaT5e4uJCQ.png" /><figcaption>Example Merkle Tree</figcaption></figure><p>Assuming we have transactions t1, t2, t3 and want to build a Merkle tree for them. The above is how it looks like. <br>Please note that the last “dummy” is something I added to make the tree a complete binary tree. I made several tweaks here and there in my implementation because it is for my use case, which is to demonstrate a simple prototype of Merkle trees and inclusion proofs. So don’t be surprised if this is different from what you studied!</p><pre>   public MerkleTree(List&lt;String&gt; transactions, DigestUtils digestUtils) {<br>        this.transactions = transactions;<br>        this.digestUtils = digestUtils;<br>        transactions = Utils.extendTillPowerOf2(transactions, &quot;&quot;);<br>        buildMerkleTree(transactions);<br>    }<br><br>    void buildMerkleTree(List&lt;String&gt; transactions) {<br><br>        List&lt;MerkleNode&gt; nodes = MerkleNode.getLeafNodes(transactions, digestUtils);<br><br>        while (nodes.size() &gt; 1) {<br>            List&lt;MerkleNode&gt; newNodes = new ArrayList&lt;&gt;();<br>            for (int i = 0; i &lt; nodes.size(); i += 2) {<br>                newNodes.add(new MerkleNode(nodes.get(i), nodes.get(i + 1), digestUtils));<br>            }<br>            nodes = newNodes;<br>        }<br><br>        this.root = nodes.get(0);<br>    }</pre><p>This is the code to generate a Merkle Tree.</p><p>Unlike traditional binary trees that generate a tree from top to bottom, here we go from bottom to root, reducing the number of nodes by half at each level. So for a transaction list of N transactions, the total number of nodes would be 2*N, and that would be log(N) base 2, the number of levels (depth of the tree).</p><p>While this might seem like more space is being utilized in Merkle Trees compared to a normal array of transactions (2*N &gt; N), don’t forget these are simple hashes, which are fixed in size, unlike the actual transactions that can be complex structures and take up a lot of space.</p><pre>   public static List&lt;String&gt; extendTillPowerOf2(List&lt;String&gt; txs, String dummyData) {<br>        while (true) {<br>            int size = txs.size();<br>            if ((size &amp; (size - 1)) == 0)<br>                break;<br>            txs.add(dummyData);<br>            <br>        }<br>        return txs;<br>    }</pre><p>The above snippet is how I ensure my tree is complete by extending transaction data to be of a power-of-2 length.</p><p>Now that we have created our Merkle Tree, let’s see how we can use them for inclusion proofs.</p><p>Inclusion proofs are used to verify if a certain transaction is included or not. Assume that you have a commitment, a Merkle root of some transactions, which was provided by someone, maybe me. Now, you want to make sure if a certain transaction, which I claim to be included, is actually included or not. So I have to prove that I really included it.</p><p>Traditionally, how is this going to happen? <br>You will be provided with the actual list of transactions instead of the Merkle root, and you will traverse through the complete list to check if the queried transaction is included or not. That would have an O(N) complexity, which sounds not bad but is, in fact, very inefficient (just think of the number to be in terms of millions).</p><p>But with Merkle inclusion proofs, you can do it in Log(N) time complexity, which can be as low as 20 for a number of 1 million. <br>Let’s see how it works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*rT-YH5Rox_G2qFZDkKOsXw.png" /><figcaption>Example of required hashes for proof</figcaption></figure><p>An observation is that to generate an intermediate node hash, we don’t need all the nodes in its sub-tree but just the 2 child node hashes of it. Thinking of that, let’s see what we actually need to generate the root from the transactions.</p><p>For example, we are checking if Tx1 is included or not. We can get the hash of Tx1, h1=hash(Tx1) We have h1​, and now we need h2​ to generate their parent hash, which is h12. So let’s mark h2 as needed.</p><p>Now we have h12​, but need h34​ to generate their parent hash, which is h1234, the root itself. Let’s mark h34 as needed.</p><p>To generate the root from the querying transaction Tx1, we needed h2​ and h34​. Let’s take another example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8tonHIo_jEktahrsmMNBQg.png" /></figure><p>Assuming that we are checking if Tx1 is included or not<br>h1 = hash (Tx1)<br>We have h1 now and we need h2 to generate their parent hash, h12. So h2 is marked as needed.<br>We have h12 and need h34 now. So h34 is marked.<br>h1234 = hash(h12, h34)<br>We have h1234 and need h5678. so h5678 is marked.<br>h12345678 = hash(1234, 5678), That’s our root!</p><p>To generate root from transactions, we needed 3 hashes, h2, h34, h5678.</p><p>So when you query for a proof of a certain transaction, I will provide you with the necessary intermediate hashes. Then you can generate the root yourself and check it against the commitment (root hash) I shared earlier.</p><p>As mentioned before, for a dataset of 1 million transactions, I only need to provide at most 20 or some intermediate hashes. Then you can generate the root hash in just 20 or some computations, which is very fast compared to the traditional linear search.</p><p>Here are my code snippets:</p><pre>  public void createInclusionProof(Stack&lt;String&gt; trace, String txData) throws Exception {<br>        String txDataHash = digestUtils.getHash(txData);<br>        if (createProof(root, trace, txDataHash))<br>            return;<br>        throw new Exception(&quot;Transaction Not Found, can&#39;t create proof&quot;);<br>    }<br><br>    private boolean createProof(MerkleNode node, Stack&lt;String&gt; trace, String targetLeafHash) {<br>        if (node.hash.equals(targetLeafHash))<br>            return true;<br><br>        if (node.left == null)<br>            return false;<br><br>        trace.push(node.right.hash);<br>        if (createProof(node.left, trace, targetLeafHash))<br>            return true;<br>        trace.pop();<br><br>        trace.push(node.left.hash);<br>        if (createProof(node.right, trace, targetLeafHash))<br>            return true;<br>        trace.pop();<br><br>        return false;<br>    }</pre><p>The above code snippet is to generate a proof. It’s a simple depth-first search (DFS) with a trick of using a stack to store the sibling hashes. Remember, I have to provide the right node hash if the target transaction is in the left sub-tree.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FoVIXwQ7CgqZyyRqeJ6-GQ.png" /></figure><p>The below is the code snippet for verifying the proof from the given stack proof.</p><pre>public boolean validateInclusionProof(Stack&lt;String&gt; trace, String transactionData, String rootHash) {<br><br>        String currentHash = digestUtils.getHash(transactionData);<br><br>        while (!trace.isEmpty()) {<br>            String siblingHash = trace.pop();<br>            if (Utils.compare(currentHash, siblingHash))<br>                currentHash = digestUtils.getHash(currentHash + siblingHash);<br>            else<br>                currentHash = digestUtils.getHash(siblingHash + currentHash);<br><br>        }<br><br>        System.out.println(&quot;calculated Hash: &quot; + currentHash + &quot; &amp; &quot; + &quot;root hash: &quot; + rootHash);<br>        return currentHash.equals(rootHash);<br>    }</pre><p>This is how we will compute our own root hash from the provided proof and check it against the shared root hash.</p><p>Note: That if coniditon (if (Utils.compare(currentHash, siblingHash))) is added so that I can have Idempotency (Hash(h1, h2) == Hash(h2, h1), which may not be there in actual implementations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*93W4FCYsf8h1uUdSv06oYQ.png" /></figure><p>Here is the link to the repo</p><p><a href="https://github.com/Teja2045/Merkle-Tree-Implementation">https://github.com/Teja2045/Merkle-Tree-Implementation</a></p><p>By the way, this is just an example implementation to show how merkle trees and inclusion proofs works from my understanding. If you want more comprehensive and production level code, you should refer their official repos.</p><p>Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb647daccc0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Security vs Inflation (Cosmos PoS block chains)]]></title>
            <link>https://medium.com/@tejargukt123/security-vs-inflation-cosmos-pos-block-chains-0a141bb5dd12?source=rss-116747073b07------2</link>
            <guid isPermaLink="false">https://medium.com/p/0a141bb5dd12</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cosmos-hub]]></category>
            <category><![CDATA[inflation]]></category>
            <category><![CDATA[cosmos-sdk]]></category>
            <category><![CDATA[minting]]></category>
            <dc:creator><![CDATA[Saiteja]]></dc:creator>
            <pubDate>Fri, 02 Feb 2024 20:57:31 GMT</pubDate>
            <atom:updated>2024-02-04T19:03:10.405Z</atom:updated>
            <content:encoded><![CDATA[<p>Before going further, I want to mention something. Initially I didn’t intend this blog to be informative. I just found a situation which was very interesting and wanted to write about it. But It somehow turned out to be an educational one…</p><p>As we know, blockchains are inherently decentralized. Any software changes or upgrade decisions must undergo rigorous consensus before implementation. The Cosmos chains, specifically those built with the Cosmos SDK and CometBFT consensus engine, employ a similar consensus mechanism called Governance. In this system, someone proposes a change, and the stakers (Validators and Delegators) vote on it. If the proposal garners enough votes within the specified time, it is passed; otherwise, it is rejected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*V2W6pCg2jsPmpFouHVThmg.jpeg" /><figcaption>Source: Google</figcaption></figure><p>12 Nov 2023, A new proposal (#848) appeared on Cosmos Hub. I won’t mention the proposal’s description here but to summarize, the proposal suggests to decrease Max Inflation to 10% ( from the original 20%), Inflation rate to 10% (from 14%) and argues that Cosmos is overpaying for security by raising inflation rates to incentivize staking. This lead to huge discussions and arguments in the Cosmos community (Don’t mind the technical terms for now).</p><p>In the end, the proposal passed, albeit with a narrow margin. However, the controversy didn’t end there. Those opposed to the proposal, led by Jae Kwon, Cosmos Co-founder, were unsatisfied with the outcome. Their argument was that accepting the proposal would put Cosmos core security at risk. Eventually, they decided to fork — AtomOne! (still a work in progress, I believe).</p><p>Who is right, the Pro side? or the opposition?<br>Are the proposed changes good for the network? or will it effect the security of the chain as Jae Kwon side claimed?</p><p>Well, I am not sure, only time will tell.</p><p>Putting that aside, What I really want talk about is not about the proposal or determining who is right or wrong, but something else.</p><p>If you observe there are a lot of terms mentioned above like :- Security, Inflation, Inflation rate, etc. We know these terms in general but what exactly are they in terms of Cosmos and blockchains?</p><p>To know that, we have to get into an important Cosmos SDK module (application logic) which implements the mechanism to generate new tokens, the Mint module.</p><p>The Mint module mints new tokens based on Inflation, a term we were just talking about. Here, Inflation refers to the number of tokens generated per year in relation to the total token supply.<br>For Example: If a chain currently have 100 tokens, a 10% inflation means 10 new tokens will be minted over a period of an year.</p><p>Note: the minting of tokens happens on a per-block basis (you will know how), and the newly minted tokens incentivized to stakers based on their stake amount. Remember this point as it is crucial.</p><p>So how to determine the inflation percentage? It’s not like we can just hard code some random value without any justification, right?</p><p>Here is how the Comos SDK decides on the inflation (this is the default code, a customized function can be plugged in if needed)</p><pre>NextInflationRate(params Params, bondedRatio math.LegacyDec) (inflation math.LegacyDec) {<br>    inflationRateChangePerYear = (1 - bondedRatio/params.GoalBonded) * params.InflationRateChange<br>    inflationRateChange = inflationRateChangePerYear/blocksPerYr<br><br>    // increase the new annual inflation for this next block<br>    inflation += inflationRateChange<br>    if inflation &gt; params.InflationMax {<br>        inflation = params.InflationMax<br>    }<br>    if inflation &lt; params.InflationMin {<br>        inflation = params.InflationMin<br>    }<br><br>    return inflation<br>}</pre><p>Lets simplify this step by step</p><p>First the terms: bondedRatio and GoalBonded. These are the most important params when determining the inflation.</p><p>bonded Ratio = The Tokens staked / Total Supply (Overall Chain)</p><p>Goal Bonded = the ideal bonded ratio which the chain wants to achieve (It is 0.67 or 67% currently)</p><p>Why does the chain wants to have 67% percent of the tokens to be staked? In fact why do the tokens even need to be staked?</p><p>This is where the proof of stake’s magic lies. The more the tokens staked, the lesser the chance for any validator to manipulate the consensus. <br>Let take a naive example, assume that there currently some N number of validators whose combined stake is some X. Now a new validator V joined the consensus with the stake &gt; 2*X. That means he alone has a voting power of &gt; 66% (voting power is 1:1 with respect to staked tokens), thus controlling the whole chain.</p><p>To avoid that, the X has to be big enough (and of course not centralized to few validators) so that the chain can be secure. (tada, that’s security!)</p><p>But why this goal bonded have to be 67%? that I’m not sure. Do let me know in comments if there is any justification for this.</p><p>Now back to the inflation calculation.</p><pre>inflationRateChangePerYear = (1 - bondedRatio/params.GoalBonded) * params.InflationRateChange</pre><p>Params.InflationRateChange is a contant which refers to the maximum change to the inflation (currently 14%).<br>Note: Not considering the 14% to 10% change from the proposal</p><p>For bondedRatio / oalBonded, there are 3 possible cases :-</p><ul><li>bondedRatio = GoalBonded, the ideal state where staked amount is exactly what the chain wants. That means inflationRateChangePerYear = 0, i.e.. the current inflation is ideal and no change is required.</li><li>bondedRatio &gt; GoalBonded, that means people are staking a lot more than expected. Well, that’s a problem. If every body just stakes, who is going to do transactions and keep the trading volume (chain activity)up? That means the chain needs to discourage staking. How is it going to do that? Well, just decrease the inflation, which results in people getting lesser rewards, thus leading them to unStake. <br>with bondedRatio &gt; GoalBonded =&gt; 1 — bondedRatio / GoalBonded will be negative =&gt; inflationRateChangePerYear will be negative.</li><li>bondedRatio &lt; GoalBonded, that means people are not staking enough. How to encourage them to stake? Increase the rewards i.e increasing the inflation.<br>1 — bondedRatio / GoalBonded will be positive =&gt; inflationRateChangePerYear will be positive</li></ul><pre>inflationRateChange = inflationRateChangePerYear/blocksPerYr</pre><p>inflationRateChangePerYear is a dynamic metric for whole year. But since the minting happens per block, we need to calculate the the inflation change for that block.</p><pre>// increase the new annual inflation for this next block<br>    inflation += inflationRateChange</pre><p>Now the calculated change will be added to the inflation. One thing to note is that inflation is global variable thus the changes will be persisted from block to block.</p><pre>    if inflation &gt; params.InflationMax {<br>        inflation = params.InflationMax<br>     }<br>    if inflation &lt; params.InflationMin {<br>        inflation = params.InflationMin<br>    }</pre><p>And finally fixing the range for inflation. inflation being dynamically generated is good and all. But what if there is a case like, people not staking despite giving more and more rewards (inflation up), then inflation will keep on increasing without restraints. That’s why there is a need for max and min caps.</p><p>By default (again, not considering the above mentioned proposal)<br>InflationMax = 20%<br>InflactionMin = 7%</p><p>So this how Cosmos chains leverages dynamic inflation mechanism to incentivize stakers thus maintaining the balance among security, liquidity and trading activity.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0a141bb5dd12" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From one of the worst students of the batch to First ever to become Guardian (Leetcode) in College…]]></title>
            <link>https://medium.com/@tejargukt123/from-one-of-the-worst-students-of-the-batch-to-first-ever-to-become-guardian-leetcode-in-college-f7402977005c?source=rss-116747073b07------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7402977005c</guid>
            <category><![CDATA[motivation]]></category>
            <category><![CDATA[student-life]]></category>
            <category><![CDATA[b-tech-college]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[btech]]></category>
            <dc:creator><![CDATA[Saiteja]]></dc:creator>
            <pubDate>Sat, 06 Jan 2024 12:36:53 GMT</pubDate>
            <atom:updated>2024-05-25T09:05:30.371Z</atom:updated>
            <content:encoded><![CDATA[<h3>From one of the worst students of the batch to First ever to become Guardian (Leetcode) in College History</h3><p>This is my journey — from being an ideal student to one of the worst of the batch, then went on becoming a good coder and and ultimately the first-ever to become Leetcode Guardian in College History. When I say one of the worst students of the batch, it wasn’t a metaphor; it was the actual truth.</p><p>My college, RGUKT Basar, while not at the level of IITs or NITs, is a great institute, especially for those who are underprivileged and from rural areas. With approximately 1500 new admissions every year, it houses almost 9000 students (2 years of PUC + 4 years of Btech) and produces hundreds of successful engineers annually.</p><p>I was part of the 2016 admission batch. The first two years of PUC were ideal, filled with friends, rivals, late-night strolls, parties, movie nights, and, despite not studying much, I maintained a GPA of 9.4+ in all four semesters, something I always take pride in.</p><p>With a CGPA of ~9.5, it wasn’t hard to get the desired branch. At that time, ECE and EEE were considered more popular than CSE. However, I decided to join CSE on a whim, a decision I still believe was one of the best I have ever made.</p><p>In 2018, I finally started my BTech first semester. Given the success of my PUC, it was almost guaranteed that my BTech would be smooth sailing. That’s what everyone — my parents, relatives, friends, basically everyone who knew me — believed. I mean, what could possibly go wrong?</p><p>The first semester passed quickly. My friends circle changed, new subjects were introduced, and the all-important Programming with C began. Coding basic stuff every day, conducting some syntax experiments — the semester went by swiftly, and in the end, I achieved a GPA of 8+, not great but still decent.</p><p>In December 2018, the second semester started, and this is when things started to go wrong.</p><p>For some reason, I suddenly lost all motivation. Little by little, I stopped going to classes, caring about assignments, internal exams, and academics. I distanced myself from friends who tried to talk to me. To escape from reality, I started reading web novels and got addicted to them. In the end, I was totally slumped.</p><p>A few months into the semester, with no surprise, I received a call from the academic section to visit the office. Panicked, I didn’t know what to reply. I wasn’t prepared for this at all. I lied and told them I wasn’t on the campus, and the call ended abruptly.</p><p>Just as I was thinking of what to do next, I got another call. Looking at the caller’s name, my heart skipped a beat; it was my dad!</p><p>I connected the dots to the previous call and knew something was off. With a chaotic mind, I hesitantly picked up the call. Indeed, my guess was right. The one who spoke to me wasn’t my dad but the academic section guy who spoke to me beforehand. He again asked me to come to the office. This time, I didn’t make any excuses and said okay.</p><p>Feeling a weight on my heart, I went to the academic section. Inside the office, I discovered my parents standing humbly before the academic section representative. My father was as usual, a bit carefree. He had always been a very optimistic guy. But my mom was different. She is a very sentimental person. It must have been a shock for her. I couldn’t see her face clearly, but I can guess she was heartbroken.</p><p>But the me from back then didn’t consider all this. At the moment, I was just ashamed and angry. I was selfishly thinking to myself, “how could they do this to me? To come to the campus without telling me and put me in this embarrassing situation, they don’t trust me.” Now that I think about it, how laughable were my thoughts back then.</p><p>The academic section guy looked at my previous grades and gave me a perplexed look. He must have been confused as well. My previous grades and my current actions don’t match at all. Then he went on reprimanding me a little and instructed me to attend the class regularly. But we both know it’s already too late to catch up. With the semester-end approaching, I had less than 40% attendance and no internal marks to add to that.</p><p>After that, my parents and I went out of the office. They didn’t say anything about why I am doing this or other stuff. Ever since I was little, I had always been the best at everything — academics, sports, arts, etc. To suddenly see me in this kind of pathetic position, even they might not have known how to react. After speaking to me a little, they went home, and I returned to the dorms. This little episode ended just like that.</p><p>Soon, the semester-end exams were announced, and as expected, I received a notice that I was ineligible to sit for the exams. I had no choice but to go home and wait for the next batch’s second semester to start before rejoining. It was six more months until the next batch’s second semester started. I had to stay at home doing nothing for the whole six months.</p><p>The bad phase didn’t end there; it had just started.</p><p>With what happened so far, I was ashamed and didn’t know how to face anyone anymore. I stopped going outside completely. To avoid interacting with anyone, I completely changed my sleeping routine — sleeping during the day and staying awake at night. This seriously affected my self-esteem and self-confidence.</p><p>This continued for the next six months. It’s not like I wasn’t conscious of the mistakes I was making, but I ignored them and thought I would change after rejoining. But who was I fooling? If we can’t address an issue at its inception, it becomes exponentially more challenging to do so later. It brings to mind the saying, “Nip it in the bud,” emphasizing the importance of addressing problems early on before they escalate.</p><p>Six months later, in December 2019, I took re-admission and rejoined with the next batch’s (2017) Btech second semester, thus officially starting my journey as one of the worst students of the batch…</p><p>To be continued…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7402977005c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>