--- title: I Built a Tool to Spy on Ethereum Blocks (And You Can Too!) description: Building BlockStream Inspector - An advanced analytics tool for examining Ethereum block production, propagation timing, transaction ordering, and MEV extraction trends tags: ethereum, rust, mev, pbs, blockchain, protocol --- # I Built a Tool to Spy on Ethereum Blocks (And You Can Too!) :::info **TL;DR**: I built BlockStream Inspector in Rust to understand how blocks are actually made, track MEV activity, and learn protocol-level development. one weeks of work, tons of learning, and applying to EF Protocol Prototyping internship! ::: ## The Story Behind BlockStream Inspector Even after building DeFi projects at Own Protocol and Sereel Technologies, interacting with smart contracts, connecting wallets, and handling transactions, I realized I only had a surface-level understanding of how Ethereum blocks really work. Sure, I knew what a block was and how transactions got mined, but the why and how of block ordering, transaction prioritization, and validator strategies? That part was murky. One day, while staring at a transaction on Etherscan, it hit me: *"Why did this transaction get in first? Who decides the order? And what’s happening behind the scenes that I don’t see?"* That curiosity led me down a rabbit hole: I discovered MEV, where participants compete to reorder transactions for profit, and PBS (Proposer-Builder Separation, where validators outsource block building entirely. It was eye-opening, and I knew I had to explore it further. But here's the thing, I'm not the type to just read about things. I need to **build something** to really understand it. So I thought: *"What if I built a tool that could actually SHOW me all this happening in real-time?"* That's how BlockStream Inspector was born. (or you can call it Ethereum BlockStream Inspector) --- ## What Does BlockStream Inspector Actually Do? Okay, imagine Ethereum is like a really busy restaurant. ### The Traditional View (what most people see): - You walk in - You order food (send transaction) - Food arrives (transaction confirmed) - You eat (transaction executed) ### What's Actually Happening (what BlockStream Inspector shows you): - There's a **CRAZY** kitchen backstage - Multiple chefs competing to cook your order (block builders) - Someone deciding which chef gets to cook (the validator/proposer) - Chefs trying to sneak extra orders in between yours for extra tips (MEV!) - A whole system of who gets paid what (gas fees, tips, burned fees) :::success **BlockStream Inspector basically puts a camera in that kitchen so you can watch everything happening.** ::: ## How It Works ### Step 1: Connect to Ethereum Like plugging into the Matrix, but less dramatic. BlockStream Inspector talks to an Ethereum node and says *"Hey, show me what's happening!"* ### Step 2: Grab a Block Think of a block like a box of LEGO pieces. Each piece is a transaction. BlockStream Inspector grabs that box and dumps everything out. ### Step 3: Examine Everything Now the fun part! BlockStream Inspector looks at: - How long did it take to make this box? (timing) - How full is it? (gas usage) - What types of pieces are inside? (transaction types) - Did anyone try to cheat? (MEV detection) - Who actually built this box? (PBS analysis) ### Step 4: Make Pretty Pictures All that data gets exported to CSV, then Python scripts turn it into graphs and charts. Because humans like pictures more than numbers. --- ## Why Did I Build This? **Honest answer?** I'm applying for the Ethereum Foundation Protocol Prototyping internship (deadline Dec 1st, if you're reading this from the future – I hopefully got in! 🀞). Lol But also: 1. **I was genuinely curious** – How do blocks ACTUALLY work? Not the theoretical stuff from docs, but the real messy reality. 2. **I wanted to see MEV in action** – Everyone talks about MEV bots making millions. I wanted to SEE them. Track them. Understand their patterns. 3. **PBS confused me** – What's this Proposer-Builder Separation thing everyone keeps mentioning? Are validators even building blocks anymore? (Spoiler: mostly no!) 4. **I learn by building** – Reading is cool, but building forces you to understand things at a deeper level. You can't fake it when you're writing code. 5. **I needed to level up** – I've been doing React and TypeScript forever. Time to get serious about protocol-level stuff if I want to work on core Ethereum infrastructure. --- ## The Technical Bits (But Simple!) ### The Stack **Rust** – Because it's fast and the Ethereum ecosystem is moving to Rust (Reth, anyone?). Also, I wanted to prove I could do more than just JavaScript. **Ethers-rs** – Library for talking to Ethereum. It's like having a translator when you visit a foreign country. **Python** – For data analysis because `pandas` + `matplotlib` = chef's kiss for making graphs. ### What I Track ```rust // 1. Timing block_time: 12.05s // How long since last block? // 2. Gas gas_used: 29,834,521 / 30,000,000 (99.4%) base_fee: 25.34 gwei fees_burned: 0.7563 ETH // Gone forever! // 3. Transactions legacy: 12 eip2930: 5 eip1559: 225 // The standard! eip4844: 5 // New blob txs for L2s // 4. MEV sandwich_attacks: 3 arbitrage_ops: 7 estimated_mev: 2.3451 ETH // 5. PBS is_pbs_block: true builder: "flashbots" ``` #### Transaction Types Breakdown | Type | Name | Usage | |------|------|-------| | Type 0 | Legacy | Old school, still around | | Type 1 | EIP-2930 | Access lists (rare) | | Type 2 | EIP-1559 | Standard today | | Type 3 | EIP-4844 | Blob txs for L2s | --- ## What I Learned (The Real Stuff) ### Technical Wins **Rust Isn't That Scary** – Everyone says Rust has a steep learning curve. It does, but it's SO worth it. The compiler is like a strict teacher who won't let you make dumb mistakes. **Async Is Everywhere** – Modern Ethereum clients are all async. You gotta embrace Tokio and futures. Fighting it makes everything harder. **RPC Rate Limits Are Real** – Free tier limits hit FAST when you're analyzing hundreds of blocks. Pro tip: use Alchemy, they're generous. **Data Pipelines Need Love** – Getting data is easy. Cleaning it, structuring it, making it useful? That's where the real work is. ### Protocol Insights :::warning **PBS Is The Reality Now** – Like 90%+ of blocks are builder-built. The "validators build blocks" mental model is outdated. ::: **MEV Is EVERYWHERE** – Even in boring blocks, there's MEV. Sometimes it's subtle, sometimes it's in your face. **EIP-1559 Works (Mostly)** – Base fee really does adjust to demand. Watching it go up and down based on network usage is mesmerizing. **Block Time Isn't Perfect** – Sometimes blocks are 10 seconds apart, sometimes 15. The 12-second target is an average, not a guarantee. **Gas Is Weird** – Full blocks don't always mean high fees. Sometimes blocks are full of cheap blob transactions. The gas market is more nuanced than I thought. ### Personal Growths **Documentation Matters** – I wrote SO much documentation for this. Not because I had to, but because future-me (and other people) need to understand what past-me was thinking. **Tests = Confidence** – I added 25+ tests. Now when I change something, I know immediately if I broke anything. Game changer. **Details Matter at Protocol Level** – In web dev, you can sometimes handwave details. At protocol level? Nope. Every wei matters. Every gas unit counts. **Reading Specs Is A Skill** – EIPs are dense. But after reading EIP-1559 and EIP-4844 thoroughly, I got better at extracting the important bits. --- # The "Holy Shit" :::danger **Moment 1**: Watching a sandwich attack happen in real-time. - Transaction 1: buy token - Transaction 2: victim buys token (price goes up) - Transaction 3: sell token for profit - **All in the SAME BLOCK** Mind = blown. ::: **Moment 2**: Realizing Flashbots dominates block building. Like, REALLY dominates. The centralization is real, folks. **Moment 3**: Seeing a 20-second block gap and wondering if a validator missed their slot. (They probably did.) **Moment 4**: Discovering that some blocks burn more ETH than they pay to proposers. EIP-1559 is literally making ETH deflationary during high activity! --- ## Challenges I Hit πŸ˜… ``` ❌ RPC Hell Free tier rate limits. Inconsistent responses. Random timeouts. RPC is hard, y'all. ❌ MEV Detection Is Hard Detecting sandwich attacks isn't straightforward. You need to parse logs, track token flows, match addresses... it's detective work. ❌ Making Sense of Data Getting a million data points is easy. Making them meaningful? That's the challenge. ❌ Async Rust Fighting the borrow checker while doing async is... character building. ❌ Testing Real Data How do you test code that talks to a live blockchain? Mock everything? Use a test network? I chose mocks + manual testing. ``` ## What's Next? Honestly? if I had more time (or when I do), here's what I'd add: - **Real mempool monitoring** – Watch transactions BEFORE they're in blocks - **Historical aggregation** – Track trends over weeks/months - **Better MEV detection** – More sophisticated algorithms - **Web dashboard** – Because command-line tools are cool but dashboards are cooler - **SSZ parsing** – Get into the real low-level consensus data structures - **Beacon chain integration** – See the full CL + EL picture --- ## Should You Build Something Like This? ### YES! If you: - Want to understand Ethereum at a deeper level - Like building tools more than reading docs - Are curious about `MEV`, `PBS (Proposed-Builder Separation)`, or `gas markets` - Want to transition from dApp dev to protocol work - Need a project for an application (like I did!) :::success **Here's the secret**: The best way to learn protocol development isn't reading papers. It's building tools that let you SEE what's happening. BlockStream Inspector was my eyes into the protocol layer. ::: ## Final Words Building BlockStream Inspector was honestly one of the most fun projects I've done. Not because it's complex (it's not), but because it taught me so much about how Ethereum ACTUALLY works. Theory is great. Docs are important. But nothing beats watching real blocks get built, seeing real MEV extracted, tracking real gas prices in real-time. If you're a web3 developer and you've never looked at what's happening at the protocol layer, I highly recommend it. It'll change how you think about transactions, gas, and blockchain architecture. Also, it makes you realize how much cool stuff is happening that we don't normally see. Ethereum isn't just smart contracts and tokens. It's this living, breathing, competitive, fascinating system with validators, builders, searchers, and users all playing different roles. Pretty cool if you ask me. 😎 --- ## Sample Output Here's what EBLA actually shows you: ```bash ═══════════════════════════════════════════════════ Block Number: 21045123 Block Hash: 0x1234567890abcdef Timestamp: 1732003200 ═══════════════════════════════════════════════════ ⏱️ TIMING METRICS Block Time: 12.05s β›½ GAS METRICS Gas Used: 29834521 / 30000000 (99.4%) Base Fee: 25.34 gwei Avg Priority Fee: 1.52 gwei Fees Burned: 0.7563 ETH Priority Fees: 0.0453 ETH πŸ“ TRANSACTIONS Total: 247 Failed: 3 Types: Legacy(12), EIP-2930(5), EIP-1559(225), EIP-4844(5) πŸ’° MEV INDICATORS Sandwich Attacks: 3 Arbitrage Ops: 7 Liquidations: 2 Estimated MEV: 2.3451 ETH πŸ—οΈ PBS METRICS PBS Block: Yes Builder: flashbots ``` --- ## Architecture Diagram ```mermaid graph LR A[Ethereum Node] -->|RPC| B[BlockStream Inspector Rust Core] B --> C[Block Analyzer] C --> D[CSV Exporter] D --> E[Python Analysis] E --> F[Visualizations] style B fill:#f96 style E fill:#9cf ``` --- ## Links & Resources | Resource | Link | |----------|------| | **Code** | [https://github.com/dicethedev/blockstream-inspector](https://github.com/dicethedev/blockstream-inspector) | | **Docs** | Check the README for setup | | **EF Protocol Team** | [ethereum.github.io/protocol-prototyping-site](https://ethereum.github.io/protocol-prototyping-site/) | | **EIP-1559** | [eips.ethereum.org/EIPS/eip-1559](https://eips.ethereum.org/EIPS/eip-1559) | | **EIP-4844** | [eips.ethereum.org/EIPS/eip-4844](https://eips.ethereum.org/EIPS/eip-4844) | --- ## Pro Tips for Builders :::info **If you're also applying to EF (or any protocol team):** Build something. Not a tutorial project. Not a clone. Something that scratches YOUR itch. Something that answers YOUR questions. The learning sticks better, and your passion shows through. ::: ### My Stack Recommendations ```yaml Language: Rust (or Go if you prefer) Why: Performance + Ethereum ecosystem momentum RPC Provider: Alchemy Why: Generous free tier + reliability Testing: Lots of it Why: Protocol work = correctness matters Documentation: Over-document Why: Future you will thank past you ``` --- ## Acknowledgments Built this in **2 weeks** for my EF internship application. Deadline: **December 1st, 2025** Wish me luck! **P.S.** Special shoutout to Claude for helping me structure my thinking (and occasionally debugging my Rust when the borrow checker was being mean). AI pair programming is wild. **P.P.S.** If you end up building something cool with BlockStream or inspired by it, hit me up! I'd love to see what you make. --- :::spoiler Click to see quick setup ```bash # 1. Clone the repo and build git clone https://github.com/dicethedev/blockstream-inspector.git cd blockstream-inspector # 2. Build it cargo build --release # The binary will be at target/release/blockstream-inspector # 3. Get RPC access (free at alchemy.com) export RPC_URL="https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY" # 4. Run it and Analyze data # Analyze a single block ./target/release/blockstream-inspector block --number latest --verbose # Analyze a range of blocks and export to CSV ./target/release/blockstream-inspector range \ --start 18000000 --end 18000100 --output data/blocks.csv # Live monitoring ./target/release/blockstream-inspector live --count 20 --output data/live.csv # MEV detection ./target/release/blockstream-inspector mev --blocks 100 --threshold 0.1 # Option 2 β€” Pass RPC manually (overrides env) ./target/release/blockstream-inspector --rpc http://localhost:8545 block --number latest ``` ::: --- <div style="text-align: center; margin-top: 50px; padding: 20px; background: #f0f0f0; border-radius: 10px;"> **Written by Blessing Samuel** *300L Student | Protocol Engineering Enthusiast | Rust Convert* [![GitHub](https://img.shields.io/badge/GitHub-Follow-black?style=for-the-badge&logo=github)](https://github.com/dicethedev) [![Twitter](https://img.shields.io/badge/Twitter-Follow-blue?style=for-the-badge&logo=twitter)](https://x.com/dicethedev) *Building in public. Learning in public. Sharing everything.* </div> --- ###### tags: `ethereum` `rust` `mev` `pbs` `protocol` `blockchain` `tutorial`