Visualizing the Ethereum Machine: The Stepwise Journey of a Transaction

Visualizing the Ethereum Machine: The Stepwise Journey of a Transaction

Confession:

Despite being active in the blockchain space since 2017, I admittedly didn’t have a deep understanding of how Ethereum actually worked under the hood until 2024. If you had asked me to explain Ethereum in 2022, I would have probably said something like…

Ethereum is decentralized computing engine that facilitates smart contracts?—? self-executing contracts with immutable terms. It operates on a decentralized network of computers, ensuring transparency and security through a distributed ledger. Every few seconds a new block of data is added to the “chain” based on all the recent transactions, and that chain is secured through cryptography.

Sounds legit?—?and technically not wrong. I would handle the obvious questions with logical, yet broad responses?—?remaining on the surface of understanding. But if asked more probing questions, I’d be limited in my ability to create clarity?—?questions like…

  • Why is ‘gas’ needed to execution transactions? Where does that gas go?
  • How specifically is it decentralized?
  • What’s the difference between a Validator node and an Execution Node?
  • How do we know the Validators are acting honestly when publishing blocks?
  • Etc.

Objective:

As tech-oriented professionals navigating a world where blockchain technology is becoming increasingly prevalent, it’s essential to understand the infrastructure that underpins this digital revolution. Ethereum, as a leading decentralized platform, will play an increasingly pivotal role in the ecosystem of decentralized finance (DeFi) and digital assets (e.g. Non-Fungible Tokens?—?NFTs). This article aims to elucidate the inner workings of Ethereum by walking you through the stepwise minting process of an NFT?—?from the initial “mint” transaction (TX), through “execution” and “consensus” layers of Ethereum’s stack, to the final confirmation that the NFT has been secured by the minting wallet. While our focus here is on the minting of an NFT, the fundamental principles and processes apply universally across various Ethereum-based applications, whether in pioneering new financial instruments, executing complex business logic, or establishing digital identity and ownership.

This space is complex and I’m not an engineer, so I’ve approached this from a different perspective. I believe the explanation and visualization below offers tech professionals and blockchain novices alike a valuable foundational understanding for how this ecosystem operates. By sharing these insights, I hope to create clarity and perhaps even ignite a spark of curiosity, encouraging you to delve deeper into the evolving decentralization narrative.

Caveat: Ethereum continues to evolve as an open-source project through the Ethereum Improvement Proposal (EIP) process. There are numerous active proposals underway that could fundamentally revise this ecosystem in the future.

The Visualization:

We’ll use the below visualization as the basis for our stepwise journey through the Ethereum (L1, or Layer 1) ecosystem:

While there’s an ample supply of different visual interpretations of the Ethereum transaction process?—?none fully satisfied my need to see multiple dimensions of the process at once. Most diagrams seem to force Ethereum’s complexity into a linear, left-to-right or top-to-bottom flow, indexing on a single participant’s perspective?—?which doesn’t represent the true nature of this complex system. By visualizing the process more as a repeating [circular] cycle, with stacked layers?—?this diagram aims to satisfy those in need of more visual depth.

Recommendation: Here’s the visualization as a PDF? —?you may find it helpful to view this on a second screen while reading?—?or print it for your own reference and notes as you read.

Note: This article focuses on Ethereum as a “Layer 1” (L1) technology, which refers to the base layer of the blockchain infrastructure. Layer 1 is the underlying main network architecture of the Ethereum protocol itself. For the sake of simplicity, I will not delve into the “Layer 2” (L2) solutions built on top of this foundational layer to address scalability and speed by handling transactions off the main Ethereum chain.

Step 1: The Initial Mint Transaction

The stepwise journey begins with the initiation of a transaction by an Externally-Owned Account, or EOA. But what exactly is an EOA, and how does it set the wheels in motion for minting an NFT?

EOAs and Wallets?—?The Starting Blocks of Ethereum Transactions

An EOA is essentially your personal foothold in the Ethereum landscape. It’s akin to a bank account in the digital realm but much more powerful. It’s controlled by a private key?—?think of this as the most secure password you’ve ever had. This key is your individual signature, your cryptographically secure way of saying, “Yes, it’s really me sending this transaction.”

A wallet, then, is the interface?—?the trusted tool that manages your EOAs. Your wallet keeps your keys, executes your commands, and interacts with the Ethereum blockchain on your behalf.

A wallet, on the other hand, serves as the interface?—?the trusted tool that manages your EOAs. Your wallet safeguards your private keys, executes your commands, and interacts with the Ethereum blockchain on your behalf. Each wallet is associated with a public address used for transactions, similar to how an email address is used for sending and receiving messages. This public address is a 42-character hexadecimal string starting with ‘0x’?—?something like this:

0x124f681646d4b755815f9cb19c1acc8565a0c2ac

This address format allows for millions of unique combinations, ensuring that each user's address is distinct and secure on the Ethereum network.

Security in Transaction?—?The Role of Signatures

So, how do you send a transaction securely? How do we prevent someone else from acting on your behalf? The answer lies in digital signatures. When you send a transaction, your wallet uses your private key to sign it cryptographically. This signature is verifiable against your public key?—?the address of your EOA?—?ensuring that only transactions from your wallet can truly come from you.

The Data in the TX?—?Encoding Intent with?OpCodes

When you, through your wallet, decide to mint an NFT, you create a transaction (TX). This isn’t just any data packet?—?it’s a bundle of intent, complete with operation codes (OpCodes) that instruct the Ethereum Virtual Machine (EVM) the series of actions it needs to execute on. These OpCodes are the language of Ethereum; they tell the smart contracts what to do, be it creating a token, transferring Ether, or, in our case, minting an NFT (more on Smart Contracts and EVM in subsequent sections). Don't worry though, the app you're engaging with will construct and present this transaction for you to sign.

The Mempool?—?Community Mailbox of the Ethereum?World

Now, where does this transaction go? Enter the mempool, Ethereum’s waiting room for transactions. It’s a bit like a community mailbox; you’ve sent your letter, but it doesn’t go directly to the recipient. Instead, it waits for a mail sorter (Execution Node) to pick it up, organize it, and then pass it on to the postman (Validator) to deliver it to its final destination (the blockchain). We’ll go over these steps in more detail soon.

In a few steps, we’ll see how this transaction is eventually selected from the mempool, batched, and executed through the Ethereum Virtual Machine (EVM)?—?but first, we need to introduce the concept of the Validator network.

Step 2: Random Validator Selection

Every 12 seconds, a digital dice rolls within the Ethereum network, a process that determines which Validator gets the honor (and reward) of proposing the next block of transactions to add to the blockchain. This is not just a game of chance; it’s a critical component of the network’s security and decentralization, determined by a Randomness Beacon known as the RANDAO algorithm.

The RANDAO Beacon?—?Ensuring Fair?Play

Imagine the RANDAO as an incorruptible lottery system. It utilizes the collective commitment of each Validator in the network, combining their inputs to generate a random number that’s as unpredictable as it is secure. This ensures that no single Validator can game the system to their advantage, embodying the spirit of equitable participation.

Validators?—?The Backbone of Ethereum’s Trust

Validators are the sentinels of the Ethereum blockchain, staking their own ETH (32 ETH?—?or about $100K at current value) as collateral to participate in the network. Anyone can be a Validator by staking the required ETH and running opensource Validator Node software (e.g. geth). The staked ETH acts as both a key to enter the Validator pool and a bond that incentivizes honest participation (if a Validator is proven to have acted maliciously, their stake is “slashed”?—?or burned). Validators perform a variety of roles, from proposing blocks to attesting the validity of others’ blocks, making them crucial to maintaining the integrity of the ledger.

The Validator Network?—?A Decentralized Watch

The selection of a block proposer (every 12 seconds) is a pivotal event in the lifecycle of the Ethereum blockchain. With thousands of Validators spread across the globe, the Ethereum network ensures that no single entity can exert too much influence. This decentralized network of Validators guards the blockchain against fraud and manipulation while upholding the principles of transparency and collective agreement.

Let’s continue with the Validator’s first responsibility in step 3.

Step 3: Establishing Parent?State

At the heart of Ethereum’s transaction processing is a continuous thread that weaves through each block, linking the past, present, and future. Step 3 is where the chosen Validator, having received the baton to propose a new block, retrieves the last block from the chain. This is a critical step: establishing the “parent state” for the next block to be built upon.

The Last Block?—?The Foundation for the?Next

Think of the blockchain as an ancestral record, with each block a generational heir to the one before. The Validator calls upon the last block to serve as a Parent?—?a foundation on which the new block will stand. This parent block is the most recently agreed-upon state of the blockchain, carrying within it the complete history and current status of all accounts and smart contracts up to that moment.

Why the Parent State?Matters

By pulling the last block, the Validator is doing more than fetching data; they are acknowledging and upholding the entire history of the blockchain. This ensures continuity and integrity, making sure that every transaction is built on a foundation of verified truth.

With Parent State established, it’s now time to build the next block. In today’s Ethereum ecosystem, the Validators aren’t typically building the block?—?that’s a role for Execution Nodes (aka Searchers and Block Builders) that we’ll explore next.

Step 4: Transaction Selection & Sequencing

After a Validator has established the parent state, the baton is handed over to the Execution Nodes?—?the workhorses that select/process transactions and construct the blocks. The separation of roles between Validators and Execution Nodes reinforces Ethereum’s decentralized nature. Different parties bring their resources to the table?—?some by staking ETH to validate, and others by dedicating computational power to execute and build blocks. It’s a symbiotic relationship that ensures no single participant holds too much power and that the blockchain operates smoothly and effectively.

Execution Nodes?—?The Discriminating Curators

Execution Nodes sift through the mempool, (recall?—?these are the candidate TXs from step 1), choosing which will be included in the next block. Their criteria are multifaceted: they consider transaction fees (gas prices), complexity, nonce?—?a transaction’s place in the sequence of a particular account’s actions?—?and dependencies between transactions.

Sequencing?—?Crafting the Narrative of Transactions

The sequencing of transactions is an art form. Each transaction contains a nonce, ensuring that all of a specific account’s transactions are processed in order relative to that account’s own TXs (e.g. if my wallet sends 3 TXs to the mempool, Execution Nodes must sequence those according to their nonces). Execution Nodes use these nonces, along with gas prices, to decide the order of operations. High gas prices can act like a fast track, moving transactions to the front of the line as they promise a higher reward for processing them. This creates a dynamic market, where users can adjust their offered fees to influence how quickly their transactions are picked up from the mempool.

Note: If a user sets the gas price too low on their transaction, they face the risk of it languishing in the mempool, potentially never being picked up by an Execution Node. Thus, it’s crucial for users to assess network activity and set appropriate gas prices to ensure their transactions are executed in a timely manner (wallets typically automate this for users).

Extraction of Value?—?Execution Nodes’ Incentive

Execution Nodes are incentivized to perform this careful selection and ordering; they extract value through the transaction fees. This process of extracting value is further nuanced by the concept of Miner Extractable Value (MEV), which refers to the additional profit Execution Nodes can achieve by strategically ordering, including, or excluding transactions. MEV arises because transactions on the Ethereum network can be openly seen in the mempool before they are confirmed, allowing Execution Nodes to prioritize or front-run certain transactions that offer higher financial returns. While Validators are remunerated for adding blocks to the chain, Execution Nodes earn their keep from both the gas fees and potential MEV opportunities of the transactions they process. This not only rewards them for their computational work but also aligns their interests with the network’s efficiency and security.

Although MEV can present complex ethical and fairness challenges, it is a risk that the Ethereum community acknowledges as part of the decentralized nature of the blockchain. The ongoing transparency and competitive nature of MEV can lead to more efficient market dynamics and better network security. Furthermore, the Ethereum community is actively engaged in discussions and development efforts to mitigate potential negative impacts of MEV, ensuring that the network remains equitable and secure for all users.

A Prelude to Execution?—?Preparing for the?EVM

Having curated and sequenced a batch of transactions, Execution Nodes will execute these transactions via the Ethereum Virtual Machine (EVM) in the next step.

Step 5: Execution via the Ethereum Virtual Machine?(EVM)

This where the theoretical becomes tangible within the Ethereum blockchain. Here, the Execution Node’s carefully sequenced transactions are processed against the deterministic nature of smart contracts, leading to the construction and broadcast of a proposed block with new state changes.

Deterministic Code?—?The Unwavering Path of Execution

In computing, determinism is the bedrock of trust and predictability. Deterministic code, by definition, will, given a particular input, always produce the same output (2+2 is always 4 on a calculator). In the Ethereum ecosystem, this ensures that smart contracts?—?the self-operating agreements written in code?—?act out their terms unfailingly. There’s no room for guesswork or interpretation; the EVM executes the smart contract code with invariable precision.

Smart Contracts?—?The Autonomous Agents of?Ethereum

Smart contracts are the autonomous agents of Ethereum, residing on the blockchain, waiting to execute their code when called upon. They are the digital equivalent of a contract in the real world, but without the need for intermediaries. A smart contract defines rules and automatically enforces them upon transaction execution. It’s a revolution in agreement execution, one that transcends traditional legal and geographical boundaries.

A fitting (albeit imperfect) analogy for Smart Contracts is the comparison to a vintage vending machine?—?whereby the machine essentially operates on an agreement to mechanically deliver product to buyer following rules. For example, if the below terms are TRUE:

the electricity is on (AND) product in slot “B7” is in inventory (AND) machine is in working condition

And you operate as follows:

You put in the required amount of coins (AND) the coins are authentic (AND) you press?“B7”

…then the vending machine will deliver the requested product in slot B7. The transaction can’t be censored by a middleman (no shirt, no shoes? no problem). Of course, in practice, we’ve probably all been in situations where a vending machine failed, required a nudge to get the product to fully drop, or didn’t give the correct change. It’s an imperfect analogy because vending machines aren’t fully operating on code (there are real-world dependencies out of the machine’s control), meaning product delivery is not actually 100% deterministic. Meanwhile, Smart Contracts operate strictly within the parameters set by their code, eliminating human error and bias, thereby offering a more reliable and transparent method for enforcing contractual agreements across the digital landscape.

Utilizing the Parent State?—?The Basis for State?Changes

The Parent State we discussed in Step 3 serves as an input to the EVM for the new batch of transactions. In our NFT example?—?if I’m minting an NFT from a collection of 10K NFTs?—?the EVM needs to validate, for example, that there are still NFTs available to mint from the contract. It validates this balance through the Parent State. If the Parent State indicates a remaining balance of only 3 NFTs and there are 5 different wallets each attempting to mint?—?the TX sequencing from step 4 is key in determining which 3 wallets are successful in minting, and which 2 wallets see a failed transaction. For each sequentially-executed transaction, the smart contract reads the current state, performs its coded operations, and proposes updates?—?often changing account balances or the states of other smart contracts.

The result is a set of proposed state changes in the form of a proposed block, a computed record of the aftermath of all executed transactions. These state changes aren’t haphazard; they’re a direct consequence of the deterministic rules prescribed in the smart contracts?—?any other Execution Node would arrive at the same proposed state if their TX selection and sequencing (step 4) were the same. But therein lies the nuance?—?thousands of Execution Nodes are operating in parallel?—?competing to build the next block, hoping the Validator will choose their block to add to the blockchain. In the next step we’ll see how a Validator chooses a proposed block from the sea of Execution Nodes proposing blocks.

Step 6: Block Selection by Validator

With transactions executed through the EVM, it’s now the Validator’s responsibility to select a proposed block and broadcast it to the network.

Incentives Behind Block Selection

Validators, holding the responsibility of block proposal, aren’t merely passive receivers of Execution clients’ suggestions. They have the agency to choose which block to propose?—?and their decision is not without self-interest. A Validator’s income is derived from block rewards in two forms:

  1. a static amount of ETH as compensation for the energy and resources they expend in the process of validating transactions and maintaining the blockchain
  2. a portion of the “gas” paid by users to have their transaction included in a block

Hence, Validators have a financial incentive to pick blocks that maximize their return without compromising the network’s rules and reliability.

Benefit to Execution Nodes and Validators

This selection process isn’t just about Validators lining their pockets; it’s part of a greater economic dance that keeps the network robust and participants honest. Execution Nodes benefit as well, for their computational efforts in processing and proposing blocks are rewarded through transaction fees?—?fees that are only collected if a Validator selects their proposed block. Thus, a symbiotic relationship exists: Execution Nodes work diligently to create valuable blocks, while Validators aim to select blocks that sustain the network’s economic and security standards.

Fairness in the?System

To a bystander, it may appear that Validators wield significant power, potentially tipping the scale towards unfairness. However, the RandDAO algorithm’s role in Validator selection (recall step 2) is the great equalizer. It ensures that no single Validator can consistently control block selection, thereby preventing any long-term strategic manipulation. This randomness in Validator selection is key to Ethereum’s security, ensuring that while individual Validators act from self-interest, collectively, they serve the network’s health and decentralization.

After selecting the proposed block, the Validator must now broadcast it to the broader Validator Network.

Step 7: Block Attestation by Validator Network

Once a Validator has made their selection and broadcast a proposed block, step 7 unfolds with the Validator Network’s critical examination. This is where individual Validators (all the other Validator’s that weren’t selected by RandDAO to be the current block proposer), acting as jurors, scrutinize the proposed block to ensure its integrity and adherence to Ethereum’s rules.

Attestation: The Validators’ Seal of?Approval

Validators within the network now engage in a process known as attestation. They review the proposed block’s transactions and state changes, checking them against the blockchain’s history and current rules. When a Validator attests to a block, they are essentially saying, “I have checked this, and it holds true to what we’ve agreed upon as a network.” It’s not dissimilar to peer review in academic publishing, where each paper is rigorously vetted before publication.

More Than Just a Formality

This isn’t just a rubber stamp. Recall, Validators stake their own ETH as a bond of their honest participation. If they attest to a fraudulent or incorrect block, they risk losing a portion of their stake?—?a process known as slashing. This risk is the sharp end of the incentive structure that keeps Validators honest.

Distributed Scrutiny for Distributed Trust

Every Validator operates independently, which means the proposed block is subjected to multiple, parallel verifications. This distributed scrutiny is crucial in a decentralized system. It means that trust in the block’s validity doesn’t rely on a single entity but is instead the result of collective agreement.

Preparing for?Finality

While step 7 is not about the finalization of the block (which comes next in the consensus mechanism), it is a preparatory phase. The attestation by the Validators signals to the network that the proposed block is ready to enter the final stage of validation. It’s the point at which the network’s collective wisdom is harnessed to maintain the blockchain’s integrity before a block is finalized and added to the chain.

Step 8: Block Finality and New?State

This is where the proposed block, having passed through the gauntlet of validations, attains finality. This is the moment when the Ethereum network collectively agrees that a block is valid and should be irrevocably added to the blockchain.

Consensus Mechanism: The Network’s Agreement

The consensus mechanism is Ethereum’s method for all Validators to agree on the state of the blockchain. This isn’t a mere majority rule; it’s a complex algorithm that ensures all participating Validators are in sync regarding the blockchain’s most recent, verified state. When a block reaches finality, it means that the network has reached sufficient consensus that the block can no longer be altered or removed?—?it becomes an immutable part of the chain.

Block Finality: The Seal on?History

Finality is akin to sealing a time capsule. Once closed, it cannot be reopened; the history it contains is set for posterity. In the blockchain context, finality means that all transactions within the block are now part of the historical ledger, their outcomes fixed, their state changes unchangeable. For users and smart contracts alike, this guarantees that transactions cannot be reversed, ensuring security and trust in the network.

With the finalization of the block, a new state is born. This isn’t just an update; it’s the next evolution of the blockchain. All accounts, smart contracts, and balances are now updated to reflect the latest transactions. This new state is what will be referenced as the Parent State by subsequent transactions and blocks, serving as the ground truth for the Ethereum network. The visualization highlights this continual, circular nature of blockchain processes, reflecting a system where each block is both a conclusion and a new beginning in Ethereum’s immutable ledger.

Step 9: Realization of Ownership

Step 9 marks the conclusion of a complex journey, from intent (the initial transaction) to immutability, where the blockchain’s new state reflects the NFT within the initiator’s wallet.

The New State: A Digital Ledger?Updated

The new state, now part of the Ethereum blockchain, carries within it the updated balances and the latest changes?—?including the freshly minted NFT. The blockchain doesn’t just record that the NFT exists; it enshrines the ownership of the NFT to the wallet of the user who initiated the minting transaction. For the user, this is the moment of realization. Their wallet, synchronized with the latest state of the Ethereum blockchain, now displays the new NFT.

In Closing: The Journey Continues

With Ethereum, the journey never truly ends. Each new block of finalized state is merely the starting point for the next series of transactions. As Ethereum evolves, with upgrades and proposals in motion that may reshape the landscape, the core principles of decentralization, transparency, and security it enshrines remain steadfast. These foundational concepts ensure that no matter how the technology adapts or grows, the integrity and trustworthiness of the blockchain are maintained.

For professionals and novices, enthusiasts and skeptics alike, this exploration serves as an open invitation to continue to learn more about the world of blockchain technology. As the boundaries between the physical and digital worlds increasingly intersect, understanding the fundamental motivations and incentives driving the various parties within the Ethereum ecosystem is crucial for anyone looking to make a significant impact on the digital landscape that will define our future.

Lex Federer

Founder @ Orca Platforms | Social commerce solution for Video Games

2 个月

Thank you!

回复

要查看或添加评论,请登录

Jeremy Posvar的更多文章

社区洞察

其他会员也浏览了