Skip to main content

One post tagged with "EIP-4895"

View All Tags

Ethereum’s Shanghai (Shapella) Upgrade, Demystified

· 6 min read
Dora Noda
Software Engineer

Withdrawals, gas tweaks, and what came next—without the hype.


The Short Version

The Shapella upgrade, a portmanteau of Shanghai (for the execution layer) and Capella (for the consensus layer), went live on Ethereum on April 12, 2023. Its landmark feature was enabling staking withdrawals for the first time since the Beacon Chain's launch.

The headline change, EIP-4895, introduced a system where validator withdrawals are automatically "pushed" from the consensus layer to the execution layer, requiring no user transaction or gas fees. Alongside this, four smaller EIPs shipped to fine-tune the EVM, including gas cost reductions (Warm COINBASE), bytecode optimizations (PUSH0), and contract creation limits (Initcode metering). The upgrade also served as a final warning to developers that the SELFDESTRUCT opcode was on its way out.

Shapella effectively closed the loop on the Merge, and the next major upgrade, Dencun, followed on March 13, 2024, shifting the network's focus to scalability with EIP-4844 "blobs."


Why Shapella Was a Critical Milestone

From the Beacon Chain's inception until April 2023, staking ETH was a one-way street. You could deposit 32 ETH to help secure the network and earn rewards, but you couldn't get your principal or those consensus-layer rewards back out. This locked liquidity was a significant commitment and a barrier for many potential stakers.

Shapella changed everything by opening the exit door.

The upgrade's core was EIP-4895, which ingeniously designed a system-level "withdrawal operation." Instead of requiring stakers to craft a transaction and pay gas to withdraw, the protocol itself now automatically sweeps eligible funds from the consensus layer and pushes them into the execution layer. This clean, push-based design minimized complexity and risk, making the change much easier to test and deploy safely.


What Actually Changed: The EIPs in Plain English

Shapella was a bundle of five key Ethereum Improvement Proposals (EIPs):

  • EIP-4895 — Beacon Chain Withdrawals (Push-based) This was the main event. It enabled both partial (rewards) and full (principal + rewards) withdrawals to flow from the consensus layer to a staker's specified withdrawal address. The key innovation is that these are not user-initiated transactions; they are automatic operations embedded in proposed blocks.

  • EIP-3651 — “Warm COINBASE” This EIP made a small but important gas optimization. In the EVM, COINBASE refers to the address of the block producer (the validator), not the exchange. Before Shapella, the first time a smart contract accessed this address within a transaction, it incurred a higher gas cost. EIP-3651 made the COINBASE address "warm" by default, reducing the gas cost for protocols that frequently interact with it, such as those paying MEV tips directly to the block builder.

  • EIP-3855 — PUSH0 Opcode A simple but elegant addition to the EVM. This new opcode, PUSH0, does exactly what it says: it pushes the value zero onto the stack. Previously, developers had to use heavier, more expensive opcodes to achieve this. PUSH0 makes bytecode slightly smaller and more gas-efficient, especially for the numerous contracts that initialize variables to zero.

  • EIP-3860 — Limit & Meter initcode This change introduced two rules for the code used to create a smart contract (initcode). First, it capped the maximum size of initcode at 49,152 bytes. Second, it added a small gas fee for every 32-byte chunk of this code. This prevents denial-of-service attacks involving overly large contracts and makes contract creation costs more predictable.

  • EIP-6049 — Deprecate SELFDESTRUCT (Warning) This wasn't a code change but a formal warning to the developer community. It signaled that the SELFDESTRUCT opcode, which allows a contract to delete itself and send its ETH to a target address, would have its functionality drastically changed in a future upgrade. This gave developers time to phase out their reliance on it before the Dencun upgrade later altered its behavior with EIP-6780.


Withdrawals 101: Partial vs. Full

Shapella introduced two types of automatic withdrawals, each with its own rules.

  • Partial Withdrawals These are automatic rewards sweeps. If a validator's balance grows above 32 ETH from consensus-layer rewards, the protocol automatically "skims" the excess amount and sends it to the designated withdrawal address. The validator remains active and continues its duties. This happens with no action required from the staker.

  • Full Withdrawals (Exiting) This is for stakers who want to stop validating and retrieve their entire balance. The staker must first broadcast a voluntary exit message. After a waiting period, the validator becomes eligible for a full withdrawal. Once processed in the sweep, the entire balance is sent to the withdrawal address, and the validator is no longer part of the active set.

Throughput and Cadence

The network is designed to process withdrawals smoothly without causing instability.

  • Up to 16 withdrawals can be included in each block (every 12 seconds), allowing for a maximum of approximately 115,200 withdrawals per day.
  • The block proposer scans the list of active validators and includes the first 16 eligible withdrawals. The next block proposer picks up where the last one left off, ensuring every validator gets a turn in the queue.
  • To prevent a mass exodus from destabilizing the network, the number of validators that can exit per epoch (every ~6.4 minutes) is limited by a churn limit. This limit is dynamic based on the total number of active validators, smoothing out exit waves.

It's also important to note that consensus-layer rewards are handled by this EIP-4895 withdrawal mechanism, while execution-layer rewards (priority fees and MEV) are sent directly to a validator's configured fee recipient address and are available immediately.


What Came Next: Dencun and the Road to Scalability

Shapella marked the successful completion of the "Merge era." With staking now a fully liquid, two-way process, developers turned their attention to Ethereum's next big challenge: scalability.

The very next major upgrade, Dencun (Deneb + Cancun), arrived on March 13, 2024. Its centerpiece was EIP-4844, which introduced "blobs"—a new, cheaper way for Layer 2 rollups to post transaction data to the Ethereum mainnet. This dramatically lowered transaction fees on L2s and was a massive step forward on the rollup-centric roadmap. Dencun also delivered on the promise of EIP-6049 by implementing EIP-6780, which significantly curtailed the power of the SELFDESTRUCT opcode.


The Big Picture

Shapella was the essential confidence milestone for Ethereum's Proof-of-Stake consensus. By enabling withdrawals, it de-risked staking, restored liquidity, and affirmed the network's ability to execute complex, coordinated upgrades. It also delivered a handful of pragmatic EVM improvements that cleaned up technical debt and paved the way for future optimizations.

In short, Shapella didn't just open the exit door for stakers—it solidified the foundation of the post-Merge era and cleared the runway for Ethereum to focus on its next frontier: mass scalability.