<?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 Vijay Gaur on Medium]]></title>
        <description><![CDATA[Stories by Vijay Gaur on Medium]]></description>
        <link>https://medium.com/@vjgaur?source=rss-ee70eb692f33------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*iVOCuL2Y3mk0S0ti64JW1w.jpeg</url>
            <title>Stories by Vijay Gaur on Medium</title>
            <link>https://medium.com/@vjgaur?source=rss-ee70eb692f33------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 00:34:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vjgaur/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[Your Agent Isn’t Broken. Your Architecture Is.]]></title>
            <link>https://medium.com/@vjgaur/your-agent-isnt-broken-your-architecture-is-fb2f5538efb4?source=rss-ee70eb692f33------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb2f5538efb4</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Vijay Gaur]]></dc:creator>
            <pubDate>Wed, 26 Aug 2026 07:49:36 GMT</pubDate>
            <atom:updated>2026-08-26T07:49:36.288Z</atom:updated>
            <content:encoded><![CDATA[<p>Loop, graph, and harness: the three layers that decide whether an agent survives production.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CID-RlugPfVqsJyLZRKDWQ.png" /></figure><p>The demo always works.</p><p>You give the model a goal, a handful of tools, and a pep-talk system prompt. It searches, writes a plan, calls an API, and produces something that looks like progress. Then you put it on a schedule. Then you add a second agent. Then it spends your budget, overwrites a teammate’s files, emails a customer with a half-true summary, or merges a patch that “looks right” and fails in CI three hours later.</p><p>At that point people upgrade the model.</p><p>That is usually the wrong layer.</p><p>In 2026 the scarce skill is not prompting a smarter worker. It is building the system that assigns work, bounds tools, keeps state outside the context window, records every consequential step, and interrupts only when the action cannot be undone. The model is a noisy, talented contractor. The product is the shop floor around it.</p><p>This article is the shop-floor map.</p><h3><strong>The claim</strong></h3><p>An agent is not <strong>LLM + tools + a while loop</strong>.</p><p>That definition is how you get a demo.</p><p>Production systems have three nested layers, and each layer owns a different class of failure:</p><p><strong>The loop controls iteration.</strong><br>Retries, budgets, stop conditions, “are we actually done?”</p><p><strong>The graph controls structure.</strong><br>Who exists, what they own, how work splits, where it joins, which artifacts move across the edge.</p><p><strong>The harness controls exposure.</strong><br>Tools, credentials, sandboxes, traces, evals, humans.The loop runs inside a graph node.</p><p><strong>The graph runs inside a harness.</strong><br>The model sits inside the loop.When something breaks, debug the layer that owns the failure. Do not open the prompt first.</p><h3><strong>Layer 1 — Loop engineering</strong></h3><p>A loop is the local unit of agency: <strong>plan → tool → observe → update state → decide whether to continue</strong>.A good loop has five explicit controls:</p><ol><li><strong>A goal that can fail closed</strong>. “Improve the checkout flow” is not a goal. “Make test_checkout_tax.py pass without changing public API” is a goal.</li><li><strong>A budget.</strong> Max steps, max dollars, max minutes, max files touched. Infinite loops are not a personality trait. They are a missing limiter.</li><li><strong>A stop condition that is checked outside the model.</strong> The model will claim success. Tests, schemas, and diff stats should get a vote.</li><li><strong>An observation that is grounded.</strong> Tool output, test logs, and file hashes beat “I think it worked.”</li><li><strong>A persistence point every cycle.</strong> If the process dies, the next run should resume from disk, not from vibes.</li></ol><p><strong>This is why coding agents matured first.</strong></p><p>The world talks back: compiler, tests, diff, CI. Research and trading loops are the same shape with worse oracles. If you cannot name the oracle, you do not have a loop. You have a monologue with side effects.</p><p><strong>Loop failures look like this</strong></p><ul><li><strong>Fake progress:</strong> the agent rewrites the same function and calls it a refactor.</li><li><strong>Context saturation:</strong> the transcript becomes the state, then the state becomes sludge.</li><li><strong>Unrecoverable tool errors:</strong> one 500 and the run invents a workaround that mutates prod.</li><li><strong>Process porn:</strong> more markdown plans, fewer merged patches.</li></ul><p>The fix is almost never a longer system prompt. The fix is a cheaper, dumber gate after each act: <strong>did the artifact change in the allowed way, and do we still have budget?</strong></p><h3><strong>Layer 2 — Graph engineering</strong></h3><p>One good loop does not make a team.The moment you add a researcher, a coder, and a reviewer, you have created a coordination problem. That problem does not live inside any single model. I<strong>t lives in the graph: nodes, edges, state, and authority.</strong>Five patterns cover almost all production topologies:</p><ul><li>Sequential — A then B then C.</li><li>Parallel fan-out / fan-in — many workers, one merge.</li><li>Hierarchical — supervisor decomposes, workers execute.</li><li>Handoff — route to a specialist by task type.</li><li>Evaluate-and-loop — keep iterating until a quality gate passes.</li></ul><p>Pick the simplest graph that can express the dependency. Do not start with a swarm because swarms are fashionable.</p><p><strong>The real multi-agent bug: context decay:</strong></p><p>This is the production failure that listicles skip.Each handoff quietly drops constraints. Agent A was told “do not touch billing.” Agent B receives a summary that says “fix checkout.” Agent C receives a patch and a vibe. The last node solves a different problem than the first node started.Chat logs make this worse. They feel like memory. They are actually a lossy compression of intent.Put a contract on every edge. A handoff payload should be typed and boring:</p><ul><li>goal</li><li>non-goals / hard constraints</li><li>inputs (paths, ticket ids, URLs)</li><li>definition of done</li><li>allowed tools</li><li>artifacts expected back</li><li>owner of the next gate</li></ul><p>If it cannot fit that schema, it is not ready to leave the node.</p><p><strong>Give parallel workers isolation.</strong> Isolated worktrees, branches, or sandboxes. <strong>Two agents writing the same repo without isolation is not “multi-agent.” </strong>It is a race condition with extra tokens.</p><p><strong>Add a verifier that assumes the worker is wrong.</strong> The second agent’s job is not to be polite. It is to look for missing tests, constraint violations, and “looks done.” Verification is a node, not a hope.</p><p><strong>A graph also needs a system of record underneath it:</strong> tickets, files, run folders, commit SHAs. If the only picture of the work is a conversation, the graph is standing on weather.</p><h3>Layer 3 — Harness engineering</h3><p>The harness is the product.It is the runtime shell that decides what the model is allowed to see and touch: tool surface, permissions, filesystem, network, memory stores, traces, approvals, timeouts, retries, and kill switches.Think of it as the difference between hiring a contractor and handing them the master key, the corporate card, and no badge log.</p><p>A production harness does at least this:</p><ul><li><strong>Narrow tools. </strong>Idempotent, schema-checked, least privilege. “Shell as root” is not a tool. It is a wish.</li><li><strong>Sandbox.</strong> Generated code does not run on the host by default.</li><li><strong>Durable memory outside the window.</strong> Files, databases, artifact stores. <strong>AGENTS.md</strong> and run logs beat a 200k-token souvenir.</li><li><strong>One trace across the whole trajectory.</strong> Model steps, retrieval, tool calls, cost, latency, the decision to act.</li><li><strong>Evals, not just traces.</strong> A flight recorder without pass/fail is how you ship silent breakage.</li><li><strong>Human control as policy.</strong> Interrupt by action class, not by anxiety.</li></ul><p>This is why “agent engineering” became a phrase. The quality of the system is dominated by planning, memory, and authority, the parts a minimal <strong>LLM + tools + loop </strong>definition trains you to forget.</p><h3>Autonomy is a permission table</h3><p>“Human in the loop” is not a strategy if every step needs a click. Reviewers stop reading. That is approval fatigue, and it is a design failure.</p><p>Route interruptions by risk and reversibility.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fjLe3m1UmCmtXLVST9M_Mw.png" /></figure><p>A practical split of the OODA loop, from people who have actually tried to go hands-off:</p><ul><li><strong>Observe — agent-assisted.</strong> Humans still pick what to watch.</li><li><strong>Orient — agent-assisted.</strong> Agents miss taste and the frame.</li><li><strong>Decide — human-led.</strong> Agents follow rubrics and miss the forest.</li><li><strong>Act — agent-led.</strong> Once the decision exists, execution is the easy part.</li></ul><p>Keep humans in Decide and in irreversible Act. Let agents live in Observe and reversible Act. If you invert that, you get either a chatbot with extra meetings or an intern with prod credentials.</p><h3>One worked system: a coding fleet you can operate</h3><p>Use coding as the first laboratory. The oracle is sharp. The same skeleton later ports to research, trading, and lab work.</p><p>Nodes:</p><ol><li><strong>Scheduler</strong> — cron, GitHub issue, failing CI. Discovers work. Does not write code.</li><li><strong>Worker</strong> — gets an isolated worktree and a typed task contract.</li><li><strong>Tools</strong> — read_file, patch, run_tests, search_repo. No unbound shell.</li><li><strong>Persistence</strong> — every cycle writes run.md, the patch, and test output to disk.</li><li><strong>Verifier</strong> — separate agent, separate prompt: assume the patch is wrong.</li><li><strong>Human gate</strong> — only on merge to main.</li><li><strong>Eval hook</strong> — store the trajectory; failing runs become fixtures.</li></ol><p>A single cycle:</p><pre>issue → contract<br>     → isolated worktree<br>     → loop(plan, patch, test) until budget or tests pass<br>     → persist artifacts<br>     → verifier<br>     → approve merge or reopen with the verifier’s objections<br>     → trace + score</pre><p>Notice what you did not build: a general assistant that “handles engineering.” You built a workload. Narrow goal. Named artifacts. Bounded tools. A second reader. A human only where git history gets expensive.</p><p>That is what “constrained autonomy” means in production. Not a smaller dream. A smaller blast radius.T</p><p>he same skeleton shows up in other labs:</p><ul><li><strong>Research</strong> — raw files in, code execution in the middle, inspectable intermediate docs out.</li><li><strong>Trading</strong> — paper loop first, live loop behind spend caps and an audit trail of why the position exists.</li><li><strong>Biology</strong> — design → instrument → measurements back into state. Throughput and data quality become the harness.</li></ul><p>Do not start there. Start where the oracle is cheap.</p><h3>Failure catalog</h3><p>Use this as a quick reference when something breaks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XRiy4ewmHcZxQzAHAyy2Gw.png" /><figcaption>Most “agent reliability” threads are this table with adjectives.</figcaption></figure><h4>This is not an argument against better models.</h4><p>Use the best worker you can afford.It is an argument against treating the worker as the architecture.It is also not an argument for multi-agent theater.</p><p>One observed loop with disk, tests, and a trace will beat a five-agent crew that shares a group chat. Add nodes when a single worker has a clean reason to specialize <strong>retrieval vs mutation vs review </strong>and only after the handoff contract exists.</p><p>Standards fit here as plumbing, not as the plot. MCP is how an agent reaches tools and data. A2A is how one agent delegates a task to another agent across runtimes. <strong>You need MCP first. You need A2A when you actually have independent agents with their own identities and tools</strong>, not when you want a slide that says “multi-agent.”</p><p>Enterprise uptake follows the same discipline: support routing, invoice fetch, contract review, on-call triage, codegen-in-a-repo. Narrow workflows with a named owner and a measurable outcome. Open-ended autonomy stays in the lab because irreversible actions are where architecture becomes liability.</p><h4>Build this weekend</h4><p>Do not start a platform. Start a workload.</p><ol><li>Pick one repo and one failing test or one well-specified issue.</li><li>Write the task contract in a file. Not in chat.</li><li>Give the worker four tools and a budget of N steps.</li><li>After every cycle, write artifacts to<strong> ./runs/&lt;id&gt;/.</strong></li><li>Add a verifier agent that only reads the diff and the test log.</li><li>Put a human approval on <strong>git merge.</strong></li><li>Log one trace per run. Promote the first failure into an eval case.</li></ol><p>If you do only that, you will feel the shift the founder circles keep repeating: you stopped prompting the agent. You built the system that prompts it, bounds it, records it, and wakes it up again tomorrow.</p><h3><strong>Resource appendix</strong></h3><p>Read these after the article, not instead of building.</p><p><strong>Mental models</strong></p><p>Anthropic, Building effective agents — the clean split between predefined workflows and agents that direct their own tool use.swyx, agent engineering / IMPACT — why “LLM + tools + loop” drops the parts that determine quality.<br>O’Reilly Radar, The AI Agents Stack (2026) — especially the eval vs observability gap.</p><p><strong>Implementation</strong><br>LangGraph docs on state, interrupts, and checkpointers.<br>Your coding-agent harness of choice (Claude Code, Codex, Cursor, OpenHands, or a thin custom loop). Study the isolation and permission model, not the landing page.</p><p><strong>Protocols, when you need them</strong><br>Model Context Protocol for tools.<br>Agent2Agent / Agentic AI Foundation for cross-runtime delegation.</p><p><strong>Ops</strong><br>LangSmith, Langfuse, or OpenTelemetry traces that include tool spans.<br>One regression suite of saved trajectories. If you cannot replay a bad run, you cannot improve the system.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb2f5538efb4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why RAG Is the Wrong Primitive for Agent Memory]]></title>
            <link>https://medium.com/@vjgaur/why-rag-is-the-wrong-primitive-for-agent-memory-2bc0f815b437?source=rss-ee70eb692f33------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bc0f815b437</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[agentic-rag]]></category>
            <category><![CDATA[llm-agent]]></category>
            <dc:creator><![CDATA[Vijay Gaur]]></dc:creator>
            <pubDate>Tue, 18 Aug 2026 11:19:39 GMT</pubDate>
            <atom:updated>2026-08-18T11:19:39.411Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KdmL7HxDe4uzvoF-0F0Epg.png" /></figure><p>Most agent memory systems are built on RAG. Recent research argues this is a structural mismatch, not a tuning problem.</p><p>RAG was designed for large, heterogeneous corpora. The main failure mode it defends against is irrelevance retrieving a passage that has nothing to do with the query.</p><p>Agent memory is the opposite shape. It is a bounded, coherent stream of one ongoing conversation. Candidate spans are highly correlated and often near-duplicates, because the same topics recur across sessions.</p><p>When you run fixed top-k similarity over a stream like that, the results collapse into a single dense region. You get twenty chunks that all say roughly the same thing. The retriever never separates what is needed from what is merely similar. Redundancy, not irrelevance, becomes the dominant failure mode. Top-k has no mechanism to notice this it ranks by similarity, and everything is similar.</p><p>The obvious fix is to prune or compress the retrieved context. This is where it gets interesting: the research found pruning makes it worse, not better.</p><p>Conversational evidence is temporally entangled through co-reference, ellipsis, and timeline dependencies. Facts depend on neighbouring turns to be interpretable at all. A pruning module designed under RAG assumptions scores relevance locally and ends up deleting prerequisites in an evidence chain rather than removing redundancy.</p><p>The measured effect: adding an established pruning module dropped accuracy below plain RAG (BLEU 26.55 vs 27.92, F1 34.58 vs 36.42) and needed more retrieved blocks to cover the same answer (13.31 vs 10.81). The pruner systematically shifted blocks from multi-hit to 1-hit. It was compressing away the answer while keeping text that looked topically relevant.</p><p>Their alternative reframes the problem. Don’t rank raw spans at all. Decompose the stream into a four-level hierarchy: raw messages → episodes (contiguous blocks, summarised) → semantics (reusable facts distilled from episodes) → themes (groups of related semantics). Retrieve top-down over that structure. Two spans in different components won’t get retrieved together even if their embeddings are nearly identical. Redundancy is killed by construction rather than by post-hoc filtering.</p><p>The second clever piece: expansion into finer-grained evidence is gated on uncertainty. The system only pulls episode-level or raw message detail when doing so actually reduces the reader’s uncertainty, and stops as soon as more detail stops helping. Not a fixed k. A stopping condition.</p><p>Result: 34.48 BLEU / 43.98 F1 versus 27.92 / 36.42 for naive RAG, while needing about half the blocks (5.66 vs 10.81) and about half the tokens.</p><p>The broader lesson holds even if you never touch this specific system: when you inherit an architecture, you inherit its assumptions about what failure looks like. RAG assumes your corpus is diverse and your risk is irrelevance. Agent memory is neither.</p><p>Worth checking what your retrieval stack is actually optimising for before you tune k again.</p><p>Paper: arxiv.org/abs/2602.02007</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bc0f815b437" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond the CAP Theorem: Designing Distributed Systems for the Real World]]></title>
            <link>https://medium.com/@vjgaur/beyond-the-cap-theorem-designing-distributed-systems-for-the-real-world-e97e3a141b39?source=rss-ee70eb692f33------2</link>
            <guid isPermaLink="false">https://medium.com/p/e97e3a141b39</guid>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[systems-thinking]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Vijay Gaur]]></dc:creator>
            <pubDate>Wed, 08 May 2024 14:07:10 GMT</pubDate>
            <atom:updated>2024-05-08T14:08:54.664Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G81TLWTHOHaLnVaglVaAnA.jpeg" /></figure><p>While researching and diving deep into the world of distributed systems, I found myself captivated by the complex and ever-evolving landscape that underpins much of our modern computing infrastructure. From the massive scale of cloud computing platforms to the intricate networks of micro-services that power our favourite applications, distributed systems have become the backbone of the digital world we inhabit.</p><p>As I delved further into the subject, I quickly realised that building reliable, scalable, and high-performing distributed and decentralised systems is no easy feat. The challenges that engineers and architects face are numerous and often daunting, ranging from the inherent unpredictability of network failures to the difficulties of maintaining consistency across multiple nodes.</p><p>One of the foundational concepts that I encountered in my research was the CAP theorem, introduced by Dr. Eric Brewer from Google.</p><p>This theorem posits that in any distributed system, there are three key guarantees that designers must balance:</p><p>a) consistency,</p><p>b) availability, and</p><p>c) partition tolerance.</p><p>The catch? You can only achieve two out of these three guarantees simultaneously. This means that system designers must make difficult trade-offs based on their specific requirements, often sacrificing one aspect in favour of the others.</p><p>But the challenges of distributed systems extend far beyond the technical realm. As Charity Majors, a renowned expert in the field, points out, “We are all distributed systems engineers now.” This statement underscores the fact that the complexity of modern systems has reached a point where every engineer, regardless of their specific role, must have a deep understanding of distributed systems principles to effectively build and maintain these systems.</p><p>Throughout my research, I also came across the work of Leslie Lamport, a pioneering researcher who made significant contributions to the field of distributed systems.</p><p>His famous quote, “A distributed system is one in which the failure of a computer you didn’t even know existed can render your own computer unusable,” perfectly encapsulates the inherent unpredictability and uncertainty that engineers must grapple with when designing and operating these systems.</p><p>As I continued to explore the intricacies of distributed systems, I began to appreciate the crucial role that the human factor plays in their success or failure.</p><p>Woods’ theorem, which states that “as the complexity of a system increases, the accuracy of any single agent’s own model of that system decreases rapidly,” highlights the importance of fostering a culture of collaboration, communication, and continuous learning within teams working on distributed systems.</p><p>One of the key strategies that emerged from my research for managing complexity in distributed systems is the embrace of failure. As the saying goes, “failure is not an option; it’s inevitable,” and accepting this reality is crucial to building resilient systems.</p><p>By designing systems with failure in mind, engineers can create architectures that can gracefully handle and recover from inevitable outages and disruptions. (Rosenthal et al., 2017)</p><p>Incident analysis and blameless postmortems also stood out as powerful tools for learning from failures and continuously improving distributed systems. By focusing on understanding the root causes of incidents without assigning blame, teams can gain valuable insights into the system’s behaviour and identify opportunities for optimisation and resilience.</p><p>As I reflect on my deep dive into distributed systems, I realise the journey is as much about people as it is about technology. Denise Yu’s insightful words, “We owe it to our end users and to our teams to understand and design for the whole system, including the fleshy human parts,” serve as a poignant reminder that the human elements of the system are just as critical as the technical components.</p><p>My exploration of distributed systems has been on going fascinating and eye-opening journey. Designing distributed systems is not for the faint of heart. It requires a deep understanding of the various components and underlying principles, a willingness to embrace complexity. By embracing complexity, learning from failures, and prioritising the human factors of the system, we can create distributed systems that power the technologies of tomorrow.</p><p>References</p><p>Rosenthal, C., Hochstein, L., Blohowiak, A., Jones, N., &amp; Basiri, A. (2017). Chaos Engineering: Building Confidence in System Behavior through Experiments. O’Reilly Media, Inc. <a href="https://www.oreilly.com/library/view/chaos-engineering/9781491988459/">https://www.oreilly.com/library/view/chaos-engineering/9781491988459/</a></p><p>Woods, D. D. (1988). Coping with Complexity: The Psychology of Human Behaviour in Complex Systems. Tasks, Errors, and Mental Models, 128–148. <a href="https://www.researchgate.net/publication/238687897_Coping_with_complexity_The_psychology_of_human_behavior_in_complex_systems">https://www.researchgate.net/publication/238687897_Coping_with_complexity_The_psychology_of_human_behavior_in_complex_systems</a></p><p>Yu, D. (2021). Why Distributed Systems Are So Hard. QCon, London, UK. <a href="https://qconlondon.com/london2021/presentation/why-distributed-systems-are-so-hard">https://qconlondon.com/london2021/presentation/why-distributed-systems-are-so-hard</a></p><p><a href="https://deniseyu.io/talks/">https://deniseyu.io/talks/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e97e3a141b39" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Polkadot to Jam: Gavin Wood’s Vision for Infinitely Scalable Blockchain Infrastructure]]></title>
            <link>https://medium.com/@vjgaur/from-polkadot-to-jam-gavin-woods-vision-for-infinitely-scalable-blockchain-infrastructure-e625e29e8b29?source=rss-ee70eb692f33------2</link>
            <guid isPermaLink="false">https://medium.com/p/e625e29e8b29</guid>
            <category><![CDATA[parachain]]></category>
            <category><![CDATA[substrate]]></category>
            <category><![CDATA[polkadot]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[rust]]></category>
            <dc:creator><![CDATA[Vijay Gaur]]></dc:creator>
            <pubDate>Sat, 20 Apr 2024 07:25:55 GMT</pubDate>
            <atom:updated>2024-04-20T07:25:55.900Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cuz_tfQGSGo4l49KNAumvA.png" /></figure><p>At the <strong>Token2049</strong> conference on April 18th, 2024, Dr. Gavin Wood, the renowned co-founder of Ethereum and founder of Polkadot, unveiled a groundbreaking new blockchain architecture called Jam. Presented in the form of a graypaper, Jam is designed to massively increase the scalability and performance of decentralised computation, potentially offering a quantum leap compared to existing platforms.</p><p>The Jam graypaper is a deep technical dive, filled with dense mathematics and formal specifications. In this article, we will attempt to distill the core concepts and innovations proposed in this 58-page document, focusing on the high-level architecture and implications while leaving the heaviest math to the appendices. My goal is to provide an accessible overview of Jam’s potential to revolutionise the blockchain landscape.</p><p><strong>Jam, short for Join-Accumulate Machine</strong>, represents a prospective design to succeed Polkadot’s relay chain. It adopts a novel computation model called <strong>CoreJAM</strong> (<strong>Collect, Refine, Join, Accumulate</strong>), where the<strong> Collect and Refine processes occur off-chain, and the Join and Accumulate functions are executed on-chain.</strong></p><p>At its core, Jam aims to massively increase the amount of useful computation that can be done in a decentralised, trust-less manner. It does this through a novel architecture that separates computation into two layers:</p><ol><li><strong>An off-chain, massively parallel computation layer called “refine” that can process huge volumes of data and complex logic. This is where most of the heavy lifting happens.</strong></li><li><strong>An on-chain “accumulate” layer that takes the results of the refine computation, verifies it through a crypto-economic staking mechanism, and integrates the validated results into a single authoritative state.</strong></li></ol><p>This separation allows computation to be spread across many machines working in<strong> parallel off-chain</strong>, while still providing strong security guarantees and a coherent global state. Jam calls this the <strong>“collect-refine-join-accumulate” model.</strong></p><p><strong>Jam</strong> shares similarities with smart contract chains, allowing permissionless code execution directly on the chain and organising state into distinct encapsulations called <strong>services</strong>. Services encompass code, balance, and state, resembling the structure of smart contracts.</p><p>However, Jam distinguishes itself by operating transactionlessly. All actions undergo an initial <strong>Refine stage</strong>, where <strong>input data is pre-refined into work reports consisting of work results</strong>. These results are then transferred onto the chain.</p><p>The Refine function is the primary workhorse, handling largely stateless operations. It can accept up to <strong>5 MB of data per 6-second time slot</strong> and <strong>yield a maximum of 4 kB of compacted data</strong>. Refine can execute for up to<strong> 6 seconds of PVM (Polkadot Virtual Machine) gas</strong>, equivalent to a full relay chain block period.</p><p>The Accumulate function integrates the output from Refine into the chain state. It is stateful, granting access to Jam’s state, and can read storage from any service, write to its<strong> key-value store</strong>, <strong>transfer funds</strong>, and perform other functionalities. Accumulate’s execution time per output is considerably shorter than Refine’s, typically around<strong> 10 milliseconds.</strong></p><p>Jam also introduces the <strong>onTransfer function,</strong> enabling asynchronous communication between services. Both Accumulate and onTransfer are designed to be executed in parallel, allowing simultaneous processing across different services.</p><p>Let’s dive deeper to unpack some of the key technical components that make Jam’s scalability possible:</p><p><strong>Cores</strong> are the individual units of<strong> off-chain computation in Jam</strong>, a bit like very powerful virtual CPUs. Each core can process inputs of up to<strong> 6MB per block</strong> and <strong>produce outputs of around 90kb</strong>. <strong>Jam aims to support 300+ cores.</strong></p><p>Work done by cores is packaged into units called <strong>work-packages</strong> by validators called guarantors. Guarantors put down stakes vouching for the correctness of the work.</p><p>These packaged results are submitted on-chain as <strong>work-reports</strong>. Chunks of the <strong>work-package</strong> are also distributed to other validators who attest to its availability. This is to ensure the data can be audited.</p><p>A subset of validators are pseudorandomly selected to audit each work-report by pulling the full package, rerunning the computation, and comparing it to the report. If they detect any errors, they can submit a dispute.</p><p>If over <strong>1/3 of validators</strong> dispute a report, it is considered invalid and the reporting guarantors are penalised. But if a supermajority confirm correctness, the results are accepted on-chain.</p><p>This audit-and-dispute process is the key security mechanism allowing Jam to safely outsource and <strong>parallelise computation off-chain</strong>. The crypto-economic incentives make it infeasible for malicious validators to game the system.</p><p>Another <strong>vital component of Jam is its virtual machine, PVM</strong>. Unlike Ethereum’s aging EVM, PVM is based on the <strong>RISC-V instruction set,</strong> offering a much more flexible, efficient, and powerful environment for smart contract execution. <strong>PVM</strong> offers simplicity, security, and exceptional execution speeds when run on conventional hardware.</p><p>Jam employs the <strong>SAFROLE</strong> block production algorithm, a simplification of <strong>SASSAFRAS</strong>. SAFROLE is a SNARK-based algorithm that delivers constant-time, almost entirely fork-free block production. It leverages the anonymity features of SNARKs to ensure the security of the block production mechanism.</p><p>Networking in Jam utilises the <strong>QUIC protocol</strong>, enabling direct point-to-point connections between a large number of validators. Gossip is avoided, and grid-diffusal is used for distributing packages within small subsets of validators.</p><p>Jam introduces a <strong>pipelining</strong> approach for efficient block processing. By placing the prior state root in the block header instead of the posterior state root, lightweight computations can be executed, and the block can be distributed immediately. The remaining computations, primarily accumulation tasks, can be completed subsequently, allowing the next block to start before the current block’s execution is finished.</p><p>To put Jam’s potential in perspective, let’s compare it to Ethereum. <strong>Ethereum</strong> processes all transactions and smart contract execution on-chain, which <strong>limits throughput to what a single node can process</strong>.</p><p>In contrast, <strong>Jam splits the work across hundreds of powerful off-chain cores that can process orders of magnitude more data in parallel</strong>. The paper estimates that a single Jam core could process somewhere between <strong>500 and 5000 Ethereum gas</strong> equivalents <strong>per microsecond</strong> — orders of magnitude more than <strong>Ethereum’s 1.25. And with 300+ cores</strong>, the total computation capacity is immense.</p><p>The upshot is that Jam could hypothetically process simple <strong>transfers at a rate of over a million per second, compared to Ethereum’s ~15</strong>. And it could run vastly more complex smart contract logic on top. The scalability is on a whole different level.</p><p>Of course, realising this potential will require overcoming significant challenges. Implementing a system as complex as Jam is a monumental engineering task. Ensuring the security and robustness of <strong>off-chain</strong> computation, preventing collusion among validators, and optimising the performance of <strong>PVM</strong> and the accumulate layer will all be critical.</p><p>There are also questions about the economic viability and decentralisation of such a system. <strong>Will the costs of computation and staking be accessible to a wide range of participants, or will it lead to concentration among a few powerful actors?</strong> How will the token economics work to incentivize honest participation? The graypaper provides some initial thoughts on these issues, but much remains to be fleshed out.</p><p>Despite these challenges, the potential upside of Jam is immense. If successfully implemented, it could enable a <strong>new generation of decentralised applications</strong> that are simply not possible on current platforms due to scalability constraints. From high-frequency decentralised exchanges to complex multi-party computations, the use cases are boundless.</p><p>Jam maintains compatibility with existing Polkadot 1 parachains while introducing significant enhancements. It offers the potential to streamline <strong>benchmarking efforts</strong>, introduces the concept of accords for enforcing interaction protocols between parachains, and provides full C<strong>ross-Chain Message Passing (XCMP)</strong> support.</p><p>In general, Jam represents a groundbreaking advancement in blockchain scalability and performance. By leveraging a novel computation model, a powerful virtual machine, and a range of cryptographic and game-theoretic techniques, Jam aims to enable a new generation of decentralised applications that can process orders of magnitude more transactions and complex smart contract logic than current platforms.</p><p>While significant challenges remain in implementing such a complex system, the potential impact of Jam is transformative. With Dr. Wood’s track record of launching groundbreaking platforms like Ethereum and Polkadot, the blockchain community will undoubtedly be watching Jam’s development closely.</p><p>I would love to hear your thoughts! Do you think Jam has the potential to revolutionise blockchain scalability? What excites you most about its design and capabilities? Let me know in the comments below.</p><p>Follow me for more such insight at <a href="https://twitter.com/nceevij">NceeVij</a> and <a href="https://medium.com/u/ee70eb692f33">Vijay Gaur</a></p><p><strong>References</strong></p><p><a href="https://graypaper.com/graypaper.pdf">https://graypaper.com/graypaper.pdf</a></p><p><a href="https://wiki.polkadot.network/docs/learn-jam-chain">Polkadot&#39;s JAM Chain · Polkadot Wiki</a></p><p><a href="https://www.youtube.com/watch?v=_-W13rZDLw0&amp;ab_channel=PolytopeLabs">https://www.youtube.com/watch?v=_-W13rZDLw0&amp;ab_channel=PolytopeLabs</a></p><iframe src="https://drive.google.com/viewerng/viewer?url=https%3A//graypaper.com/graypaper.pdf&amp;embedded=true" width="600" height="780" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e818778446c38fac3b34c17402efbcb/href">https://medium.com/media/0e818778446c38fac3b34c17402efbcb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e625e29e8b29" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Rust Abstractions and Dispatch Mechanisms]]></title>
            <link>https://medium.com/@vjgaur/exploring-rust-abstractions-and-dispatch-mechanisms-1fbc97567d44?source=rss-ee70eb692f33------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fbc97567d44</guid>
            <category><![CDATA[rust-programming-language]]></category>
            <category><![CDATA[abstraction]]></category>
            <category><![CDATA[rustlang]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[dynamic-dispatch]]></category>
            <dc:creator><![CDATA[Vijay Gaur]]></dc:creator>
            <pubDate>Fri, 13 Oct 2023 09:20:02 GMT</pubDate>
            <atom:updated>2023-10-13T09:20:02.500Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*G6jV_l2SrsIHG8cWBukC5Q.png" /></figure><p>Hey <a href="https://twitter.com/hashtag/RustCommunity?src=hashtag_click">#RustCommunity</a>! Let’s dive into some fascinating concepts that make Rust shine: zero-cost abstraction and dynamic dispatch using &amp;dyn.</p><p>Rust is all about writing code that’s both high-level and super fast.Zero-cost abstraction means you can use powerful, abstract concepts without worrying about slowing down your program during runtime. Rust optimises code behind the scenes to ensure performance isn’t compromised</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pqT63oQRjhEJCjwE2_Nd3A.png" /></figure><p>Imagine you want to deal with different shapes, but you don’t know their types until runtime. This is where dynamic dispatch using &amp;dyn comes in. It allows you to choose the right method implementation at runtime based on the actual type of the object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Xm-wpeyFEX_hC1EE8xpYA.png" /></figure><p>When you use &amp;dyn, Rust creates a “fat pointer” to the data. A fat pointer consists of two parts: one pointer to the actual data and another pointer to the vtable (virtual function table). The vtable holds pointers to all the methods implemented by the type.</p><p>The vtable is where the real magic happens. It contains pointers to all the methods that a struct implements. When you call a method on a dynamically dispatched object, Rust looks up the vtable to find the correct method to execute at runtime. This enables runtime flexibility in choosing methods based on the object’s actual type.</p><p>Rust also provides static dispatch using the impl keyword. This approach determines the method to call at compile time, which is highly efficient. If you know the exact type at compile time. You can use impl to ensure your code runs with minimal overhead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GDq2Y6mZkMQ4-98HKrqqRA.png" /></figure><p>Rust’s zero-cost abstractions and dynamic dispatch with &amp;dyn empower you to write expressive, high-level code that’s also blazing fast When you need even more control over method resolution, Rust’s static dispatch using impl comes to the rescue.</p><p>Happy #rust coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fbc97567d44" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Beginner Friendly Introduction: Integrating the Balances Pallet into a Custom Substrate-based…]]></title>
            <link>https://medium.com/@vjgaur/a-beginner-friendly-introduction-integrating-the-balances-pallet-into-a-custom-substrate-based-a155e7140462?source=rss-ee70eb692f33------2</link>
            <guid isPermaLink="false">https://medium.com/p/a155e7140462</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[polkadot]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[rustlang]]></category>
            <category><![CDATA[substrate]]></category>
            <dc:creator><![CDATA[Vijay Gaur]]></dc:creator>
            <pubDate>Tue, 31 Jan 2023 12:03:58 GMT</pubDate>
            <atom:updated>2023-01-31T12:18:58.601Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Beginner Friendly Introduction: Integrating the Balances Pallet into a Custom Substrate-based Blockchain</h3><p>Substrate provides several pre-built pallets for common blockchain functionality, including:</p><ol><li><strong>System</strong>: The core module that provides basic functions for managing the blockchain and managing accounts.</li><li><strong>Timestamp</strong>: Provides a timestamp for transactions and blocks.</li><li><strong>Balances</strong>: Implements a token system for the blockchain, including token transfers and staking.</li><li><strong>Session</strong>: Manages the session changes, which determine when validators are swapped.</li><li><strong>Staking</strong>: Implements a staking mechanism for validators.</li><li><strong>Elections</strong>: Manages the election of validators.</li><li><strong>Contracts</strong>: Provides a framework for smart contract development.</li></ol><p>To integrate a pre-built pallet into a custom blockchain, you need to add the pallet to the chain specification and configure its parameters. Then, you can use the functionality provided by the pallet in your custom runtime.</p><p>Here is an example of how to integrate the Balances pallet into a custom runtime:</p><pre>// Import the pallet<br>use pallet_balances as balances;<br><br>// Add the pallet to the chain specification<br>construct_runtime!(<br>    pub enum Runtime where<br>        Block = Block,<br>        NodeBlock = opaque::Block,<br>        UncheckedExtrinsic = UncheckedExtrinsic<br>    {<br>        System: system::{Module, Call, Config, Storage, Event&lt;T&gt;},<br>        Timestamp: timestamp::{Module, Call, Storage, Inherent},<br>        Balances: balances::{Module, Call, Storage, Config&lt;T&gt;, Event&lt;T&gt;},<br>        // ...<br>    }<br>);<br><br>// Use the functionality provided by the pallet in the custom runtime<br>impl&lt;T: Trait&gt; Module&lt;T&gt; {<br>    // ...<br>    pub fn transfer(origin, dest: T::AccountId, value: T::Balance) -&gt; dispatch::Result {<br>        let origin = ensure_signed(origin)?;<br>        let dest = T::Lookup::lookup(dest)?;<br>        &lt;balances::Module&lt;T&gt;&gt;::transfer(&amp;origin, &amp;dest, value)?;<br>        Ok(())<br>    }<br>}</pre><p>Here is a step by step explanation of the above code:</p><ol><li>Import the pallet: The first line use pallet_balances as balances; imports the Balances pallet into the code and gives it the alias balances.</li><li>Add the pallet to the chain specification: The construct_runtime! macro is used to construct the runtime of the custom blockchain. The Balances module is added to the runtime as one of its components. This means that the Balances pallet will be part of the blockchain&#39;s core functionality.</li><li>Use the functionality provided by the pallet: A method transfer is defined within the custom runtime that transfers tokens from one account to another. The method uses the transfer function provided by the Balances pallet to carry out the transfer. The ensure_signed function is used to ensure that the origin of the transfer is a signed account, and the T::Lookup::lookup function is used to resolve the destination account ID to an actual account.</li></ol><p>This is just a basic example of what a custom runtime in Substrate could look like. You would need to learn about the specific pallets you want to use and how to integrate them into your custom runtime.</p><p>You would also need to understand how to configure and deploy your blockchain, including setting up the network, nodes, and consensus mechanism. You will find some interesting stuff coming on these topics soon. Follow this space for more.</p><p>I hope this gives you a good starting point for your journey in Substrate-based blockchain development!</p><p>You can follow me on Twitter <a href="https://twitter.com/nceevij">https://twitter.com/nceevij</a> where I share my learning and resources on Rust/Substrate/Polkadot on daily basis.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a155e7140462" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unsafe Pointers in Rust: Common Pitfalls and How to Avoid Them]]></title>
            <link>https://medium.com/@vjgaur/unsafe-pointers-in-rust-common-pitfalls-and-how-to-avoid-them-efa6573397bc?source=rss-ee70eb692f33------2</link>
            <guid isPermaLink="false">https://medium.com/p/efa6573397bc</guid>
            <category><![CDATA[rustlang]]></category>
            <category><![CDATA[programming-tips]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[rust-programming-language]]></category>
            <category><![CDATA[pointers]]></category>
            <dc:creator><![CDATA[Vijay Gaur]]></dc:creator>
            <pubDate>Mon, 09 Jan 2023 08:48:24 GMT</pubDate>
            <atom:updated>2023-01-09T09:14:48.621Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_b62JoclsLqk81y8jQJdsg.png" /><figcaption>Raw Pointers</figcaption></figure><p>In Rust, pointers are used to reference a location in memory. They are a way of borrowing data stored at a particular address rather than copying it. Pointers are an important feature in Rust, but they can also be a source of bugs if used incorrectly. In this article, we will discuss some common pitfalls when using pointers in Rust and how to avoid them.</p><p>One of the main issues with pointers is that they can be null, meaning they do not point to a valid location in memory. In Rust, the null pointer is represented by the null keyword.</p><p>Using a null pointer can lead to a null reference error, which occurs when you try to access data through a null pointer. This can cause the program to crash or produce undefined behaviour.</p><p>To prevent null reference errors, it is important to check for null pointers before dereferencing them. This can be done with an if statement or the .as_ref() method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e0S1Yr9yVIIPSIkGIkqFvw.png" /><figcaption>Null pointers</figcaption></figure><p>Another issue with pointers is that they can be dangling, meaning they point to a location in memory that has been deallocated. This can occur when a pointer is created to an object that goes out of scope, and the memory it occupied is then freed.</p><p>Using a dangling pointer can lead to data races or segmentation faults, as the memory location it points to may have been reused for something else.</p><p>To prevent dangling pointers, it is important to ensure that the data a pointer points to remains valid for the lifetime of the pointer. In Rust, this can be achieved through the use of reference counting or by using lifetimes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LhHbWYIHOJWZrnZ_9lABeg.png" /><figcaption>Segmentation Fault</figcaption></figure><p>In the example above, the vec_ptr pointer is created to the first element of the vec vector. However, when the vector is cleared, the memory occupied by its elements is freed, making vec_ptr a dangling pointer</p><p>To fix this issue, we can use reference counting by changing the vec vector to a Rc&lt;Vec&lt;i32&gt;&gt;. This will ensure that the memory occupied by the vector is not freed until all references to it have gone out of scope</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jx6jT3stHmplCttrJlRz4g.png" /></figure><p>Another way to fix this issue is to use lifetimes. Lifetimes are a way of specifying the lifetime of a reference in Rust. They are used to ensure that references are valid for a certain period of time.</p><p>Here is an example of how lifetimes can be used to ensure that a pointer remains valid:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FybCEVpoyXkxUrv4KJ25wQ.png" /></figure><p>In this example, the vec_ptr pointer is created to the first element of the vec vector. The lifetime of the reference is specified with the &#39;static keyword, which means that the reference is valid for the entire duration of the program. As the vec vector is not deallocated, the vec_ptr pointer remains valid and can be safely dereferenced.</p><p>On the other hand, if we try to create a pointer to an object that goes out of scope, we will get a compile-time error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IL-Mf5aC0-H8BlCgU-HHmw.png" /></figure><p>In this example, the vec_ptr pointer is created to the x reference, which points to the first element of the vec vector. However, x goes out of scope at the end of the inner block, and the vec_ptr pointer becomes a dangling pointer. The Rust compiler will detect this and prevent the program from compiling</p><p>Lifetimes can also be used in conjunction with structs and functions to ensure that references remain valid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JeWKX1DFGT7tnLskRH5_UA.png" /></figure><p>In this example, the MyStruct struct has a reference field with the lifetime &#39;a, and the my_function function has a reference parameter with the same lifetime. This means that the references stored in the struct and returned by the function will remain valid for the same lifetime &#39;a. In this case, &#39;a is the lifetime of the x variable, so the references will remain valid as long as x remains in scope.</p><p>Overall, lifetimes are a useful tool for ensuring the validity of references in Rust, particularly when working with pointers. By specifying the lifetimes of references, we can prevent dangling pointers and ensure that our program is safe and correct.</p><p>I share my learning on daily basis on twitter and LinkedIn:</p><p>For More such interesting tips follow me on twitter</p><p><a href="https://twitter.com/nceevij">https://twitter.com/nceevij</a></p><p>and LinkedIn</p><p><a href="https://www.linkedin.com/in/vijendr/">https://www.linkedin.com/in/vijendr/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=efa6573397bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Rust borrow checker]]></title>
            <link>https://medium.com/@vjgaur/the-rust-borrow-checker-2be5533de15c?source=rss-ee70eb692f33------2</link>
            <guid isPermaLink="false">https://medium.com/p/2be5533de15c</guid>
            <category><![CDATA[rust-programming-language]]></category>
            <category><![CDATA[borrow-checker]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[rustlang]]></category>
            <dc:creator><![CDATA[Vijay Gaur]]></dc:creator>
            <pubDate>Sat, 07 Jan 2023 09:16:31 GMT</pubDate>
            <atom:updated>2023-04-11T15:04:56.646Z</atom:updated>
            <content:encoded><![CDATA[<p>The Rust borrow checker is a central part of the Rust programming language that helps to ensure memory safety and prevent data races. It is responsible for enforcing the borrowing and mutability rules that are at the heart of Rust’s ownership system.</p><p>To better understand how the borrow checker works, let’s consider the following example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*upNebIJdDO4w4NnbBJLpCw.png" /></figure><p>In this code, we have a variable x with an initial value of 5. We then create a mutable reference to x, which we call y. We use the dereference operator (*) to modify the value of x through the reference y. Finally, we print out the value of x.</p><p>The borrow checker will analyze this code to ensure that there are no conflicts or other issues with the borrows. In this case, it will determine that the borrow of x through y is safe and allow the code to execute.</p><p>However, if we try to modify x directly after creating the mutable reference y, the borrow checker will raise an error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XfiCW4OHNNPKEfdC9aT0-Q.png" /></figure><p>In this code, the attempt to modify x directly after creating the mutable reference y is not allowed because it would conflict with the mutable borrow of x through y. The borrow checker will prevent this code from compiling, ensuring that the borrow rules are not violated.</p><p>It is worth noting that the borrow checker is a static analysis tool, which means that it operates at compile time rather than runtime. This makes it an extremely fast and efficient way to ensure the safety of Rust code.</p><p>Overall, the Rust borrow checker is an essential part of the language that helps to ensure the reliability and safety of Rust code.</p><p>By following its rules and best practices, Rust developers can build systems that are resistant to common memory safety issues and can be trusted to behave correctly in production environments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2be5533de15c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>