<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
      <title>In Rust We Trust 🦀 - blockchain</title>
      <link>https://nikolaishelekhov.com</link>
      <description>Nikolai is a Rust software engineer building high-performance systems, backend and blockchain infrastructure.</description>
      <generator>Zola</generator>
      <language>en</language>
      <atom:link href="https://nikolaishelekhov.com/tags/blockchain/rss.xml" rel="self" type="application/rss+xml"/>
      <lastBuildDate>Sun, 09 Nov 2025 00:00:00 +0000</lastBuildDate>
      <item>
          <title>Designing an On-Chain Price Oracle in Substrate</title>
          <pubDate>Sun, 09 Nov 2025 00:00:00 +0000</pubDate>
          <author>Nikolai Shelekhov</author>
          <link>https://nikolaishelekhov.com/blog/substrate-price-oracle/</link>
          <guid>https://nikolaishelekhov.com/blog/substrate-price-oracle/</guid>
          <description xml:base="https://nikolaishelekhov.com/blog/substrate-price-oracle/">&lt;p&gt;Accurate price data is foundational to any DeFi system.&lt;&#x2F;p&gt;
&lt;p&gt;DEXs, lending protocols, liquidations, MEV strategies —&lt;br &#x2F;&gt;
all depend on reliable and timely asset pricing.&lt;&#x2F;p&gt;
&lt;p&gt;Instead of relying purely on external infrastructure, I wanted to explore a runtime-native approach using Substrate.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-goal&quot;&gt;The Goal&lt;&#x2F;h2&gt;
&lt;p&gt;Design a modular price oracle pallet that:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Fetches asset prices from external sources&lt;&#x2F;li&gt;
&lt;li&gt;Aggregates them deterministically&lt;&#x2F;li&gt;
&lt;li&gt;Stores them on-chain&lt;&#x2F;li&gt;
&lt;li&gt;Exposes them to other runtime modules&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;The constraint: maintain composability and determinism at the runtime level.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;architecture-overview&quot;&gt;Architecture Overview&lt;&#x2F;h2&gt;
&lt;p&gt;The design uses Substrate’s off-chain workers:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Off-chain worker fetches external price data&lt;&#x2F;li&gt;
&lt;li&gt;Data is validated and formatted&lt;&#x2F;li&gt;
&lt;li&gt;An unsigned transaction submits updated price information&lt;&#x2F;li&gt;
&lt;li&gt;Runtime storage is updated&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;This keeps:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Network requests off the runtime path&lt;&#x2F;li&gt;
&lt;li&gt;Deterministic execution within the state machine&lt;&#x2F;li&gt;
&lt;li&gt;Minimal trust assumptions beyond data sources&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;key-design-decisions&quot;&gt;Key Design Decisions&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;1-off-chain-workers&quot;&gt;1. Off-Chain Workers&lt;&#x2F;h3&gt;
&lt;p&gt;External HTTP requests cannot block runtime execution.&lt;&#x2F;p&gt;
&lt;p&gt;Off-chain workers allow background fetching without compromising block production.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;2-fixed-point-arithmetic&quot;&gt;2. Fixed-Point Arithmetic&lt;&#x2F;h3&gt;
&lt;p&gt;Floating-point operations are not deterministic across architectures.&lt;&#x2F;p&gt;
&lt;p&gt;All price calculations use fixed-point arithmetic to ensure:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Deterministic execution&lt;&#x2F;li&gt;
&lt;li&gt;Predictable rounding&lt;&#x2F;li&gt;
&lt;li&gt;Cross-node consistency&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;3-storage-layout&quot;&gt;3. Storage Layout&lt;&#x2F;h3&gt;
&lt;p&gt;Prices are stored in optimized maps keyed by asset identifiers.&lt;&#x2F;p&gt;
&lt;p&gt;Design priorities:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Fast reads (price access is frequent)&lt;&#x2F;li&gt;
&lt;li&gt;Minimal storage overhead&lt;&#x2F;li&gt;
&lt;li&gt;Clear upgrade path&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;why-not-just-use-an-external-oracle&quot;&gt;Why Not Just Use an External Oracle?&lt;&#x2F;h2&gt;
&lt;p&gt;External oracle networks are powerful — but they introduce:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Latency&lt;&#x2F;li&gt;
&lt;li&gt;Trust layers&lt;&#x2F;li&gt;
&lt;li&gt;Dependency on third-party infrastructure&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Embedding oracle logic inside the runtime:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Improves composability&lt;&#x2F;li&gt;
&lt;li&gt;Reduces architectural complexity&lt;&#x2F;li&gt;
&lt;li&gt;Enables tighter integration with DeFi pallets&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;For experimentation and MEV research, this approach gives full control over the data lifecycle.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;what-i-learned&quot;&gt;What I Learned&lt;&#x2F;h2&gt;
&lt;p&gt;Building runtime logic reinforces an important principle:&lt;&#x2F;p&gt;
&lt;p&gt;Blockchain development is systems programming.&lt;&#x2F;p&gt;
&lt;p&gt;You’re writing deterministic state machines,
with strict performance constraints,
and zero room for undefined behavior.&lt;&#x2F;p&gt;
&lt;p&gt;Rust and Substrate make that not only possible —
but enjoyable.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Blockchain or Rust? Why I Choose Both — On My Terms</title>
          <pubDate>Sun, 12 Oct 2025 00:00:00 +0000</pubDate>
          <author>Nikolai Shelekhov</author>
          <link>https://nikolaishelekhov.com/blog/blockchain-or-rust/</link>
          <guid>https://nikolaishelekhov.com/blog/blockchain-or-rust/</guid>
          <description xml:base="https://nikolaishelekhov.com/blog/blockchain-or-rust/">&lt;p&gt;A few months ago, I was asked in an interview:&lt;&#x2F;p&gt;
&lt;p&gt;“What do you love more — Rust or blockchain?”&lt;&#x2F;p&gt;
&lt;p&gt;My answer was immediate.&lt;&#x2F;p&gt;
&lt;p&gt;Rust comes first.&lt;&#x2F;p&gt;
&lt;p&gt;But not just any Rust work — deep, idiomatic, systems-level Rust programming.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;rust-first&quot;&gt;Rust First&lt;&#x2F;h2&gt;
&lt;p&gt;What draws me to Rust is not hype.&lt;&#x2F;p&gt;
&lt;p&gt;It’s:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Memory safety without garbage collection&lt;&#x2F;li&gt;
&lt;li&gt;Zero-cost abstractions&lt;&#x2F;li&gt;
&lt;li&gt;Explicit control over performance&lt;&#x2F;li&gt;
&lt;li&gt;Deterministic behavior&lt;&#x2F;li&gt;
&lt;li&gt;Strong type-driven design&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Rust feels like systems programming done correctly.&lt;&#x2F;p&gt;
&lt;p&gt;That foundation matters more to me than the domain.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;blockchain-but-only-at-the-right-layer&quot;&gt;Blockchain — But Only at the Right Layer&lt;&#x2F;h2&gt;
&lt;p&gt;If I work in blockchain, it has to be infrastructure.&lt;&#x2F;p&gt;
&lt;p&gt;Not smart contracts.
Not application-layer glue code.
Not framework-heavy abstraction stacks.&lt;&#x2F;p&gt;
&lt;p&gt;There is a fundamental difference between:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Building on top of someone else’s platform&lt;&#x2F;li&gt;
&lt;li&gt;Building the platform itself&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;I’m interested in the second.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;why-polkadot&quot;&gt;Why Polkadot&lt;&#x2F;h2&gt;
&lt;p&gt;Polkadot stands out for one specific reason:&lt;&#x2F;p&gt;
&lt;p&gt;It is pure Rust.&lt;&#x2F;p&gt;
&lt;p&gt;Substrate is not a thin wrapper around another runtime.
It is not macro-driven sugar hiding complexity.
It exposes the machinery.&lt;&#x2F;p&gt;
&lt;p&gt;You write runtime logic.
You design state transitions.
You control storage.
You reason about determinism.&lt;&#x2F;p&gt;
&lt;p&gt;It feels like systems engineering — not scripting on-chain.&lt;&#x2F;p&gt;
&lt;p&gt;That alignment matters.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;infrastructure-over-applications&quot;&gt;Infrastructure Over Applications&lt;&#x2F;h2&gt;
&lt;p&gt;I am drawn to:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Runtime design&lt;&#x2F;li&gt;
&lt;li&gt;Consensus-adjacent components&lt;&#x2F;li&gt;
&lt;li&gt;Performance-critical infrastructure&lt;&#x2F;li&gt;
&lt;li&gt;Cross-chain execution logic&lt;&#x2F;li&gt;
&lt;li&gt;State machine design&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Not UI.
Not token launches.
Not yield optimizers.&lt;&#x2F;p&gt;
&lt;p&gt;I want to work on the systems that make everything else possible.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-boundary-i-ve-drawn&quot;&gt;The Boundary I’ve Drawn&lt;&#x2F;h2&gt;
&lt;p&gt;My focus is clear:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Deep systems programming in Rust&lt;&#x2F;li&gt;
&lt;li&gt;Blockchain infrastructure (not application layer)&lt;&#x2F;li&gt;
&lt;li&gt;Preferably within the Polkadot ecosystem&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;That doesn’t invalidate other paths.&lt;&#x2F;p&gt;
&lt;p&gt;It just reflects what I value.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;why-this-matters&quot;&gt;Why This Matters&lt;&#x2F;h2&gt;
&lt;p&gt;Careers compound.&lt;&#x2F;p&gt;
&lt;p&gt;If you spend years writing surface-level abstractions,
you become good at surface-level abstractions.&lt;&#x2F;p&gt;
&lt;p&gt;If you spend years designing deterministic state machines,
optimizing performance,
and reasoning about low-level invariants,&lt;&#x2F;p&gt;
&lt;p&gt;you become something else entirely.&lt;&#x2F;p&gt;
&lt;p&gt;I choose the latter.&lt;&#x2F;p&gt;
&lt;p&gt;Rust is the constant.
Blockchain is optional — but only when it allows Rust to be used at its full depth.&lt;&#x2F;p&gt;
&lt;p&gt;That’s the line I’ve drawn.&lt;&#x2F;p&gt;
</description>
      </item>
    </channel>
</rss>
